diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
commit | 837b550238aa671a591ccf282dddeab29cadb206 (patch) | |
tree | 914b6b8862bace72bd3245ca184d374b08d8a672 /tests | |
parent | Adding debian version 1.70.0+dfsg2-1. (diff) | |
download | rustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz rustc-837b550238aa671a591ccf282dddeab29cadb206.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
2340 files changed, 30446 insertions, 9524 deletions
diff --git a/tests/assembly/asm/inline-asm-avx.rs b/tests/assembly/asm/inline-asm-avx.rs new file mode 100644 index 000000000..c2875f3e0 --- /dev/null +++ b/tests/assembly/asm/inline-asm-avx.rs @@ -0,0 +1,25 @@ +// assembly-output: emit-asm +// compile-flags: --crate-type=lib +// only-x86_64 +// ignore-sgx + +#![feature(portable_simd)] + +use std::simd::Simd; +use std::arch::asm; + +#[target_feature(enable = "avx")] +#[no_mangle] +// CHECK-LABEL: convert: +pub unsafe fn convert(a: *const f32) -> Simd<f32, 8> { + // CHECK: vbroadcastss (%{{[er][a-ds0-9][xpi0-9]?}}), {{%ymm[0-7]}} + let b: Simd<f32, 8>; + unsafe { + asm!( + "vbroadcastss {b}, [{a}]", + a = in(reg) a, + b = out(ymm_reg) b, + ); + } + b +} diff --git a/tests/assembly/asm/loongarch-type.rs b/tests/assembly/asm/loongarch-type.rs new file mode 100644 index 000000000..4e296f3ad --- /dev/null +++ b/tests/assembly/asm/loongarch-type.rs @@ -0,0 +1,196 @@ +// min-llvm-version: 16.0 +// assembly-output: emit-asm +// compile-flags: --target loongarch64-unknown-linux-gnu +// needs-llvm-components: loongarch + +#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] +#![crate_type = "rlib"] +#![no_core] +#![allow(asm_sub_register, non_camel_case_types)] + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} +#[rustc_builtin_macro] +macro_rules! concat { + () => {}; +} +#[rustc_builtin_macro] +macro_rules! stringify { + () => {}; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +type ptr = *const i32; + +impl Copy for i8 {} +impl Copy for i16 {} +impl Copy for i32 {} +impl Copy for i64 {} +impl Copy for f32 {} +impl Copy for f64 {} +impl Copy for ptr {} +extern "C" { + fn extern_func(); + static extern_static: u8; +} + +// Hack to avoid function merging +extern "Rust" { + fn dont_merge(s: &str); +} + +// CHECK-LABEL: sym_fn: +// CHECK: #APP +// CHECK: pcalau12i $t0, %got_pc_hi20(extern_func) +// CHECK: ld.d $t0, $t0, %got_pc_lo12(extern_func) +// CHECK: #NO_APP +#[no_mangle] +pub unsafe fn sym_fn() { + asm!("la.got $r12, {}", sym extern_func); +} + +// CHECK-LABEL: sym_static: +// CHECK: #APP +// CHECK: pcalau12i $t0, %got_pc_hi20(extern_static) +// CHECK: ld.d $t0, $t0, %got_pc_lo12(extern_static) +// CHECK: #NO_APP +#[no_mangle] +pub unsafe fn sym_static() { + asm!("la.got $r12, {}", sym extern_static); +} + +macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => { + #[no_mangle] + pub unsafe fn $func(x: $ty) -> $ty { + dont_merge(stringify!($func)); + + let y; + asm!(concat!($mov," {}, {}"), out($class) y, in($class) x); + y + } +};} + +macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => { + #[no_mangle] + pub unsafe fn $func(x: $ty) -> $ty { + dont_merge(stringify!($func)); + + let y; + asm!(concat!($mov, " ", $reg, ", ", $reg), lateout($reg) y, in($reg) x); + y + } +};} + +// CHECK-LABEL: reg_i8: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_i8, i8, reg, "move"); + +// CHECK-LABEL: reg_i16: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_i16, i16, reg, "move"); + +// CHECK-LABEL: reg_i32: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_i32, i32, reg, "move"); + +// CHECK-LABEL: reg_f32: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_f32, f32, reg, "move"); + +// CHECK-LABEL: reg_i64: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_i64, i64, reg, "move"); + +// CHECK-LABEL: reg_f64: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_f64, f64, reg, "move"); + +// CHECK-LABEL: reg_ptr: +// CHECK: #APP +// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// CHECK: #NO_APP +check!(reg_ptr, ptr, reg, "move"); + +// CHECK-LABEL: freg_f32: +// CHECK: #APP +// CHECK: fmov.s $f{{[a-z0-9]+}}, $f{{[a-z0-9]+}} +// CHECK: #NO_APP +check!(freg_f32, f32, freg, "fmov.s"); + +// CHECK-LABEL: freg_f64: +// CHECK: #APP +// CHECK: fmov.d $f{{[a-z0-9]+}}, $f{{[a-z0-9]+}} +// CHECK: #NO_APP +check!(freg_f64, f64, freg, "fmov.d"); + +// CHECK-LABEL: r4_i8: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_i8, i8, "$r4", "move"); + +// CHECK-LABEL: r4_i16: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_i16, i16, "$r4", "move"); + +// CHECK-LABEL: r4_i32: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_i32, i32, "$r4", "move"); + +// CHECK-LABEL: r4_f32: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_f32, f32, "$r4", "move"); + +// CHECK-LABEL: r4_i64: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_i64, i64, "$r4", "move"); + +// CHECK-LABEL: r4_f64: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_f64, f64, "$r4", "move"); + +// CHECK-LABEL: r4_ptr: +// CHECK: #APP +// CHECK: move $a0, $a0 +// CHECK: #NO_APP +check_reg!(r4_ptr, ptr, "$r4", "move"); + +// CHECK-LABEL: f0_f32: +// CHECK: #APP +// CHECK: fmov.s $f{{[a-z0-9]+}}, $f{{[a-z0-9]+}} +// CHECK: #NO_APP +check_reg!(f0_f32, f32, "$f0", "fmov.s"); + +// CHECK-LABEL: f0_f64: +// CHECK: #APP +// CHECK: fmov.d $f{{[a-z0-9]+}}, $f{{[a-z0-9]+}} +// CHECK: #NO_APP +check_reg!(f0_f64, f64, "$f0", "fmov.d"); diff --git a/tests/assembly/option-nonzero-eq.rs b/tests/assembly/option-nonzero-eq.rs new file mode 100644 index 000000000..f5d88de76 --- /dev/null +++ b/tests/assembly/option-nonzero-eq.rs @@ -0,0 +1,28 @@ +// revisions: WIN LIN +// [WIN] only-windows +// [LIN] only-linux +// assembly-output: emit-asm +// compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel +// only-x86_64 +// ignore-sgx +// ignore-debug + +use std::cmp::Ordering; + +// CHECK-lABEL: ordering_eq: +#[no_mangle] +pub fn ordering_eq(l: Option<Ordering>, r: Option<Ordering>) -> bool { + // Linux (System V): first two arguments are rdi then rsi + // Windows: first two arguments are rcx then rdx + // Both use rax for the return value. + + // CHECK-NOT: mov + // CHECK-NOT: test + // CHECK-NOT: cmp + + // LIN: cmp dil, sil + // WIN: cmp cl, dl + // CHECK-NEXT: sete al + // CHECK-NEXT: ret + l == r +} diff --git a/tests/assembly/slice-is_ascii.rs b/tests/assembly/slice-is_ascii.rs new file mode 100644 index 000000000..b3e1fee15 --- /dev/null +++ b/tests/assembly/slice-is_ascii.rs @@ -0,0 +1,35 @@ +// revisions: WIN LIN +// [WIN] only-windows +// [LIN] only-linux +// assembly-output: emit-asm +// compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel +// min-llvm-version: 14 +// only-x86_64 +// ignore-sgx +// ignore-debug + +#![feature(str_internals)] + +// CHECK-LABEL: is_ascii_simple_demo: +#[no_mangle] +pub fn is_ascii_simple_demo(bytes: &[u8]) -> bool { + // Linux (System V): pointer is rdi; length is rsi + // Windows: pointer is rcx; length is rdx. + + // CHECK-NOT: mov + // CHECK-NOT: test + // CHECK-NOT: cmp + + // CHECK: .[[LOOPHEAD:.+]]: + // CHECK-NEXT: mov [[TEMP:.+]], [[LEN:rsi|rdx]] + // CHECK-NEXT: sub [[LEN]], 1 + // CHECK-NEXT: jb .[[LOOPEXIT:.+]] + // CHECK-NEXT: cmp byte ptr [{{rdi|rcx}} + [[TEMP]] - 1], 0 + // CHECK-NEXT: jns .[[LOOPHEAD]] + + // CHECK-NEXT: .[[LOOPEXIT]]: + // CHECK-NEXT: test [[TEMP]], [[TEMP]] + // CHECK-NEXT: sete al + // CHECK-NEXT: ret + core::slice::is_ascii_simple(bytes) +} diff --git a/tests/codegen-units/item-collection/cross-crate-trait-method.rs b/tests/codegen-units/item-collection/cross-crate-trait-method.rs index dc0984c8a..b7216a143 100644 --- a/tests/codegen-units/item-collection/cross-crate-trait-method.rs +++ b/tests/codegen-units/item-collection/cross-crate-trait-method.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/function-as-argument.rs b/tests/codegen-units/item-collection/function-as-argument.rs index ea500c311..d951cbfac 100644 --- a/tests/codegen-units/item-collection/function-as-argument.rs +++ b/tests/codegen-units/item-collection/function-as-argument.rs @@ -1,5 +1,4 @@ -// -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/generic-functions.rs b/tests/codegen-units/item-collection/generic-functions.rs index 04383bb8e..f790cd0da 100644 --- a/tests/codegen-units/item-collection/generic-functions.rs +++ b/tests/codegen-units/item-collection/generic-functions.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/generic-impl.rs b/tests/codegen-units/item-collection/generic-impl.rs index 4260230c2..e19eec36b 100644 --- a/tests/codegen-units/item-collection/generic-impl.rs +++ b/tests/codegen-units/item-collection/generic-impl.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/trait-implementations.rs b/tests/codegen-units/item-collection/trait-implementations.rs index a816cb032..ad0ed7da2 100644 --- a/tests/codegen-units/item-collection/trait-implementations.rs +++ b/tests/codegen-units/item-collection/trait-implementations.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/trait-method-as-argument.rs b/tests/codegen-units/item-collection/trait-method-as-argument.rs index 235569728..164ef794c 100644 --- a/tests/codegen-units/item-collection/trait-method-as-argument.rs +++ b/tests/codegen-units/item-collection/trait-method-as-argument.rs @@ -1,5 +1,4 @@ -// -// compile-flags:-Zprint-mono-items=eager +// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen-units/item-collection/trait-method-default-impl.rs b/tests/codegen-units/item-collection/trait-method-default-impl.rs index bfcdb6fa1..d953582cc 100644 --- a/tests/codegen-units/item-collection/trait-method-default-impl.rs +++ b/tests/codegen-units/item-collection/trait-method-default-impl.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on +// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on -Zinline-mir=no #![deny(dead_code)] #![feature(start)] diff --git a/tests/codegen/abi-main-signature-16bit-c-int.rs b/tests/codegen/abi-main-signature-16bit-c-int.rs index 3548cc06a..353e7489b 100644 --- a/tests/codegen/abi-main-signature-16bit-c-int.rs +++ b/tests/codegen/abi-main-signature-16bit-c-int.rs @@ -17,6 +17,7 @@ // ignore-wasm32 // ignore-x86 // ignore-x86_64 +// ignore-loongarch64 fn main() { } diff --git a/tests/codegen/addr-of-mutate.rs b/tests/codegen/addr-of-mutate.rs new file mode 100644 index 000000000..bea1aad23 --- /dev/null +++ b/tests/codegen/addr-of-mutate.rs @@ -0,0 +1,34 @@ +// compile-flags: -C opt-level=3 -C no-prepopulate-passes +// min-llvm-version: 15.0 (for opaque pointers) + +#![crate_type = "lib"] + +// Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. +// See <https://github.com/rust-lang/rust/issues/111502>. + +// CHECK: i8 @foo(ptr noalias nocapture noundef dereferenceable(128) %x) +#[no_mangle] +pub fn foo(x: [u8; 128]) -> u8 { + let ptr = core::ptr::addr_of!(x).cast_mut(); + unsafe { + (*ptr)[0] = 1; + } + x[0] +} + +// CHECK: i1 @second(ptr noalias nocapture noundef dereferenceable({{[0-9]+}}) %a_ptr_and_b) +#[no_mangle] +pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { + let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); + (*b_bool_ptr) = true; + a_ptr_and_b.1.1 +} + +// If going through a deref (and there are no other mutating accesses), then `readonly` is fine. +// CHECK: i1 @third(ptr noalias nocapture noundef readonly dereferenceable({{[0-9]+}}) %a_ptr_and_b) +#[no_mangle] +pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { + let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); + (*b_bool_ptr) = true; + a_ptr_and_b.1.1 +} diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index c5886cf28..f3cf614e1 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -7,3 +7,43 @@ #[no_mangle] #[repr(align(16))] pub fn fn_align() {} + +pub struct A; + +impl A { + // CHECK: align 16 + #[no_mangle] + #[repr(align(16))] + pub fn method_align(self) {} + + // CHECK: align 16 + #[no_mangle] + #[repr(align(16))] + pub fn associated_fn() {} +} + +trait T: Sized { + fn trait_fn() {} + + // CHECK: align 32 + #[repr(align(32))] + fn trait_method(self) {} +} + +impl T for A { + // CHECK: align 16 + #[no_mangle] + #[repr(align(16))] + fn trait_fn() {} + + // CHECK: align 16 + #[no_mangle] + #[repr(align(16))] + fn trait_method(self) {} +} + +impl T for () {} + +pub fn foo() { + ().trait_method(); +} diff --git a/tests/codegen/align-offset.rs b/tests/codegen/align-offset.rs new file mode 100644 index 000000000..7c7660c5a --- /dev/null +++ b/tests/codegen/align-offset.rs @@ -0,0 +1,78 @@ +// compile-flags: -O +// min-llvm-version: 15.0 (because we're using opaque pointers) +// ignore-debug (debug assertions in `slice::from_raw_parts` block optimizations) + +#![crate_type = "lib"] + +// CHECK-LABEL: @align8 +#[no_mangle] +pub fn align8(p: *const u8) -> bool { + // CHECK: ret i1 true + p.align_offset(8) < 8 +} + +#[repr(align(4))] +pub struct Align4([u8; 4]); + +// CHECK-LABEL: @align_to4 +#[no_mangle] +pub fn align_to4(x: &[u8]) -> bool { + // CHECK: ret i1 true + let (prefix, _middle, suffix) = unsafe { x.align_to::<Align4>() }; + prefix.len() < 4 && suffix.len() < 4 +} + +// CHECK-LABEL: @align_offset_byte_ptr(ptr{{.+}}%ptr) +#[no_mangle] +pub fn align_offset_byte_ptr(ptr: *const u8) -> usize { + // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE:i[0-9]+]] + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 + // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 + // CHECK: %[[OFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] + + // Since we're offsetting a byte pointer, there's no further fixups + // CHECK-NOT: shr + // CHECK-NOT: div + // CHECK-NOT: select + + // CHECK: ret [[USIZE]] %[[OFFSET]] + ptr.align_offset(32) +} + +// CHECK-LABEL: @align_offset_word_slice(ptr{{.+}}align 4{{.+}}%slice.0 +#[no_mangle] +pub fn align_offset_word_slice(slice: &[Align4]) -> usize { + // CHECK: %[[ADDR:.+]] = ptrtoint ptr %slice.0 to [[USIZE]] + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 + // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 + // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] + // CHECK: %[[OFFSET:.+]] = lshr exact [[USIZE]] %[[BOFFSET]], 2 + + // Slices are known to be aligned, so we don't need the "maybe -1" path + // CHECK-NOT: select + + // CHECK: ret [[USIZE]] %[[OFFSET]] + slice.as_ptr().align_offset(32) +} + + +// CHECK-LABEL: @align_offset_word_ptr(ptr{{.+}}%ptr +#[no_mangle] +pub fn align_offset_word_ptr(ptr: *const Align4) -> usize { + // CHECK: %[[ADDR:.+]] = ptrtoint ptr %ptr to [[USIZE]] + // CHECK: %[[UP:.+]] = add [[USIZE]] %[[ADDR]], 31 + // CHECK: %[[ALIGNED:.+]] = and [[USIZE]] %[[UP]], -32 + // CHECK: %[[BOFFSET:.+]] = sub [[USIZE]] %[[ALIGNED]], %[[ADDR]] + + // While we can always get a *byte* offset that will work, if the original + // pointer is unaligned it might be impossible to return an *element* offset + // that will make it aligned. We want it to be a `select`, not a `br`, so + // that the assembly will be branchless. + // CHECK: %[[LOW:.+]] = and [[USIZE]] %[[ADDR]], 3 + // CHECK: %[[ORIGINAL_ALIGNED:.+]] = icmp eq [[USIZE]] %[[LOW]], 0 + // CHECK: %[[OFFSET:.+]] = lshr exact [[USIZE]] %[[BOFFSET]], 2 + // CHECK: %[[R:.+]] = select i1 %[[ORIGINAL_ALIGNED]], [[USIZE]] %[[OFFSET]], [[USIZE]] -1 + + // CHECK: ret [[USIZE]] %[[R]] + ptr.align_offset(32) +} diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs index c3ffaeb95..f88d695d8 100644 --- a/tests/codegen/alloc-optimisation.rs +++ b/tests/codegen/alloc-optimisation.rs @@ -1,12 +1,13 @@ // // no-system-llvm // compile-flags: -O -#![crate_type="lib"] +#![crate_type = "lib"] #[no_mangle] pub fn alloc_test(data: u32) { // CHECK-LABEL: @alloc_test // CHECK-NEXT: start: + // CHECK-NEXT: {{.*}} load volatile i8, ptr @__rust_no_alloc_shim_is_unstable, align 1 // CHECK-NEXT: ret void let x = Box::new(data); drop(x); diff --git a/tests/codegen/array-map.rs b/tests/codegen/array-map.rs index 7b8ab2c79..3706ddf99 100644 --- a/tests/codegen/array-map.rs +++ b/tests/codegen/array-map.rs @@ -21,7 +21,7 @@ pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] { pub fn short_integer_zip_map(x: [u32; 8], y: [u32; 8]) -> [u32; 8] { // CHECK: %[[A:.+]] = load <8 x i32> // CHECK: %[[B:.+]] = load <8 x i32> - // CHECK: sub <8 x i32> %[[A]], %[[B]] + // CHECK: sub <8 x i32> %[[B]], %[[A]] // CHECK: store <8 x i32> x.zip(y).map(|(x, y)| x - y) } diff --git a/tests/codegen/ascii-char.rs b/tests/codegen/ascii-char.rs new file mode 100644 index 000000000..4167becf5 --- /dev/null +++ b/tests/codegen/ascii-char.rs @@ -0,0 +1,37 @@ +// compile-flags: -C opt-level=1 +// ignore-debug (the extra assertions get in the way) + +#![crate_type = "lib"] +#![feature(ascii_char)] + +use std::ascii::Char as AsciiChar; + +// CHECK-LABEL: i8 @unwrap_digit_from_remainder(i32 +#[no_mangle] +pub fn unwrap_digit_from_remainder(v: u32) -> AsciiChar { + // CHECK-NOT: icmp + // CHECK-NOT: panic + + // CHECK: %[[R:.+]] = urem i32 %v, 10 + // CHECK-NEXT: %[[T:.+]] = trunc i32 %[[R]] to i8 + // CHECK-NEXT: %[[D:.+]] = or i8 %[[T]], 48 + // CHECK-NEXT: ret i8 %[[D]] + + // CHECK-NOT: icmp + // CHECK-NOT: panic + AsciiChar::digit((v % 10) as u8).unwrap() +} + +// CHECK-LABEL: i8 @unwrap_from_masked(i8 +#[no_mangle] +pub fn unwrap_from_masked(b: u8) -> AsciiChar { + // CHECK-NOT: icmp + // CHECK-NOT: panic + + // CHECK: %[[M:.+]] = and i8 %b, 127 + // CHECK-NEXT: ret i8 %[[M]] + + // CHECK-NOT: icmp + // CHECK-NOT: panic + AsciiChar::from_u8(b & 0x7f).unwrap() +} diff --git a/tests/codegen/binary-search-index-no-bound-check.rs b/tests/codegen/binary-search-index-no-bound-check.rs index c1766a4a4..595969a89 100644 --- a/tests/codegen/binary-search-index-no-bound-check.rs +++ b/tests/codegen/binary-search-index-no-bound-check.rs @@ -9,7 +9,9 @@ #[no_mangle] pub fn binary_search_index_no_bounds_check(s: &[u8]) -> u8 { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check if let Ok(idx) = s.binary_search(&b'\\') { s[idx] } else { diff --git a/tests/codegen/call-llvm-intrinsics.rs b/tests/codegen/call-llvm-intrinsics.rs index cb8abae19..11f291771 100644 --- a/tests/codegen/call-llvm-intrinsics.rs +++ b/tests/codegen/call-llvm-intrinsics.rs @@ -1,6 +1,7 @@ // compile-flags: -C no-prepopulate-passes -Copt-level=0 // ignore-riscv64 +// ignore-loongarch64 #![feature(link_llvm_intrinsics)] #![crate_type = "lib"] diff --git a/tests/codegen/catch-unwind.rs b/tests/codegen/catch-unwind.rs index b90ef104c..6b63b83ef 100644 --- a/tests/codegen/catch-unwind.rs +++ b/tests/codegen/catch-unwind.rs @@ -10,6 +10,8 @@ // ignore-riscv64 FIXME // On s390x the closure is also in another function // ignore-s390x FIXME +// On loongarch64 the closure is also in another function +// ignore-loongarch64 FIXME #![crate_type = "lib"] #![feature(c_unwind)] diff --git a/tests/codegen/debug-vtable.rs b/tests/codegen/debug-vtable.rs index d82b737de..e52392b26 100644 --- a/tests/codegen/debug-vtable.rs +++ b/tests/codegen/debug-vtable.rs @@ -11,8 +11,6 @@ // Make sure that vtables don't have the unnamed_addr attribute when debuginfo is enabled. // This helps debuggers more reliably map from dyn pointer to concrete type. -// CHECK: @vtable.0 = private constant <{ -// CHECK: @vtable.1 = private constant <{ // CHECK: @vtable.2 = private constant <{ // CHECK: @vtable.3 = private constant <{ // CHECK: @vtable.4 = private constant <{ diff --git a/tests/codegen/debuginfo-constant-locals.rs b/tests/codegen/debuginfo-constant-locals.rs new file mode 100644 index 000000000..95a1b8c9d --- /dev/null +++ b/tests/codegen/debuginfo-constant-locals.rs @@ -0,0 +1,28 @@ +// compile-flags: -g -O + +// Check that simple constant values are preserved in debuginfo across both MIR opts and LLVM opts + +#![crate_type = "lib"] + +#[no_mangle] +pub fn check_it() { + let a = 1; + let b = 42; + + foo(a + b); +} + +#[inline(never)] +fn foo(x: i32) { + std::process::exit(x); +} + +// CHECK-LABEL: @check_it +// CHECK: call void @llvm.dbg.value(metadata i32 1, metadata ![[a_metadata:[0-9]+]], metadata !DIExpression()) +// CHECK: call void @llvm.dbg.value(metadata i32 42, metadata ![[b_metadata:[0-9]+]], metadata !DIExpression()) + +// CHECK: ![[a_metadata]] = !DILocalVariable(name: "a" +// CHECK-SAME: line: 9 + +// CHECK: ![[b_metadata]] = !DILocalVariable(name: "b" +// CHECK-SAME: line: 10 diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs new file mode 100644 index 000000000..725e6fc04 --- /dev/null +++ b/tests/codegen/drop-in-place-noalias.rs @@ -0,0 +1,38 @@ +// compile-flags: -O -C no-prepopulate-passes + +// Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`. +// Note that non-Unpin types should not get `noalias`, matching &mut behavior. + +#![crate_type="lib"] + +use std::marker::PhantomPinned; + +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}({{.*\*|ptr}} noalias noundef align 4 dereferenceable(12) %{{.+}}) + +// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}({{.*\*|ptr}} noundef nonnull align 4 %{{.+}}) + +pub struct StructUnpin { + a: i32, + b: i32, + c: i32, +} + +impl Drop for StructUnpin { + fn drop(&mut self) {} +} + +pub struct StructNotUnpin { + a: i32, + b: i32, + c: i32, + p: PhantomPinned, +} + +impl Drop for StructNotUnpin { + fn drop(&mut self) {} +} + +pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) { + drop(x); + drop(y); +} diff --git a/tests/codegen/enable-lto-unit-splitting.rs b/tests/codegen/enable-lto-unit-splitting.rs new file mode 100644 index 000000000..7daa05f69 --- /dev/null +++ b/tests/codegen/enable-lto-unit-splitting.rs @@ -0,0 +1,10 @@ +// Verifies that "EnableSplitLTOUnit" module flag is added. +// +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsplit-lto-unit + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1} diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs index 7f383a5c1..a09c79592 100644 --- a/tests/codegen/fewer-names.rs +++ b/tests/codegen/fewer-names.rs @@ -7,14 +7,14 @@ #[no_mangle] pub fn sum(x: u32, y: u32) -> u32 { -// YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1) -// YES-NEXT: %3 = add i32 %1, %0 -// YES-NEXT: ret i32 %3 + // YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1) + // YES-NEXT: %3 = add i32 %1, %0 + // YES-NEXT: ret i32 %3 -// NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y) -// NO-NEXT: start: -// NO-NEXT: %0 = add i32 %y, %x -// NO-NEXT: ret i32 %0 + // NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y) + // NO-NEXT: start: + // NO-NEXT: %0 = add i32 %y, %x + // NO-NEXT: ret i32 %0 let z = x + y; z } diff --git a/tests/codegen/global_asm.rs b/tests/codegen/global_asm.rs index 9912b1e75..41a99530a 100644 --- a/tests/codegen/global_asm.rs +++ b/tests/codegen/global_asm.rs @@ -18,6 +18,7 @@ // ignore-wasm32 // ignore-wasm64 // ignore-emscripten +// ignore-loongarch64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/global_asm_include.rs b/tests/codegen/global_asm_include.rs index b68c5ad3b..e25c164f4 100644 --- a/tests/codegen/global_asm_include.rs +++ b/tests/codegen/global_asm_include.rs @@ -18,6 +18,7 @@ // ignore-wasm32 // ignore-wasm64 // ignore-emscripten +// ignore-loongarch64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/global_asm_x2.rs b/tests/codegen/global_asm_x2.rs index d87e02bef..71ecef124 100644 --- a/tests/codegen/global_asm_x2.rs +++ b/tests/codegen/global_asm_x2.rs @@ -18,6 +18,7 @@ // ignore-wasm32 // ignore-wasm64 // ignore-emscripten +// ignore-loongarch64 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/inline-hint.rs b/tests/codegen/inline-hint.rs index d3ea1915a..bb2a8e6a6 100644 --- a/tests/codegen/inline-hint.rs +++ b/tests/codegen/inline-hint.rs @@ -1,7 +1,7 @@ // Checks that closures, constructors, and shims except // for a drop glue receive inline hint by default. // -// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0 +// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0 -Zinline-mir=no #![crate_type = "lib"] pub fn f() { diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs new file mode 100644 index 000000000..7fc4f4498 --- /dev/null +++ b/tests/codegen/intrinsics/offset.rs @@ -0,0 +1,34 @@ +// compile-flags: -O -C no-prepopulate-passes +// min-llvm-version: 15.0 (because we're using opaque pointers) + +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::offset; + +// CHECK-LABEL: ptr @offset_zst +// CHECK-SAME: (ptr noundef %p, [[SIZE:i[0-9]+]] noundef %d) +#[no_mangle] +pub unsafe fn offset_zst(p: *const (), d: usize) -> *const () { + // CHECK-NOT: getelementptr + // CHECK: ret ptr %p + offset(p, d) +} + +// CHECK-LABEL: ptr @offset_isize +// CHECK-SAME: (ptr noundef %p, [[SIZE]] noundef %d) +#[no_mangle] +pub unsafe fn offset_isize(p: *const u32, d: isize) -> *const u32 { + // CHECK: %[[R:.*]] = getelementptr inbounds i32, ptr %p, [[SIZE]] %d + // CHECK-NEXT: ret ptr %[[R]] + offset(p, d) +} + +// CHECK-LABEL: ptr @offset_usize +// CHECK-SAME: (ptr noundef %p, [[SIZE]] noundef %d) +#[no_mangle] +pub unsafe fn offset_usize(p: *const u64, d: usize) -> *const u64 { + // CHECK: %[[R:.*]] = getelementptr inbounds i64, ptr %p, [[SIZE]] %d + // CHECK-NEXT: ret ptr %[[R]] + offset(p, d) +} diff --git a/tests/codegen/intrinsics/transmute-niched.rs b/tests/codegen/intrinsics/transmute-niched.rs new file mode 100644 index 000000000..69e9b1d12 --- /dev/null +++ b/tests/codegen/intrinsics/transmute-niched.rs @@ -0,0 +1,184 @@ +// revisions: OPT DBG +// [OPT] compile-flags: -C opt-level=3 -C no-prepopulate-passes +// [DBG] compile-flags: -C opt-level=0 -C no-prepopulate-passes +// only-64bit (so I don't need to worry about usize) +// min-llvm-version: 15.0 # this test assumes `ptr`s + +#![crate_type = "lib"] + +use std::mem::transmute; +use std::num::NonZeroU32; + +#[repr(u8)] +pub enum SmallEnum { + A = 10, + B = 11, + C = 12, +} + +// CHECK-LABEL: @check_to_enum( +#[no_mangle] +pub unsafe fn check_to_enum(x: i8) -> SmallEnum { + // OPT: %0 = icmp uge i8 %x, 10 + // OPT: call void @llvm.assume(i1 %0) + // OPT: %1 = icmp ule i8 %x, 12 + // OPT: call void @llvm.assume(i1 %1) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i8 %x + + transmute(x) +} + +// CHECK-LABEL: @check_from_enum( +#[no_mangle] +pub unsafe fn check_from_enum(x: SmallEnum) -> i8 { + // OPT: %0 = icmp uge i8 %x, 10 + // OPT: call void @llvm.assume(i1 %0) + // OPT: %1 = icmp ule i8 %x, 12 + // OPT: call void @llvm.assume(i1 %1) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i8 %x + + transmute(x) +} + +// CHECK-LABEL: @check_to_ordering( +#[no_mangle] +pub unsafe fn check_to_ordering(x: u8) -> std::cmp::Ordering { + // OPT: %0 = icmp uge i8 %x, -1 + // OPT: %1 = icmp ule i8 %x, 1 + // OPT: %2 = or i1 %0, %1 + // OPT: call void @llvm.assume(i1 %2) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i8 %x + + transmute(x) +} + +// CHECK-LABEL: @check_from_ordering( +#[no_mangle] +pub unsafe fn check_from_ordering(x: std::cmp::Ordering) -> u8 { + // OPT: %0 = icmp uge i8 %x, -1 + // OPT: %1 = icmp ule i8 %x, 1 + // OPT: %2 = or i1 %0, %1 + // OPT: call void @llvm.assume(i1 %2) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i8 %x + + transmute(x) +} + +#[repr(i32)] +pub enum Minus100ToPlus100 { + A = -100, + B = -90, + C = -80, + D = -70, + E = -60, + F = -50, + G = -40, + H = -30, + I = -20, + J = -10, + K = 0, + L = 10, + M = 20, + N = 30, + O = 40, + P = 50, + Q = 60, + R = 70, + S = 80, + T = 90, + U = 100, +} + +// CHECK-LABEL: @check_enum_from_char( +#[no_mangle] +pub unsafe fn check_enum_from_char(x: char) -> Minus100ToPlus100 { + // OPT: %0 = icmp ule i32 %x, 1114111 + // OPT: call void @llvm.assume(i1 %0) + // OPT: %1 = icmp uge i32 %x, -100 + // OPT: %2 = icmp ule i32 %x, 100 + // OPT: %3 = or i1 %1, %2 + // OPT: call void @llvm.assume(i1 %3) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i32 %x + + transmute(x) +} + +// CHECK-LABEL: @check_enum_to_char( +#[no_mangle] +pub unsafe fn check_enum_to_char(x: Minus100ToPlus100) -> char { + // OPT: %0 = icmp uge i32 %x, -100 + // OPT: %1 = icmp ule i32 %x, 100 + // OPT: %2 = or i1 %0, %1 + // OPT: call void @llvm.assume(i1 %2) + // OPT: %3 = icmp ule i32 %x, 1114111 + // OPT: call void @llvm.assume(i1 %3) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i32 %x + + transmute(x) +} + +// CHECK-LABEL: @check_swap_pair( +#[no_mangle] +pub unsafe fn check_swap_pair(x: (char, NonZeroU32)) -> (NonZeroU32, char) { + // OPT: %0 = icmp ule i32 %x.0, 1114111 + // OPT: call void @llvm.assume(i1 %0) + // OPT: %1 = icmp uge i32 %x.0, 1 + // OPT: call void @llvm.assume(i1 %1) + // OPT: %2 = icmp uge i32 %x.1, 1 + // OPT: call void @llvm.assume(i1 %2) + // OPT: %3 = icmp ule i32 %x.1, 1114111 + // OPT: call void @llvm.assume(i1 %3) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: %[[P1:.+]] = insertvalue { i32, i32 } poison, i32 %x.0, 0 + // CHECK: %[[P2:.+]] = insertvalue { i32, i32 } %[[P1]], i32 %x.1, 1 + // CHECK: ret { i32, i32 } %[[P2]] + + transmute(x) +} + +// CHECK-LABEL: @check_bool_from_ordering( +#[no_mangle] +pub unsafe fn check_bool_from_ordering(x: std::cmp::Ordering) -> bool { + // OPT: %0 = icmp uge i8 %x, -1 + // OPT: %1 = icmp ule i8 %x, 1 + // OPT: %2 = or i1 %0, %1 + // OPT: call void @llvm.assume(i1 %2) + // OPT: %3 = icmp ule i8 %x, 1 + // OPT: call void @llvm.assume(i1 %3) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: %[[R:.+]] = trunc i8 %x to i1 + // CHECK: ret i1 %[[R]] + + transmute(x) +} + +// CHECK-LABEL: @check_bool_to_ordering( +#[no_mangle] +pub unsafe fn check_bool_to_ordering(x: bool) -> std::cmp::Ordering { + // CHECK: %0 = zext i1 %x to i8 + // OPT: %1 = icmp ule i8 %0, 1 + // OPT: call void @llvm.assume(i1 %1) + // OPT: %2 = icmp uge i8 %0, -1 + // OPT: %3 = icmp ule i8 %0, 1 + // OPT: %4 = or i1 %2, %3 + // OPT: call void @llvm.assume(i1 %4) + // DBG-NOT: icmp + // DBG-NOT: assume + // CHECK: ret i8 %0 + + transmute(x) +} diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index 57f901c67..664e697c2 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -8,10 +8,10 @@ #![feature(inline_const)] #![allow(unreachable_code)] -use std::mem::{transmute, MaybeUninit}; +use std::mem::MaybeUninit; +use std::intrinsics::{transmute, transmute_unchecked}; -// Some of the cases here are statically rejected by `mem::transmute`, so -// we need to generate custom MIR for those cases to get to codegen. +// Some of these need custom MIR to not get removed by MIR optimizations. use std::intrinsics::mir::*; enum Never {} @@ -30,59 +30,35 @@ pub struct Aggregate8(u8); // CHECK-LABEL: @check_bigger_size( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] pub unsafe fn check_bigger_size(x: u16) -> u32 { // CHECK: call void @llvm.trap - mir!{ - { - RET = CastTransmute(x); - Return() - } - } + transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_size( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] pub unsafe fn check_smaller_size(x: u32) -> u16 { // CHECK: call void @llvm.trap - mir!{ - { - RET = CastTransmute(x); - Return() - } - } + transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_array( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] pub unsafe fn check_smaller_array(x: [u32; 7]) -> [u32; 3] { // CHECK: call void @llvm.trap - mir!{ - { - RET = CastTransmute(x); - Return() - } - } + transmute_unchecked(x) } // CHECK-LABEL: @check_bigger_array( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] pub unsafe fn check_bigger_array(x: [u32; 3]) -> [u32; 7] { // CHECK: call void @llvm.trap - mir!{ - { - RET = CastTransmute(x); - Return() - } - } + transmute_unchecked(x) } // CHECK-LABEL: @check_to_uninhabited( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] +#[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_to_uninhabited(x: u16) -> BigNever { // CHECK: call void @llvm.trap mir!{ @@ -95,7 +71,7 @@ pub unsafe fn check_to_uninhabited(x: u16) -> BigNever { // CHECK-LABEL: @check_from_uninhabited( #[no_mangle] -#[custom_mir(dialect = "runtime", phase = "initial")] +#[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_from_uninhabited(x: BigNever) -> u16 { // CHECK: ret i16 poison mir!{ @@ -169,8 +145,8 @@ pub unsafe fn check_aggregate_from_bool(x: bool) -> Aggregate8 { #[no_mangle] pub unsafe fn check_byte_to_bool(x: u8) -> bool { // CHECK-NOT: alloca - // CHECK: %0 = trunc i8 %x to i1 - // CHECK: ret i1 %0 + // CHECK: %[[R:.+]] = trunc i8 %x to i1 + // CHECK: ret i1 %[[R]] transmute(x) } @@ -178,8 +154,8 @@ pub unsafe fn check_byte_to_bool(x: u8) -> bool { #[no_mangle] pub unsafe fn check_byte_from_bool(x: bool) -> u8 { // CHECK-NOT: alloca - // CHECK: %0 = zext i1 %x to i8 - // CHECK: ret i8 %0 + // CHECK: %[[R:.+]] = zext i1 %x to i8 + // CHECK: ret i8 %[[R:.+]] transmute(x) } diff --git a/tests/codegen/issues/issue-103840.rs b/tests/codegen/issues/issue-103840.rs index f19d7031b..da64692d2 100644 --- a/tests/codegen/issues/issue-103840.rs +++ b/tests/codegen/issues/issue-103840.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// min-llvm-version: 16.0 #![crate_type = "lib"] pub fn foo(t: &mut Vec<usize>) { diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index d54ac9e33..2ee4d7cca 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -19,4 +19,5 @@ pub fn outer_function(x: S, y: S) -> usize { // CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) -// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[spill]], ptr {{align .*}} %x +// CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]] +// CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[inner]], ptr {{align .*}} %x diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs new file mode 100644 index 000000000..90b3c314d --- /dev/null +++ b/tests/codegen/issues/issue-111603.rs @@ -0,0 +1,28 @@ +// compile-flags: -O + +#![crate_type = "lib"] +#![feature(get_mut_unchecked, new_uninit)] + +use std::sync::Arc; + +// CHECK-LABEL: @new_uninit +#[no_mangle] +pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> { + // CHECK: call alloc::sync::arcinner_layout_for_value_layout + // CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout + let mut arc = Arc::new_uninit(); + unsafe { Arc::get_mut_unchecked(&mut arc) }.write([x; 1000]); + unsafe { arc.assume_init() } +} + +// CHECK-LABEL: @new_uninit_slice +#[no_mangle] +pub fn new_uninit_slice(x: u64) -> Arc<[u64]> { + // CHECK: call alloc::sync::arcinner_layout_for_value_layout + // CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout + let mut arc = Arc::new_uninit_slice(1000); + for elem in unsafe { Arc::get_mut_unchecked(&mut arc) } { + elem.write(x); + } + unsafe { arc.assume_init() } +} diff --git a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs index 8d07a67a1..2d7797887 100644 --- a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs +++ b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs @@ -9,7 +9,10 @@ #[no_mangle] pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().position(|b| *b == b'\\') { &s[..idx] } else { @@ -21,7 +24,10 @@ pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] { #[no_mangle] pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().position(|b| *b == b'\\') { &s[idx..] } else { @@ -33,7 +39,10 @@ pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] { #[no_mangle] pub fn position_index_no_bounds_check(s: &[u8]) -> u8 { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().position(|b| *b == b'\\') { s[idx] } else { @@ -44,7 +53,10 @@ pub fn position_index_no_bounds_check(s: &[u8]) -> u8 { #[no_mangle] pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { &s[..idx] } else { @@ -56,7 +68,10 @@ pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] { #[no_mangle] pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { &s[idx..] } else { @@ -68,7 +83,10 @@ pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] { #[no_mangle] pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 { // CHECK-NOT: panic - // CHECK-NOT: slice_index_len_fail + // CHECK-NOT: slice_start_index_len_fail + // CHECK-NOT: slice_end_index_len_fail + // CHECK-NOT: panic_bounds_check + // CHECK-NOT: unreachable if let Some(idx) = s.iter().rposition(|b| *b == b'\\') { s[idx] } else { diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs index 9ccbcb24f..c0be7fab2 100644 --- a/tests/codegen/issues/issue-86106.rs +++ b/tests/codegen/issues/issue-86106.rs @@ -1,4 +1,5 @@ // min-llvm-version: 15.0 +// only-64bit llvm appears to use stores instead of memset on 32bit // compile-flags: -C opt-level=3 -Z merge-functions=disabled // The below two functions ensure that both `String::new()` and `"".to_string()` @@ -9,12 +10,9 @@ // CHECK-LABEL: define void @string_new #[no_mangle] pub fn string_new() -> String { - // CHECK-NOT: load i8 - // CHECK: store i{{32|64}} + // CHECK: store ptr inttoptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: store ptr - // CHECK-NEXT: getelementptr - // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: call void @llvm.memset // CHECK-NEXT: ret void String::new() } @@ -22,12 +20,9 @@ pub fn string_new() -> String { // CHECK-LABEL: define void @empty_to_string #[no_mangle] pub fn empty_to_string() -> String { - // CHECK-NOT: load i8 - // CHECK: store i{{32|64}} - // CHECK-NEXT: getelementptr - // CHECK-NEXT: store ptr + // CHECK: store ptr inttoptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: call void @llvm.memset // CHECK-NEXT: ret void "".to_string() } @@ -38,12 +33,9 @@ pub fn empty_to_string() -> String { // CHECK-LABEL: @empty_vec #[no_mangle] pub fn empty_vec() -> Vec<u8> { - // CHECK: store i{{32|64}} - // CHECK-NOT: load i8 + // CHECK: store ptr inttoptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: store ptr - // CHECK-NEXT: getelementptr - // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: call void @llvm.memset // CHECK-NEXT: ret void vec![] } @@ -51,12 +43,9 @@ pub fn empty_vec() -> Vec<u8> { // CHECK-LABEL: @empty_vec_clone #[no_mangle] pub fn empty_vec_clone() -> Vec<u8> { - // CHECK: store i{{32|64}} - // CHECK-NOT: load i8 - // CHECK-NEXT: getelementptr - // CHECK-NEXT: store ptr + // CHECK: store ptr inttoptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: store i{{32|64}} + // CHECK-NEXT: call void @llvm.memset // CHECK-NEXT: ret void vec![].clone() } diff --git a/tests/codegen/local-generics-in-exe-internalized.rs b/tests/codegen/local-generics-in-exe-internalized.rs index e5430fbf1..449c5ca75 100644 --- a/tests/codegen/local-generics-in-exe-internalized.rs +++ b/tests/codegen/local-generics-in-exe-internalized.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes +// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes -Zinline-mir=no // Check that local generics are internalized if they are in the same CGU diff --git a/tests/codegen/loongarch-abi/call-llvm-intrinsics.rs b/tests/codegen/loongarch-abi/call-llvm-intrinsics.rs new file mode 100644 index 000000000..4b78f6e24 --- /dev/null +++ b/tests/codegen/loongarch-abi/call-llvm-intrinsics.rs @@ -0,0 +1,31 @@ +// compile-flags: -C no-prepopulate-passes + +// only-loongarch64 + +#![feature(link_llvm_intrinsics)] +#![crate_type = "lib"] + +struct A; + +impl Drop for A { + fn drop(&mut self) { + println!("A"); + } +} + +extern "C" { + #[link_name = "llvm.sqrt.f32"] + fn sqrt(x: f32) -> f32; +} + +pub fn do_call() { + let _a = A; + + unsafe { + // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them + // CHECK: store float 4.000000e+00, ptr %{{.}}, align 4 + // CHECK: load float, ptr %{{.}}, align 4 + // CHECK: call float @llvm.sqrt.f32(float %{{.}} + sqrt(4.0); + } +} diff --git a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs new file mode 100644 index 000000000..7555553c2 --- /dev/null +++ b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs @@ -0,0 +1,293 @@ +// compile-flags: -C no-prepopulate-passes +// only-loongarch64 +// only-linux + +#![crate_type = "lib"] + +// CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i) +#[no_mangle] +pub extern "C" fn f_fpr_tracking( + a: f64, + b: f64, + c: f64, + d: f64, + e: f64, + f: f64, + g: f64, + h: f64, + i: u8, +) { +} + +#[repr(C)] +pub struct Double { + f: f64, +} + +#[repr(C)] +pub struct DoubleDouble { + f: f64, + g: f64, +} + +#[repr(C)] +pub struct DoubleFloat { + f: f64, + g: f32, +} + +// CHECK: define void @f_double_s_arg(double %0) +#[no_mangle] +pub extern "C" fn f_double_s_arg(a: Double) {} + +// CHECK: define double @f_ret_double_s() +#[no_mangle] +pub extern "C" fn f_ret_double_s() -> Double { + Double { f: 1. } +} + +// CHECK: define void @f_double_double_s_arg({ double, double } %0) +#[no_mangle] +pub extern "C" fn f_double_double_s_arg(a: DoubleDouble) {} + +// CHECK: define { double, double } @f_ret_double_double_s() +#[no_mangle] +pub extern "C" fn f_ret_double_double_s() -> DoubleDouble { + DoubleDouble { f: 1., g: 2. } +} + +// CHECK: define void @f_double_float_s_arg({ double, float } %0) +#[no_mangle] +pub extern "C" fn f_double_float_s_arg(a: DoubleFloat) {} + +// CHECK: define { double, float } @f_ret_double_float_s() +#[no_mangle] +pub extern "C" fn f_ret_double_float_s() -> DoubleFloat { + DoubleFloat { f: 1., g: 2. } +} + +// CHECK: define void @f_double_double_s_arg_insufficient_fprs(double %0, double %1, double %2, double %3, double %4, double %5, double %6, [2 x i64] %7) +#[no_mangle] +pub extern "C" fn f_double_double_s_arg_insufficient_fprs( + a: f64, + b: f64, + c: f64, + d: f64, + e: f64, + f: f64, + g: f64, + h: DoubleDouble, +) { +} + +#[repr(C)] +pub struct DoubleInt8 { + f: f64, + i: i8, +} + +#[repr(C)] +pub struct DoubleUInt8 { + f: f64, + i: u8, +} + +#[repr(C)] +pub struct DoubleInt32 { + f: f64, + i: i32, +} + +#[repr(C)] +pub struct DoubleInt64 { + f: f64, + i: i64, +} + +// CHECK: define void @f_double_int8_s_arg({ double, i8 } %0) +#[no_mangle] +pub extern "C" fn f_double_int8_s_arg(a: DoubleInt8) {} + +// CHECK: define { double, i8 } @f_ret_double_int8_s() +#[no_mangle] +pub extern "C" fn f_ret_double_int8_s() -> DoubleInt8 { + DoubleInt8 { f: 1., i: 2 } +} + +// CHECK: define void @f_double_int32_s_arg({ double, i32 } %0) +#[no_mangle] +pub extern "C" fn f_double_int32_s_arg(a: DoubleInt32) {} + +// CHECK: define { double, i32 } @f_ret_double_int32_s() +#[no_mangle] +pub extern "C" fn f_ret_double_int32_s() -> DoubleInt32 { + DoubleInt32 { f: 1., i: 2 } +} + +// CHECK: define void @f_double_uint8_s_arg({ double, i8 } %0) +#[no_mangle] +pub extern "C" fn f_double_uint8_s_arg(a: DoubleUInt8) {} + +// CHECK: define { double, i8 } @f_ret_double_uint8_s() +#[no_mangle] +pub extern "C" fn f_ret_double_uint8_s() -> DoubleUInt8 { + DoubleUInt8 { f: 1., i: 2 } +} + +// CHECK: define void @f_double_int64_s_arg({ double, i64 } %0) +#[no_mangle] +pub extern "C" fn f_double_int64_s_arg(a: DoubleInt64) {} + +// CHECK: define { double, i64 } @f_ret_double_int64_s() +#[no_mangle] +pub extern "C" fn f_ret_double_int64_s() -> DoubleInt64 { + DoubleInt64 { f: 1., i: 2 } +} + +// CHECK: define void @f_double_int8_s_arg_insufficient_gprs(i32 noundef signext %a, i32 noundef signext %b, i32 noundef signext %c, i32 noundef signext %d, i32 noundef signext %e, i32 noundef signext %f, i32 noundef signext %g, i32 noundef signext %h, [2 x i64] %0) +#[no_mangle] +pub extern "C" fn f_double_int8_s_arg_insufficient_gprs( + a: i32, + b: i32, + c: i32, + d: i32, + e: i32, + f: i32, + g: i32, + h: i32, + i: DoubleInt8, +) { +} + +// CHECK: define void @f_struct_double_int8_insufficient_fprs(float %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, [2 x i64] %8) +#[no_mangle] +pub extern "C" fn f_struct_double_int8_insufficient_fprs( + a: f32, + b: f64, + c: f64, + d: f64, + e: f64, + f: f64, + g: f64, + h: f64, + i: DoubleInt8, +) { +} + +#[repr(C)] +pub struct DoubleArr1 { + a: [f64; 1], +} + +// CHECK: define void @f_doublearr1_s_arg(double %0) +#[no_mangle] +pub extern "C" fn f_doublearr1_s_arg(a: DoubleArr1) {} + +// CHECK: define double @f_ret_doublearr1_s() +#[no_mangle] +pub extern "C" fn f_ret_doublearr1_s() -> DoubleArr1 { + DoubleArr1 { a: [1.] } +} + +#[repr(C)] +pub struct DoubleArr2 { + a: [f64; 2], +} + +// CHECK: define void @f_doublearr2_s_arg({ double, double } %0) +#[no_mangle] +pub extern "C" fn f_doublearr2_s_arg(a: DoubleArr2) {} + +// CHECK: define { double, double } @f_ret_doublearr2_s() +#[no_mangle] +pub extern "C" fn f_ret_doublearr2_s() -> DoubleArr2 { + DoubleArr2 { a: [1., 2.] } +} + +#[repr(C)] +pub struct Tricky1 { + f: [f64; 1], +} + +#[repr(C)] +pub struct DoubleArr2Tricky1 { + g: [Tricky1; 2], +} + +// CHECK: define void @f_doublearr2_tricky1_s_arg({ double, double } %0) +#[no_mangle] +pub extern "C" fn f_doublearr2_tricky1_s_arg(a: DoubleArr2Tricky1) {} + +// CHECK: define { double, double } @f_ret_doublearr2_tricky1_s() +#[no_mangle] +pub extern "C" fn f_ret_doublearr2_tricky1_s() -> DoubleArr2Tricky1 { + DoubleArr2Tricky1 { g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] } +} + +#[repr(C)] +pub struct EmptyStruct {} + +#[repr(C)] +pub struct DoubleArr2Tricky2 { + s: EmptyStruct, + g: [Tricky1; 2], +} + +// CHECK: define void @f_doublearr2_tricky2_s_arg({ double, double } %0) +#[no_mangle] +pub extern "C" fn f_doublearr2_tricky2_s_arg(a: DoubleArr2Tricky2) {} + +// CHECK: define { double, double } @f_ret_doublearr2_tricky2_s() +#[no_mangle] +pub extern "C" fn f_ret_doublearr2_tricky2_s() -> DoubleArr2Tricky2 { + DoubleArr2Tricky2 { s: EmptyStruct {}, g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] } +} + +#[repr(C)] +pub struct IntDoubleInt { + a: i32, + b: f64, + c: i32, +} + +// CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef dereferenceable(24) %a) +#[no_mangle] +pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} + +// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) dereferenceable(24) %0) +#[no_mangle] +pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt { + IntDoubleInt { a: 1, b: 2., c: 3 } +} + +#[repr(C)] +pub struct CharCharDouble { + a: u8, + b: u8, + c: f64, +} + +// CHECK: define void @f_char_char_double_s_arg([2 x i64] %0) +#[no_mangle] +pub extern "C" fn f_char_char_double_s_arg(a: CharCharDouble) {} + +// CHECK: define [2 x i64] @f_ret_char_char_double_s() +#[no_mangle] +pub extern "C" fn f_ret_char_char_double_s() -> CharCharDouble { + CharCharDouble { a: 1, b: 2, c: 3. } +} + +#[repr(C)] +pub union DoubleU { + a: f64, +} + +// CHECK: define void @f_double_u_arg(i64 %0) +#[no_mangle] +pub extern "C" fn f_double_u_arg(a: DoubleU) {} + +// CHECK: define i64 @f_ret_double_u() +#[no_mangle] +pub extern "C" fn f_ret_double_u() -> DoubleU { + unsafe { DoubleU { a: 1. } } +} diff --git a/tests/codegen/mem-replace-big-type.rs b/tests/codegen/mem-replace-big-type.rs index f6898e2f7..c6b920cf5 100644 --- a/tests/codegen/mem-replace-big-type.rs +++ b/tests/codegen/mem-replace-big-type.rs @@ -11,7 +11,9 @@ #[repr(C, align(8))] pub struct Big([u64; 7]); pub fn replace_big(dst: &mut Big, src: Big) -> Big { - // Before the `read_via_copy` intrinsic, this emitted six `memcpy`s. + // Back in 1.68, this emitted six `memcpy`s. + // `read_via_copy` in 1.69 got that down to three. + // `write_via_move` and nvro get this down to the essential two. std::mem::replace(dst, src) } @@ -22,15 +24,10 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big { // For a large type, we expect exactly three `memcpy`s // CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big) - // CHECK-NOT: alloca - // CHECK: alloca %Big - // CHECK-NOT: alloca - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) - // CHECK-NOT: call void @llvm.memcpy +// CHECK-NOT: call void @llvm.memcpy +// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %0, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false) +// CHECK-NOT: call void @llvm.memcpy +// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false) +// CHECK-NOT: call void @llvm.memcpy // CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/mem-replace-direct-memcpy.rs b/tests/codegen/mem-replace-direct-memcpy.rs deleted file mode 100644 index 83babab4f..000000000 --- a/tests/codegen/mem-replace-direct-memcpy.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This test ensures that `mem::replace::<T>` only ever calls `@llvm.memcpy` -// with `size_of::<T>()` as the size, and never goes through any wrapper that -// may e.g. multiply `size_of::<T>()` with a variable "count" (which is only -// known to be `1` after inlining). - -// compile-flags: -C no-prepopulate-passes -Zinline-mir=no -// ignore-debug: the debug assertions get in the way - -#![crate_type = "lib"] - -pub fn replace_byte(dst: &mut u8, src: u8) -> u8 { - std::mem::replace(dst, src) -} - -// NOTE(eddyb) the `CHECK-NOT`s ensure that the only calls of `@llvm.memcpy` in -// the entire output, are the direct calls we want, from `ptr::replace`. - -// CHECK-NOT: call void @llvm.memcpy - -// For a small type, we expect one each of `load`/`store`/`memcpy` instead -// CHECK-LABEL: define internal noundef i8 @{{.+}}mem{{.+}}replace - // CHECK-NOT: alloca - // CHECK: alloca i8 - // CHECK-NOT: alloca - // CHECK-NOT: call void @llvm.memcpy - // CHECK: load i8 - // CHECK-NOT: call void @llvm.memcpy - // CHECK: store i8 - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{.*}} 1, i1 false) - // CHECK-NOT: call void @llvm.memcpy - -// CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs new file mode 100644 index 000000000..4253ef136 --- /dev/null +++ b/tests/codegen/mem-replace-simple-type.rs @@ -0,0 +1,34 @@ +// compile-flags: -O -C no-prepopulate-passes +// min-llvm-version: 15.0 (for opaque pointers) +// only-x86_64 (to not worry about usize differing) +// ignore-debug (the debug assertions get in the way) + +#![crate_type = "lib"] + +#[no_mangle] +// CHECK-LABEL: @replace_usize( +pub fn replace_usize(r: &mut usize, v: usize) -> usize { + // CHECK-NOT: alloca + // CHECK: %[[R:.+]] = load i64, ptr %r + // CHECK: store i64 %v, ptr %r + // CHECK: ret i64 %[[R]] + std::mem::replace(r, v) +} + +#[no_mangle] +// CHECK-LABEL: @replace_ref_str( +pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str { + // CHECK-NOT: alloca + // CHECK: %[[A:.+]] = load ptr + // CHECK: %[[B:.+]] = load i64 + // CHECK-NOT: store + // CHECK-NOT: load + // CHECK: store ptr + // CHECK: store i64 + // CHECK-NOT: load + // CHECK-NOT: store + // CHECK: %[[P1:.+]] = insertvalue { ptr, i64 } poison, ptr %[[A]], 0 + // CHECK: %[[P2:.+]] = insertvalue { ptr, i64 } %[[P1]], i64 %[[B]], 1 + // CHECK: ret { ptr, i64 } %[[P2]] + std::mem::replace(r, v) +} diff --git a/tests/codegen/noalias-box-off.rs b/tests/codegen/noalias-box-off.rs index afd17c7c1..c82c53b2a 100644 --- a/tests/codegen/noalias-box-off.rs +++ b/tests/codegen/noalias-box-off.rs @@ -4,5 +4,8 @@ // CHECK-LABEL: @box_should_not_have_noalias_if_disabled( // CHECK-NOT: noalias +// CHECK-SAME: %foo) #[no_mangle] -pub fn box_should_not_have_noalias_if_disabled(_b: Box<u8>) {} +pub fn box_should_not_have_noalias_if_disabled(foo: Box<u8>) { + drop(foo); +} diff --git a/tests/codegen/nrvo.rs b/tests/codegen/nrvo.rs index fddb0d1fb..b2ae99f37 100644 --- a/tests/codegen/nrvo.rs +++ b/tests/codegen/nrvo.rs @@ -8,7 +8,7 @@ pub fn nrvo(init: fn(&mut [u8; 4096])) -> [u8; 4096] { // CHECK-LABEL: nrvo // CHECK: @llvm.memset - // CHECK-NOT: @llvm.memcpy + // FIXME: turn on nrvo then check-not: @llvm.memcpy // CHECK: ret // CHECK-EMPTY let mut buf = [0; 4096]; diff --git a/tests/codegen/optimize-attr-1.rs b/tests/codegen/optimize-attr-1.rs index 1d1f0a386..d95ba8530 100644 --- a/tests/codegen/optimize-attr-1.rs +++ b/tests/codegen/optimize-attr-1.rs @@ -9,7 +9,7 @@ // CHECK-LABEL: define{{.*}}i32 @nothing // CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]] // SIZE-OPT: ret i32 4 -// SPEEC-OPT: ret i32 4 +// SPEED-OPT: ret i32 4 #[no_mangle] pub fn nothing() -> i32 { 2 + 2 diff --git a/tests/codegen/option-as-slice.rs b/tests/codegen/option-as-slice.rs index d735d5583..1edd9ba9f 100644 --- a/tests/codegen/option-as-slice.rs +++ b/tests/codegen/option-as-slice.rs @@ -1,5 +1,7 @@ // compile-flags: -O -Z randomize-layout=no // only-x86_64 +// ignore-llvm-version: 16.0.0 +// ^ needs https://reviews.llvm.org/D146149 in 16.0.1 #![crate_type = "lib"] #![feature(option_as_slice)] diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-nonzero-eq.rs index 835decd3e..a394695f3 100644 --- a/tests/codegen/option-nonzero-eq.rs +++ b/tests/codegen/option-nonzero-eq.rs @@ -7,6 +7,9 @@ use core::cmp::Ordering; use core::num::{NonZeroU32, NonZeroI64}; use core::ptr::NonNull; +// See also tests/assembly/option-nonzero-eq.rs, for cases with `assume`s in the +// LLVM and thus don't optimize down clearly here, but do in assembly. + // CHECK-lABEL: @non_zero_eq #[no_mangle] pub fn non_zero_eq(l: Option<NonZeroU32>, r: Option<NonZeroU32>) -> bool { @@ -33,12 +36,3 @@ pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool { // CHECK-NEXT: ret i1 l == r } - -// CHECK-lABEL: @ordering_eq -#[no_mangle] -pub fn ordering_eq(l: Option<Ordering>, r: Option<Ordering>) -> bool { - // CHECK: start: - // CHECK-NEXT: icmp eq i8 - // CHECK-NEXT: ret i1 - l == r -} diff --git a/tests/codegen/remap_path_prefix/auxiliary/xcrate-generic.rs b/tests/codegen/remap_path_prefix/auxiliary/xcrate-generic.rs index 59092dbf6..15bd0f174 100644 --- a/tests/codegen/remap_path_prefix/auxiliary/xcrate-generic.rs +++ b/tests/codegen/remap_path_prefix/auxiliary/xcrate-generic.rs @@ -3,4 +3,6 @@ #![crate_type = "lib"] -pub fn foo<T>() {} +pub fn foo<T: Default>() -> T { + T::default() +} diff --git a/tests/codegen/remap_path_prefix/xcrate-generic.rs b/tests/codegen/remap_path_prefix/xcrate-generic.rs index 7a9d2ca9b..399deec1f 100644 --- a/tests/codegen/remap_path_prefix/xcrate-generic.rs +++ b/tests/codegen/remap_path_prefix/xcrate-generic.rs @@ -7,7 +7,7 @@ extern crate xcrate_generic; pub fn foo() { - xcrate_generic::foo::<u32>(); + println!("{}", xcrate_generic::foo::<u32>()); } // Here we check that local debuginfo is mapped correctly. diff --git a/tests/codegen/repr-transparent-aggregates-1.rs b/tests/codegen/repr-transparent-aggregates-1.rs index f733de12b..9c4b0e58e 100644 --- a/tests/codegen/repr-transparent-aggregates-1.rs +++ b/tests/codegen/repr-transparent-aggregates-1.rs @@ -10,6 +10,7 @@ // ignore-riscv64 see codegen/riscv-abi // ignore-s390x // ignore-windows +// ignore-loongarch64 // See repr-transparent.rs #![feature(transparent_unions)] diff --git a/tests/codegen/repr-transparent-aggregates-2.rs b/tests/codegen/repr-transparent-aggregates-2.rs index e9fa5143b..a7bde2d05 100644 --- a/tests/codegen/repr-transparent-aggregates-2.rs +++ b/tests/codegen/repr-transparent-aggregates-2.rs @@ -12,6 +12,7 @@ // ignore-sparc64 // ignore-x86 // ignore-x86_64 +// ignore-loongarch64 // See repr-transparent.rs #![feature(transparent_unions)] diff --git a/tests/codegen/repr-transparent.rs b/tests/codegen/repr-transparent.rs index 311cbfbaa..759ddea67 100644 --- a/tests/codegen/repr-transparent.rs +++ b/tests/codegen/repr-transparent.rs @@ -3,6 +3,7 @@ // ignore-riscv64 riscv64 has an i128 type used with test_Vector // see codegen/riscv-abi for riscv functiona call tests // ignore-s390x s390x with default march passes vector types per reference +// ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests #![crate_type="lib"] #![feature(repr_simd, transparent_unions)] diff --git a/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs b/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs index c42fbba74..1ee8bdfc3 100644 --- a/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs +++ b/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs @@ -8,4 +8,4 @@ pub fn foo() { } -// CHECK: !{{[0-9]+}} = !{i32 2, !"CFI Canonical Jump Tables", i32 1} +// CHECK: !{{[0-9]+}} = !{i32 4, !"CFI Canonical Jump Tables", i32 1} diff --git a/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs b/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs new file mode 100644 index 000000000..68c91384b --- /dev/null +++ b/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs @@ -0,0 +1,11 @@ +// Verifies that "EnableSplitLTOUnit" module flag is added. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1} diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs new file mode 100644 index 000000000..2b61c9078 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs @@ -0,0 +1,18 @@ +// Verifies that pointer type membership tests for indirect calls are omitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_sanitize)] + +#[no_sanitize(cfi)] +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: sanitizer_cfi_emit_type_checks_attr_no_sanitize::foo + // CHECK: Function Attrs: {{.*}} + // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: start: + // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) + // CHECK-NEXT: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer-cfi-emit-type-checks.rs index 597b867eb..cea6aac8b 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-checks.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-checks.rs @@ -6,13 +6,12 @@ #![crate_type="lib"] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} + // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: start: // CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}") // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail // CHECK: type_test.pass: // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) - // CHECK-NEXT: br label %bb1 // CHECK: type_test.fail: // CHECK-NEXT: call void @llvm.trap() // CHECK-NEXT: unreachable diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs new file mode 100644 index 000000000..084d8bf80 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs @@ -0,0 +1,48 @@ +// Verifies that user-defined CFI encoding for types are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] +#![feature(cfi_encoding, extern_types)] + +#[cfi_encoding = "3Foo"] +pub struct Type1(i32); + +extern { + #[cfi_encoding = "3Bar"] + type Type2; +} + +#[cfi_encoding = "3Baz"] +#[repr(transparent)] +pub struct Type3(i32); + +pub fn foo0(_: Type1) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: Type1, _: Type1) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo2(_: Type1, _: Type1, _: Type1) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: *mut Type2) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: *mut Type2, _: *mut Type2) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo5(_: *mut Type2, _: *mut Type2, _: *mut Type2) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *mut Type3) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *mut Type3, _: *mut Type3) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo8(_: *mut Type3, _: *mut Type3, _: *mut Type3) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv3FooE"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFv3FooS_E"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFv3FooS_S_E"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvP3BarE"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvP3BarS0_E"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvP3BarS0_S0_E"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvP3BazE"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvP3BazS0_E"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvP3BazS0_S0_E"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs index b9c339143..ebb26cd35 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -10,7 +10,7 @@ #![feature(adt_const_params, extern_types, inline_const, type_alias_impl_trait)] extern crate core; -use core::ffi::c_void; +use core::ffi::*; use std::marker::PhantomData; // User-defined type (structure) @@ -44,7 +44,7 @@ impl<T> Trait1<T> for i32 { } // Trait implementation -impl<T> Trait1<T> for Struct1<T> { +impl<T, U> Trait1<T> for Struct1<U> { fn foo(&self) { } } @@ -113,9 +113,10 @@ pub fn fn1<'a>() { let _: Type11 = Quuux; } -// repr(transparent) user-defined type +// Helper type to make Type12 have an unique id struct Foo(i32); +// repr(transparent) user-defined type #[repr(transparent)] pub struct Type12 { member1: (), @@ -131,313 +132,313 @@ pub struct Type13<'a> { member3: &'a Type13<'a>, } -// Helper type to allow `Type14<Bar>` to be a unique ID +// Helper type to make Type14 have an unique id pub struct Bar; -// repr(transparent) parameterized type +// repr(transparent) user-defined generic type #[repr(transparent)] pub struct Type14<T>(T); pub fn foo0(_: ()) { } -// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] -pub fn foo1(_: c_void, _: ()) { } -// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: (), _: c_void) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo2(_: (), _: c_void, _: c_void) { } -// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] -pub fn foo3(_: *mut c_void) { } -// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] -pub fn foo4(_: *mut c_void, _: *mut ()) { } -// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: *mut ()) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: *mut (), _: *mut c_void) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo5(_: *mut (), _: *mut c_void, _: *mut c_void) { } -// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] -pub fn foo6(_: *const c_void) { } -// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] -pub fn foo7(_: *const c_void, _: *const ()) { } -// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *const ()) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *const (), _: *const c_void) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo8(_: *const (), _: *const c_void, _: *const c_void) { } -// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo9(_: bool) { } -// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo10(_: bool, _: bool) { } -// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo11(_: bool, _: bool, _: bool) { } -// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo12(_: i8) { } -// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] +// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo13(_: i8, _: i8) { } -// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] +// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo14(_: i8, _: i8, _: i8) { } -// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] +// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo15(_: i16) { } -// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] +// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo16(_: i16, _: i16) { } -// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] +// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo17(_: i16, _: i16, _: i16) { } -// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] +// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo18(_: i32) { } -// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] +// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo19(_: i32, _: i32) { } -// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] +// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo20(_: i32, _: i32, _: i32) { } -// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] +// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo21(_: i64) { } -// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] +// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo22(_: i64, _: i64) { } -// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] +// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo23(_: i64, _: i64, _: i64) { } -// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] +// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo24(_: i128) { } -// CHECK: define{{.*}}foo24{{.*}}!type ![[TYPE24:[0-9]+]] +// CHECK: define{{.*}}foo24{{.*}}!type ![[TYPE24:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo25(_: i128, _: i128) { } -// CHECK: define{{.*}}foo25{{.*}}!type ![[TYPE25:[0-9]+]] +// CHECK: define{{.*}}foo25{{.*}}!type ![[TYPE25:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo26(_: i128, _: i128, _: i128) { } -// CHECK: define{{.*}}foo26{{.*}}!type ![[TYPE26:[0-9]+]] +// CHECK: define{{.*}}foo26{{.*}}!type ![[TYPE26:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo27(_: isize) { } -// CHECK: define{{.*}}foo27{{.*}}!type ![[TYPE27:[0-9]+]] +// CHECK: define{{.*}}foo27{{.*}}!type ![[TYPE27:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo28(_: isize, _: isize) { } -// CHECK: define{{.*}}foo28{{.*}}!type ![[TYPE28:[0-9]+]] +// CHECK: define{{.*}}foo28{{.*}}!type ![[TYPE28:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo29(_: isize, _: isize, _: isize) { } -// CHECK: define{{.*}}foo29{{.*}}!type ![[TYPE29:[0-9]+]] +// CHECK: define{{.*}}foo29{{.*}}!type ![[TYPE29:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo30(_: u8) { } -// CHECK: define{{.*}}foo30{{.*}}!type ![[TYPE30:[0-9]+]] +// CHECK: define{{.*}}foo30{{.*}}!type ![[TYPE30:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo31(_: u8, _: u8) { } -// CHECK: define{{.*}}foo31{{.*}}!type ![[TYPE31:[0-9]+]] +// CHECK: define{{.*}}foo31{{.*}}!type ![[TYPE31:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo32(_: u8, _: u8, _: u8) { } -// CHECK: define{{.*}}foo32{{.*}}!type ![[TYPE32:[0-9]+]] +// CHECK: define{{.*}}foo32{{.*}}!type ![[TYPE32:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo33(_: u16) { } -// CHECK: define{{.*}}foo33{{.*}}!type ![[TYPE33:[0-9]+]] +// CHECK: define{{.*}}foo33{{.*}}!type ![[TYPE33:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo34(_: u16, _: u16) { } -// CHECK: define{{.*}}foo34{{.*}}!type ![[TYPE34:[0-9]+]] +// CHECK: define{{.*}}foo34{{.*}}!type ![[TYPE34:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo35(_: u16, _: u16, _: u16) { } -// CHECK: define{{.*}}foo35{{.*}}!type ![[TYPE35:[0-9]+]] +// CHECK: define{{.*}}foo35{{.*}}!type ![[TYPE35:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo36(_: u32) { } -// CHECK: define{{.*}}foo36{{.*}}!type ![[TYPE36:[0-9]+]] +// CHECK: define{{.*}}foo36{{.*}}!type ![[TYPE36:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo37(_: u32, _: u32) { } -// CHECK: define{{.*}}foo37{{.*}}!type ![[TYPE37:[0-9]+]] +// CHECK: define{{.*}}foo37{{.*}}!type ![[TYPE37:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo38(_: u32, _: u32, _: u32) { } -// CHECK: define{{.*}}foo38{{.*}}!type ![[TYPE38:[0-9]+]] +// CHECK: define{{.*}}foo38{{.*}}!type ![[TYPE38:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo39(_: u64) { } -// CHECK: define{{.*}}foo39{{.*}}!type ![[TYPE39:[0-9]+]] +// CHECK: define{{.*}}foo39{{.*}}!type ![[TYPE39:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo40(_: u64, _: u64) { } -// CHECK: define{{.*}}foo40{{.*}}!type ![[TYPE40:[0-9]+]] +// CHECK: define{{.*}}foo40{{.*}}!type ![[TYPE40:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo41(_: u64, _: u64, _: u64) { } -// CHECK: define{{.*}}foo41{{.*}}!type ![[TYPE41:[0-9]+]] +// CHECK: define{{.*}}foo41{{.*}}!type ![[TYPE41:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo42(_: u128) { } -// CHECK: define{{.*}}foo42{{.*}}!type ![[TYPE42:[0-9]+]] +// CHECK: define{{.*}}foo42{{.*}}!type ![[TYPE42:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo43(_: u128, _: u128) { } -// CHECK: define{{.*}}foo43{{.*}}!type ![[TYPE43:[0-9]+]] +// CHECK: define{{.*}}foo43{{.*}}!type ![[TYPE43:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo44(_: u128, _: u128, _: u128) { } -// CHECK: define{{.*}}foo44{{.*}}!type ![[TYPE44:[0-9]+]] +// CHECK: define{{.*}}foo44{{.*}}!type ![[TYPE44:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo45(_: usize) { } -// CHECK: define{{.*}}foo45{{.*}}!type ![[TYPE45:[0-9]+]] +// CHECK: define{{.*}}foo45{{.*}}!type ![[TYPE45:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo46(_: usize, _: usize) { } -// CHECK: define{{.*}}foo46{{.*}}!type ![[TYPE46:[0-9]+]] +// CHECK: define{{.*}}foo46{{.*}}!type ![[TYPE46:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo47(_: usize, _: usize, _: usize) { } -// CHECK: define{{.*}}foo47{{.*}}!type ![[TYPE47:[0-9]+]] +// CHECK: define{{.*}}foo47{{.*}}!type ![[TYPE47:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo48(_: f32) { } -// CHECK: define{{.*}}foo48{{.*}}!type ![[TYPE48:[0-9]+]] +// CHECK: define{{.*}}foo48{{.*}}!type ![[TYPE48:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo49(_: f32, _: f32) { } -// CHECK: define{{.*}}foo49{{.*}}!type ![[TYPE49:[0-9]+]] +// CHECK: define{{.*}}foo49{{.*}}!type ![[TYPE49:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo50(_: f32, _: f32, _: f32) { } -// CHECK: define{{.*}}foo50{{.*}}!type ![[TYPE50:[0-9]+]] +// CHECK: define{{.*}}foo50{{.*}}!type ![[TYPE50:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo51(_: f64) { } -// CHECK: define{{.*}}foo51{{.*}}!type ![[TYPE51:[0-9]+]] +// CHECK: define{{.*}}foo51{{.*}}!type ![[TYPE51:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo52(_: f64, _: f64) { } -// CHECK: define{{.*}}foo52{{.*}}!type ![[TYPE52:[0-9]+]] +// CHECK: define{{.*}}foo52{{.*}}!type ![[TYPE52:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo53(_: f64, _: f64, _: f64) { } -// CHECK: define{{.*}}foo53{{.*}}!type ![[TYPE53:[0-9]+]] +// CHECK: define{{.*}}foo53{{.*}}!type ![[TYPE53:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo54(_: char) { } -// CHECK: define{{.*}}foo54{{.*}}!type ![[TYPE54:[0-9]+]] +// CHECK: define{{.*}}foo54{{.*}}!type ![[TYPE54:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo55(_: char, _: char) { } -// CHECK: define{{.*}}foo55{{.*}}!type ![[TYPE55:[0-9]+]] +// CHECK: define{{.*}}foo55{{.*}}!type ![[TYPE55:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo56(_: char, _: char, _: char) { } -// CHECK: define{{.*}}foo56{{.*}}!type ![[TYPE56:[0-9]+]] +// CHECK: define{{.*}}foo56{{.*}}!type ![[TYPE56:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo57(_: &str) { } -// CHECK: define{{.*}}foo57{{.*}}!type ![[TYPE57:[0-9]+]] +// CHECK: define{{.*}}foo57{{.*}}!type ![[TYPE57:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo58(_: &str, _: &str) { } -// CHECK: define{{.*}}foo58{{.*}}!type ![[TYPE58:[0-9]+]] +// CHECK: define{{.*}}foo58{{.*}}!type ![[TYPE58:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo59(_: &str, _: &str, _: &str) { } -// CHECK: define{{.*}}foo59{{.*}}!type ![[TYPE59:[0-9]+]] +// CHECK: define{{.*}}foo59{{.*}}!type ![[TYPE59:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo60(_: (i32, i32)) { } -// CHECK: define{{.*}}foo60{{.*}}!type ![[TYPE60:[0-9]+]] +// CHECK: define{{.*}}foo60{{.*}}!type ![[TYPE60:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo61(_: (i32, i32), _: (i32, i32)) { } -// CHECK: define{{.*}}foo61{{.*}}!type ![[TYPE61:[0-9]+]] +// CHECK: define{{.*}}foo61{{.*}}!type ![[TYPE61:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo62(_: (i32, i32), _: (i32, i32), _: (i32, i32)) { } -// CHECK: define{{.*}}foo62{{.*}}!type ![[TYPE62:[0-9]+]] +// CHECK: define{{.*}}foo62{{.*}}!type ![[TYPE62:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo63(_: [i32; 32]) { } -// CHECK: define{{.*}}foo63{{.*}}!type ![[TYPE63:[0-9]+]] +// CHECK: define{{.*}}foo63{{.*}}!type ![[TYPE63:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo64(_: [i32; 32], _: [i32; 32]) { } -// CHECK: define{{.*}}foo64{{.*}}!type ![[TYPE64:[0-9]+]] +// CHECK: define{{.*}}foo64{{.*}}!type ![[TYPE64:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo65(_: [i32; 32], _: [i32; 32], _: [i32; 32]) { } -// CHECK: define{{.*}}foo65{{.*}}!type ![[TYPE65:[0-9]+]] +// CHECK: define{{.*}}foo65{{.*}}!type ![[TYPE65:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo66(_: &[i32]) { } -// CHECK: define{{.*}}foo66{{.*}}!type ![[TYPE66:[0-9]+]] +// CHECK: define{{.*}}foo66{{.*}}!type ![[TYPE66:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo67(_: &[i32], _: &[i32]) { } -// CHECK: define{{.*}}foo67{{.*}}!type ![[TYPE67:[0-9]+]] +// CHECK: define{{.*}}foo67{{.*}}!type ![[TYPE67:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo68(_: &[i32], _: &[i32], _: &[i32]) { } -// CHECK: define{{.*}}foo68{{.*}}!type ![[TYPE68:[0-9]+]] +// CHECK: define{{.*}}foo68{{.*}}!type ![[TYPE68:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo69(_: &Struct1::<i32>) { } -// CHECK: define{{.*}}foo69{{.*}}!type ![[TYPE69:[0-9]+]] +// CHECK: define{{.*}}foo69{{.*}}!type ![[TYPE69:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo70(_: &Struct1::<i32>, _: &Struct1::<i32>) { } -// CHECK: define{{.*}}foo70{{.*}}!type ![[TYPE70:[0-9]+]] +// CHECK: define{{.*}}foo70{{.*}}!type ![[TYPE70:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo71(_: &Struct1::<i32>, _: &Struct1::<i32>, _: &Struct1::<i32>) { } -// CHECK: define{{.*}}foo71{{.*}}!type ![[TYPE71:[0-9]+]] +// CHECK: define{{.*}}foo71{{.*}}!type ![[TYPE71:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo72(_: &Enum1::<i32>) { } -// CHECK: define{{.*}}foo72{{.*}}!type ![[TYPE72:[0-9]+]] +// CHECK: define{{.*}}foo72{{.*}}!type ![[TYPE72:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo73(_: &Enum1::<i32>, _: &Enum1::<i32>) { } -// CHECK: define{{.*}}foo73{{.*}}!type ![[TYPE73:[0-9]+]] +// CHECK: define{{.*}}foo73{{.*}}!type ![[TYPE73:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo74(_: &Enum1::<i32>, _: &Enum1::<i32>, _: &Enum1::<i32>) { } -// CHECK: define{{.*}}foo74{{.*}}!type ![[TYPE74:[0-9]+]] +// CHECK: define{{.*}}foo74{{.*}}!type ![[TYPE74:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo75(_: &Union1::<i32>) { } -// CHECK: define{{.*}}foo75{{.*}}!type ![[TYPE75:[0-9]+]] +// CHECK: define{{.*}}foo75{{.*}}!type ![[TYPE75:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo76(_: &Union1::<i32>, _: &Union1::<i32>) { } -// CHECK: define{{.*}}foo76{{.*}}!type ![[TYPE76:[0-9]+]] +// CHECK: define{{.*}}foo76{{.*}}!type ![[TYPE76:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo77(_: &Union1::<i32>, _: &Union1::<i32>, _: &Union1::<i32>) { } -// CHECK: define{{.*}}foo77{{.*}}!type ![[TYPE77:[0-9]+]] +// CHECK: define{{.*}}foo77{{.*}}!type ![[TYPE77:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo78(_: *mut type1) { } -// CHECK: define{{.*}}foo78{{.*}}!type ![[TYPE78:[0-9]+]] +// CHECK: define{{.*}}foo78{{.*}}!type ![[TYPE78:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo79(_: *mut type1, _: *mut type1) { } -// CHECK: define{{.*}}foo79{{.*}}!type ![[TYPE79:[0-9]+]] +// CHECK: define{{.*}}foo79{{.*}}!type ![[TYPE79:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo80(_: *mut type1, _: *mut type1, _: *mut type1) { } -// CHECK: define{{.*}}foo80{{.*}}!type ![[TYPE80:[0-9]+]] +// CHECK: define{{.*}}foo80{{.*}}!type ![[TYPE80:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo81(_: &mut i32) { } -// CHECK: define{{.*}}foo81{{.*}}!type ![[TYPE81:[0-9]+]] +// CHECK: define{{.*}}foo81{{.*}}!type ![[TYPE81:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo82(_: &mut i32, _: &i32) { } -// CHECK: define{{.*}}foo82{{.*}}!type ![[TYPE82:[0-9]+]] +// CHECK: define{{.*}}foo82{{.*}}!type ![[TYPE82:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo83(_: &mut i32, _: &i32, _: &i32) { } -// CHECK: define{{.*}}foo83{{.*}}!type ![[TYPE83:[0-9]+]] +// CHECK: define{{.*}}foo83{{.*}}!type ![[TYPE83:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo84(_: &i32) { } -// CHECK: define{{.*}}foo84{{.*}}!type ![[TYPE84:[0-9]+]] +// CHECK: define{{.*}}foo84{{.*}}!type ![[TYPE84:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo85(_: &i32, _: &mut i32) { } -// CHECK: define{{.*}}foo85{{.*}}!type ![[TYPE85:[0-9]+]] +// CHECK: define{{.*}}foo85{{.*}}!type ![[TYPE85:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo86(_: &i32, _: &mut i32, _: &mut i32) { } -// CHECK: define{{.*}}foo86{{.*}}!type ![[TYPE86:[0-9]+]] +// CHECK: define{{.*}}foo86{{.*}}!type ![[TYPE86:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo87(_: *mut i32) { } -// CHECK: define{{.*}}foo87{{.*}}!type ![[TYPE87:[0-9]+]] +// CHECK: define{{.*}}foo87{{.*}}!type ![[TYPE87:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo88(_: *mut i32, _: *const i32) { } -// CHECK: define{{.*}}foo88{{.*}}!type ![[TYPE88:[0-9]+]] +// CHECK: define{{.*}}foo88{{.*}}!type ![[TYPE88:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo89(_: *mut i32, _: *const i32, _: *const i32) { } -// CHECK: define{{.*}}foo89{{.*}}!type ![[TYPE89:[0-9]+]] +// CHECK: define{{.*}}foo89{{.*}}!type ![[TYPE89:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo90(_: *const i32) { } -// CHECK: define{{.*}}foo90{{.*}}!type ![[TYPE90:[0-9]+]] +// CHECK: define{{.*}}foo90{{.*}}!type ![[TYPE90:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo91(_: *const i32, _: *mut i32) { } -// CHECK: define{{.*}}foo91{{.*}}!type ![[TYPE91:[0-9]+]] +// CHECK: define{{.*}}foo91{{.*}}!type ![[TYPE91:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo92(_: *const i32, _: *mut i32, _: *mut i32) { } -// CHECK: define{{.*}}foo92{{.*}}!type ![[TYPE92:[0-9]+]] +// CHECK: define{{.*}}foo92{{.*}}!type ![[TYPE92:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo93(_: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo93{{.*}}!type ![[TYPE93:[0-9]+]] +// CHECK: define{{.*}}foo93{{.*}}!type ![[TYPE93:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo94(_: fn(i32) -> i32, _: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo94{{.*}}!type ![[TYPE94:[0-9]+]] +// CHECK: define{{.*}}foo94{{.*}}!type ![[TYPE94:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo95(_: fn(i32) -> i32, _: fn(i32) -> i32, _: fn(i32) -> i32) { } -// CHECK: define{{.*}}foo95{{.*}}!type ![[TYPE95:[0-9]+]] +// CHECK: define{{.*}}foo95{{.*}}!type ![[TYPE95:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo96(_: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo96{{.*}}!type ![[TYPE96:[0-9]+]] +// CHECK: define{{.*}}foo96{{.*}}!type ![[TYPE96:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo97(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo97{{.*}}!type ![[TYPE97:[0-9]+]] +// CHECK: define{{.*}}foo97{{.*}}!type ![[TYPE97:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo98(_: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32, _: &dyn Fn(i32) -> i32) { } -// CHECK: define{{.*}}foo98{{.*}}!type ![[TYPE98:[0-9]+]] +// CHECK: define{{.*}}foo98{{.*}}!type ![[TYPE98:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo99(_: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo99{{.*}}!type ![[TYPE99:[0-9]+]] +// CHECK: define{{.*}}foo99{{.*}}!type ![[TYPE99:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo100(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo100{{.*}}!type ![[TYPE100:[0-9]+]] +// CHECK: define{{.*}}foo100{{.*}}!type ![[TYPE100:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo101(_: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32, _: &dyn FnMut(i32) -> i32) { } -// CHECK: define{{.*}}foo101{{.*}}!type ![[TYPE101:[0-9]+]] +// CHECK: define{{.*}}foo101{{.*}}!type ![[TYPE101:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo102(_: &dyn FnOnce(i32) -> i32) { } -// CHECK: define{{.*}}foo102{{.*}}!type ![[TYPE102:[0-9]+]] +// CHECK: define{{.*}}foo102{{.*}}!type ![[TYPE102:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo103(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) { } -// CHECK: define{{.*}}foo103{{.*}}!type ![[TYPE103:[0-9]+]] +// CHECK: define{{.*}}foo103{{.*}}!type ![[TYPE103:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo104(_: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32, _: &dyn FnOnce(i32) -> i32) {} -// CHECK: define{{.*}}foo104{{.*}}!type ![[TYPE104:[0-9]+]] +// CHECK: define{{.*}}foo104{{.*}}!type ![[TYPE104:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo105(_: &dyn Send) { } -// CHECK: define{{.*}}foo105{{.*}}!type ![[TYPE105:[0-9]+]] +// CHECK: define{{.*}}foo105{{.*}}!type ![[TYPE105:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo106(_: &dyn Send, _: &dyn Send) { } -// CHECK: define{{.*}}foo106{{.*}}!type ![[TYPE106:[0-9]+]] +// CHECK: define{{.*}}foo106{{.*}}!type ![[TYPE106:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo107(_: &dyn Send, _: &dyn Send, _: &dyn Send) { } -// CHECK: define{{.*}}foo107{{.*}}!type ![[TYPE107:[0-9]+]] +// CHECK: define{{.*}}foo107{{.*}}!type ![[TYPE107:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo108(_: Type1) { } -// CHECK: define{{.*}}foo108{{.*}}!type ![[TYPE108:[0-9]+]] +// CHECK: define{{.*}}foo108{{.*}}!type ![[TYPE108:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo109(_: Type1, _: Type1) { } -// CHECK: define{{.*}}foo109{{.*}}!type ![[TYPE109:[0-9]+]] +// CHECK: define{{.*}}foo109{{.*}}!type ![[TYPE109:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo110(_: Type1, _: Type1, _: Type1) { } -// CHECK: define{{.*}}foo110{{.*}}!type ![[TYPE110:[0-9]+]] +// CHECK: define{{.*}}foo110{{.*}}!type ![[TYPE110:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo111(_: Type2) { } -// CHECK: define{{.*}}foo111{{.*}}!type ![[TYPE111:[0-9]+]] +// CHECK: define{{.*}}foo111{{.*}}!type ![[TYPE111:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo112(_: Type2, _: Type2) { } -// CHECK: define{{.*}}foo112{{.*}}!type ![[TYPE112:[0-9]+]] +// CHECK: define{{.*}}foo112{{.*}}!type ![[TYPE112:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo113(_: Type2, _: Type2, _: Type2) { } -// CHECK: define{{.*}}foo113{{.*}}!type ![[TYPE113:[0-9]+]] +// CHECK: define{{.*}}foo113{{.*}}!type ![[TYPE113:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo114(_: Type3) { } -// CHECK: define{{.*}}foo114{{.*}}!type ![[TYPE114:[0-9]+]] +// CHECK: define{{.*}}foo114{{.*}}!type ![[TYPE114:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo115(_: Type3, _: Type3) { } -// CHECK: define{{.*}}foo115{{.*}}!type ![[TYPE115:[0-9]+]] +// CHECK: define{{.*}}foo115{{.*}}!type ![[TYPE115:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo116(_: Type3, _: Type3, _: Type3) { } -// CHECK: define{{.*}}foo116{{.*}}!type ![[TYPE116:[0-9]+]] +// CHECK: define{{.*}}foo116{{.*}}!type ![[TYPE116:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo117(_: Type4) { } -// CHECK: define{{.*}}foo117{{.*}}!type ![[TYPE117:[0-9]+]] +// CHECK: define{{.*}}foo117{{.*}}!type ![[TYPE117:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo118(_: Type4, _: Type4) { } -// CHECK: define{{.*}}foo118{{.*}}!type ![[TYPE118:[0-9]+]] +// CHECK: define{{.*}}foo118{{.*}}!type ![[TYPE118:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo119(_: Type4, _: Type4, _: Type4) { } -// CHECK: define{{.*}}foo119{{.*}}!type ![[TYPE119:[0-9]+]] +// CHECK: define{{.*}}foo119{{.*}}!type ![[TYPE119:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo120(_: Type5) { } -// CHECK: define{{.*}}foo120{{.*}}!type ![[TYPE120:[0-9]+]] +// CHECK: define{{.*}}foo120{{.*}}!type ![[TYPE120:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo121(_: Type5, _: Type5) { } -// CHECK: define{{.*}}foo121{{.*}}!type ![[TYPE121:[0-9]+]] +// CHECK: define{{.*}}foo121{{.*}}!type ![[TYPE121:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo122(_: Type5, _: Type5, _: Type5) { } -// CHECK: define{{.*}}foo122{{.*}}!type ![[TYPE122:[0-9]+]] +// CHECK: define{{.*}}foo122{{.*}}!type ![[TYPE122:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo123(_: Type6) { } -// CHECK: define{{.*}}foo123{{.*}}!type ![[TYPE123:[0-9]+]] +// CHECK: define{{.*}}foo123{{.*}}!type ![[TYPE123:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo124(_: Type6, _: Type6) { } -// CHECK: define{{.*}}foo124{{.*}}!type ![[TYPE124:[0-9]+]] +// CHECK: define{{.*}}foo124{{.*}}!type ![[TYPE124:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo125(_: Type6, _: Type6, _: Type6) { } -// CHECK: define{{.*}}foo125{{.*}}!type ![[TYPE125:[0-9]+]] +// CHECK: define{{.*}}foo125{{.*}}!type ![[TYPE125:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo126(_: Type7) { } -// CHECK: define{{.*}}foo126{{.*}}!type ![[TYPE126:[0-9]+]] +// CHECK: define{{.*}}foo126{{.*}}!type ![[TYPE126:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo127(_: Type7, _: Type7) { } -// CHECK: define{{.*}}foo127{{.*}}!type ![[TYPE127:[0-9]+]] +// CHECK: define{{.*}}foo127{{.*}}!type ![[TYPE127:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo128(_: Type7, _: Type7, _: Type7) { } -// CHECK: define{{.*}}foo128{{.*}}!type ![[TYPE128:[0-9]+]] +// CHECK: define{{.*}}foo128{{.*}}!type ![[TYPE128:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo129(_: Type8) { } -// CHECK: define{{.*}}foo129{{.*}}!type ![[TYPE129:[0-9]+]] +// CHECK: define{{.*}}foo129{{.*}}!type ![[TYPE129:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo130(_: Type8, _: Type8) { } -// CHECK: define{{.*}}foo130{{.*}}!type ![[TYPE130:[0-9]+]] +// CHECK: define{{.*}}foo130{{.*}}!type ![[TYPE130:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo131(_: Type8, _: Type8, _: Type8) { } -// CHECK: define{{.*}}foo131{{.*}}!type ![[TYPE131:[0-9]+]] +// CHECK: define{{.*}}foo131{{.*}}!type ![[TYPE131:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo132(_: Type9) { } -// CHECK: define{{.*}}foo132{{.*}}!type ![[TYPE132:[0-9]+]] +// CHECK: define{{.*}}foo132{{.*}}!type ![[TYPE132:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo133(_: Type9, _: Type9) { } -// CHECK: define{{.*}}foo133{{.*}}!type ![[TYPE133:[0-9]+]] +// CHECK: define{{.*}}foo133{{.*}}!type ![[TYPE133:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo134(_: Type9, _: Type9, _: Type9) { } -// CHECK: define{{.*}}foo134{{.*}}!type ![[TYPE134:[0-9]+]] +// CHECK: define{{.*}}foo134{{.*}}!type ![[TYPE134:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo135(_: Type10) { } -// CHECK: define{{.*}}foo135{{.*}}!type ![[TYPE135:[0-9]+]] +// CHECK: define{{.*}}foo135{{.*}}!type ![[TYPE135:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo136(_: Type10, _: Type10) { } -// CHECK: define{{.*}}foo136{{.*}}!type ![[TYPE136:[0-9]+]] +// CHECK: define{{.*}}foo136{{.*}}!type ![[TYPE136:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo137(_: Type10, _: Type10, _: Type10) { } -// CHECK: define{{.*}}foo137{{.*}}!type ![[TYPE137:[0-9]+]] +// CHECK: define{{.*}}foo137{{.*}}!type ![[TYPE137:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo138(_: Type11) { } -// CHECK: define{{.*}}foo138{{.*}}!type ![[TYPE138:[0-9]+]] +// CHECK: define{{.*}}foo138{{.*}}!type ![[TYPE138:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo139(_: Type11, _: Type11) { } -// CHECK: define{{.*}}foo139{{.*}}!type ![[TYPE139:[0-9]+]] +// CHECK: define{{.*}}foo139{{.*}}!type ![[TYPE139:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo140(_: Type11, _: Type11, _: Type11) { } -// CHECK: define{{.*}}foo140{{.*}}!type ![[TYPE140:[0-9]+]] +// CHECK: define{{.*}}foo140{{.*}}!type ![[TYPE140:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo141(_: Type12) { } -// CHECK: define{{.*}}foo141{{.*}}!type ![[TYPE141:[0-9]+]] +// CHECK: define{{.*}}foo141{{.*}}!type ![[TYPE141:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo142(_: Type12, _: Type12) { } -// CHECK: define{{.*}}foo142{{.*}}!type ![[TYPE142:[0-9]+]] +// CHECK: define{{.*}}foo142{{.*}}!type ![[TYPE142:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo143(_: Type12, _: Type12, _: Type12) { } -// CHECK: define{{.*}}foo143{{.*}}!type ![[TYPE143:[0-9]+]] +// CHECK: define{{.*}}foo143{{.*}}!type ![[TYPE143:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo144(_: Type13) { } -// CHECK: define{{.*}}foo144{{.*}}!type ![[TYPE144:[0-9]+]] +// CHECK: define{{.*}}foo144{{.*}}!type ![[TYPE144:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo145(_: Type13, _: Type13) { } -// CHECK: define{{.*}}foo145{{.*}}!type ![[TYPE145:[0-9]+]] +// CHECK: define{{.*}}foo145{{.*}}!type ![[TYPE145:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo146(_: Type13, _: Type13, _: Type13) { } -// CHECK: define{{.*}}foo146{{.*}}!type ![[TYPE146:[0-9]+]] +// CHECK: define{{.*}}foo146{{.*}}!type ![[TYPE146:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo147(_: Type14<Bar>) { } -// CHECK: define{{.*}}foo147{{.*}}!type ![[TYPE147:[0-9]+]] +// CHECK: define{{.*}}foo147{{.*}}!type ![[TYPE147:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo148(_: Type14<Bar>, _: Type14<Bar>) { } -// CHECK: define{{.*}}foo148{{.*}}!type ![[TYPE148:[0-9]+]] +// CHECK: define{{.*}}foo148{{.*}}!type ![[TYPE148:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { } -// CHECK: define{{.*}}foo149{{.*}}!type ![[TYPE149:[0-9]+]] +// CHECK: define{{.*}}foo149{{.*}}!type ![[TYPE149:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvvE"} // CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvvvE"} @@ -535,15 +536,15 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { } // CHECK: ![[TYPE93]] = !{i64 0, !"_ZTSFvPFu3i32S_EE"} // CHECK: ![[TYPE94]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_E"} // CHECK: ![[TYPE95]] = !{i64 0, !"_ZTSFvPFu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE96]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEEE"} -// CHECK: ![[TYPE97]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_E"} -// CHECK: ![[TYPE98]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_S5_E"} -// CHECK: ![[TYPE99]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEEE"} -// CHECK: ![[TYPE100]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_E"} -// CHECK: ![[TYPE101]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_S5_E"} -// CHECK: ![[TYPE102]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEEE"} -// CHECK: ![[TYPE103]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_E"} -// CHECK: ![[TYPE104]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5tupleIu3i32EEu{{[0-9]+}}NtNtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnce6OutputIS0_ES_u6regionEES5_S5_E"} +// CHECK: ![[TYPE96]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEEE"} +// CHECK: ![[TYPE97]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE98]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function2FnIu5paramEu6regionEES3_S3_E"} +// CHECK: ![[TYPE99]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEEE"} +// CHECK: ![[TYPE100]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE101]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function5FnMutIu5paramEu6regionEES3_S3_E"} +// CHECK: ![[TYPE102]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEEE"} +// CHECK: ![[TYPE103]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_E"} +// CHECK: ![[TYPE104]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops8function6FnOnceIu5paramEu6regionEES3_S3_E"} // CHECK: ![[TYPE105]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEEE"} // CHECK: ![[TYPE106]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_E"} // CHECK: ![[TYPE107]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_S2_E"} @@ -565,9 +566,9 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { } // CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} // CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} // CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} -// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_EE"} -// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_ES3_E"} -// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_ES3_S3_E"} +// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32EE"} +// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_E"} +// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_S4_E"} // CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_EE"} // CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_E"} // CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_S0_E"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs new file mode 100644 index 000000000..78ef0c2c7 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -0,0 +1,31 @@ +// Verifies that generalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.generalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.generalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.generalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.generalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs new file mode 100644 index 000000000..3b72459c4 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -0,0 +1,31 @@ +// Verifies that normalized and generalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}![[TYPE1:[0-9]+]] + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized.generalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}![[TYPE2:[0-9]+]] + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized.generalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}![[TYPE3:[0-9]+]] + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized.generalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PKvS_E.normalized.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PKvS_S_E.normalized.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PKvS_S_S_E.normalized.generalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs new file mode 100644 index 000000000..9218e9947 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -0,0 +1,31 @@ +// Verifies that normalized type metadata for functions are emitted. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E.normalized") + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E.normalized") + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E.normalized") + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFu3i32PFS_S_ES_E.normalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_ES_S_E.normalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFu3i32PFS_S_S_S_ES_S_S_E.normalized"} diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs index bafc4c659..f9fd816de 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs @@ -7,21 +7,21 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] + // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_E") f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] + // CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_E") f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] + // CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFu3i32S_S_S_E") f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs new file mode 100644 index 000000000..0f79adab7 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs @@ -0,0 +1,120 @@ +// Verifies that type metadata identifiers for trait objects are emitted correctly. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![crate_type="lib"] + +pub trait Trait1 { + fn foo(&self); +} + +#[derive(Clone, Copy)] +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) { + } +} + +pub trait Trait2<T> { + fn bar(&self); +} + +pub struct Type2; + +impl Trait2<i32> for Type2 { + fn bar(&self) { + } +} + +pub trait Trait3<T> { + fn baz(&self, _: &T); +} + +pub struct Type3; + +impl<T, U> Trait3<U> for T { + fn baz(&self, _: &U) { + } +} + +pub trait Trait4<'a, T> { + type Output: 'a; + fn qux(&self, _: &T) -> Self::Output; +} + +pub struct Type4; + +impl<'a, T, U> Trait4<'a, U> for T { + type Output = &'a i32; + fn qux(&self, _: &U) -> Self::Output { + &0 + } +} + +pub fn foo1(a: &dyn Trait1) { + a.foo(); + // CHECK-LABEL: define{{.*}}4foo1{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE1:[[:print:]]+]]") +} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); + // CHECK-LABEL: define{{.*}}4bar1{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn foo2<T>(a: &dyn Trait2<T>) { + a.bar(); + // CHECK-LABEL: define{{.*}}4foo2{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn bar2() { + let a = Type2; + foo2(&a); + let b = &a as &dyn Trait2<i32>; + b.bar(); + // CHECK-LABEL: define{{.*}}4bar2{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE2:[[:print:]]+]]") +} + +pub fn foo3(a: &dyn Trait3<Type3>) { + let b = Type3; + a.baz(&b); + // CHECK-LABEL: define{{.*}}4foo3{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") +} + +pub fn bar3() { + let a = Type3; + foo3(&a); + let b = &a as &dyn Trait3<Type3>; + b.baz(&a); + // CHECK-LABEL: define{{.*}}4bar3{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE3:[[:print:]]+]]") +} + +pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { + let b = Type4; + a.qux(&b); + // CHECK-LABEL: define{{.*}}4foo4{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") +} + +pub fn bar4<'a>() { + let a = Type4; + foo4(&a); + let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; + b.qux(&a); + // CHECK-LABEL: define{{.*}}4bar4{{.*}}!type !{{[0-9]+}} + // CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%[0-9]}}, metadata !"[[TYPE4:[[:print:]]+]]") +} + +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE1]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE2]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE3]]"} +// CHECK: !{{[0-9]+}} = !{i64 0, !"[[TYPE4]]"} diff --git a/tests/codegen/sanitizer-cfi-generalize-pointers.rs b/tests/codegen/sanitizer-cfi-generalize-pointers.rs new file mode 100644 index 000000000..677ebdb27 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-generalize-pointers.rs @@ -0,0 +1,46 @@ +// Verifies that pointer types are generalized. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] + +extern crate core; + +pub fn foo0(_: &mut i32) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo1(_: &mut i32, _: &mut i32) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo3(_: &i32) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo4(_: &i32, _: &i32) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo5(_: &i32, _: &i32, _: &i32) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo6(_: *mut i32) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo7(_: *mut i32, _: *mut i32) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo9(_: *const i32) { } +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo10(_: *const i32, _: *const i32) { } +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} +pub fn foo11(_: *const i32, _: *const i32, _: *const i32) { } +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvU3mutu3refIvEE.generalized"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_E.generalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_S0_E.generalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu3refIvEE.generalized"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIvES_E.generalized"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIvES_S_E.generalized"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPvE.generalized"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPvS_E.generalized"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPvS_S_E.generalized"} +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvPKvE.generalized"} +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvPKvS0_E.generalized"} +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvPKvS0_S0_E.generalized"} diff --git a/tests/codegen/sanitizer-cfi-normalize-integers.rs b/tests/codegen/sanitizer-cfi-normalize-integers.rs new file mode 100644 index 000000000..aa3913cb8 --- /dev/null +++ b/tests/codegen/sanitizer-cfi-normalize-integers.rs @@ -0,0 +1,83 @@ +// Verifies that integer types are normalized. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] + +extern crate core; +use core::ffi::*; + +pub fn foo0(_: bool) { } +// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} +pub fn foo1(_: bool, _: c_uchar) { } +// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} +pub fn foo2(_: bool, _: c_uchar, _: c_uchar) { } +// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} +pub fn foo3(_: isize) { } +// CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} +pub fn foo4(_: isize, _: c_long) { } +// CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} +pub fn foo5(_: isize, _: c_long, _: c_longlong) { } +// CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} +pub fn foo6(_: usize) { } +// CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} +pub fn foo7(_: usize, _: c_ulong) { } +// CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} +pub fn foo8(_: usize, _: c_ulong, _: c_ulonglong) { } +// CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} +pub fn foo9(_: c_schar) { } +// CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} +pub fn foo10(_: c_char, _: c_schar) { } +// CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} +pub fn foo11(_: c_char, _: c_schar, _: c_schar) { } +// CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} +pub fn foo12(_: c_int) { } +// CHECK: define{{.*}}foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} +pub fn foo13(_: c_int, _: c_int) { } +// CHECK: define{{.*}}foo13{{.*}}!type ![[TYPE13:[0-9]+]] !type !{{[0-9]+}} +pub fn foo14(_: c_int, _: c_int, _: c_int) { } +// CHECK: define{{.*}}foo14{{.*}}!type ![[TYPE14:[0-9]+]] !type !{{[0-9]+}} +pub fn foo15(_: c_short) { } +// CHECK: define{{.*}}foo15{{.*}}!type ![[TYPE15:[0-9]+]] !type !{{[0-9]+}} +pub fn foo16(_: c_short, _: c_short) { } +// CHECK: define{{.*}}foo16{{.*}}!type ![[TYPE16:[0-9]+]] !type !{{[0-9]+}} +pub fn foo17(_: c_short, _: c_short, _: c_short) { } +// CHECK: define{{.*}}foo17{{.*}}!type ![[TYPE17:[0-9]+]] !type !{{[0-9]+}} +pub fn foo18(_: c_uint) { } +// CHECK: define{{.*}}foo18{{.*}}!type ![[TYPE18:[0-9]+]] !type !{{[0-9]+}} +pub fn foo19(_: c_uint, _: c_uint) { } +// CHECK: define{{.*}}foo19{{.*}}!type ![[TYPE19:[0-9]+]] !type !{{[0-9]+}} +pub fn foo20(_: c_uint, _: c_uint, _: c_uint) { } +// CHECK: define{{.*}}foo20{{.*}}!type ![[TYPE20:[0-9]+]] !type !{{[0-9]+}} +pub fn foo21(_: c_ushort) { } +// CHECK: define{{.*}}foo21{{.*}}!type ![[TYPE21:[0-9]+]] !type !{{[0-9]+}} +pub fn foo22(_: c_ushort, _: c_ushort) { } +// CHECK: define{{.*}}foo22{{.*}}!type ![[TYPE22:[0-9]+]] !type !{{[0-9]+}} +pub fn foo23(_: c_ushort, _: c_ushort, _: c_ushort) { } +// CHECK: define{{.*}}foo23{{.*}}!type ![[TYPE23:[0-9]+]] !type !{{[0-9]+}} + +// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvu2u8E.normalized"} +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu2u8S_E.normalized"} +// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu2u8S_S_E.normalized"} +// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}E.normalized"} +// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}{{u3i32|u3i64|S_}}{{u3i64|S_|S0_}}E.normalized"} +// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} +// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}E.normalized"} +// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}{{u3u32|u3u64|S_}}{{u3u64|S_|S0_}}E.normalized"} +// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu2i8E.normalized"} +// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFv{{u2i8S_|u2u8u2i8}}E.normalized"} +// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFv{{u2i8S_S_|u2u8u2i8S0_}}E.normalized"} +// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"} +// CHECK: ![[TYPE13]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_E.normalized"} +// CHECK: ![[TYPE14]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_S_E.normalized"} +// CHECK: ![[TYPE15]] = !{i64 0, !"_ZTSFvu3i16E.normalized"} +// CHECK: ![[TYPE16]] = !{i64 0, !"_ZTSFvu3i16S_E.normalized"} +// CHECK: ![[TYPE17]] = !{i64 0, !"_ZTSFvu3i16S_S_E.normalized"} +// CHECK: ![[TYPE18]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}E.normalized"} +// CHECK: ![[TYPE19]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_E.normalized"} +// CHECK: ![[TYPE20]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64}}S_S_E.normalized"} +// CHECK: ![[TYPE21]] = !{i64 0, !"_ZTSFvu3u16E.normalized"} +// CHECK: ![[TYPE22]] = !{i64 0, !"_ZTSFvu3u16S_E.normalized"} +// CHECK: ![[TYPE23]] = !{i64 0, !"_ZTSFvu3u16S_S_E.normalized"} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs new file mode 100644 index 000000000..bb317e4a2 --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -0,0 +1,30 @@ +// Verifies that KCFI operand bundles are omitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_core, no_sanitize, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +#[no_sanitize(kcfi)] +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: sanitizer_kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo + // CHECK: Function Attrs: {{.*}} + // CHECK-LABEL: define{{.*}}foo{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: start: + // CHECK-NOT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] + // CHECK: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs new file mode 100644 index 000000000..29e4df351 --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -0,0 +1,44 @@ +// Verifies that generalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 233085384) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 435418021) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1003721339) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 -1741689296} +// CHECK: ![[TYPE2]] = !{i32 489439372} +// CHECK: ![[TYPE3]] = !{i32 2026563871} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs new file mode 100644 index 000000000..84d678a33 --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -0,0 +1,44 @@ +// Verifies that normalized and generalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -686570305) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1281038450) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 -1751512973) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 975484707} +// CHECK: ![[TYPE2]] = !{i32 1658833102} +// CHECK: ![[TYPE3]] = !{i32 230429758} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs new file mode 100644 index 000000000..761c37a9e --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -0,0 +1,44 @@ +// Verifies that normalized KCFI type metadata for functions are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -841055669) ] + f(arg) +} + +pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { + // CHECK-LABEL: define{{.*}}bar + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 1390819368) ] + f(arg1, arg2) +} + +pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { + // CHECK-LABEL: define{{.*}}baz + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 586925835) ] + f(arg1, arg2, arg3) +} + +// CHECK: ![[TYPE1]] = !{i32 -458317079} +// CHECK: ![[TYPE2]] = !{i32 1737138182} +// CHECK: ![[TYPE3]] = !{i32 197182412} diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs index 2537df80a..83cda0ef1 100644 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -20,22 +20,22 @@ impl Copy for i32 {} pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo - // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: call i32 %f(i32 %arg){{.*}}[ "kcfi"(i32 -1666898348) ] + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE1:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 -1666898348) ] f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar - // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: call i32 %f(i32 %arg1, i32 %arg2){{.*}}[ "kcfi"(i32 -1789026986) ] + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE2:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2){{.*}}[ "kcfi"(i32 -1789026986) ] f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz - // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: call i32 %f(i32 %arg1, i32 %arg2, i32 %arg3){{.*}}[ "kcfi"(i32 1248878270) ] + // CHECK-SAME: {{.*}}!{{<unknown kind #36>|kcfi_type}} ![[TYPE3:[0-9]+]] + // CHECK: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg1, i32 {{(noundef )*}}%arg2, i32 {{(noundef )*}}%arg3){{.*}}[ "kcfi"(i32 1248878270) ] f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs new file mode 100644 index 000000000..e1d617b5e --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs @@ -0,0 +1,27 @@ +// Verifies that KCFI operand bundles are emitted. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } + +impl Copy for i32 {} + +pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { + // CHECK-LABEL: define{{.*}}foo{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: start: + // CHECK-NEXT: {{%.+}} = call {{(noundef )*}}i32 %f(i32 {{(noundef )*}}%arg){{.*}}[ "kcfi"(i32 {{[-0-9]+}}) ] + // CHECK-NEXT: ret i32 {{%.+}} + f(arg) +} diff --git a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs new file mode 100644 index 000000000..004a67e7d --- /dev/null +++ b/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs @@ -0,0 +1,144 @@ +// Verifies that type metadata identifiers for trait objects are emitted correctly. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 + +#![crate_type="lib"] +#![feature(arbitrary_self_types, no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } +#[lang="receiver"] +trait Receiver { } +#[lang="dispatch_from_dyn"] +trait DispatchFromDyn<T> { } +impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} +#[lang = "unsize"] +trait Unsize<T: ?Sized> { } +#[lang = "coerce_unsized"] +pub trait CoerceUnsized<T: ?Sized> { } +impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +#[lang="freeze"] +trait Freeze { } +#[lang="drop_in_place"] +fn drop_in_place_fn<T>() { } + +pub trait Trait1 { + fn foo(&self); +} + +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) { + } +} + +pub trait Trait2<T> { + fn bar(&self); +} + +pub struct Type2; + +impl Trait2<i32> for Type2 { + fn bar(&self) { + } +} + +pub trait Trait3<T> { + fn baz(&self, _: &T); +} + +pub struct Type3; + +impl<T, U> Trait3<U> for T { + fn baz(&self, _: &U) { + } +} + +pub trait Trait4<'a, T> { + type Output: 'a; + fn qux(&self, _: &T) -> Self::Output; +} + +pub struct Type4; + +impl<'a, T, U> Trait4<'a, U> for T { + type Output = &'a i32; + fn qux(&self, _: &U) -> Self::Output { + &0 + } +} + +pub fn foo1(a: &dyn Trait1) { + a.foo(); + // CHECK-LABEL: define{{.*}}4foo1{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] +} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); + // CHECK-LABEL: define{{.*}}4bar1{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE1:[[:print:]]+]]) ] +} + +pub fn foo2<T>(a: &dyn Trait2<T>) { + a.bar(); + // CHECK-LABEL: define{{.*}}4foo2{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] +} + +pub fn bar2() { + let a = Type2; + foo2(&a); + let b = &a as &dyn Trait2<i32>; + b.bar(); + // CHECK-LABEL: define{{.*}}4bar2{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE2:[[:print:]]+]]) ] +} + +pub fn foo3(a: &dyn Trait3<Type3>) { + let b = Type3; + a.baz(&b); + // CHECK-LABEL: define{{.*}}4foo3{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] +} + +pub fn bar3() { + let a = Type3; + foo3(&a); + let b = &a as &dyn Trait3<Type3>; + b.baz(&a); + // CHECK-LABEL: define{{.*}}4bar3{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call void %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type3\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE3:[[:print:]]+]]) ] +} + +pub fn foo4<'a>(a: &dyn Trait4<'a, Type4, Output = &'a i32>) { + let b = Type4; + a.qux(&b); + // CHECK-LABEL: define{{.*}}4foo4{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] +} + +pub fn bar4<'a>() { + let a = Type4; + foo4(&a); + let b = &a as &dyn Trait4<'a, Type4, Output = &'a i32>; + b.qux(&a); + // CHECK-LABEL: define{{.*}}4bar4{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} + // CHECK: call align 4 {{ptr|i32\*}} %{{[0-9]}}({{\{\}\*|ptr}} align 1 {{%[a-z]\.0|%_[0-9]}}, {{\{\}\*|ptr|%Type4\*}} align 1 {{%[a-z]\.0|%_[0-9]}}){{.*}}[ "kcfi"(i32 [[TYPE4:[[:print:]]+]]) ] +} + +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE2]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE3]]} +// CHECK: !{{[0-9]+}} = !{i32 [[TYPE4]]} diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs new file mode 100644 index 000000000..997bdaf56 --- /dev/null +++ b/tests/codegen/slice-iter-nonnull.rs @@ -0,0 +1,77 @@ +// no-system-llvm +// compile-flags: -O +// ignore-debug (these add extra checks that make it hard to verify) +#![crate_type = "lib"] + +// The slice iterator used to `assume` that the `start` pointer was non-null. +// That ought to be unneeded, though, since the type is `NonNull`, so this test +// confirms that the appropriate metadata is included to denote that. + +// CHECK-LABEL: @slice_iter_next( +#[no_mangle] +pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: %[[START:.+]] = load ptr, ptr %it, + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: icmp eq ptr %[[START]], %[[END]] + + // CHECK: store ptr{{.+}}, ptr %it, + + it.next() +} + +// CHECK-LABEL: @slice_iter_next_back( +#[no_mangle] +pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: %[[START:.+]] = load ptr, ptr %it, + // CHECK-SAME: !nonnull + // CHECK-SAME: !noundef + // CHECK: icmp eq ptr %[[START]], %[[END]] + + // CHECK: store ptr{{.+}}, ptr %[[ENDP]], + + it.next_back() +} + +// The slice iterator `new` methods used to `assume` that the pointer is non-null, +// but passing slices already requires that, to the extent that LLVM actually +// removed the `call @llvm.assume` anyway. These tests just demonstrate that the +// attribute is there, and confirms adding the assume back doesn't do anything. + +// CHECK-LABEL: @slice_iter_new +// CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef %slice.1) +#[no_mangle] +pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> { + // CHECK-NOT: slice + // CHECK: %[[END:.+]] = getelementptr inbounds i32{{.+}} %slice.0{{.+}} %slice.1 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %slice.0, 0 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %[[END]], 1 + // CHECK-NOT: slice + // CHECK: } + slice.iter() +} + +// CHECK-LABEL: @slice_iter_mut_new +// CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef %slice.1) +#[no_mangle] +pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> { + // CHECK-NOT: slice + // CHECK: %[[END:.+]] = getelementptr inbounds i32{{.+}} %slice.0{{.+}} %slice.1 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %slice.0, 0 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %[[END]], 1 + // CHECK-NOT: slice + // CHECK: } + slice.iter_mut() +} diff --git a/tests/codegen/split-lto-unit.rs b/tests/codegen/split-lto-unit.rs new file mode 100644 index 000000000..dc6570be3 --- /dev/null +++ b/tests/codegen/split-lto-unit.rs @@ -0,0 +1,11 @@ +// Verifies that "EnableSplitLTOUnit" module flag is added. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsplit-lto-unit + +#![crate_type="lib"] + +pub fn foo() { +} + +// CHECK: !{{[0-9]+}} = !{i32 4, !"EnableSplitLTOUnit", i32 1} diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs index aa7fab7fb..caf0366d2 100644 --- a/tests/codegen/thread-local.rs +++ b/tests/codegen/thread-local.rs @@ -20,8 +20,8 @@ thread_local!(static A: Cell<u32> = const { Cell::new(1) }); // CHECK-LABEL: @get #[no_mangle] fn get() -> u32 { - // CHECK: %0 = load i32, {{.*}}[[TLS]]{{.*}} - // CHECK-NEXT: ret i32 %0 + // CHECK: [[RET_0:%.+]] = load i32, {{.*}}[[TLS]]{{.*}} + // CHECK-NEXT: ret i32 [[RET_0]] A.with(|a| a.get()) } @@ -36,8 +36,8 @@ fn set(v: u32) { // CHECK-LABEL: @get_aux #[no_mangle] fn get_aux() -> u64 { - // CHECK: %0 = load i64, {{.*}}[[TLS_AUX]] - // CHECK-NEXT: ret i64 %0 + // CHECK: [[RET_1:%.+]] = load i64, {{.*}}[[TLS_AUX]] + // CHECK-NEXT: ret i64 [[RET_1]] aux::A.with(|a| a.get()) } diff --git a/tests/codegen/tied-features-strength.rs b/tests/codegen/tied-features-strength.rs new file mode 100644 index 000000000..51334c121 --- /dev/null +++ b/tests/codegen/tied-features-strength.rs @@ -0,0 +1,29 @@ +// ignore-tidy-linelength +// revisions: ENABLE_SVE DISABLE_SVE DISABLE_NEON ENABLE_NEON +// compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu +// needs-llvm-components: aarch64 + +// The "+v8a" feature is matched as optional as it isn't added when we +// are targeting older LLVM versions. Once the min supported version +// is LLVM-14 we can remove the optional regex matching for this feature. + +// [ENABLE_SVE] compile-flags: -C target-feature=+sve +// ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?))*}}" } + +// [DISABLE_SVE] compile-flags: -C target-feature=-sve +// DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" } + +// [DISABLE_NEON] compile-flags: -C target-feature=-neon +// DISABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-fp-armv8,?)|(-neon,?))*}}" } + +// [ENABLE_NEON] compile-flags: -C target-feature=+neon +// ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" } + + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +pub fn test() {} diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs new file mode 100644 index 000000000..461dd550c --- /dev/null +++ b/tests/codegen/transmute-optimized.rs @@ -0,0 +1,109 @@ +// compile-flags: -O -Z merge-functions=disabled +// min-llvm-version: 15.0 # this test uses `ptr`s +// ignore-debug + +#![crate_type = "lib"] + +// This tests that LLVM can optimize based on the niches in the source or +// destination types for transmutes. + +#[repr(u32)] +pub enum AlwaysZero32 { X = 0 } + +// CHECK-LABEL: i32 @issue_109958(i32 +#[no_mangle] +pub fn issue_109958(x: AlwaysZero32) -> i32 { + // CHECK: ret i32 0 + unsafe { std::mem::transmute(x) } +} + +// CHECK-LABEL: i1 @reference_is_null(ptr +#[no_mangle] +pub fn reference_is_null(x: &i32) -> bool { + // CHECK: ret i1 false + let p: *const i32 = unsafe { std::mem::transmute(x) }; + p.is_null() +} + +// CHECK-LABEL: i1 @non_null_is_null(ptr +#[no_mangle] +pub fn non_null_is_null(x: std::ptr::NonNull<i32>) -> bool { + // CHECK: ret i1 false + let p: *const i32 = unsafe { std::mem::transmute(x) }; + p.is_null() +} + +// CHECK-LABEL: i1 @non_zero_is_null( +#[no_mangle] +pub fn non_zero_is_null(x: std::num::NonZeroUsize) -> bool { + // CHECK: ret i1 false + let p: *const i32 = unsafe { std::mem::transmute(x) }; + p.is_null() +} + +// CHECK-LABEL: i1 @non_null_is_zero(ptr +#[no_mangle] +pub fn non_null_is_zero(x: std::ptr::NonNull<i32>) -> bool { + // CHECK: ret i1 false + let a: isize = unsafe { std::mem::transmute(x) }; + a == 0 +} + +// CHECK-LABEL: i1 @bool_ordering_is_ge(i1 +#[no_mangle] +pub fn bool_ordering_is_ge(x: bool) -> bool { + // CHECK: ret i1 true + let y: std::cmp::Ordering = unsafe { std::mem::transmute(x) }; + y.is_ge() +} + +// CHECK-LABEL: i1 @ordering_is_ge_then_transmute_to_bool(i8 +#[no_mangle] +pub fn ordering_is_ge_then_transmute_to_bool(x: std::cmp::Ordering) -> bool { + let r = x.is_ge(); + let _: bool = unsafe { std::mem::transmute(x) }; + r +} + +// CHECK-LABEL: i32 @normal_div(i32 +#[no_mangle] +pub fn normal_div(a: u32, b: u32) -> u32 { + // CHECK: call core::panicking::panic + a / b +} + +// CHECK-LABEL: i32 @div_transmute_nonzero(i32 +#[no_mangle] +pub fn div_transmute_nonzero(a: u32, b: std::num::NonZeroI32) -> u32 { + // CHECK-NOT: call core::panicking::panic + // CHECK: %[[R:.+]] = udiv i32 %a, %b + // CHECK-NEXT: ret i32 %[[R]] + // CHECK-NOT: call core::panicking::panic + let d: u32 = unsafe { std::mem::transmute(b) }; + a / d +} + +#[repr(i8)] +pub enum OneTwoThree { One = 1, Two = 2, Three = 3 } + +// CHECK-LABEL: i8 @ordering_transmute_onetwothree(i8 +#[no_mangle] +pub unsafe fn ordering_transmute_onetwothree(x: std::cmp::Ordering) -> OneTwoThree { + // CHECK: ret i8 1 + std::mem::transmute(x) +} + +// CHECK-LABEL: i8 @onetwothree_transmute_ordering(i8 +#[no_mangle] +pub unsafe fn onetwothree_transmute_ordering(x: OneTwoThree) -> std::cmp::Ordering { + // CHECK: ret i8 1 + std::mem::transmute(x) +} + +// CHECK-LABEL: i1 @char_is_negative(i32 +#[no_mangle] +pub fn char_is_negative(c: char) -> bool { + // CHECK: ret i1 false + let x: i32 = unsafe { std::mem::transmute(c) }; + x < 0 +} diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs index af2cef472..a0894a505 100644 --- a/tests/codegen/transmute-scalar.rs +++ b/tests/codegen/transmute-scalar.rs @@ -1,4 +1,4 @@ -// compile-flags: -O -C no-prepopulate-passes +// compile-flags: -C opt-level=0 -C no-prepopulate-passes // min-llvm-version: 15.0 # this test assumes `ptr`s and thus no `pointercast`s #![crate_type = "lib"] @@ -10,7 +10,7 @@ // However, `bitcast`s and `ptrtoint`s and `inttoptr`s are still worth doing when // that allows us to avoid the `alloca`s entirely; see `rvalue_creates_operand`. -// CHECK-LABEL: define{{.*}}i32 @f32_to_bits(float noundef %x) +// CHECK-LABEL: define{{.*}}i32 @f32_to_bits(float %x) // CHECK: %0 = bitcast float %x to i32 // CHECK-NEXT: ret i32 %0 #[no_mangle] @@ -18,7 +18,7 @@ pub fn f32_to_bits(x: f32) -> u32 { unsafe { std::mem::transmute(x) } } -// CHECK-LABEL: define{{.*}}i8 @bool_to_byte(i1 noundef zeroext %b) +// CHECK-LABEL: define{{.*}}i8 @bool_to_byte(i1 zeroext %b) // CHECK: %0 = zext i1 %b to i8 // CHECK-NEXT: ret i8 %0 #[no_mangle] @@ -26,7 +26,7 @@ pub fn bool_to_byte(b: bool) -> u8 { unsafe { std::mem::transmute(b) } } -// CHECK-LABEL: define{{.*}}noundef zeroext i1 @byte_to_bool(i8 noundef %byte) +// CHECK-LABEL: define{{.*}}zeroext i1 @byte_to_bool(i8 %byte) // CHECK: %0 = trunc i8 %byte to i1 // CHECK-NEXT: ret i1 %0 #[no_mangle] @@ -34,14 +34,14 @@ pub unsafe fn byte_to_bool(byte: u8) -> bool { std::mem::transmute(byte) } -// CHECK-LABEL: define{{.*}}ptr @ptr_to_ptr(ptr noundef %p) +// CHECK-LABEL: define{{.*}}ptr @ptr_to_ptr(ptr %p) // CHECK: ret ptr %p #[no_mangle] pub fn ptr_to_ptr(p: *mut u16) -> *mut u8 { unsafe { std::mem::transmute(p) } } -// CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int(ptr noundef %p) +// CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int(ptr %p) // CHECK: %0 = ptrtoint ptr %p to [[USIZE]] // CHECK-NEXT: ret [[USIZE]] %0 #[no_mangle] @@ -49,7 +49,7 @@ pub fn ptr_to_int(p: *mut u16) -> usize { unsafe { std::mem::transmute(p) } } -// CHECK: define{{.*}}ptr @int_to_ptr([[USIZE]] noundef %i) +// CHECK: define{{.*}}ptr @int_to_ptr([[USIZE]] %i) // CHECK: %0 = inttoptr [[USIZE]] %i to ptr // CHECK-NEXT: ret ptr %0 #[no_mangle] diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs index 9143fad23..6f477a796 100644 --- a/tests/codegen/vec-optimizes-away.rs +++ b/tests/codegen/vec-optimizes-away.rs @@ -1,12 +1,13 @@ // ignore-debug: the debug assertions get in the way // no-system-llvm // compile-flags: -O -#![crate_type="lib"] +#![crate_type = "lib"] #[no_mangle] pub fn sum_me() -> i32 { // CHECK-LABEL: @sum_me // CHECK-NEXT: {{^.*:$}} + // CHECK-NEXT: {{.*}} load volatile i8, ptr @__rust_no_alloc_shim_is_unstable, align 1 // CHECK-NEXT: ret i32 6 vec![1, 2, 3].iter().sum::<i32>() } diff --git a/tests/codegen/vec-shrink-panik.rs b/tests/codegen/vec-shrink-panik.rs index b3c3483fe..88b7edff2 100644 --- a/tests/codegen/vec-shrink-panik.rs +++ b/tests/codegen/vec-shrink-panik.rs @@ -25,7 +25,7 @@ pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> { // Call to panic_cannot_unwind in case of double-panic is expected // on LLVM 16 and older, but other panics are not. - // CHECK: cleanup + // old: filter // old-NEXT: ; call core::panicking::panic_cannot_unwind // old-NEXT: panic_cannot_unwind @@ -40,7 +40,7 @@ pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> { // Call to panic_cannot_unwind in case of double-panic is expected, // on LLVM 16 and older, but other panics are not. - // CHECK: cleanup + // old: filter // old-NEXT: ; call core::panicking::panic_cannot_unwind // old-NEXT: panic_cannot_unwind diff --git a/tests/debuginfo/associated-types.rs b/tests/debuginfo/associated-types.rs index 0a0ce3c67..a1735520b 100644 --- a/tests/debuginfo/associated-types.rs +++ b/tests/debuginfo/associated-types.rs @@ -1,6 +1,6 @@ // Some versions of the non-rust-enabled LLDB print the wrong generic // parameter type names in this test. -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/auxiliary/dependency-with-embedded-visualizers.rs b/tests/debuginfo/auxiliary/dependency-with-embedded-visualizers.rs index 327515b10..c187df637 100644 --- a/tests/debuginfo/auxiliary/dependency-with-embedded-visualizers.rs +++ b/tests/debuginfo/auxiliary/dependency-with-embedded-visualizers.rs @@ -2,7 +2,6 @@ // ignore-lldb // no-prefer-dynamic -#![feature(debugger_visualizer)] #![debugger_visualizer(natvis_file = "dependency-with-embedded-visualizers.natvis")] #![debugger_visualizer(gdb_script_file = "dependency-with-embedded-visualizers.py")] #![crate_type = "rlib"] diff --git a/tests/debuginfo/auxiliary/macro-stepping.rs b/tests/debuginfo/auxiliary/macro-stepping.rs index 4447dd22d..ae50e1144 100644 --- a/tests/debuginfo/auxiliary/macro-stepping.rs +++ b/tests/debuginfo/auxiliary/macro-stepping.rs @@ -5,6 +5,6 @@ #[macro_export] macro_rules! new_scope { () => { - let x = 1; + let x = 1; opaque(x); } } diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index f3e465dc6..37d458cb4 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -1,6 +1,6 @@ // Require a gdb or lldb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/embedded-visualizer.rs b/tests/debuginfo/embedded-visualizer.rs index 2898e75e0..ac4210928 100644 --- a/tests/debuginfo/embedded-visualizer.rs +++ b/tests/debuginfo/embedded-visualizer.rs @@ -60,7 +60,6 @@ // gdb-check:$4 = "Person A" is 10 years old. #![allow(unused_variables)] -#![feature(debugger_visualizer)] #![debugger_visualizer(natvis_file = "embedded-visualizer.natvis")] #![debugger_visualizer(gdb_script_file = "embedded-visualizer.py")] diff --git a/tests/debuginfo/generic-method-on-generic-struct.rs b/tests/debuginfo/generic-method-on-generic-struct.rs index 97609ef5d..2d54c2b07 100644 --- a/tests/debuginfo/generic-method-on-generic-struct.rs +++ b/tests/debuginfo/generic-method-on-generic-struct.rs @@ -2,7 +2,7 @@ // Some versions of the non-rust-enabled LLDB print the wrong generic // parameter type names in this test. -// rust-lldb +// needs-rust-lldb // === GDB TESTS =================================================================================== diff --git a/tests/debuginfo/generic-struct.rs b/tests/debuginfo/generic-struct.rs index 5fa5ce800..5213eebc1 100644 --- a/tests/debuginfo/generic-struct.rs +++ b/tests/debuginfo/generic-struct.rs @@ -1,6 +1,6 @@ // Some versions of the non-rust-enabled LLDB print the wrong generic // parameter type names in this test. -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/generic-tuple-style-enum.rs b/tests/debuginfo/generic-tuple-style-enum.rs index 60362e54e..a55402691 100644 --- a/tests/debuginfo/generic-tuple-style-enum.rs +++ b/tests/debuginfo/generic-tuple-style-enum.rs @@ -1,6 +1,6 @@ // Require a gdb or lldb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/macro-stepping.rs b/tests/debuginfo/macro-stepping.rs index e4b2b7b79..a7287cffd 100644 --- a/tests/debuginfo/macro-stepping.rs +++ b/tests/debuginfo/macro-stepping.rs @@ -79,22 +79,28 @@ extern crate macro_stepping; // exports new_scope!() // lldb-check:[...]#inc-loc2[...] // lldb-command:next // lldb-command:frame select +// lldb-check:[...]#inc-loc1[...] +// lldb-command:next +// lldb-command:frame select +// lldb-check:[...]#inc-loc2[...] +// lldb-command:next +// lldb-command:frame select // lldb-check:[...]#inc-loc3[...] macro_rules! foo { () => { - let a = 1; - let b = 2; - let c = 3; - } + let a = 1; opaque(a); + let b = 2; opaque(b); + let c = 3; opaque(c); + }; } macro_rules! foo2 { () => { foo!(); - let x = 1; + let x = 1; opaque(x); foo!(); - } + }; } fn main() { @@ -118,4 +124,6 @@ fn main() { fn zzz() {()} +fn opaque(_: u32) {} + include!("macro-stepping.inc"); diff --git a/tests/debuginfo/method-on-generic-struct.rs b/tests/debuginfo/method-on-generic-struct.rs index bf0474491..138d8391d 100644 --- a/tests/debuginfo/method-on-generic-struct.rs +++ b/tests/debuginfo/method-on-generic-struct.rs @@ -1,6 +1,6 @@ // Some versions of the non-rust-enabled LLDB print the wrong generic // parameter type names in this test. -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/pretty-std.rs b/tests/debuginfo/pretty-std.rs index 7bb2810c2..c7df7dc3c 100644 --- a/tests/debuginfo/pretty-std.rs +++ b/tests/debuginfo/pretty-std.rs @@ -130,8 +130,8 @@ // cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] // cdb-command: dx linkedlist -// cdb-check:linkedlist : { len=0x2 } [Type: alloc::collections::linked_list::LinkedList<i32>] -// cdb-check: [<Raw View>] [Type: alloc::collections::linked_list::LinkedList<i32>] +// cdb-check:linkedlist : { len=0x2 } [Type: alloc::collections::linked_list::LinkedList<i32,alloc::alloc::Global>] +// cdb-check: [<Raw View>] [Type: alloc::collections::linked_list::LinkedList<i32,alloc::alloc::Global>] // cdb-check: [0x0] : 128 [Type: int] // cdb-check: [0x1] : 42 [Type: int] diff --git a/tests/debuginfo/reference-debuginfo.rs b/tests/debuginfo/reference-debuginfo.rs new file mode 100644 index 000000000..85ade170a --- /dev/null +++ b/tests/debuginfo/reference-debuginfo.rs @@ -0,0 +1,173 @@ +// Copy of `borrowed-basic.rs` which enables the `ReferencePropagation` MIR pass. +// That pass replaces debuginfo for `a => _x` where `_x = &b` to be `a => &b`, +// and leaves codegen to create a ladder of allocations so as `*a == b`. +// +// compile-flags:-g -Zmir-enable-passes=+ReferencePropagation,-ConstDebugInfo +// min-lldb-version: 310 + +// === GDB TESTS =================================================================================== + +// gdb-command:run +// gdb-command:print *bool_ref +// gdb-check:$1 = true + +// gdb-command:print *int_ref +// gdb-check:$2 = -1 + +// gdb-command:print/d *char_ref +// gdb-check:$3 = 97 + +// gdb-command:print *i8_ref +// gdbg-check:$4 = 68 'D' +// gdbr-check:$4 = 68 + +// gdb-command:print *i16_ref +// gdb-check:$5 = -16 + +// gdb-command:print *i32_ref +// gdb-check:$6 = -32 + +// gdb-command:print *i64_ref +// gdb-check:$7 = -64 + +// gdb-command:print *uint_ref +// gdb-check:$8 = 1 + +// gdb-command:print *u8_ref +// gdbg-check:$9 = 100 'd' +// gdbr-check:$9 = 100 + +// gdb-command:print *u16_ref +// gdb-check:$10 = 16 + +// gdb-command:print *u32_ref +// gdb-check:$11 = 32 + +// gdb-command:print *u64_ref +// gdb-check:$12 = 64 + +// gdb-command:print *f32_ref +// gdb-check:$13 = 2.5 + +// gdb-command:print *f64_ref +// gdb-check:$14 = 3.5 + +// gdb-command:print *f64_double_ref +// gdb-check:$15 = 3.5 + + +// === LLDB TESTS ================================================================================== + +// lldb-command:run +// lldb-command:print *bool_ref +// lldbg-check:[...]$0 = true +// lldbr-check:(bool) *bool_ref = true + +// lldb-command:print *int_ref +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) *int_ref = -1 + +// NOTE: only rust-enabled lldb supports 32bit chars +// lldbr-command:print *char_ref +// lldbr-check:(char) *char_ref = 'a' + +// lldb-command:print *i8_ref +// lldbg-check:[...]$2 = 'D' +// lldbr-check:(i8) *i8_ref = 68 + +// lldb-command:print *i16_ref +// lldbg-check:[...]$3 = -16 +// lldbr-check:(i16) *i16_ref = -16 + +// lldb-command:print *i32_ref +// lldbg-check:[...]$4 = -32 +// lldbr-check:(i32) *i32_ref = -32 + +// lldb-command:print *i64_ref +// lldbg-check:[...]$5 = -64 +// lldbr-check:(i64) *i64_ref = -64 + +// lldb-command:print *uint_ref +// lldbg-check:[...]$6 = 1 +// lldbr-check:(usize) *uint_ref = 1 + +// lldb-command:print *u8_ref +// lldbg-check:[...]$7 = 'd' +// lldbr-check:(u8) *u8_ref = 100 + +// lldb-command:print *u16_ref +// lldbg-check:[...]$8 = 16 +// lldbr-check:(u16) *u16_ref = 16 + +// lldb-command:print *u32_ref +// lldbg-check:[...]$9 = 32 +// lldbr-check:(u32) *u32_ref = 32 + +// lldb-command:print *u64_ref +// lldbg-check:[...]$10 = 64 +// lldbr-check:(u64) *u64_ref = 64 + +// lldb-command:print *f32_ref +// lldbg-check:[...]$11 = 2.5 +// lldbr-check:(f32) *f32_ref = 2.5 + +// lldb-command:print *f64_ref +// lldbg-check:[...]$12 = 3.5 +// lldbr-check:(f64) *f64_ref = 3.5 + +// lldb-command:print *f64_double_ref +// lldbg-check:[...]$13 = 3.5 +// lldbr-check:(f64) **f64_double_ref = 3.5 + +#![allow(unused_variables)] +#![feature(omit_gdb_pretty_printer_section)] +#![omit_gdb_pretty_printer_section] + +fn main() { + let bool_val: bool = true; + let bool_ref: &bool = &bool_val; + + let int_val: isize = -1; + let int_ref: &isize = &int_val; + + let char_val: char = 'a'; + let char_ref: &char = &char_val; + + let i8_val: i8 = 68; + let i8_ref: &i8 = &i8_val; + + let i16_val: i16 = -16; + let i16_ref: &i16 = &i16_val; + + let i32_val: i32 = -32; + let i32_ref: &i32 = &i32_val; + + let i64_val: i64 = -64; + let i64_ref: &i64 = &i64_val; + + let uint_val: usize = 1; + let uint_ref: &usize = &uint_val; + + let u8_val: u8 = 100; + let u8_ref: &u8 = &u8_val; + + let u16_val: u16 = 16; + let u16_ref: &u16 = &u16_val; + + let u32_val: u32 = 32; + let u32_ref: &u32 = &u32_val; + + let u64_val: u64 = 64; + let u64_ref: &u64 = &u64_val; + + let f32_val: f32 = 2.5; + let f32_ref: &f32 = &f32_val; + + let f64_val: f64 = 3.5; + let f64_ref: &f64 = &f64_val; + let f64_double_ref: &f64 = &f64_ref; + + zzz(); // #break +} + +fn zzz() {()} diff --git a/tests/debuginfo/struct-style-enum.rs b/tests/debuginfo/struct-style-enum.rs index 3d819e368..0152dd9ea 100644 --- a/tests/debuginfo/struct-style-enum.rs +++ b/tests/debuginfo/struct-style-enum.rs @@ -1,6 +1,6 @@ // Require a gdb or lldb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/thread.rs b/tests/debuginfo/thread.rs index 388d50c5c..e7e83c7aa 100644 --- a/tests/debuginfo/thread.rs +++ b/tests/debuginfo/thread.rs @@ -1,4 +1,4 @@ -// Testing the the display of JoinHandle and Thread in cdb. +// Testing the display of JoinHandle and Thread in cdb. // cdb-only // min-cdb-version: 10.0.18317.1001 diff --git a/tests/debuginfo/tuple-style-enum.rs b/tests/debuginfo/tuple-style-enum.rs index 39ead172e..60f3ecbd2 100644 --- a/tests/debuginfo/tuple-style-enum.rs +++ b/tests/debuginfo/tuple-style-enum.rs @@ -1,6 +1,6 @@ // Require a gdb or lldb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/unique-enum.rs b/tests/debuginfo/unique-enum.rs index d7dfaeefe..1ff6f5d9c 100644 --- a/tests/debuginfo/unique-enum.rs +++ b/tests/debuginfo/unique-enum.rs @@ -1,6 +1,6 @@ // Require a gdb or lldb that can read DW_TAG_variant_part. // min-gdb-version: 8.2 -// rust-lldb +// needs-rust-lldb // compile-flags:-g diff --git a/tests/debuginfo/unsized.rs b/tests/debuginfo/unsized.rs index b1ec9b068..3b8280bc4 100644 --- a/tests/debuginfo/unsized.rs +++ b/tests/debuginfo/unsized.rs @@ -1,4 +1,6 @@ // compile-flags:-g +// ignore-gdb-version: 13.1 - 99.0 +// ^ https://sourceware.org/bugzilla/show_bug.cgi?id=30330 // === GDB TESTS =================================================================================== diff --git a/tests/incremental/change_crate_dep_kind.rs b/tests/incremental/change_crate_dep_kind.rs index 8c35f6ca0..f51826601 100644 --- a/tests/incremental/change_crate_dep_kind.rs +++ b/tests/incremental/change_crate_dep_kind.rs @@ -2,6 +2,7 @@ // detected then -Zincremental-verify-ich will trigger an assertion. // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind // revisions:cfail1 cfail2 // compile-flags: -Z query-dep-graph -Cpanic=unwind // build-pass (FIXME(62277): could be check-pass?) diff --git a/tests/incremental/const-generic-type-cycle.rs b/tests/incremental/const-generic-type-cycle.rs new file mode 100644 index 000000000..ca7b12e9e --- /dev/null +++ b/tests/incremental/const-generic-type-cycle.rs @@ -0,0 +1,17 @@ +// Verify that we do not ICE when we try to overwrite an anon-const's type because of a trait +// cycle. +// +// compile-flags: -Zincremental-ignore-spans +// revisions: cpass cfail +// error-pattern: cycle detected when computing type of `Bar::N` + +#![feature(trait_alias)] +#![crate_type="lib"] + +#[cfg(cpass)] +trait Bar<const N: usize> {} + +#[cfg(cfail)] +trait Bar<const N: dyn BB> {} + +trait BB = Bar<{ 2 + 1 }>; diff --git a/tests/incremental/const-generics/change-const-param-gat.rs b/tests/incremental/const-generics/change-const-param-gat.rs new file mode 100644 index 000000000..f1449d568 --- /dev/null +++ b/tests/incremental/const-generics/change-const-param-gat.rs @@ -0,0 +1,29 @@ +// revisions: rpass1 rpass2 rpass3 +// compile-flags: -Zincremental-ignore-spans +#![feature(generic_associated_types)] + +// This test unsures that with_opt_const_param returns the +// def_id of the N param in the Foo::Assoc GAT. + +trait Foo { + type Assoc<const N: usize>; + fn foo( + &self, + ) -> Self::Assoc<{ if cfg!(rpass2) { 3 } else { 2 } }>; +} + +impl Foo for () { + type Assoc<const N: usize> = [(); N]; + fn foo( + &self, + ) -> Self::Assoc<{ if cfg!(rpass2) { 3 } else { 2 } }> { + [(); { if cfg!(rpass2) { 3 } else { 2 } }] + } +} + +fn main() { + assert_eq!( + ().foo(), + [(); { if cfg!(rpass2) { 3 } else { 2 } }] + ); +} diff --git a/tests/incremental/const-generics/change-const-param-type.rs b/tests/incremental/const-generics/change-const-param-type.rs new file mode 100644 index 000000000..1aac1bc7d --- /dev/null +++ b/tests/incremental/const-generics/change-const-param-type.rs @@ -0,0 +1,68 @@ +// revisions: rpass1 rpass2 rpass3 +// compile-flags: -Zincremental-ignore-spans + +enum Foo<const N: usize> { + Variant, + Variant2(), + Variant3 {}, +} + +impl Foo<1> { + fn foo<const N: usize>(&self) -> [(); N] { [(); N] } +} + +impl Foo<2> { + fn foo<const N: u32>(self) -> usize { N as usize } +} + +struct Bar<const N: usize>; +struct Bar2<const N: usize>(); +struct Bar3<const N: usize> {} + +#[cfg(rpass1)] +struct ChangingStruct<const N: usize>; + +#[cfg(any(rpass2, rpass3))] +struct ChangingStruct<const N: u32>; + +struct S; + +impl S { + #[cfg(rpass1)] + fn changing_method<const N: usize>(self) {} + + #[cfg(any(rpass2, rpass3))] + fn changing_method<const N: u32>(self) {} +} + +// We want to verify that all goes well when the value of the const argument change. +// To avoid modifying `main`'s HIR, we use a separate constant, and use `{ FOO_ARG + 1 }` +// inside the body to keep having an `AnonConst` to compute. +const FOO_ARG: usize = if cfg!(rpass2) { 1 } else { 0 }; + +fn main() { + let foo = Foo::Variant::<{ FOO_ARG + 1 }>; + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let foo = Foo::Variant2::<{ FOO_ARG + 1 }>(); + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let foo = Foo::Variant3::<{ FOO_ARG + 1 }> {}; + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let foo = Foo::<{ FOO_ARG + 1 }>::Variant; + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let foo = Foo::<{ FOO_ARG + 1 }>::Variant2(); + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let foo = Foo::<{ FOO_ARG + 1 }>::Variant3 {}; + foo.foo::<{ if cfg!(rpass3) { 3 } else { 4 } }>(); + + let _ = Bar::<{ FOO_ARG + 1 }>; + let _ = Bar2::<{ FOO_ARG + 1 }>(); + let _ = Bar3::<{ FOO_ARG + 1 }> {}; + + let _ = ChangingStruct::<{ 5 }>; + let _ = S.changing_method::<{ 5 }>(); +} diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs index db367d070..f685fe46d 100644 --- a/tests/incremental/hashes/enum_constructors.rs +++ b/tests/incremental/hashes/enum_constructors.rs @@ -334,9 +334,9 @@ pub fn change_constructor_variant_c_like() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")] +#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")] #[rustc_clean(cfg="cfail6")] pub fn change_constructor_variant_c_like() { let _x = Clike::C; diff --git a/tests/incremental/hashes/let_expressions.rs b/tests/incremental/hashes/let_expressions.rs index 7aca43242..a835b8eef 100644 --- a/tests/incremental/hashes/let_expressions.rs +++ b/tests/incremental/hashes/let_expressions.rs @@ -91,7 +91,7 @@ pub fn change_mutability_of_slot() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail6")] @@ -176,7 +176,7 @@ pub fn change_mutability_of_binding_in_pattern() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail6")] @@ -193,9 +193,9 @@ pub fn add_initializer() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")] +#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail6")] pub fn add_initializer() { let _x: i16 = 3i16; @@ -210,9 +210,9 @@ pub fn change_initializer() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")] +#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] #[rustc_clean(cfg="cfail6")] pub fn change_initializer() { let _x = 5u16; diff --git a/tests/incremental/issue-80691-bad-eval-cache.rs b/tests/incremental/issue-80691-bad-eval-cache.rs index 1a644fd88..ad8a338a7 100644 --- a/tests/incremental/issue-80691-bad-eval-cache.rs +++ b/tests/incremental/issue-80691-bad-eval-cache.rs @@ -1,6 +1,7 @@ // revisions: rfail1 rfail2 // failure-status: 101 // error-pattern: not implemented +// needs-unwind -Cpanic=abort causes abort instead of exit(101) pub trait Interner { type InternedVariableKinds; diff --git a/tests/mir-opt/bool_compare.opt1.InstCombine.diff b/tests/mir-opt/bool_compare.opt1.InstSimplify.diff index 0af5d82d3..6c9df8f04 100644 --- a/tests/mir-opt/bool_compare.opt1.InstCombine.diff +++ b/tests/mir-opt/bool_compare.opt1.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt1` before InstCombine -+ // MIR for `opt1` after InstCombine +- // MIR for `opt1` before InstSimplify ++ // MIR for `opt1` after InstSimplify fn opt1(_1: bool) -> u32 { debug x => _1; // in scope 0 at $DIR/bool_compare.rs:+0:9: +0:10 diff --git a/tests/mir-opt/bool_compare.opt2.InstCombine.diff b/tests/mir-opt/bool_compare.opt2.InstSimplify.diff index f5d1febd9..9fb398265 100644 --- a/tests/mir-opt/bool_compare.opt2.InstCombine.diff +++ b/tests/mir-opt/bool_compare.opt2.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt2` before InstCombine -+ // MIR for `opt2` after InstCombine +- // MIR for `opt2` before InstSimplify ++ // MIR for `opt2` after InstSimplify fn opt2(_1: bool) -> u32 { debug x => _1; // in scope 0 at $DIR/bool_compare.rs:+0:9: +0:10 diff --git a/tests/mir-opt/bool_compare.opt3.InstCombine.diff b/tests/mir-opt/bool_compare.opt3.InstSimplify.diff index e7432adac..3a47da867 100644 --- a/tests/mir-opt/bool_compare.opt3.InstCombine.diff +++ b/tests/mir-opt/bool_compare.opt3.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt3` before InstCombine -+ // MIR for `opt3` after InstCombine +- // MIR for `opt3` before InstSimplify ++ // MIR for `opt3` after InstSimplify fn opt3(_1: bool) -> u32 { debug x => _1; // in scope 0 at $DIR/bool_compare.rs:+0:9: +0:10 diff --git a/tests/mir-opt/bool_compare.opt4.InstCombine.diff b/tests/mir-opt/bool_compare.opt4.InstSimplify.diff index 6b3e27772..5319c987d 100644 --- a/tests/mir-opt/bool_compare.opt4.InstCombine.diff +++ b/tests/mir-opt/bool_compare.opt4.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt4` before InstCombine -+ // MIR for `opt4` after InstCombine +- // MIR for `opt4` before InstSimplify ++ // MIR for `opt4` after InstSimplify fn opt4(_1: bool) -> u32 { debug x => _1; // in scope 0 at $DIR/bool_compare.rs:+0:9: +0:10 diff --git a/tests/mir-opt/bool_compare.rs b/tests/mir-opt/bool_compare.rs index 4435bf5b0..080f7f72d 100644 --- a/tests/mir-opt/bool_compare.rs +++ b/tests/mir-opt/bool_compare.rs @@ -1,21 +1,21 @@ -// unit-test: InstCombine +// unit-test: InstSimplify -// EMIT_MIR bool_compare.opt1.InstCombine.diff +// EMIT_MIR bool_compare.opt1.InstSimplify.diff fn opt1(x: bool) -> u32 { if x != true { 0 } else { 1 } } -// EMIT_MIR bool_compare.opt2.InstCombine.diff +// EMIT_MIR bool_compare.opt2.InstSimplify.diff fn opt2(x: bool) -> u32 { if true != x { 0 } else { 1 } } -// EMIT_MIR bool_compare.opt3.InstCombine.diff +// EMIT_MIR bool_compare.opt3.InstSimplify.diff fn opt3(x: bool) -> u32 { if x == false { 0 } else { 1 } } -// EMIT_MIR bool_compare.opt4.InstCombine.diff +// EMIT_MIR bool_compare.opt4.InstSimplify.diff fn opt4(x: bool) -> u32 { if false == x { 0 } else { 1 } } diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 7cce3415f..a9d1477b9 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -4,7 +4,7 @@ _0: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:15:8: 15:14 (#8), + span: $DIR/async_await.rs:15:9: 15:14 (#8), scope: scope[0], }, ignore_for_traits: false, @@ -12,7 +12,7 @@ _1: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:16:8: 16:14 (#11), + span: $DIR/async_await.rs:16:9: 16:14 (#10), scope: scope[0], }, ignore_for_traits: false, @@ -35,42 +35,42 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, debug _task_context => _38; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _0: std::task::Poll<()>; // return place in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let _3: (); // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _5: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:8 - let mut _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _7: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 - let _8: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let _8: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _13: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 let mut _14: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _18: !; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _22: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:8 - let mut _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let _24: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let _24: (); // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _29: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 let mut _30: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 - let mut _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _34: !; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 - let mut _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _37: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _38: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _39: u32; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 scope 1 { - debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // in scope 1 at $DIR/async_await.rs:+1:8: +1:14 + debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // in scope 1 at $DIR/async_await.rs:+1:9: +1:14 let _17: (); // in scope 1 at $DIR/async_await.rs:+1:5: +1:14 scope 2 { } @@ -79,7 +79,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } } scope 4 { - debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // in scope 4 at $DIR/async_await.rs:+2:8: +2:14 + debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // in scope 4 at $DIR/async_await.rs:+2:9: +2:14 let _33: (); // in scope 4 at $DIR/async_await.rs:+2:5: +2:14 scope 5 { } @@ -96,7 +96,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb1: { _38 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_3); // scope 0 at $DIR/async_await.rs:+1:5: +1:14 - StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:9: +1:14 StorageLive(_5); // scope 0 at $DIR/async_await.rs:+1:5: +1:8 _5 = a() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:5: +1:8 // mir::Constant @@ -105,30 +105,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb2: { - _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 + _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } } bb3: { StorageDead(_5); // scope 0 at $DIR/async_await.rs:+1:13: +1:14 - nop; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 - (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 - goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + nop; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 + (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 + goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb4: { - StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } } @@ -136,8 +136,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_11); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 StorageLive(_13); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 StorageLive(_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 - StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _15 = _38; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _15 = _38; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 _14 = move _15; // scope 2 at $DIR/async_await.rs:+1:5: +1:14 goto -> bb6; // scope 2 at $DIR/async_await.rs:+1:5: +1:14 } @@ -145,35 +145,35 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb6: { _13 = &mut (*_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 StorageDead(_15); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 - _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } } bb7: { StorageDead(_13); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_10); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 - _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb8: { - _8 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _8 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 StorageDead(_14); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_12); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_9); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_8); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - _20 = (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - return; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + _20 = (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + return; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb9: { - unreachable; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + unreachable; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb10: { @@ -190,10 +190,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb11: { StorageDead(_20); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 StorageDead(_19); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - _7 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _7 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb12: { @@ -204,7 +204,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb13: { StorageDead(_4); // scope 0 at $DIR/async_await.rs:+1:14: +1:15 StorageDead(_3); // scope 0 at $DIR/async_await.rs:+1:14: +1:15 - StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:9: +2:14 StorageLive(_22); // scope 0 at $DIR/async_await.rs:+2:5: +2:8 _22 = a() -> [return: bb14, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:5: +2:8 // mir::Constant @@ -213,30 +213,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb14: { - _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 + _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } } bb15: { StorageDead(_22); // scope 0 at $DIR/async_await.rs:+2:13: +2:14 - nop; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 - (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 - goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + nop; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 + (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 + goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb16: { - StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } } @@ -244,8 +244,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_27); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 StorageLive(_29); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 StorageLive(_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 - StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _31 = _38; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _31 = _38; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 _30 = move _31; // scope 5 at $DIR/async_await.rs:+2:5: +2:14 goto -> bb18; // scope 5 at $DIR/async_await.rs:+2:5: +2:14 } @@ -253,31 +253,31 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb18: { _29 = &mut (*_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 StorageDead(_31); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 - _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } } bb19: { StorageDead(_29); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_26); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 - _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb20: { - _24 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _24 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 StorageDead(_30); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_28); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_25); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_24); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - _36 = (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - return; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + _36 = (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + return; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb21: { @@ -294,10 +294,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb22: { StorageDead(_36); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 StorageDead(_35); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - _7 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _7 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb23: { diff --git a/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir new file mode 100644 index 000000000..5233d0489 --- /dev/null +++ b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir @@ -0,0 +1,12 @@ +// MIR for `copy_for_deref` after built + +fn copy_for_deref(_1: (&i32, i32)) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:38: +0:41 + let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _2 = deref_copy (_1.0: &i32); // scope 0 at $DIR/projections.rs:+4:13: +4:37 + _0 = (*_2); // scope 0 at $DIR/projections.rs:+5:13: +5:24 + return; // scope 0 at $DIR/projections.rs:+6:13: +6:21 + } +} diff --git a/tests/mir-opt/building/custom/projections.rs b/tests/mir-opt/building/custom/projections.rs index 5e472e531..3c155deae 100644 --- a/tests/mir-opt/building/custom/projections.rs +++ b/tests/mir-opt/building/custom/projections.rs @@ -21,13 +21,10 @@ fn unions(u: U) -> i32 { #[custom_mir(dialect = "analysis", phase = "post-cleanup")] fn tuples(i: (u32, i32)) -> (u32, i32) { mir!( - // FIXME(JakobDegen): This is necessary because we can't give type hints for `RET` - let temp: (u32, i32); + type RET = (u32, i32); { - temp.0 = i.0; - temp.1 = i.1; - - RET = temp; + RET.0 = i.0; + RET.1 = i.1; Return() } ) @@ -71,6 +68,19 @@ fn simple_index(a: [i32; 10], b: &[i32]) -> i32 { }) } +// EMIT_MIR projections.copy_for_deref.built.after.mir +#[custom_mir(dialect = "runtime", phase = "initial")] +fn copy_for_deref(x: (&i32, i32)) -> i32 { + mir!( + let temp: &i32; + { + temp = CopyForDeref(x.0); + RET = *temp; + Return() + } + ) +} + fn main() { assert_eq!(unions(U { a: 5 }), 5); assert_eq!(tuples((5, 6)), (5, 6)); @@ -82,4 +92,7 @@ fn main() { assert_eq!(o, Some(10)); assert_eq!(simple_index([0; 10], &[0; 10]), 0); + + let one = 1; + assert_eq!(copy_for_deref((&one, one)), 1); } diff --git a/tests/mir-opt/building/custom/projections.tuples.built.after.mir b/tests/mir-opt/building/custom/projections.tuples.built.after.mir index 65487d3c9..dec575200 100644 --- a/tests/mir-opt/building/custom/projections.tuples.built.after.mir +++ b/tests/mir-opt/building/custom/projections.tuples.built.after.mir @@ -2,12 +2,10 @@ fn tuples(_1: (u32, i32)) -> (u32, i32) { let mut _0: (u32, i32); // return place in scope 0 at $DIR/projections.rs:+0:29: +0:39 - let mut _2: (u32, i32); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL bb0: { - (_2.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+5:13: +5:25 - (_2.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+6:13: +6:25 - _0 = _2; // scope 0 at $DIR/projections.rs:+8:13: +8:23 - return; // scope 0 at $DIR/projections.rs:+9:13: +9:21 + (_0.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+4:13: +4:24 + (_0.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+5:13: +5:24 + return; // scope 0 at $DIR/projections.rs:+6:13: +6:21 } } diff --git a/tests/mir-opt/building/enum_cast.bar.built.after.mir b/tests/mir-opt/building/enum_cast.bar.built.after.mir index 0746e0b49..9f14c0284 100644 --- a/tests/mir-opt/building/enum_cast.bar.built.after.mir +++ b/tests/mir-opt/building/enum_cast.bar.built.after.mir @@ -5,17 +5,16 @@ fn bar(_1: Bar) -> usize { let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 let _2: Bar; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + let mut _4: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 bb0: { StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _4 = Ge(const 1_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _5 = Le(const 0_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _5 = Le(_4, const 1_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(move _5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 diff --git a/tests/mir-opt/building/enum_cast.boo.built.after.mir b/tests/mir-opt/building/enum_cast.boo.built.after.mir index 699c876b0..715dedcf2 100644 --- a/tests/mir-opt/building/enum_cast.boo.built.after.mir +++ b/tests/mir-opt/building/enum_cast.boo.built.after.mir @@ -5,17 +5,16 @@ fn boo(_1: Boo) -> usize { let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 let _2: Boo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 let mut _3: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + let mut _4: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 bb0: { StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _4 = Ge(const 1_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _5 = Le(const 0_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _5 = Le(_4, const 1_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(move _5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir index 1112177fb..6c177c61e 100644 --- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir @@ -6,7 +6,7 @@ fn droppy() -> () { let _2: Droppy; // in scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 let _4: Droppy; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 let mut _5: isize; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 - let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27 + let mut _6: u8; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27 let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27 let _8: Droppy; // in scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 scope 1 { @@ -31,10 +31,9 @@ fn droppy() -> () { StorageLive(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 _4 = move _2; // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 _5 = discriminant(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - _6 = Ge(const 2_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - assume(_6); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - _7 = Le(const 0_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - assume(_7); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + _6 = _5 as u8 (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + _7 = Le(_6, const 2_u8); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + assume(move _7); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 _3 = move _5 as usize (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 drop(_4) -> [return: bb1, unwind: bb4]; // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27 } diff --git a/tests/mir-opt/building/enum_cast.far.built.after.mir b/tests/mir-opt/building/enum_cast.far.built.after.mir new file mode 100644 index 000000000..ab8129ca0 --- /dev/null +++ b/tests/mir-opt/building/enum_cast.far.built.after.mir @@ -0,0 +1,22 @@ +// MIR for `far` after built + +fn far(_1: Far) -> isize { + debug far => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 + let mut _0: isize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 + let _2: Far; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _3: i16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _4: u16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _4 = _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _5 = Le(_4, const 1_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(move _5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _0 = move _3 as isize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/building/enum_cast.offsetty.built.after.mir b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir new file mode 100644 index 000000000..7b2b583f2 --- /dev/null +++ b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir @@ -0,0 +1,26 @@ +// MIR for `offsetty` after built + +fn offsetty(_1: NotStartingAtZero) -> u32 { + debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:13: +0:14 + let mut _0: u32; // return place in scope 0 at $DIR/enum_cast.rs:+0:38: +0:41 + let _2: NotStartingAtZero; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + let mut _4: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _5 = Ge(_4, const 4_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _6 = Le(_4, const 8_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _7 = BitAnd(move _5, move _6); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + assume(move _7); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _0 = move _3 as u32 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:12: +1:13 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs index 98fd5acfb..431b5c708 100644 --- a/tests/mir-opt/building/enum_cast.rs +++ b/tests/mir-opt/building/enum_cast.rs @@ -1,6 +1,7 @@ // EMIT_MIR enum_cast.foo.built.after.mir // EMIT_MIR enum_cast.bar.built.after.mir // EMIT_MIR enum_cast.boo.built.after.mir +// EMIT_MIR enum_cast.far.built.after.mir enum Foo { A @@ -15,6 +16,11 @@ enum Boo { A, B } +#[repr(i16)] +enum Far { + A, B +} + fn foo(foo: Foo) -> usize { foo as usize } @@ -27,6 +33,10 @@ fn boo(boo: Boo) -> usize { boo as usize } +fn far(far: Far) -> isize { + far as isize +} + // EMIT_MIR enum_cast.droppy.built.after.mir enum Droppy { A, B, C @@ -46,5 +56,37 @@ fn droppy() { let z = Droppy::B; } +#[repr(i16)] +enum SignedAroundZero { + A = -2, + B = 0, + C = 2, +} + +#[repr(u16)] +enum UnsignedAroundZero { + A = 65535, + B = 0, + C = 1, +} + +// EMIT_MIR enum_cast.signy.built.after.mir +fn signy(x: SignedAroundZero) -> i16 { + x as i16 +} + +// EMIT_MIR enum_cast.unsigny.built.after.mir +fn unsigny(x: UnsignedAroundZero) -> u16 { + // FIXME: This doesn't get an around-the-end range today, sadly. + x as u16 +} + +enum NotStartingAtZero { A = 4, B = 6, C = 8 } + +// EMIT_MIR enum_cast.offsetty.built.after.mir +fn offsetty(x: NotStartingAtZero) -> u32 { + x as u32 +} + fn main() { } diff --git a/tests/mir-opt/building/enum_cast.signy.built.after.mir b/tests/mir-opt/building/enum_cast.signy.built.after.mir new file mode 100644 index 000000000..ef4fea604 --- /dev/null +++ b/tests/mir-opt/building/enum_cast.signy.built.after.mir @@ -0,0 +1,26 @@ +// MIR for `signy` after built + +fn signy(_1: SignedAroundZero) -> i16 { + debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:10: +0:11 + let mut _0: i16; // return place in scope 0 at $DIR/enum_cast.rs:+0:34: +0:37 + let _2: SignedAroundZero; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + let mut _3: i16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + let mut _4: u16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _4 = _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _5 = Ge(_4, const 65534_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _6 = Le(_4, const 2_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _7 = BitOr(move _5, move _6); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + assume(move _7); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + _0 = move _3 as i16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:12: +1:13 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/building/enum_cast.unsigny.built.after.mir b/tests/mir-opt/building/enum_cast.unsigny.built.after.mir new file mode 100644 index 000000000..7ca147b15 --- /dev/null +++ b/tests/mir-opt/building/enum_cast.unsigny.built.after.mir @@ -0,0 +1,17 @@ +// MIR for `unsigny` after built + +fn unsigny(_1: UnsignedAroundZero) -> u16 { + debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:12: +0:13 + let mut _0: u16; // return place in scope 0 at $DIR/enum_cast.rs:+0:38: +0:41 + let _2: UnsignedAroundZero; // in scope 0 at $DIR/enum_cast.rs:+2:5: +2:6 + let mut _3: u16; // in scope 0 at $DIR/enum_cast.rs:+2:5: +2:6 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:6 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+2:5: +2:6 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:13 + _0 = move _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:13 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+2:12: +2:13 + return; // scope 0 at $DIR/enum_cast.rs:+3:2: +3:2 + } +} diff --git a/tests/mir-opt/casts.redundant.InstCombine.diff b/tests/mir-opt/casts.redundant.InstSimplify.diff index 528a8e5a9..a641b69de 100644 --- a/tests/mir-opt/casts.redundant.InstCombine.diff +++ b/tests/mir-opt/casts.redundant.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `redundant` before InstCombine -+ // MIR for `redundant` after InstCombine +- // MIR for `redundant` before InstSimplify ++ // MIR for `redundant` after InstSimplify fn redundant(_1: *const &u8) -> *const &u8 { debug x => _1; // in scope 0 at $DIR/casts.rs:+0:30: +0:31 diff --git a/tests/mir-opt/casts.rs b/tests/mir-opt/casts.rs index 259c462da..413b0e09d 100644 --- a/tests/mir-opt/casts.rs +++ b/tests/mir-opt/casts.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -// EMIT_MIR casts.redundant.InstCombine.diff +// EMIT_MIR casts.redundant.InstSimplify.diff // EMIT_MIR casts.redundant.PreCodegen.after.mir pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { generic_cast::<&'a u8, &'b u8>(x) as *const &'a u8 diff --git a/tests/mir-opt/combine_array_len.norm2.InstCombine.diff b/tests/mir-opt/combine_array_len.norm2.InstSimplify.diff index c73150f94..0777007ce 100644 --- a/tests/mir-opt/combine_array_len.norm2.InstCombine.diff +++ b/tests/mir-opt/combine_array_len.norm2.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `norm2` before InstCombine -+ // MIR for `norm2` after InstCombine +- // MIR for `norm2` before InstSimplify ++ // MIR for `norm2` after InstSimplify fn norm2(_1: [f32; 2]) -> f32 { debug x => _1; // in scope 0 at $DIR/combine_array_len.rs:+0:10: +0:11 diff --git a/tests/mir-opt/combine_array_len.rs b/tests/mir-opt/combine_array_len.rs index 08c5f1a1f..970cafafc 100644 --- a/tests/mir-opt/combine_array_len.rs +++ b/tests/mir-opt/combine_array_len.rs @@ -1,6 +1,6 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test: InstCombine -// EMIT_MIR combine_array_len.norm2.InstCombine.diff +// unit-test: InstSimplify +// EMIT_MIR combine_array_len.norm2.InstSimplify.diff fn norm2(x: [f32; 2]) -> f32 { let a = x[0]; diff --git a/tests/mir-opt/combine_clone_of_primitives.rs b/tests/mir-opt/combine_clone_of_primitives.rs index 7cc50a86e..1deee9dd6 100644 --- a/tests/mir-opt/combine_clone_of_primitives.rs +++ b/tests/mir-opt/combine_clone_of_primitives.rs @@ -1,7 +1,7 @@ -// unit-test: InstCombine +// unit-test: InstSimplify // ignore-wasm32 compiled with panic=abort by default -// EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +// EMIT_MIR combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff #[derive(Clone)] struct MyThing<T> { diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff index b715a544f..bb0811a7a 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +++ b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` before InstCombine -+ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` after InstCombine +- // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` before InstSimplify ++ // MIR for `<impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone` after InstSimplify fn <impl at $DIR/combine_clone_of_primitives.rs:6:10: 6:15>::clone(_1: &MyThing<T>) -> MyThing<T> { debug self => _1; // in scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 diff --git a/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff deleted file mode 100644 index 168e8c610..000000000 --- a/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff +++ /dev/null @@ -1,158 +0,0 @@ -- // MIR for `adt_transmutes` before InstCombine -+ // MIR for `adt_transmutes` after InstCombine - - fn adt_transmutes() -> () { - let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:32: +0:32 - let _1: u8; // in scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 - let mut _2: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 - let mut _4: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+2:28: +2:41 - let mut _6: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+3:31: +3:47 - let mut _8: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+4:31: +4:47 - let mut _10: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+5:28: +5:52 - let mut _12: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+6:28: +6:52 - let mut _14: std::option::Option<std::num::NonZeroU8>; // in scope 0 at $DIR/combine_transmutes.rs:+7:28: +7:58 - let mut _16: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+8:29: +8:54 - let mut _18: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+9:29: +9:54 - let mut _20: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+10:29: +10:47 - let mut _22: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+11:29: +11:47 - let mut _24: std::mem::MaybeUninit<std::string::String>; // in scope 0 at $DIR/combine_transmutes.rs:+12:46: +12:77 - scope 1 { - debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+1:9: +1:11 - let _3: i8; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 - scope 2 { - debug _a => _3; // in scope 2 at $DIR/combine_transmutes.rs:+2:9: +2:11 - let _5: usize; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 - scope 3 { - debug _a => _5; // in scope 3 at $DIR/combine_transmutes.rs:+3:9: +3:11 - let _7: isize; // in scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 - scope 4 { - debug _a => _7; // in scope 4 at $DIR/combine_transmutes.rs:+4:9: +4:11 - let _9: u8; // in scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 - scope 5 { - debug _a => _9; // in scope 5 at $DIR/combine_transmutes.rs:+5:9: +5:11 - let _11: i8; // in scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 - scope 6 { - debug _a => _11; // in scope 6 at $DIR/combine_transmutes.rs:+6:9: +6:11 - let _13: u8; // in scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 - scope 7 { - debug _a => _13; // in scope 7 at $DIR/combine_transmutes.rs:+7:9: +7:11 - let _15: i16; // in scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 - scope 8 { - debug _a => _15; // in scope 8 at $DIR/combine_transmutes.rs:+8:9: +8:11 - let _17: u16; // in scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 - scope 9 { - debug _a => _17; // in scope 9 at $DIR/combine_transmutes.rs:+9:9: +9:11 - let _19: u32; // in scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 - scope 10 { - debug _a => _19; // in scope 10 at $DIR/combine_transmutes.rs:+10:9: +10:11 - let _21: i32; // in scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 - scope 11 { - debug _a => _21; // in scope 11 at $DIR/combine_transmutes.rs:+11:9: +11:11 - let _23: std::mem::ManuallyDrop<std::string::String>; // in scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 - scope 12 { - debug _a => _23; // in scope 12 at $DIR/combine_transmutes.rs:+12:9: +12:11 - } - } - } - } - } - } - } - } - } - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 - StorageLive(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 - _2 = EnumNoRepr::A; // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 - _1 = move _2 as u8 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+1:18: +1:42 - StorageDead(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:41: +1:42 - StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 - StorageLive(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 - _4 = EnumNoRepr::B; // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 - _3 = move _4 as i8 (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+2:18: +2:42 - StorageDead(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:41: +2:42 - StorageLive(_5); // scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 - StorageLive(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 - _6 = EnumReprIsize::A; // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 - _5 = move _6 as usize (Transmute); // scope 2 at $DIR/combine_transmutes.rs:+3:21: +3:48 - StorageDead(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:47: +3:48 - StorageLive(_7); // scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 - StorageLive(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 - _8 = EnumReprIsize::B; // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 -- _7 = move _8 as isize (Transmute); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 -+ _7 = discriminant(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 - StorageDead(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:47: +4:48 - StorageLive(_9); // scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 - StorageLive(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 - _10 = Less; // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 - _9 = move _10 as u8 (Transmute); // scope 4 at $DIR/combine_transmutes.rs:+5:18: +5:53 - StorageDead(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:52: +5:53 - StorageLive(_11); // scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 - StorageLive(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 - _12 = Less; // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 -- _11 = move _12 as i8 (Transmute); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 -+ _11 = discriminant(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 - StorageDead(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:52: +6:53 - StorageLive(_13); // scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 - StorageLive(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 - _14 = Option::<NonZeroU8>::Some(const _); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 - // mir::Constant - // + span: $DIR/combine_transmutes.rs:41:33: 41:57 - // + literal: Const { ty: NonZeroU8, val: Unevaluated(NonZeroU8::MAX, [], None) } - _13 = move _14 as u8 (Transmute); // scope 6 at $DIR/combine_transmutes.rs:+7:18: +7:59 - StorageDead(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:58: +7:59 - StorageLive(_15); // scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 - StorageLive(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 - _16 = Wrapping::<i16>(const 0_i16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 -- _15 = move _16 as i16 (Transmute); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 -+ _15 = move (_16.0: i16); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 - StorageDead(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:54: +8:55 - StorageLive(_17); // scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 - StorageLive(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 - _18 = Wrapping::<i16>(const 0_i16); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 - _17 = move _18 as u16 (Transmute); // scope 8 at $DIR/combine_transmutes.rs:+9:19: +9:55 - StorageDead(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:54: +9:55 - StorageLive(_19); // scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 - StorageLive(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 - _20 = Union32 { u32: const 0_i32 }; // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 - _19 = move _20 as u32 (Transmute); // scope 9 at $DIR/combine_transmutes.rs:+10:19: +10:48 - StorageDead(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:47: +10:48 - StorageLive(_21); // scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 - StorageLive(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 - _22 = Union32 { u32: const 0_u32 }; // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 - _21 = move _22 as i32 (Transmute); // scope 10 at $DIR/combine_transmutes.rs:+11:19: +11:48 - StorageDead(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:47: +11:48 - StorageLive(_23); // scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 - StorageLive(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 - _24 = MaybeUninit::<String>::uninit() -> [return: bb1, unwind unreachable]; // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 - // mir::Constant - // + span: $DIR/combine_transmutes.rs:46:46: 46:75 - // + user_ty: UserType(23) - // + literal: Const { ty: fn() -> MaybeUninit<String> {MaybeUninit::<String>::uninit}, val: Value(<ZST>) } - } - - bb1: { -- _23 = move _24 as std::mem::ManuallyDrop<std::string::String> (Transmute); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 -+ _23 = move (_24.1: std::mem::ManuallyDrop<std::string::String>); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 - StorageDead(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:77: +12:78 - _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:32: +13:2 - StorageDead(_23); // scope 11 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_21); // scope 10 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_19); // scope 9 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_17); // scope 8 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_15); // scope 7 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_13); // scope 6 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_11); // scope 5 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_9); // scope 4 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_7); // scope 3 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_5); // scope 2 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+13:1: +13:2 - StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+13:1: +13:2 - return; // scope 0 at $DIR/combine_transmutes.rs:+13:2: +13:2 - } - } - diff --git a/tests/mir-opt/combine_transmutes.adt_transmutes.InstSimplify.diff b/tests/mir-opt/combine_transmutes.adt_transmutes.InstSimplify.diff new file mode 100644 index 000000000..15117ea89 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.adt_transmutes.InstSimplify.diff @@ -0,0 +1,90 @@ +- // MIR for `adt_transmutes` before InstSimplify ++ // MIR for `adt_transmutes` after InstSimplify + + fn adt_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:32: +0:32 + let _1: u8; // in scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let mut _2: std::option::Option<std::num::NonZeroU8>; // in scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:58 + let mut _4: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+2:29: +2:54 + let mut _6: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+3:29: +3:54 + let mut _8: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+4:29: +4:47 + let mut _10: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+5:29: +5:47 + let mut _12: std::mem::MaybeUninit<std::string::String>; // in scope 0 at $DIR/combine_transmutes.rs:+6:46: +6:77 + scope 1 { + debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let _3: i16; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + scope 2 { + debug _a => _3; // in scope 2 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let _5: u16; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + scope 3 { + debug _a => _5; // in scope 3 at $DIR/combine_transmutes.rs:+3:9: +3:11 + let _7: u32; // in scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + scope 4 { + debug _a => _7; // in scope 4 at $DIR/combine_transmutes.rs:+4:9: +4:11 + let _9: i32; // in scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + scope 5 { + debug _a => _9; // in scope 5 at $DIR/combine_transmutes.rs:+5:9: +5:11 + let _11: std::mem::ManuallyDrop<std::string::String>; // in scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + scope 6 { + debug _a => _11; // in scope 6 at $DIR/combine_transmutes.rs:+6:9: +6:11 + } + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + StorageLive(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:58 + _2 = Option::<NonZeroU8>::Some(const _); // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:58 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:35:33: 35:57 + // + literal: Const { ty: NonZeroU8, val: Unevaluated(NonZeroU8::MAX, [], None) } + _1 = move _2 as u8 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+1:18: +1:59 + StorageDead(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:58: +1:59 + StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + StorageLive(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:29: +2:54 + _4 = Wrapping::<i16>(const 0_i16); // scope 1 at $DIR/combine_transmutes.rs:+2:29: +2:54 +- _3 = move _4 as i16 (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+2:19: +2:55 ++ _3 = move (_4.0: i16); // scope 1 at $DIR/combine_transmutes.rs:+2:19: +2:55 + StorageDead(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:54: +2:55 + StorageLive(_5); // scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + StorageLive(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:29: +3:54 + _6 = Wrapping::<i16>(const 0_i16); // scope 2 at $DIR/combine_transmutes.rs:+3:29: +3:54 + _5 = move _6 as u16 (Transmute); // scope 2 at $DIR/combine_transmutes.rs:+3:19: +3:55 + StorageDead(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:54: +3:55 + StorageLive(_7); // scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + StorageLive(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:29: +4:47 + _8 = Union32 { u32: const 0_i32 }; // scope 3 at $DIR/combine_transmutes.rs:+4:29: +4:47 + _7 = move _8 as u32 (Transmute); // scope 3 at $DIR/combine_transmutes.rs:+4:19: +4:48 + StorageDead(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:47: +4:48 + StorageLive(_9); // scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + StorageLive(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:29: +5:47 + _10 = Union32 { u32: const 0_u32 }; // scope 4 at $DIR/combine_transmutes.rs:+5:29: +5:47 + _9 = move _10 as i32 (Transmute); // scope 4 at $DIR/combine_transmutes.rs:+5:19: +5:48 + StorageDead(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:47: +5:48 + StorageLive(_11); // scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + StorageLive(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:46: +6:77 + _12 = MaybeUninit::<String>::uninit() -> [return: bb1, unwind unreachable]; // scope 5 at $DIR/combine_transmutes.rs:+6:46: +6:77 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:40:46: 40:75 + // + user_ty: UserType(11) + // + literal: Const { ty: fn() -> MaybeUninit<String> {MaybeUninit::<String>::uninit}, val: Value(<ZST>) } + } + + bb1: { +- _11 = move _12 as std::mem::ManuallyDrop<std::string::String> (Transmute); // scope 5 at $DIR/combine_transmutes.rs:+6:36: +6:78 ++ _11 = move (_12.1: std::mem::ManuallyDrop<std::string::String>); // scope 5 at $DIR/combine_transmutes.rs:+6:36: +6:78 + StorageDead(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:77: +6:78 + _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:32: +7:2 + StorageDead(_11); // scope 5 at $DIR/combine_transmutes.rs:+7:1: +7:2 + StorageDead(_9); // scope 4 at $DIR/combine_transmutes.rs:+7:1: +7:2 + StorageDead(_7); // scope 3 at $DIR/combine_transmutes.rs:+7:1: +7:2 + StorageDead(_5); // scope 2 at $DIR/combine_transmutes.rs:+7:1: +7:2 + StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+7:1: +7:2 + return; // scope 0 at $DIR/combine_transmutes.rs:+7:2: +7:2 + } + } + diff --git a/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.identity_transmutes.InstSimplify.diff index ae1185c7f..57d9f4b14 100644 --- a/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff +++ b/tests/mir-opt/combine_transmutes.identity_transmutes.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `identity_transmutes` before InstCombine -+ // MIR for `identity_transmutes` after InstCombine +- // MIR for `identity_transmutes` before InstSimplify ++ // MIR for `identity_transmutes` after InstSimplify fn identity_transmutes() -> () { let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:37: +0:37 diff --git a/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.integer_transmutes.InstSimplify.diff index 8de7c34e6..ec7c982c1 100644 --- a/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff +++ b/tests/mir-opt/combine_transmutes.integer_transmutes.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `integer_transmutes` before InstCombine -+ // MIR for `integer_transmutes` after InstCombine +- // MIR for `integer_transmutes` before InstSimplify ++ // MIR for `integer_transmutes` after InstSimplify fn integer_transmutes() -> () { let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:36: +0:36 diff --git a/tests/mir-opt/combine_transmutes.rs b/tests/mir-opt/combine_transmutes.rs index de9b9c35c..403f9356c 100644 --- a/tests/mir-opt/combine_transmutes.rs +++ b/tests/mir-opt/combine_transmutes.rs @@ -1,4 +1,4 @@ -// unit-test: InstCombine +// unit-test: InstSimplify // compile-flags: -C panic=abort #![crate_type = "lib"] @@ -8,7 +8,7 @@ use std::intrinsics::mir::*; use std::mem::{MaybeUninit, ManuallyDrop, transmute}; -// EMIT_MIR combine_transmutes.identity_transmutes.InstCombine.diff +// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff pub unsafe fn identity_transmutes() { // These are nops and should be removed let _a = transmute::<i32, i32>(1); @@ -16,7 +16,7 @@ pub unsafe fn identity_transmutes() { } #[custom_mir(dialect = "runtime", phase = "initial")] -// EMIT_MIR combine_transmutes.integer_transmutes.InstCombine.diff +// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff pub unsafe fn integer_transmutes() { mir! { { @@ -30,14 +30,8 @@ pub unsafe fn integer_transmutes() { } } -// EMIT_MIR combine_transmutes.adt_transmutes.InstCombine.diff +// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff pub unsafe fn adt_transmutes() { - let _a: u8 = transmute(EnumNoRepr::A); - let _a: i8 = transmute(EnumNoRepr::B); - let _a: usize = transmute(EnumReprIsize::A); - let _a: isize = transmute(EnumReprIsize::B); - let _a: u8 = transmute(std::cmp::Ordering::Less); - let _a: i8 = transmute(std::cmp::Ordering::Less); let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX)); let _a: i16 = transmute(std::num::Wrapping(0_i16)); let _a: u16 = transmute(std::num::Wrapping(0_i16)); @@ -46,20 +40,4 @@ pub unsafe fn adt_transmutes() { let _a: ManuallyDrop<String> = transmute(MaybeUninit::<String>::uninit()); } -#[inline(always)] -#[custom_mir(dialect = "runtime", phase = "initial")] -const unsafe fn mir_transmute<T, U>(x: T) -> U { - mir!{ - { - RET = CastTransmute(x); - Return() - } - } -} - -pub enum EnumNoRepr { A, B, C } - -#[repr(isize)] -pub enum EnumReprIsize { A, B, C } - pub union Union32 { u32: u32, i32: i32 } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index 9b69f79c2..169e99dee 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -21,42 +21,42 @@ fn main() -> () { } alloc1 (static: FOO, size: 8, align: 4) { - ╾─alloc18─╼ 03 00 00 00 │ ╾──╼.... + ╾─alloc19─╼ 03 00 00 00 │ ╾──╼.... } -alloc18 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc5──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc13─╼ 03 00 00 00 │ ....*...╾──╼.... +alloc19 (size: 48, align: 4) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc6──╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc9──╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ....*...╾──╼.... } -alloc5 (size: 0, align: 4) {} +alloc6 (size: 0, align: 4) {} -alloc8 (size: 16, align: 4) { - ╾─alloc9──╼ 03 00 00 00 ╾─alloc10─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +alloc9 (size: 16, align: 4) { + ╾─alloc10─╼ 03 00 00 00 ╾─alloc11─╼ 03 00 00 00 │ ╾──╼....╾──╼.... } -alloc9 (size: 3, align: 1) { +alloc10 (size: 3, align: 1) { 66 6f 6f │ foo } -alloc10 (size: 3, align: 1) { +alloc11 (size: 3, align: 1) { 62 61 72 │ bar } -alloc13 (size: 24, align: 4) { - 0x00 │ ╾─alloc14─╼ 03 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ╾──╼....╾──╼.... - 0x10 │ ╾─alloc16─╼ 04 00 00 00 │ ╾──╼.... +alloc14 (size: 24, align: 4) { + 0x00 │ ╾─alloc15─╼ 03 00 00 00 ╾─alloc16─╼ 03 00 00 00 │ ╾──╼....╾──╼.... + 0x10 │ ╾─alloc17─╼ 04 00 00 00 │ ╾──╼.... } -alloc14 (size: 3, align: 1) { +alloc15 (size: 3, align: 1) { 6d 65 68 │ meh } -alloc15 (size: 3, align: 1) { +alloc16 (size: 3, align: 1) { 6d 6f 70 │ mop } -alloc16 (size: 4, align: 1) { +alloc17 (size: 4, align: 1) { 6d c3 b6 70 │ m..p } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index d0f196e72..db1f96488 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -21,46 +21,46 @@ fn main() -> () { } alloc1 (static: FOO, size: 16, align: 8) { - ╾───────alloc18───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾───────alloc19───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc18 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc5────────╼ │ ....░░░░╾──────╼ +alloc19 (size: 72, align: 8) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc6────────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc8────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc13───────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc9────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc14───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } -alloc5 (size: 0, align: 8) {} +alloc6 (size: 0, align: 8) {} -alloc8 (size: 32, align: 8) { - 0x00 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾───────alloc10───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc9 (size: 32, align: 8) { + 0x00 │ ╾───────alloc10───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾───────alloc11───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc9 (size: 3, align: 1) { +alloc10 (size: 3, align: 1) { 66 6f 6f │ foo } -alloc10 (size: 3, align: 1) { +alloc11 (size: 3, align: 1) { 62 61 72 │ bar } -alloc13 (size: 48, align: 8) { - 0x00 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x10 │ ╾───────alloc15───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x20 │ ╾───────alloc16───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc14 (size: 48, align: 8) { + 0x00 │ ╾───────alloc15───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x10 │ ╾───────alloc16───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x20 │ ╾───────alloc17───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc14 (size: 3, align: 1) { +alloc15 (size: 3, align: 1) { 6d 65 68 │ meh } -alloc15 (size: 3, align: 1) { +alloc16 (size: 3, align: 1) { 6d 6f 70 │ mop } -alloc16 (size: 4, align: 1) { +alloc17 (size: 4, align: 1) { 6d c3 b6 70 │ m..p } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir index aab005c52..999acb48a 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir @@ -21,41 +21,41 @@ fn main() -> () { } alloc1 (static: FOO, size: 8, align: 4) { - ╾─alloc22─╼ 03 00 00 00 │ ╾──╼.... + ╾─alloc23─╼ 03 00 00 00 │ ╾──╼.... } -alloc22 (size: 48, align: 4) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc9──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc14─╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc20─╼ 03 00 00 00 │ ....*...╾──╼.... +alloc23 (size: 48, align: 4) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc10─╼ 00 00 00 00 │ ....░░░░╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc15─╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc21─╼ 03 00 00 00 │ ....*...╾──╼.... } -alloc9 (size: 0, align: 4) {} +alloc10 (size: 0, align: 4) {} -alloc14 (size: 8, align: 4) { - ╾─alloc12─╼ ╾─alloc13─╼ │ ╾──╼╾──╼ +alloc15 (size: 8, align: 4) { + ╾─alloc13─╼ ╾─alloc14─╼ │ ╾──╼╾──╼ } -alloc12 (size: 1, align: 1) { +alloc13 (size: 1, align: 1) { 05 │ . } -alloc13 (size: 1, align: 1) { +alloc14 (size: 1, align: 1) { 06 │ . } -alloc20 (size: 12, align: 4) { - ╾─a17+0x3─╼ ╾─alloc18─╼ ╾─a19+0x2─╼ │ ╾──╼╾──╼╾──╼ +alloc21 (size: 12, align: 4) { + ╾─a18+0x3─╼ ╾─alloc19─╼ ╾─a20+0x2─╼ │ ╾──╼╾──╼╾──╼ } -alloc17 (size: 4, align: 1) { +alloc18 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } -alloc18 (size: 1, align: 1) { +alloc19 (size: 1, align: 1) { 2a │ * } -alloc19 (size: 4, align: 1) { +alloc20 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir index 0eff9474c..30311890e 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir @@ -21,44 +21,44 @@ fn main() -> () { } alloc1 (static: FOO, size: 16, align: 8) { - ╾───────alloc22───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ + ╾───────alloc23───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc22 (size: 72, align: 8) { - 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc9────────╼ │ ....░░░░╾──────╼ +alloc23 (size: 72, align: 8) { + 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc10───────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc14───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc20───────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc15───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc21───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } -alloc9 (size: 0, align: 8) {} +alloc10 (size: 0, align: 8) {} -alloc14 (size: 16, align: 8) { - ╾───────alloc12───────╼ ╾───────alloc13───────╼ │ ╾──────╼╾──────╼ +alloc15 (size: 16, align: 8) { + ╾───────alloc13───────╼ ╾───────alloc14───────╼ │ ╾──────╼╾──────╼ } -alloc12 (size: 1, align: 1) { +alloc13 (size: 1, align: 1) { 05 │ . } -alloc13 (size: 1, align: 1) { +alloc14 (size: 1, align: 1) { 06 │ . } -alloc20 (size: 24, align: 8) { - 0x00 │ ╾─────alloc17+0x3─────╼ ╾───────alloc18───────╼ │ ╾──────╼╾──────╼ - 0x10 │ ╾─────alloc19+0x2─────╼ │ ╾──────╼ +alloc21 (size: 24, align: 8) { + 0x00 │ ╾─────alloc18+0x3─────╼ ╾───────alloc19───────╼ │ ╾──────╼╾──────╼ + 0x10 │ ╾─────alloc20+0x2─────╼ │ ╾──────╼ } -alloc17 (size: 4, align: 1) { +alloc18 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } -alloc18 (size: 1, align: 1) { +alloc19 (size: 1, align: 1) { 2a │ * } -alloc19 (size: 4, align: 1) { +alloc20 (size: 4, align: 1) { 2a 45 15 6f │ *E.o } diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir index 55c6db5d0..d592e59fa 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir @@ -21,30 +21,30 @@ fn main() -> () { } alloc1 (static: FOO, size: 4, align: 4) { - ╾─alloc11─╼ │ ╾──╼ + ╾─alloc12─╼ │ ╾──╼ } -alloc11 (size: 168, align: 1) { +alloc12 (size: 168, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc6──╼ │ ............╾──╼ + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc7──╼ │ ............╾──╼ 0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─alloc8──╼ 00 00 │ ..........╾──╼.. - 0x90 │ ╾─a9+0x63─╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ + 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾─alloc9──╼ 00 00 │ ..........╾──╼.. + 0x90 │ ╾a10+0x63─╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ 0xa0 │ 00 00 00 00 00 00 00 00 │ ........ } -alloc6 (size: 4, align: 4) { +alloc7 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc8 (fn: main) +alloc9 (fn: main) -alloc9 (size: 100, align: 1) { +alloc10 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir index 27492a7fd..ca53b28be 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir @@ -21,12 +21,12 @@ fn main() -> () { } alloc1 (static: FOO, size: 8, align: 8) { - ╾───────alloc11───────╼ │ ╾──────╼ + ╾───────alloc12───────╼ │ ╾──────╼ } -alloc11 (size: 180, align: 1) { +alloc12 (size: 180, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──alloc6── │ ............╾─── + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──alloc7── │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -34,18 +34,18 @@ alloc11 (size: 180, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ╾──── │ ..............╾─ - 0x90 │ ─────alloc8─────╼ 00 00 ╾─────alloc9+0x63─────╼ │ ─────╼..╾──────╼ + 0x90 │ ─────alloc9─────╼ 00 00 ╾────alloc10+0x63─────╼ │ ─────╼..╾──────╼ 0xa0 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0xb0 │ 00 00 00 00 │ .... } -alloc6 (size: 4, align: 4) { +alloc7 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc8 (fn: main) +alloc9 (fn: main) -alloc9 (size: 100, align: 1) { +alloc10 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 19daae865..41657b53f 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -7,10 +7,10 @@ promoted[0] in FOO: &[&i32; 1] = { let mut _3: *const i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 bb0: { - _3 = const {alloc2: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 + _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 // mir::Constant // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 - // + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) } + // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } _2 = &(*_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 _1 = [move _2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 _0 = &_1; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 @@ -18,4 +18,4 @@ promoted[0] in FOO: &[&i32; 1] = { } } -alloc2 (extern static: X) +alloc3 (extern static: X) diff --git a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index 5b13d6005..25ba0face 100644 --- a/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -18,11 +18,11 @@ - StorageLive(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 - StorageLive(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45 - StorageLive(_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 -- _5 = const {alloc2: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 +- _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 + _6 = const _; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 // mir::Constant - // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 -- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) } +- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } - _4 = &(*_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 - _3 = [move _4]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 - _2 = &_3; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 @@ -50,5 +50,5 @@ } } - -- alloc2 (extern static: X) +- alloc3 (extern static: X) diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff new file mode 100644 index 000000000..d50b12044 --- /dev/null +++ b/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff @@ -0,0 +1,46 @@ +- // MIR for `fn0` before ConstProp ++ // MIR for `fn0` after ConstProp + + fn fn0() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/address_of_pair.rs:+0:17: +0:21 + let mut _1: !; // in scope 0 at $DIR/address_of_pair.rs:+0:22: +9:2 + let mut _2: (i32, bool); // in scope 0 at $DIR/address_of_pair.rs:+1:9: +1:17 + let _4: (); // in scope 0 at $DIR/address_of_pair.rs:+4:5: +6:6 + let mut _6: bool; // in scope 0 at $DIR/address_of_pair.rs:+7:16: +7:22 + scope 1 { + debug pair => _2; // in scope 1 at $DIR/address_of_pair.rs:+1:9: +1:17 + let _3: *mut bool; // in scope 1 at $DIR/address_of_pair.rs:+2:9: +2:12 + scope 2 { + debug ptr => _3; // in scope 2 at $DIR/address_of_pair.rs:+2:9: +2:12 + let _5: bool; // in scope 2 at $DIR/address_of_pair.rs:+7:9: +7:12 + scope 3 { + } + scope 4 { + debug ret => _5; // in scope 4 at $DIR/address_of_pair.rs:+7:9: +7:12 + } + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/address_of_pair.rs:+1:9: +1:17 + _2 = (const 1_i32, const false); // scope 0 at $DIR/address_of_pair.rs:+1:20: +1:30 + StorageLive(_3); // scope 1 at $DIR/address_of_pair.rs:+2:9: +2:12 + _3 = &raw mut (_2.1: bool); // scope 1 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + _2 = (const 1_i32, const false); // scope 2 at $DIR/address_of_pair.rs:+3:5: +3:22 + StorageLive(_4); // scope 2 at $DIR/address_of_pair.rs:+4:5: +6:6 + (*_3) = const true; // scope 3 at $DIR/address_of_pair.rs:+5:9: +5:20 + _4 = const (); // scope 3 at $DIR/address_of_pair.rs:+4:5: +6:6 + StorageDead(_4); // scope 2 at $DIR/address_of_pair.rs:+6:5: +6:6 + StorageLive(_5); // scope 2 at $DIR/address_of_pair.rs:+7:9: +7:12 + StorageLive(_6); // scope 2 at $DIR/address_of_pair.rs:+7:16: +7:22 + _6 = (_2.1: bool); // scope 2 at $DIR/address_of_pair.rs:+7:16: +7:22 + _5 = Not(move _6); // scope 2 at $DIR/address_of_pair.rs:+7:15: +7:22 + StorageDead(_6); // scope 2 at $DIR/address_of_pair.rs:+7:21: +7:22 + _0 = _5; // scope 4 at $DIR/address_of_pair.rs:+8:12: +8:15 + StorageDead(_5); // scope 2 at $DIR/address_of_pair.rs:+9:1: +9:2 + StorageDead(_3); // scope 1 at $DIR/address_of_pair.rs:+9:1: +9:2 + StorageDead(_2); // scope 0 at $DIR/address_of_pair.rs:+9:1: +9:2 + return; // scope 0 at $DIR/address_of_pair.rs:+9:2: +9:2 + } + } + diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs new file mode 100644 index 000000000..43dc9bae6 --- /dev/null +++ b/tests/mir-opt/const_prop/address_of_pair.rs @@ -0,0 +1,17 @@ +// unit-test: ConstProp + +// EMIT_MIR address_of_pair.fn0.ConstProp.diff +pub fn fn0() -> bool { + let mut pair = (1, false); + let ptr = core::ptr::addr_of_mut!(pair.1); + pair = (1, false); + unsafe { + *ptr = true; + } + let ret = !pair.1; + return ret; +} + +pub fn main() { + println!("{}", fn0()); +} diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff index bedfa5992..85d6b5e3d 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff @@ -18,29 +18,35 @@ } bb0: { + StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10 _1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14 StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 -- _4 = Eq(_1, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 +- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 +- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ _3 = const 0_i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 + _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb1: { -- _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb2: { -- _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 + _0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +3:2 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 + StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index a1078472c..93d558250 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default // EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff index e711babf0..d72675c2d 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff @@ -6,16 +6,17 @@ let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 + let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 scope 1 { debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 scope 2 { - let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 scope 3 { - debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 } } } @@ -23,27 +24,32 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 + StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { - _4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 +- _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _5 = (*_1)[3 of 4]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 + _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 + StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff index e711babf0..d72675c2d 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff @@ -6,16 +6,17 @@ let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35 + let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 scope 1 { debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 scope 2 { - let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 scope 3 { - debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 } } } @@ -23,27 +24,32 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant - // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35 + // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 - StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 + StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 + StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 + _7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { - _4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 - StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 +- _5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _5 = (*_1)[3 of 4]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26 + _0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6 + StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6 StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2 return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2 } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index 3d252f2d2..ef148d16d 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,4 +1,7 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default +// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen + // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff #[allow(unconditional_panic)] diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 85dedf68c..1752d222f 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -7,13 +7,17 @@ let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63 let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59 let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55 + let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73 + let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65 scope 1 { debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22 let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 scope 3 { debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21 + let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 scope 5 { debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31 + let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 scope 7 { debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22 } @@ -39,17 +43,25 @@ StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 -- _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 + // mir::Constant + // + span: no-location + // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } -+ _3 = [const Scalar(0x00000004): E]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) } + _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 + nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 + nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 + StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 + _8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 + nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 + nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 + nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 + StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 + nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 + nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 + nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index eb6172cdf..bdbc5a199 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -1,3 +1,5 @@ +// unit-test: ConstProp +// compile-flags: -Zmir-enable-passes=+RemoveZsts // Verify that we can pretty print invalid constants. #![feature(adt_const_params)] diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff index 5331e5b82..33bbad2f4 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff @@ -18,17 +18,20 @@ _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 +- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 } bb1: { - _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 +- _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ _1 = _2[2 of 3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 + _0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff index 5331e5b82..33bbad2f4 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff @@ -18,17 +18,20 @@ _2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29 StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 _3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31 - _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 +- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 + _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 } bb1: { - _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 +- _1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 ++ _1 = _2[2 of 3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32 StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33 + _0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2 StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2 return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index 073f98495..0876445bf 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,4 +1,6 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default +// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR large_array_index.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index c839f92f2..7bd30975a 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O -Zmir-opt-level=4 +// unit-test: ConstProp // EMIT_MIR mult_by_zero.test.ConstProp.diff fn test(x : i32) -> i32 { diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff index 1cfe47d0a..629c8e601 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff @@ -7,8 +7,11 @@ let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 bb0: { -- _0 = Mul(_1, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 + _2 = _1; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 +- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:7: +1:8 return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff index a672c457a..bd010e7b1 100644 --- a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff @@ -19,6 +19,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 - _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _0 = const (); // scope 0 at $DIR/mutable_variable.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index cb01719dd..95987ef7f 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index d088c4f66..539f6dd94 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -3,27 +3,26 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11 - let mut _3: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let mut _4: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 scope 1 { - debug x => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let _1: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 - let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 scope 2 { - debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 } } bb0: { - StorageLive(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - _3 = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - _4 = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - _4 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 + StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 +- _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 ++ _1 = const (42_i32, 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 + (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 -- _2 = _4; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 -+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 +- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 ++ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 - StorageDead(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 + StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index d4ff8d890..a145c0354 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index 134f0c080..bec641ecf 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -9,10 +9,9 @@ let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 scope 2 { debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 - let _3: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - let _4: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 scope 3 { - debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 } } } @@ -24,11 +23,9 @@ _2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19 ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - _3 = (_1.0: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 - _4 = (_1.1: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +5:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2 diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index 9060f7e9b..3099e659f 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff index 75f6ebc58..374151057 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff @@ -16,7 +16,7 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34 // mir::Constant - // + span: $DIR/mutable_variable_aggregate_partial_read.rs:7:29: 7:32 + // + span: $DIR/mutable_variable_aggregate_partial_read.rs:6:29: 6:32 // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } } @@ -26,6 +26,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 - _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2 diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 70a287cf3..0e823e9dc 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,6 +1,5 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index 7fa29cccd..fab810630 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -4,34 +4,39 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11 let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let mut _2: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - let mut _3: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let _2: (); // in scope 0 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 + let mut _3: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let mut _4: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 scope 1 { debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _4: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + let _5: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 scope 2 { } scope 3 { - debug y => _4; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + debug y => _5; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 } } bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 _1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19 - StorageLive(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _3 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 // mir::Constant - // + span: $DIR/mutable_variable_no_prop.rs:10:13: 10:19 + // + span: $DIR/mutable_variable_no_prop.rs:9:13: 9:19 // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) } - _2 = (*_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _1 = move _2; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 - StorageDead(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 - StorageLive(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 - _4 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 - StorageDead(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 + _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 + StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 + _2 = const (); // scope 2 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 + StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+4:5: +4:6 + StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + _5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +6:2 + StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index b69ec931a..e51c62235 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp static mut STATIC: u32 = 0x42424242; diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 9582504b2..3048122d8 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -4,17 +4,16 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 scope 1 { debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _5: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 scope 2 { - debug x => (i32, i32){ .0 => _5, .1 => _6, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let _3: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 scope 3 { - debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 + debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 scope 4 { debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 } @@ -26,22 +25,27 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18 // mir::Constant - // + span: $DIR/mutable_variable_unprop_assign.rs:7:13: 7:16 + // + span: $DIR/mutable_variable_unprop_assign.rs:6:13: 6:16 // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } } bb1: { - StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - _5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - _6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _2 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _6 = move _2; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 - StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - _3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 +- _2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 ++ _2 = const (1_i32, 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + (_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 + StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 +- _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 ++ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 + _0 = const (); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2 + StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index fabd04e9b..5577f78a9 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,6 +1,5 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff new file mode 100644 index 000000000..e3757941c --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff @@ -0,0 +1,44 @@ +- // MIR for `concrete` before ConstProp ++ // MIR for `concrete` after ConstProp + + fn concrete() -> () { + let mut _0: (); // return place in scope 0 at $DIR/offset_of.rs:+0:15: +0:15 + let _1: usize; // in scope 0 at $DIR/offset_of.rs:+1:9: +1:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/offset_of.rs:+1:9: +1:10 + let _2: usize; // in scope 1 at $DIR/offset_of.rs:+2:9: +2:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/offset_of.rs:+2:9: +2:10 + let _3: usize; // in scope 2 at $DIR/offset_of.rs:+3:9: +3:11 + scope 3 { + debug z0 => _3; // in scope 3 at $DIR/offset_of.rs:+3:9: +3:11 + let _4: usize; // in scope 3 at $DIR/offset_of.rs:+4:9: +4:11 + scope 4 { + debug z1 => _4; // in scope 4 at $DIR/offset_of.rs:+4:9: +4:11 + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:10 +- _1 = OffsetOf(Alpha, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL ++ _1 = const 4_usize; // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:10 +- _2 = OffsetOf(Alpha, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL ++ _2 = const 0_usize; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11 +- _3 = OffsetOf(Alpha, [2, 0]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL ++ _3 = const 2_usize; // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 +- _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL ++ _4 = const 3_usize; // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2 + StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/offset_of.rs:+5:1: +5:2 + return; // scope 0 at $DIR/offset_of.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff new file mode 100644 index 000000000..4a655604c --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff @@ -0,0 +1,40 @@ +- // MIR for `generic` before ConstProp ++ // MIR for `generic` after ConstProp + + fn generic() -> () { + let mut _0: (); // return place in scope 0 at $DIR/offset_of.rs:+0:17: +0:17 + let _1: usize; // in scope 0 at $DIR/offset_of.rs:+1:9: +1:11 + scope 1 { + debug gx => _1; // in scope 1 at $DIR/offset_of.rs:+1:9: +1:11 + let _2: usize; // in scope 1 at $DIR/offset_of.rs:+2:9: +2:11 + scope 2 { + debug gy => _2; // in scope 2 at $DIR/offset_of.rs:+2:9: +2:11 + let _3: usize; // in scope 2 at $DIR/offset_of.rs:+3:9: +3:11 + scope 3 { + debug dx => _3; // in scope 3 at $DIR/offset_of.rs:+3:9: +3:11 + let _4: usize; // in scope 3 at $DIR/offset_of.rs:+4:9: +4:11 + scope 4 { + debug dy => _4; // in scope 4 at $DIR/offset_of.rs:+4:9: +4:11 + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/offset_of.rs:+1:9: +1:11 + _1 = OffsetOf(Gamma<T>, [0]); // scope 0 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_2); // scope 1 at $DIR/offset_of.rs:+2:9: +2:11 + _2 = OffsetOf(Gamma<T>, [1]); // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_3); // scope 2 at $DIR/offset_of.rs:+3:9: +3:11 + _3 = OffsetOf(Delta<T>, [1]); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 + _4 = OffsetOf(Delta<T>, [2]); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2 + StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/offset_of.rs:+5:1: +5:2 + return; // scope 0 at $DIR/offset_of.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs new file mode 100644 index 000000000..4cdcd28ee --- /dev/null +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -0,0 +1,48 @@ +// unit-test: ConstProp + +#![feature(offset_of)] + +use std::marker::PhantomData; +use std::mem::offset_of; + +struct Alpha { + x: u8, + y: u16, + z: Beta, +} + +struct Beta(u8, u8); + +struct Gamma<T> { + x: u8, + y: u16, + _t: T, +} + +#[repr(C)] +struct Delta<T> { + _phantom: PhantomData<T>, + x: u8, + y: u16, +} + +// EMIT_MIR offset_of.concrete.ConstProp.diff +fn concrete() { + let x = offset_of!(Alpha, x); + let y = offset_of!(Alpha, y); + let z0 = offset_of!(Alpha, z.0); + let z1 = offset_of!(Alpha, z.1); +} + +// EMIT_MIR offset_of.generic.ConstProp.diff +fn generic<T>() { + let gx = offset_of!(Gamma<T>, x); + let gy = offset_of!(Gamma<T>, y); + let dx = offset_of!(Delta<T>, x); + let dy = offset_of!(Delta<T>, y); +} + +fn main() { + concrete(); + generic::<()>(); +} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir deleted file mode 100644 index 81cfd22db..000000000 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir +++ /dev/null @@ -1,25 +0,0 @@ -// MIR for `main` after PreCodegen - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - scope 1 { - debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 3 { - debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir deleted file mode 100644 index 81cfd22db..000000000 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir +++ /dev/null @@ -1,25 +0,0 @@ -// MIR for `main` after PreCodegen - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - scope 1 { - debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 3 { - debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir deleted file mode 100644 index 002e914e8..000000000 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir +++ /dev/null @@ -1,25 +0,0 @@ -// MIR for `main` after SimplifyLocals-final - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - scope 1 { - debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 3 { - debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir deleted file mode 100644 index 002e914e8..000000000 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir +++ /dev/null @@ -1,25 +0,0 @@ -// MIR for `main` after SimplifyLocals-final - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - scope 1 { - debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 2 { - debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - scope 3 { - debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 - StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 - return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 - } -} diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index 388c6ca81..c290fba56 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -18,7 +18,7 @@ StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 _3 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 // mir::Constant - // + span: $DIR/read_immutable_static.rs:8:13: 8:16 + // + span: $DIR/read_immutable_static.rs:7:13: 7:16 // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } - _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 + _2 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 @@ -26,7 +26,7 @@ StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 _5 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 // mir::Constant - // + span: $DIR/read_immutable_static.rs:8:19: 8:22 + // + span: $DIR/read_immutable_static.rs:7:19: 7:22 // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } - _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22 @@ -36,6 +36,7 @@ StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 + _0 = const (); // scope 0 at $DIR/read_immutable_static.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2 return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 4f7afe6ca..fb8f9fe99 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp static FOO: u8 = 2; diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff index 15c93f270..077b9bf83 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff @@ -3,21 +3,26 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11 - let mut _1: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - let mut _2: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 + let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 scope 1 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 - _2 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 + StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 + _3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17 // mir::Constant - // + span: $DIR/reify_fn_ptr.rs:4:13: 4:17 + // + span: $DIR/reify_fn_ptr.rs:5:13: 5:17 // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } - _1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 - StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 - StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 + _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26 + StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26 + _1 = move _2 as *const fn() (PointerFromExposedAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41 + StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41 + StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:41: +1:42 + _0 = const (); // scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +2:2 return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs index bfe2563ad..5f6382066 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.rs +++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // EMIT_MIR reify_fn_ptr.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff index 636032adb..6641220db 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff @@ -20,11 +20,12 @@ _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 - _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 +- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 ++ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 } bb1: { @@ -35,6 +36,7 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 + _0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff index 636032adb..6641220db 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff @@ -20,11 +20,12 @@ _3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25 StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27 _4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27 - _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 +- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28 - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 ++ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 + _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28 } bb1: { @@ -35,6 +36,7 @@ StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32 StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33 + _0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2 return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 2f3b7d2c5..9c11dbc5b 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,7 +1,8 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default -// compile-flags: -O - +// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen // EMIT_MIR_FOR_EACH_BIT_WIDTH + // EMIT_MIR repeat.main.ConstProp.diff fn main() { let x: u32 = [42; 8][2] + 0; diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir index ececd9942..b12d84fa4 100644 --- a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir @@ -2,8 +2,14 @@ fn add() -> u32 { let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16 + let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:+1:5: +1:10 bb0: { + _1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:+1:5: +1:10 + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 + } + + bb1: { _0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10 return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index ae119df85..0e68309f0 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default // compile-flags: -C overflow-checks=on diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index a091b4ace..c2f97a0f6 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -11,15 +11,23 @@ } bb0: { + StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 -- _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 -+ _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 + StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 + StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 +- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 ++ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 + _2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/scalar_literal_propagation.rs:5:5: 5:12 + // + span: $DIR/scalar_literal_propagation.rs:6:5: 6:12 // + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) } } bb1: { + StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15 + StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 + _0 = const (); // scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +3:2 + StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index e13e352f8..fc33cc2d0 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default // EMIT_MIR scalar_literal_propagation.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 4499c54f2..9821d1b1e 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,6 +1,6 @@ // ignore-wasm32 compiled with panic=abort by default // unit-test: ConstProp -// compile-flags: -Zmir-enable-passes=+InstCombine +// compile-flags: -Zmir-enable-passes=+InstSimplify // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR slice_len.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff index 85704c48a..664b7839f 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.diff @@ -15,14 +15,14 @@ bb1: { _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 // mir::Constant - // + span: $DIR/switch_int.rs:10:14: 10:17 + // + span: $DIR/switch_int.rs:12:14: 12:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } bb2: { _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 // mir::Constant - // + span: $DIR/switch_int.rs:9:14: 9:17 + // + span: $DIR/switch_int.rs:11:14: 11:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff index 0864db225..ef2c4d5fa 100644 --- a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff +++ b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff @@ -15,14 +15,14 @@ bb1: { _0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21 // mir::Constant - // + span: $DIR/switch_int.rs:10:14: 10:17 + // + span: $DIR/switch_int.rs:12:14: 12:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } bb2: { _0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20 // mir::Constant - // + span: $DIR/switch_int.rs:9:14: 9:17 + // + span: $DIR/switch_int.rs:11:14: 11:17 // + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) } } diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index 2a2322e43..7158ea4d2 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,3 +1,5 @@ +// unit-test: ConstProp +// compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop // ignore-wasm32 compiled with panic=abort by default #[inline(never)] fn foo(_: i32) { } diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff index 933dfbb51..933dfbb51 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff new file mode 100644 index 000000000..933dfbb51 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff @@ -0,0 +1,15 @@ +- // MIR for `from_char` before ConstProp ++ // MIR for `from_char` after ConstProp + + fn from_char() -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/transmute.rs:+0:23: +0:26 + scope 1 { + } + + bb0: { +- _0 = const 'R' as i32 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:28 ++ _0 = const 82_i32; // scope 1 at $DIR/transmute.rs:+1:14: +1:28 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff index f3474855f..4a31194de 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff @@ -7,7 +7,8 @@ } bb0: { - _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 +- _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 ++ _0 = const {transmute(0xff): bool}; // scope 1 at $DIR/transmute.rs:+1:14: +1:30 return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff new file mode 100644 index 000000000..4a31194de --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff @@ -0,0 +1,15 @@ +- // MIR for `invalid_bool` before ConstProp ++ // MIR for `invalid_bool` after ConstProp + + fn invalid_bool() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + scope 1 { + } + + bb0: { +- _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30 ++ _0 = const {transmute(0xff): bool}; // scope 1 at $DIR/transmute.rs:+1:14: +1:30 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff index ba087e226..2c541f2f6 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff @@ -7,7 +7,8 @@ } bb0: { - _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 +- _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 ++ _0 = const {transmute(0x7fffffff): char}; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff new file mode 100644 index 000000000..2c541f2f6 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff @@ -0,0 +1,15 @@ +- // MIR for `invalid_char` before ConstProp ++ // MIR for `invalid_char` after ConstProp + + fn invalid_char() -> char { + let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37 + scope 1 { + } + + bb0: { +- _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 ++ _0 = const {transmute(0x7fffffff): char}; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff index 76d464789..76d464789 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff new file mode 100644 index 000000000..76d464789 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff @@ -0,0 +1,23 @@ +- // MIR for `less_as_i8` before ConstProp ++ // MIR for `less_as_i8` after ConstProp + + fn less_as_i8() -> i8 { + let mut _0: i8; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:26 + let mut _1: std::cmp::Ordering; // in scope 0 at $DIR/transmute.rs:+1:24: +1:48 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/transmute.rs:+1:24: +1:48 +- _1 = Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 +- _0 = move _1 as i8 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:49 ++ _1 = const Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0xff)) } ++ _0 = const -1_i8; // scope 1 at $DIR/transmute.rs:+1:14: +1:49 + StorageDead(_1); // scope 1 at $DIR/transmute.rs:+1:48: +1:49 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs index b753cdccd..762c42171 100644 --- a/tests/mir-opt/const_prop/transmute.rs +++ b/tests/mir-opt/const_prop/transmute.rs @@ -1,5 +1,7 @@ // unit-test: ConstProp // compile-flags: -O --crate-type=lib +// ignore-endian-big +// EMIT_MIR_FOR_EACH_BIT_WIDTH use std::mem::transmute; diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff index 538b1f26e..538b1f26e 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff new file mode 100644 index 000000000..538b1f26e --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff @@ -0,0 +1,22 @@ +- // MIR for `undef_union_as_integer` before ConstProp ++ // MIR for `undef_union_as_integer` after ConstProp + + fn undef_union_as_integer() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/transmute.rs:+0:43: +0:46 + let mut _1: undef_union_as_integer::Union32; // in scope 0 at $DIR/transmute.rs:+2:24: +2:44 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+2:40: +2:42 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/transmute.rs:+2:24: +2:44 + StorageLive(_2); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 + _2 = (); // scope 1 at $DIR/transmute.rs:+2:40: +2:42 + _1 = Union32 { value: move _2 }; // scope 1 at $DIR/transmute.rs:+2:24: +2:44 + StorageDead(_2); // scope 1 at $DIR/transmute.rs:+2:43: +2:44 + _0 = move _1 as u32 (Transmute); // scope 1 at $DIR/transmute.rs:+2:14: +2:45 + StorageDead(_1); // scope 1 at $DIR/transmute.rs:+2:44: +2:45 + return; // scope 0 at $DIR/transmute.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff new file mode 100644 index 000000000..5258d75bd --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_box` before ConstProp ++ // MIR for `unreachable_box` after ConstProp + + fn unreachable_box() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let _1: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: Box<Never>, val: Value(Scalar(0x00000001)) } + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff new file mode 100644 index 000000000..7e57e06a5 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_box` before ConstProp ++ // MIR for `unreachable_box` after ConstProp + + fn unreachable_box() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let _1: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: Box<Never>, val: Value(Scalar(0x0000000000000001)) } + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff deleted file mode 100644 index 8bf97996a..000000000 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.diff +++ /dev/null @@ -1,23 +0,0 @@ -- // MIR for `unreachable_box` before ConstProp -+ // MIR for `unreachable_box` after ConstProp - - fn unreachable_box() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 - scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 - } - scope 2 { - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 - unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 - } - } - diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff new file mode 100644 index 000000000..032681f23 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff @@ -0,0 +1,22 @@ +- // MIR for `unreachable_direct` before ConstProp ++ // MIR for `unreachable_direct` after ConstProp + + fn unreachable_direct() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 + let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff new file mode 100644 index 000000000..032681f23 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff @@ -0,0 +1,22 @@ +- // MIR for `unreachable_direct` before ConstProp ++ // MIR for `unreachable_direct` after ConstProp + + fn unreachable_direct() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 + let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff deleted file mode 100644 index 81b7b3689..000000000 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.diff +++ /dev/null @@ -1,25 +0,0 @@ -- // MIR for `unreachable_direct` before ConstProp -+ // MIR for `unreachable_direct` after ConstProp - - fn unreachable_direct() -> ! { - let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2 - let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15 - scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 - } - scope 2 { - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 - unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 - } - } - diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff index 34f7aea8e..ec8a62bd6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff @@ -3,24 +3,24 @@ fn unreachable_mut() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 - _2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 - StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 +- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: &mut Never, val: Value(Scalar(0x00000001)) } + _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff new file mode 100644 index 000000000..288da6e56 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff @@ -0,0 +1,27 @@ +- // MIR for `unreachable_mut` before ConstProp ++ // MIR for `unreachable_mut` after ConstProp + + fn unreachable_mut() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 +- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: &mut Never, val: Value(Scalar(0x0000000000000001)) } + _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff index ff95f2a0b..dcca0fca6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff @@ -3,20 +3,20 @@ fn unreachable_ref() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: &Never, val: Value(Scalar(0x00000001)) } unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff new file mode 100644 index 000000000..3a0b967e6 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff @@ -0,0 +1,23 @@ +- // MIR for `unreachable_ref` before ConstProp ++ // MIR for `unreachable_ref` after ConstProp + + fn unreachable_ref() -> ! { + let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 + let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: &Never, val: Value(Scalar(0x0000000000000001)) } + unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 + } + } + diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff index eac33b730..eac33b730 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff new file mode 100644 index 000000000..eac33b730 --- /dev/null +++ b/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff @@ -0,0 +1,15 @@ +- // MIR for `valid_char` before ConstProp ++ // MIR for `valid_char` after ConstProp + + fn valid_char() -> char { + let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:28 + scope 1 { + } + + bb0: { +- _0 = const 82_u32 as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33 ++ _0 = const 'R'; // scope 1 at $DIR/transmute.rs:+1:14: +1:33 + return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index 12313b6c5..e4a7c0d1e 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -11,15 +11,24 @@ } bb0: { + StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10 - _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 + _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - _2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 + StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 + StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 +- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 ++ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 + _2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 // mir::Constant - // + span: $DIR/tuple_literal_propagation.rs:6:5: 6:12 + // + span: $DIR/tuple_literal_propagation.rs:7:5: 7:12 // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) } } bb1: { + StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15 + StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 + _0 = const (); // scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +4:2 + StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index edd748d00..f342ae270 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp // ignore-wasm32 compiled with panic=abort by default // EMIT_MIR tuple_literal_propagation.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff index a4f2d8c84..377324218 100644 --- a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff @@ -4,8 +4,13 @@ fn change_loop_body() -> () { let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27 let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 - let mut _3: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 + let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:+0:1: +6:2 + let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32 + let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25 + let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:+2:33: +5:6 + let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 + let _7: (); // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 + let mut _8: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6 scope 1 { debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15 scope 2 { @@ -15,29 +20,33 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 _1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19 - StorageLive(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - _2 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 -- _3 = discriminant(_2); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -- switchInt(move _3) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 -+ _3 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + StorageLive(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 + _3 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 +- _4 = discriminant(_3); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 +- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 ++ _4 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 } bb1: { - switchInt(((_2 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 } bb2: { _1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15 + _0 = const (); // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 } bb3: { + StorageLive(_7); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 + _0 = const (); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6 + StorageDead(_7); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 goto -> bb4; // scope 1 at no-location } bb4: { - StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 + StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs index fc56cd698..595a94b88 100644 --- a/tests/mir-opt/while_let_loops.rs +++ b/tests/mir-opt/const_prop/while_let_loops.rs @@ -1,5 +1,5 @@ +// unit-test: ConstProp // EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff -// EMIT_MIR while_let_loops.change_loop_body.PreCodegen.after.mir pub fn change_loop_body() { let mut _x = 0; diff --git a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff index def9fc642..a5f52d089 100644 --- a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff +++ b/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff @@ -19,8 +19,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 -- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 -+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 + _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 StorageLive(_3); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 _3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 diff --git a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff b/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff index b54c10a14..42ddc2a56 100644 --- a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff +++ b/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff @@ -16,8 +16,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 -- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 -+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 + _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+2:6: +2:14 _2 = &mut (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+2:6: +2:14 (*_2) = const 5_i32; // scope 1 at $DIR/const_prop_miscompile.rs:+2:5: +2:18 diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff index 2a0bff57d..51707e716 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff @@ -20,8 +20,7 @@ } bb1: { -- _0 = opaque::<u8>(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 -+ _0 = opaque::<u8>(_1) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 + _0 = opaque::<u8>(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 // mir::Constant // + span: $DIR/borrowed_local.rs:28:28: 28:34 // + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff index 69acebf76..1c7b6494d 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff @@ -6,15 +6,17 @@ let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:27: +0:30 let _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 scope 1 { - debug y => _2; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 +- debug y => _2; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 ++ debug y => _0; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 } bb0: { - StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 - _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 +- StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 +- _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 ++ _0 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 _1 = const 123_i32; // scope 1 at $DIR/copy_propagation_arg.rs:+2:5: +2:12 - _0 = _2; // scope 1 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 - StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+4:1: +4:2 +- _0 = _2; // scope 1 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 +- StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+4:1: +4:2 return; // scope 0 at $DIR/copy_propagation_arg.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff b/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff new file mode 100644 index 000000000..586643905 --- /dev/null +++ b/tests/mir-opt/copy-prop/partial_init.main.CopyProp.diff @@ -0,0 +1,13 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/partial_init.rs:+0:15: +0:15 + let mut _1: (isize,); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + (_1.0: isize) = const 1_isize; // scope 0 at $DIR/partial_init.rs:+4:13: +4:20 + return; // scope 0 at $DIR/partial_init.rs:+5:13: +5:21 + } + } + diff --git a/tests/mir-opt/copy-prop/partial_init.rs b/tests/mir-opt/copy-prop/partial_init.rs new file mode 100644 index 000000000..f5ab9974f --- /dev/null +++ b/tests/mir-opt/copy-prop/partial_init.rs @@ -0,0 +1,18 @@ +// unit-test: CopyProp +// Verify that we do not ICE on partial initializations. + +#![feature(custom_mir, core_intrinsics)] +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR partial_init.main.CopyProp.diff +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +pub fn main() { + mir! ( + let x: (isize, ); + { + x.0 = 1; + Return() + } + ) +} diff --git a/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.diff new file mode 100644 index 000000000..761c074ed --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.diff @@ -0,0 +1,25 @@ +- // MIR for `main` before DeadStoreElimination ++ // MIR for `main` after DeadStoreElimination + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/place_mention.rs:+0:11: +0:11 + let mut _1: (&str, &str); // in scope 0 at $DIR/place_mention.rs:+3:18: +3:36 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 + _1 = (const "Hello", const "World"); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 + // mir::Constant + // + span: $DIR/place_mention.rs:8:19: 8:26 + // + literal: Const { ty: &str, val: Value(Slice(..)) } + // mir::Constant + // + span: $DIR/place_mention.rs:8:28: 8:35 + // + literal: Const { ty: &str, val: Value(Slice(..)) } + PlaceMention(_1); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 + StorageDead(_1); // scope 0 at $DIR/place_mention.rs:+3:36: +3:37 + _0 = const (); // scope 0 at $DIR/place_mention.rs:+0:11: +4:2 + return; // scope 0 at $DIR/place_mention.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/dead-store-elimination/place_mention.rs b/tests/mir-opt/dead-store-elimination/place_mention.rs new file mode 100644 index 000000000..59dc74454 --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/place_mention.rs @@ -0,0 +1,9 @@ +// unit-test: DeadStoreElimination +// compile-flags: -Zmir-keep-place-mention + +// EMIT_MIR place_mention.main.DeadStoreElimination.diff +fn main() { + // Verify that we account for the `PlaceMention` statement as a use of the tuple, + // and don't remove it as a dead store. + let (_, _) = ("Hello", "World"); +} diff --git a/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff b/tests/mir-opt/dont_yeet_assert.generic.InstSimplify.diff index c0fc1fb1d..cadf05152 100644 --- a/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff +++ b/tests/mir-opt/dont_yeet_assert.generic.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before InstCombine -+ // MIR for `generic` after InstCombine +- // MIR for `generic` before InstSimplify ++ // MIR for `generic` after InstSimplify fn generic() -> () { let mut _0: (); // return place in scope 0 at $DIR/dont_yeet_assert.rs:+0:21: +0:21 diff --git a/tests/mir-opt/dont_yeet_assert.rs b/tests/mir-opt/dont_yeet_assert.rs index 7cec761ea..38cc5a293 100644 --- a/tests/mir-opt/dont_yeet_assert.rs +++ b/tests/mir-opt/dont_yeet_assert.rs @@ -1,11 +1,11 @@ // compile-flags: --crate-type=lib -// unit-test: InstCombine +// unit-test: InstSimplify #![feature(core_intrinsics)] // Want to make sure this assertion isn't compiled away in generic code. -// EMIT_MIR dont_yeet_assert.generic.InstCombine.diff +// EMIT_MIR dont_yeet_assert.generic.InstSimplify.diff pub fn generic<T>() { core::intrinsics::assert_mem_uninitialized_valid::<&T>(); } diff --git a/tests/mir-opt/equal_true.opt.InstCombine.diff b/tests/mir-opt/equal_true.opt.InstSimplify.diff index 8b542a7c1..4ef413200 100644 --- a/tests/mir-opt/equal_true.opt.InstCombine.diff +++ b/tests/mir-opt/equal_true.opt.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt` before InstCombine -+ // MIR for `opt` after InstCombine +- // MIR for `opt` before InstSimplify ++ // MIR for `opt` after InstSimplify fn opt(_1: bool) -> i32 { debug x => _1; // in scope 0 at $DIR/equal_true.rs:+0:8: +0:9 diff --git a/tests/mir-opt/equal_true.rs b/tests/mir-opt/equal_true.rs index 717d10c6d..fbb5d8d37 100644 --- a/tests/mir-opt/equal_true.rs +++ b/tests/mir-opt/equal_true.rs @@ -1,6 +1,6 @@ -// unit-test InstCombine +// unit-test InstSimplify -// EMIT_MIR equal_true.opt.InstCombine.diff +// EMIT_MIR equal_true.opt.InstSimplify.diff fn opt(x: bool) -> i32 { if x == true { 0 } else { 1 } diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.diff index 18df6f9af..3aebfb69e 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.diff @@ -8,7 +8,7 @@ + let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:14:8: 14:21 + let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:12:18: 12:25 + scope 2 { -+ debug buffer => _3; // in scope 2 at $DIR/issue_106141.rs:12:9: 12:15 ++ debug buffer => const _; // in scope 2 at $DIR/issue_106141.rs:12:9: 12:15 + scope 3 { + debug index => _0; // in scope 3 at $DIR/issue_106141.rs:13:9: 13:14 + } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff index 6184a0acd..d76cd0e2b 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -10,50 +10,52 @@ + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ let mut _6: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { -+ scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ } -+ scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _12: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 6 { -+ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ scope 7 { -+ scope 8 { -+ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _8: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _9: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ scope 4 { ++ scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _12: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } + } -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 10 { -+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _14: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 8 { ++ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ } ++ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _15: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ } ++ } + } + } ++ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ } + } + } -+ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL -+ } + } + } + } @@ -67,75 +69,81 @@ - // mir::Constant - // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 - // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) } -+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _11 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { -+ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ -+ bb2: { + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + -+ bb3: { -+ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ bb2: { ++ _9 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } -+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb3: { ++ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _12 = _7 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = Result::<u16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = _4 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _8 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { -+ _6 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { -+ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _14 = move ((_9 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _8 = Option::<u16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ _12 = move ((_7 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ _6 = Option::<u16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _5 = move ((_8 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir index 726b6bbf9..3c175ed15 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -7,122 +7,130 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _4: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _5: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { - scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _8: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - } - scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - scope 6 { - debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - } - scope 7 { - scope 8 { - debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _10: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } } - } - } - scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _11: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - scope 10 { - debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _12: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { + debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } } } + scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } } } - scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL - } } } } bb0: { - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _9 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb2: { StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } - bb3: { - _5 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + bb2: { + _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } - goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb3: { + StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _10 = _5 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb4: { - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = _2 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = Result::<u16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _6 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - _4 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb7: { - unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _12 = move ((_7 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _6 = Option::<u16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb8: { - _10 = move ((_5 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - _4 = Option::<u16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb9: { - _3 = move ((_4 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _3 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff index 35d5b6e72..f3d3e6090 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -10,50 +10,52 @@ + scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ let mut _6: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { -+ scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ } -+ scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _12: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 6 { -+ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ scope 7 { -+ scope 8 { -+ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _8: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _9: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ scope 4 { ++ scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _12: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } + } -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 10 { -+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _14: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 8 { ++ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ } ++ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _15: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ } ++ } + } + } ++ scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ } + } + } -+ scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL -+ } + } + } + } @@ -67,75 +69,81 @@ - // mir::Constant - // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 - // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) } -+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _11 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { -+ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ -+ bb2: { + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + -+ bb3: { -+ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ bb2: { ++ _9 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } -+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb3: { ++ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _12 = _7 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = Result::<i16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = _4 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _8 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { -+ _6 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { -+ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _14 = move ((_9 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _8 = Option::<i16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ _12 = move ((_7 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ _6 = Option::<i16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _5 = move ((_8 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir index b006085b5..724b3c567 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -7,122 +7,130 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _3: i16; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _4: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _5: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _3: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { - scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _8: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - } - scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - scope 6 { - debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - } - scope 7 { - scope 8 { - debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _10: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } } - } - } - scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _11: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - scope 10 { - debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _12: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { + debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } } } + scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } } } - scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL - } } } } bb0: { - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _9 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb2: { StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } - bb3: { - _5 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + bb2: { + _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } - goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb3: { + StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _10 = _5 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb4: { - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = _2 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = Result::<i16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _6 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - _4 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb7: { - unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _12 = move ((_7 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _6 = Option::<i16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb8: { - _10 = move ((_5 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - _4 = Option::<i16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb9: { - _3 = move ((_4 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _3 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff new file mode 100644 index 000000000..745f2bb19 --- /dev/null +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -0,0 +1,50 @@ +- // MIR for `caller` before Inline ++ // MIR for `caller` after Inline + + fn caller(_1: Box<[i32]>) -> () { + debug x => _1; // in scope 0 at $DIR/unsized_argument.rs:+0:11: +0:12 + let mut _0: (); // return place in scope 0 at $DIR/unsized_argument.rs:+0:26: +0:26 + let _2: (); // in scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 + let mut _3: std::boxed::Box<[i32]>; // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 + let mut _4: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + let mut _5: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + let mut _6: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + let mut _7: *const [i32]; // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 + StorageLive(_3); // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 + _3 = move _1; // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 + _7 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 + _2 = callee(move (*_7)) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 + // mir::Constant + // + span: $DIR/unsized_argument.rs:9:5: 9:11 + // + literal: Const { ty: fn([i32]) {callee}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + StorageDead(_2); // scope 0 at $DIR/unsized_argument.rs:+1:15: +1:16 + _0 = const (); // scope 0 at $DIR/unsized_argument.rs:+0:26: +2:2 + return; // scope 0 at $DIR/unsized_argument.rs:+2:2: +2:2 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/unsized_argument.rs:+0:1: +2:2 + } + + bb3: { + _4 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> bb1; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + // mir::Constant + // + span: $DIR/unsized_argument.rs:9:14: 9:15 + // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) } + } + + bb4 (cleanup): { + _6 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> [return: bb2, unwind terminate]; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 + // mir::Constant + // + span: $DIR/unsized_argument.rs:9:14: 9:15 + // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) } + } + } + diff --git a/tests/mir-opt/inline/unsized_argument.rs b/tests/mir-opt/inline/unsized_argument.rs new file mode 100644 index 000000000..b2c51407f --- /dev/null +++ b/tests/mir-opt/inline/unsized_argument.rs @@ -0,0 +1,15 @@ +// needs-unwind +#![feature(unsized_fn_params)] + +#[inline(always)] +fn callee(y: [i32]) {} + +// EMIT_MIR unsized_argument.caller.Inline.diff +fn caller(x: Box<[i32]>) { + callee(*x); +} + +fn main() { + let b = Box::new([1]); + caller(b); +} diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff index 543ddcfc4..8a8cd896e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff @@ -34,7 +34,7 @@ - // + literal: Const { ty: unsafe fn(Option<T>) -> T {Option::<T>::unwrap_unchecked}, val: Value(<ZST>) } + StorageLive(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 + _4 = discriminant(_2); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _4) -> [1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL } bb1: { diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff b/tests/mir-opt/instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff index e04079453..04ba8dd8e 100644 --- a/tests/mir-opt/instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff +++ b/tests/mir-opt/instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff @@ -1,21 +1,21 @@ -- // MIR for `assert_zero` before InstCombine -+ // MIR for `assert_zero` after InstCombine +- // MIR for `assert_zero` before InstSimplify ++ // MIR for `assert_zero` after InstSimplify fn assert_zero(_1: u8) -> u8 { - let mut _0: u8; // return place in scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+0:37: +0:39 + let mut _0: u8; // return place in scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+0:37: +0:39 bb0: { -- switchInt(_1) -> [0: bb2, 1: bb1, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 -+ switchInt(_1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+3:13: +7:14 +- switchInt(_1) -> [0: bb2, 1: bb1, otherwise: bb1]; // scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+3:13: +7:14 ++ switchInt(_1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+3:13: +7:14 } bb1: { - unreachable; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+10:13: +10:26 + unreachable; // scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+10:13: +10:26 } bb2: { - _0 = _1; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+13:13: +13:20 - return; // scope 0 at $DIR/instcombine_duplicate_switch_targets.rs:+14:13: +14:21 + _0 = _1; // scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+13:13: +13:20 + return; // scope 0 at $DIR/instsimplify_duplicate_switch_targets.rs:+14:13: +14:21 } } diff --git a/tests/mir-opt/instcombine_duplicate_switch_targets.rs b/tests/mir-opt/instsimplify_duplicate_switch_targets.rs index ef3b487af..3e280a40f 100644 --- a/tests/mir-opt/instcombine_duplicate_switch_targets.rs +++ b/tests/mir-opt/instsimplify_duplicate_switch_targets.rs @@ -3,9 +3,9 @@ use std::intrinsics::mir::*; -// unit-test: InstCombine +// unit-test: InstSimplify -// EMIT_MIR instcombine_duplicate_switch_targets.assert_zero.InstCombine.diff +// EMIT_MIR instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff #[custom_mir(dialect = "runtime", phase = "post-cleanup")] pub unsafe fn assert_zero(x: u8) -> u8 { mir!( diff --git a/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.generic.InstSimplify.diff index 09fc145e7..a59f4a43a 100644 --- a/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.generic.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before InstCombine -+ // MIR for `generic` after InstCombine +- // MIR for `generic` before InstSimplify ++ // MIR for `generic` after InstSimplify fn generic() -> () { let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +0:21 diff --git a/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.panics.InstSimplify.diff index c52174ef5..195e8bd4e 100644 --- a/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.panics.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `panics` before InstCombine -+ // MIR for `panics` after InstCombine +- // MIR for `panics` before InstSimplify ++ // MIR for `panics` after InstSimplify fn panics() -> () { let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +0:17 diff --git a/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.removable.InstSimplify.diff index d059d47ee..a4a65074c 100644 --- a/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff +++ b/tests/mir-opt/intrinsic_asserts.removable.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `removable` before InstCombine -+ // MIR for `removable` after InstCombine +- // MIR for `removable` before InstSimplify ++ // MIR for `removable` after InstSimplify fn removable() -> () { let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +0:20 diff --git a/tests/mir-opt/intrinsic_asserts.rs b/tests/mir-opt/intrinsic_asserts.rs index 8fb99cdf6..302d4bda1 100644 --- a/tests/mir-opt/intrinsic_asserts.rs +++ b/tests/mir-opt/intrinsic_asserts.rs @@ -2,7 +2,7 @@ #![feature(core_intrinsics)] // All these assertions pass, so all the intrinsic calls should be deleted. -// EMIT_MIR intrinsic_asserts.removable.InstCombine.diff +// EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff pub fn removable() { core::intrinsics::assert_inhabited::<()>(); core::intrinsics::assert_zero_valid::<u8>(); @@ -12,7 +12,7 @@ pub fn removable() { enum Never {} // These assertions all diverge, so their target blocks should become None. -// EMIT_MIR intrinsic_asserts.panics.InstCombine.diff +// EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff pub fn panics() { core::intrinsics::assert_inhabited::<Never>(); core::intrinsics::assert_zero_valid::<&u8>(); @@ -20,7 +20,7 @@ pub fn panics() { } // Whether or not these asserts pass isn't known, so they shouldn't be modified. -// EMIT_MIR intrinsic_asserts.generic.InstCombine.diff +// EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff pub fn generic<T>() { core::intrinsics::assert_inhabited::<T>(); core::intrinsics::assert_zero_valid::<T>(); diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff index d98f75e75..46b450a4e 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff @@ -22,9 +22,9 @@ } bb0: { -+ _9 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 + _7 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 + _8 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 ++ _9 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 StorageLive(_1); // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 StorageLive(_2); // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 diff --git a/tests/mir-opt/issue_72181_1.f.built.after.mir b/tests/mir-opt/issue_72181_1.f.built.after.mir index 4086da520..25f472251 100644 --- a/tests/mir-opt/issue_72181_1.f.built.after.mir +++ b/tests/mir-opt/issue_72181_1.f.built.after.mir @@ -3,27 +3,13 @@ fn f(_1: Void) -> ! { debug v => _1; // in scope 0 at $DIR/issue_72181_1.rs:+0:6: +0:7 let mut _0: !; // return place in scope 0 at $DIR/issue_72181_1.rs:+0:18: +0:19 - let mut _2: !; // in scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - let mut _3: !; // in scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - StorageLive(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 } bb1: { - unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:14: +1:15 - unreachable; // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/issue_72181_1.rs:+2:1: +2:2 return; // scope 0 at $DIR/issue_72181_1.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index abb89b91d..73b9ea46c 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -21,9 +21,9 @@ let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 let _14: &T; // in scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 scope 2 { - debug v1 => _12; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16 - debug v2 => _13; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24 - debug v3 => _14; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32 + debug v1 => &(*_2)[0 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:10: +3:16 + debug v2 => &(*_2)[1 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:18: +3:24 + debug v3 => &(*_2)[2 of 3]; // in scope 2 at $DIR/issue_76432.rs:+3:26: +3:32 } } @@ -52,15 +52,6 @@ } bb2: { - StorageLive(_12); // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 - _12 = &(*_2)[0 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:10: +3:16 - StorageLive(_13); // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 - _13 = &(*_2)[1 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:18: +3:24 - StorageLive(_14); // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 - _14 = &(*_2)[2 of 3]; // scope 1 at $DIR/issue_76432.rs:+3:26: +3:32 - StorageDead(_14); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_13); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 - StorageDead(_12); // scope 1 at $DIR/issue_76432.rs:+3:84: +3:85 StorageDead(_5); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2 StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:+6:1: +6:2 return; // scope 0 at $DIR/issue_76432.rs:+6:2: +6:2 diff --git a/tests/mir-opt/issue_78192.f.InstCombine.diff b/tests/mir-opt/issue_78192.f.InstSimplify.diff index 116ca304c..914d7ceb2 100644 --- a/tests/mir-opt/issue_78192.f.InstCombine.diff +++ b/tests/mir-opt/issue_78192.f.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `f` before InstCombine -+ // MIR for `f` after InstCombine +- // MIR for `f` before InstSimplify ++ // MIR for `f` after InstSimplify fn f(_1: &T) -> *const T { debug a => _1; // in scope 0 at $DIR/issue_78192.rs:+0:13: +0:14 diff --git a/tests/mir-opt/issue_78192.rs b/tests/mir-opt/issue_78192.rs index 39f665402..95142a3e4 100644 --- a/tests/mir-opt/issue_78192.rs +++ b/tests/mir-opt/issue_78192.rs @@ -8,4 +8,4 @@ fn main() { f(&2); } -// EMIT_MIR issue_78192.f.InstCombine.diff +// EMIT_MIR issue_78192.f.InstSimplify.diff diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index 2324f5356..0424ce3ab 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[22bb]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[22bb]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)]) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[22bb]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated([], DefId(0:8 ~ issue_99325[22bb]::main::{constant#1})) }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/issue_99325.rs:+0:15: +0:15 diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index 42b605326..9f955b471 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -4,31 +4,29 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24 let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue_59352.rs:15:12: 15:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _4: &std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let _5: std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug radix => const 8_u32; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _3: &std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let _4: std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL scope 2 (inlined Option::<u32>::is_some) { // at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _6: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _3; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _5: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } } scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue_59352.rs:15:42: 15:50 debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _6: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _7: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL scope 4 { debug val => _0; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL } } bb0: { - StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + StorageLive(_3); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _5 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _4 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL // + literal: Const { ty: fn(char, u32) -> Option<u32> {char::methods::<impl char>::to_digit}, val: Value(<ZST>) } @@ -43,8 +41,8 @@ fn num_to_digit(_1: char) -> u32 { } bb2: { - _7 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _7) -> [0: bb6, 1: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _6 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _6) -> [0: bb6, 1: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } bb3: { @@ -57,16 +55,15 @@ fn num_to_digit(_1: char) -> u32 { } bb5: { - _4 = &_5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _6 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + _3 = &_4; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _5 = discriminant((*_3)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_3); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - switchInt(move _6) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + switchInt(move _5) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 } bb6: { - _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff index cc5079af7..b022e2ba4 100644 --- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff @@ -24,7 +24,7 @@ _4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56 - _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:133:18: 133:54 +- // + span: $DIR/lower_intrinsics.rs:137:18: 137:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) } + _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 @@ -37,7 +37,7 @@ _6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56 - _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:134:18: 134:54 +- // + span: $DIR/lower_intrinsics.rs:138:18: 138:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) } + _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 + goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 diff --git a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff new file mode 100644 index 000000000..60a1dd0ba --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff @@ -0,0 +1,30 @@ +- // MIR for `ptr_offset` before LowerIntrinsics ++ // MIR for `ptr_offset` after LowerIntrinsics + + fn ptr_offset(_1: *const i32, _2: isize) -> *const i32 { + debug p => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:26: +0:27 + debug d => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:41: +0:42 + let mut _0: *const i32; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:54: +0:64 + let mut _3: *const i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + let mut _4: isize; // in scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 + + bb0: { + StorageLive(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + _3 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 + StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 + _4 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 +- _0 = offset::<*const i32, isize>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:144:5: 144:29 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, isize) -> *const i32 {offset::<*const i32, isize>}, val: Value(<ZST>) } ++ _0 = Offset(move _3, move _4); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:34: +1:35 + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 33fef930a..0ca88a42e 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -124,13 +124,22 @@ pub fn read_via_copy_uninhabited(r: &Never) -> Never { unsafe { core::intrinsics::read_via_copy(r) } } +// EMIT_MIR lower_intrinsics.write_via_move_string.LowerIntrinsics.diff +pub fn write_via_move_string(r: &mut String, v: String) { + unsafe { core::intrinsics::write_via_move(r, v) } +} + pub enum Never {} // EMIT_MIR lower_intrinsics.option_payload.LowerIntrinsics.diff -#[cfg(not(bootstrap))] pub fn option_payload(o: &Option<usize>, p: &Option<String>) { unsafe { let _x = core::intrinsics::option_payload_ptr(o); let _y = core::intrinsics::option_payload_ptr(p); } } + +// EMIT_MIR lower_intrinsics.ptr_offset.LowerIntrinsics.diff +pub unsafe fn ptr_offset(p: *const i32, d: isize) -> *const i32 { + core::intrinsics::offset(p, d) +} diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff index 8735a7500..aa5d9619d 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_box_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: std::boxed::Box<Never>; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::<usize, Box<Never>>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::<usize, Box<Never>>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:70:25: 70:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> Box<Never> {transmute::<usize, Box<Never>>}, val: Value(<ZST>) } -+ _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff index a77213277..5fafd45fe 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_mut_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: &mut Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: &mut Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::<usize, &mut Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::<usize, &mut Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:64:25: 64:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &mut Never {transmute::<usize, &mut Never>}, val: Value(<ZST>) } -+ _2 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ _1 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff index c4d53d4e8..08dead132 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_ref_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: &Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: &Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::<usize, &Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::<usize, &Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:58:21: 58:40 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &Never {transmute::<usize, &Never>}, val: Value(<ZST>) } -+ _2 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 ++ _1 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff index c0cc698c4..28e45909c 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff @@ -3,16 +3,15 @@ fn unreachable() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:25: +0:26 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:27: +2:2 - let _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + let _1: (); // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + let mut _2: !; // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 scope 1 { } bb0: { - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:47 - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 -- _3 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:47 + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 +- _2 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:31:14: 31:43 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(<ZST>) } diff --git a/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff index 0bfb34aca..217f27efe 100644 --- a/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.wrapping.LowerIntrinsics.diff @@ -30,10 +30,10 @@ _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:45: +1:46 StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:48: +1:49 _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:48: +1:49 -- _3 = wrapping_add::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 +- _3 = std::intrinsics::wrapping_add::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:9:14: 9:44 -- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {wrapping_add::<i32>}, val: Value(<ZST>) } +- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {std::intrinsics::wrapping_add::<i32>}, val: Value(<ZST>) } + _3 = Add(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:50 } @@ -46,10 +46,10 @@ _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:45: +2:46 StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:48: +2:49 _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:48: +2:49 -- _6 = wrapping_sub::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 +- _6 = std::intrinsics::wrapping_sub::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:10:14: 10:44 -- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {wrapping_sub::<i32>}, val: Value(<ZST>) } +- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> i32 {std::intrinsics::wrapping_sub::<i32>}, val: Value(<ZST>) } + _6 = Sub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 + goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:50 } diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff new file mode 100644 index 000000000..38d99f661 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff @@ -0,0 +1,36 @@ +- // MIR for `write_via_move_string` before LowerIntrinsics ++ // MIR for `write_via_move_string` after LowerIntrinsics + + fn write_via_move_string(_1: &mut String, _2: String) -> () { + debug r => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:30: +0:31 + debug v => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:46: +0:47 + let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:57: +0:57 + let mut _3: *mut std::string::String; // in scope 0 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + let mut _4: std::string::String; // in scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + scope 1 { + } + + bb0: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + _3 = &raw mut (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + StorageLive(_4); // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + _4 = move _2; // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51 +- _0 = write_via_move::<String>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:129:14: 129:46 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*mut String, String) {write_via_move::<String>}, val: Value(<ZST>) } ++ (*_3) = move _4; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/lower_intrinsics.rs:+1:51: +1:52 + StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:51: +1:52 + goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:1: +2:2 + } + + bb2: { + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir deleted file mode 100644 index 4f5df1331..000000000 --- a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir +++ /dev/null @@ -1,25 +0,0 @@ -// MIR for `f_u64` after PreCodegen - -fn f_u64() -> () { - let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics_e2e.rs:+0:16: +0:16 - let mut _1: u64; // in scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - scope 1 (inlined f_dispatch::<u64>) { // at $DIR/lower_intrinsics_e2e.rs:15:5: 15:21 - debug t => _1; // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 - let _2: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 - scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/lower_intrinsics_e2e.rs:20:8: 20:32 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - _2 = f_non_zst::<u64>(const 0_u64) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 - // mir::Constant - // + span: $DIR/lower_intrinsics_e2e.rs:23:9: 23:18 - // + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(<ZST>) } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir deleted file mode 100644 index 8654e80cd..000000000 --- a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir +++ /dev/null @@ -1,22 +0,0 @@ -// MIR for `f_unit` after PreCodegen - -fn f_unit() -> () { - let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics_e2e.rs:+0:17: +0:17 - scope 1 (inlined f_dispatch::<()>) { // at $DIR/lower_intrinsics_e2e.rs:9:5: 9:19 - debug t => const (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 - let _1: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 - scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/lower_intrinsics_e2e.rs:20:8: 20:32 - } - } - - bb0: { - _1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 - // mir::Constant - // + span: $DIR/lower_intrinsics_e2e.rs:21:9: 21:14 - // + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(<ZST>) } - } - - bb1: { - return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir b/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir index 6cd6d8b77..be5baf6ee 100644 --- a/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir +++ b/tests/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir @@ -1,39 +1,39 @@ // MIR for `use_x` 0 nll | Free Region Mapping -| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] -| '_#1r | Local | ['_#1r, '_#4r] -| '_#2r | Local | ['_#2r, '_#1r, '_#4r] -| '_#3r | Local | ['_#4r, '_#3r] -| '_#4r | Local | ['_#4r] +| '?0 | Global | ['?2, '?1, '?0, '?4, '?3] +| '?1 | Local | ['?1, '?4] +| '?2 | Local | ['?2, '?1, '?4] +| '?3 | Local | ['?4, '?3] +| '?4 | Local | ['?4] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} -| '_#1r | U0 | {bb0[0..=1], '_#1r} -| '_#2r | U0 | {bb0[0..=1], '_#2r} -| '_#3r | U0 | {bb0[0..=1], '_#3r} -| '_#4r | U0 | {bb0[0..=1], '_#4r} -| '_#5r | U0 | {bb0[0..=1], '_#1r} -| '_#6r | U0 | {bb0[0..=1], '_#2r} -| '_#7r | U0 | {bb0[0..=1], '_#1r} -| '_#8r | U0 | {bb0[0..=1], '_#3r} +| '?0 | U0 | {bb0[0..=1], '?0, '?1, '?2, '?3, '?4} +| '?1 | U0 | {bb0[0..=1], '?1} +| '?2 | U0 | {bb0[0..=1], '?2} +| '?3 | U0 | {bb0[0..=1], '?3} +| '?4 | U0 | {bb0[0..=1], '?4} +| '?5 | U0 | {bb0[0..=1], '?1} +| '?6 | U0 | {bb0[0..=1], '?2} +| '?7 | U0 | {bb0[0..=1], '?1} +| '?8 | U0 | {bb0[0..=1], '?3} | | Inference Constraints -| '_#0r live at {bb0[0..=1]} -| '_#1r live at {bb0[0..=1]} -| '_#2r live at {bb0[0..=1]} -| '_#3r live at {bb0[0..=1]} -| '_#4r live at {bb0[0..=1]} -| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) -| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) -| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) -| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) -| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) -| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) -| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) -| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) +| '?0 live at {bb0[0..=1]} +| '?1 live at {bb0[0..=1]} +| '?2 live at {bb0[0..=1]} +| '?3 live at {bb0[0..=1]} +| '?4 live at {bb0[0..=1]} +| '?1: '?5 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) +| '?1: '?7 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) +| '?2: '?6 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) +| '?3: '?8 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) +| '?5: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) +| '?6: '?2 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) +| '?7: '?1 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) +| '?8: '?3 due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) | -fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { +fn use_x(_1: &'?5 mut i32, _2: &'?6 u32, _3: &'?7 u32, _4: &'?8 u32) -> bool { debug w => _1; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:26: +0:27 debug x => _2; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:42: +0:43 debug y => _3; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:54: +0:55 diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir index 798e45df8..c425f3cd5 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir @@ -1,28 +1,28 @@ // MIR for `main` 0 nll | Free Region Mapping -| '_#0r | Global | ['_#0r, '_#1r] -| '_#1r | Local | ['_#1r] +| '?0 | Global | ['?0, '?1] +| '?1 | Local | ['?1] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '_#0r, '_#1r} -| '_#1r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '_#1r} -| '_#2r | U0 | {bb1[0..=7], bb2[0..=2]} -| '_#3r | U0 | {bb1[1..=7], bb2[0..=2]} -| '_#4r | U0 | {bb1[4..=7], bb2[0..=2]} +| '?0 | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '?0, '?1} +| '?1 | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '?1} +| '?2 | U0 | {bb1[0..=7], bb2[0..=2]} +| '?3 | U0 | {bb1[1..=7], bb2[0..=2]} +| '?4 | U0 | {bb1[4..=7], bb2[0..=2]} | | Inference Constraints -| '_#0r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} -| '_#1r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} -| '_#2r live at {bb1[0]} -| '_#3r live at {bb1[1..=3]} -| '_#4r live at {bb1[4..=7], bb2[0..=2]} -| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) -| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) +| '?0 live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} +| '?1 live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} +| '?2 live at {bb1[0]} +| '?3 live at {bb1[1..=3]} +| '?4 live at {bb1[4..=7], bb2[0..=2]} +| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) +| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 - let mut _1: [usize; Const(Value(Leaf(0x00000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let mut _1: [usize; Const { ty: usize, kind: Leaf(0x00000003) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 @@ -32,10 +32,10 @@ fn main() -> () { let _10: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 scope 1 { debug v => _1; // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 - let _2: &'_#3r usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + let _2: &'?3 usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 scope 2 { debug p => _2; // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 - let _6: &'_#4r usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + let _6: &'?4 usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 scope 3 { debug q => _6; // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 } @@ -55,7 +55,7 @@ fn main() -> () { } bb1: { - _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 + _2 = &'?2 _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 StorageLive(_6); // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 _6 = _2; // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14 diff --git a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir index 4767bfc76..22ad24f8d 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir +++ b/tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir @@ -1,28 +1,28 @@ // MIR for `main` 0 nll | Free Region Mapping -| '_#0r | Global | ['_#0r, '_#1r] -| '_#1r | Local | ['_#1r] +| '?0 | Global | ['?0, '?1] +| '?1 | Local | ['?1] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '_#0r, '_#1r} -| '_#1r | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '_#1r} -| '_#2r | U0 | {bb1[0..=7], bb2[0..=2]} -| '_#3r | U0 | {bb1[1..=7], bb2[0..=2]} -| '_#4r | U0 | {bb1[4..=7], bb2[0..=2]} +| '?0 | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '?0, '?1} +| '?1 | U0 | {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0], '?1} +| '?2 | U0 | {bb1[0..=7], bb2[0..=2]} +| '?3 | U0 | {bb1[1..=7], bb2[0..=2]} +| '?4 | U0 | {bb1[4..=7], bb2[0..=2]} | | Inference Constraints -| '_#0r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} -| '_#1r live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} -| '_#2r live at {bb1[0]} -| '_#3r live at {bb1[1..=3]} -| '_#4r live at {bb1[4..=7], bb2[0..=2]} -| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) -| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) +| '?0 live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} +| '?1 live at {bb0[0..=8], bb1[0..=7], bb2[0..=3], bb3[0..=3], bb4[0..=1], bb5[0..=2], bb6[0..=5], bb7[0]} +| '?2 live at {bb1[0]} +| '?3 live at {bb1[1..=3]} +| '?4 live at {bb1[4..=7], bb2[0..=2]} +| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) +| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 - let mut _1: [usize; Const(Value(Leaf(0x0000000000000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let mut _1: [usize; Const { ty: usize, kind: Leaf(0x0000000000000003) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 @@ -32,10 +32,10 @@ fn main() -> () { let _10: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 scope 1 { debug v => _1; // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 - let _2: &'_#3r usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + let _2: &'?3 usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 scope 2 { debug p => _2; // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 - let _6: &'_#4r usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + let _6: &'?4 usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 scope 3 { debug q => _6; // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 } @@ -55,7 +55,7 @@ fn main() -> () { } bb1: { - _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 + _2 = &'?2 _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 StorageLive(_6); // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 _6 = _2; // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14 diff --git a/tests/mir-opt/not_equal_false.opt.InstCombine.diff b/tests/mir-opt/not_equal_false.opt.InstSimplify.diff index b558c35ac..8e7776a0b 100644 --- a/tests/mir-opt/not_equal_false.opt.InstCombine.diff +++ b/tests/mir-opt/not_equal_false.opt.InstSimplify.diff @@ -1,5 +1,5 @@ -- // MIR for `opt` before InstCombine -+ // MIR for `opt` after InstCombine +- // MIR for `opt` before InstSimplify ++ // MIR for `opt` after InstSimplify fn opt(_1: bool) -> u32 { debug x => _1; // in scope 0 at $DIR/not_equal_false.rs:+0:8: +0:9 diff --git a/tests/mir-opt/not_equal_false.rs b/tests/mir-opt/not_equal_false.rs index 2ae03da40..e05607329 100644 --- a/tests/mir-opt/not_equal_false.rs +++ b/tests/mir-opt/not_equal_false.rs @@ -1,5 +1,5 @@ -// unit-test: InstCombine -// EMIT_MIR not_equal_false.opt.InstCombine.diff +// unit-test: InstSimplify +// EMIT_MIR not_equal_false.opt.InstSimplify.diff fn opt(x: bool) -> u32 { if x != false { 0 } else { 1 } diff --git a/tests/mir-opt/nrvo_miscompile_111005.rs b/tests/mir-opt/nrvo_miscompile_111005.rs new file mode 100644 index 000000000..a9f391b79 --- /dev/null +++ b/tests/mir-opt/nrvo_miscompile_111005.rs @@ -0,0 +1,22 @@ +// This is a miscompilation, #111005 to track + +// unit-test: RenameReturnPlace + +#![feature(custom_mir, core_intrinsics)] +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR nrvo_miscompile_111005.wrong.RenameReturnPlace.diff +#[custom_mir(dialect = "runtime", phase = "initial")] +pub fn wrong(arg: char) -> char { + mir!({ + let temp = arg; + RET = temp; + temp = 'b'; + Return() + }) +} + +fn main() { + assert_eq!(wrong('a'), 'a'); +} diff --git a/tests/mir-opt/nrvo_miscompile_111005.wrong.RenameReturnPlace.diff b/tests/mir-opt/nrvo_miscompile_111005.wrong.RenameReturnPlace.diff new file mode 100644 index 000000000..a0acb6e7e --- /dev/null +++ b/tests/mir-opt/nrvo_miscompile_111005.wrong.RenameReturnPlace.diff @@ -0,0 +1,18 @@ +- // MIR for `wrong` before RenameReturnPlace ++ // MIR for `wrong` after RenameReturnPlace + + fn wrong(_1: char) -> char { +- let mut _0: char; // return place in scope 0 at $DIR/nrvo_miscompile_111005.rs:+0:28: +0:32 ++ let mut _0: char; // return place in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: char; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _0 = _2; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+3:9: +3:19 +- _2 = const 'b'; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+4:9: +4:19 ++ _0 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _0 = const 'b'; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+4:9: +4:19 + return; // scope 0 at $DIR/nrvo_miscompile_111005.rs:+5:9: +5:17 + } + } + diff --git a/tests/mir-opt/pre-codegen/README.md b/tests/mir-opt/pre-codegen/README.md new file mode 100644 index 000000000..a338c18e0 --- /dev/null +++ b/tests/mir-opt/pre-codegen/README.md @@ -0,0 +1,3 @@ +The goal of this directory is to track the quality of MIR that is given to codegen in a standard `-O` condiguration. + +As such, feel free to `--bless` whatever changes you get here, so long as doing so doesn't add substantially more MIR. diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs b/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs new file mode 100644 index 000000000..d8af6b14d --- /dev/null +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.rs @@ -0,0 +1,17 @@ +// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=0 +// ignore-debug: standard library debug assertions add a panic that breaks this optimization + +#![crate_type = "lib"] + +pub enum Thing { + A, + B, +} + +// EMIT_MIR duplicate_switch_targets.ub_if_b.PreCodegen.after.mir +pub unsafe fn ub_if_b(t: Thing) -> Thing { + match t { + Thing::A => t, + Thing::B => std::hint::unreachable_unchecked(), + } +} diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir new file mode 100644 index 000000000..0e885cf94 --- /dev/null +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir @@ -0,0 +1,27 @@ +// MIR for `ub_if_b` after PreCodegen + +fn ub_if_b(_1: Thing) -> Thing { + debug t => _1; // in scope 0 at $DIR/duplicate_switch_targets.rs:+0:23: +0:24 + let mut _0: Thing; // return place in scope 0 at $DIR/duplicate_switch_targets.rs:+0:36: +0:41 + let mut _2: isize; // in scope 0 at $DIR/duplicate_switch_targets.rs:+2:9: +2:17 + scope 1 (inlined unreachable_unchecked) { // at $DIR/duplicate_switch_targets.rs:15:21: 15:55 + scope 2 { + scope 3 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + + bb0: { + _2 = discriminant(_1); // scope 0 at $DIR/duplicate_switch_targets.rs:+1:11: +1:12 + switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/duplicate_switch_targets.rs:+1:5: +1:12 + } + + bb1: { + unreachable; // scope 2 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + + bb2: { + _0 = move _1; // scope 0 at $DIR/duplicate_switch_targets.rs:+2:21: +2:22 + return; // scope 0 at $DIR/duplicate_switch_targets.rs:+5:2: +5:2 + } +} diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir new file mode 100644 index 000000000..76e1fea2f --- /dev/null +++ b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir @@ -0,0 +1,26 @@ +// MIR for `f_u64` after PreCodegen + +fn f_u64() -> () { + let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:16: +0:16 + let mut _1: u64; // in scope 0 at $DIR/intrinsics.rs:+1:5: +1:21 + scope 1 (inlined f_dispatch::<u64>) { // at $DIR/intrinsics.rs:19:5: 19:21 + debug t => const 0_u64; // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23 + let _2: (); // in scope 1 at $DIR/intrinsics.rs:27:9: 27:21 + scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/intrinsics.rs:24:8: 24:32 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21 + _1 = const 0_u64; // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21 + _2 = f_non_zst::<u64>(move _1) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:27:9: 27:21 + // mir::Constant + // + span: $DIR/intrinsics.rs:27:9: 27:18 + // + literal: Const { ty: fn(u64) {f_non_zst::<u64>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/intrinsics.rs:+1:5: +1:21 + return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir new file mode 100644 index 000000000..3d416de34 --- /dev/null +++ b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir @@ -0,0 +1,22 @@ +// MIR for `f_unit` after PreCodegen + +fn f_unit() -> () { + let mut _0: (); // return place in scope 0 at $DIR/intrinsics.rs:+0:17: +0:17 + scope 1 (inlined f_dispatch::<()>) { // at $DIR/intrinsics.rs:13:5: 13:19 + debug t => const (); // in scope 1 at $DIR/intrinsics.rs:23:22: 23:23 + let _1: (); // in scope 1 at $DIR/intrinsics.rs:25:9: 25:17 + scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/intrinsics.rs:24:8: 24:32 + } + } + + bb0: { + _1 = f_zst::<()>(const ()) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/intrinsics.rs:25:9: 25:17 + // mir::Constant + // + span: $DIR/intrinsics.rs:25:9: 25:14 + // + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/intrinsics.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/lower_intrinsics_e2e.rs b/tests/mir-opt/pre-codegen/intrinsics.rs index 872ef59b0..ecdb656cb 100644 --- a/tests/mir-opt/lower_intrinsics_e2e.rs +++ b/tests/mir-opt/pre-codegen/intrinsics.rs @@ -1,16 +1,20 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + // Checks that we do not have any branches in the MIR for the two tested functions. // compile-flags: -Cpanic=abort #![feature(core_intrinsics)] #![crate_type = "lib"] -// EMIT_MIR lower_intrinsics_e2e.f_unit.PreCodegen.after.mir +// EMIT_MIR intrinsics.f_unit.PreCodegen.after.mir pub fn f_unit() { f_dispatch(()); } -// EMIT_MIR lower_intrinsics_e2e.f_u64.PreCodegen.after.mir +// EMIT_MIR intrinsics.f_u64.PreCodegen.after.mir pub fn f_u64() { f_dispatch(0u64); } diff --git a/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir new file mode 100644 index 000000000..1d2387102 --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir @@ -0,0 +1,16 @@ +// MIR for `manual_replace` after PreCodegen + +fn manual_replace(_1: &mut u32, _2: u32) -> u32 { + debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:23: +0:24 + debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:36: +0:37 + let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:47: +0:50 + scope 1 { + debug temp => _0; // in scope 1 at $DIR/mem_replace.rs:+1:9: +1:13 + } + + bb0: { + _0 = (*_1); // scope 0 at $DIR/mem_replace.rs:+1:16: +1:18 + (*_1) = _2; // scope 1 at $DIR/mem_replace.rs:+2:5: +2:11 + return; // scope 0 at $DIR/mem_replace.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir new file mode 100644 index 000000000..50e0538c1 --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -0,0 +1,53 @@ +// MIR for `mem_replace` after PreCodegen + +fn mem_replace(_1: &mut u32, _2: u32) -> u32 { + debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:20: +0:21 + debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:33: +0:34 + let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:44: +0:47 + scope 1 (inlined std::mem::replace::<u32>) { // at $DIR/mem_replace.rs:16:5: 16:28 + debug dest => _1; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug src => _2; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + let mut _3: *const u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + let mut _4: *mut u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + scope 2 { + scope 3 { + debug result => _0; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + scope 7 (inlined std::ptr::write::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 8 { + scope 9 (inlined std::ptr::write::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 4 (inlined std::ptr::read::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 5 { + scope 6 (inlined std::ptr::read::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + (*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/mem_replace.rs b/tests/mir-opt/pre-codegen/mem_replace.rs new file mode 100644 index 000000000..e5066c38b --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.rs @@ -0,0 +1,17 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +// EMIT_MIR mem_replace.manual_replace.PreCodegen.after.mir +pub fn manual_replace(r: &mut u32, v: u32) -> u32 { + let temp = *r; + *r = v; + temp +} + +// EMIT_MIR mem_replace.mem_replace.PreCodegen.after.mir +pub fn mem_replace(r: &mut u32, v: u32) -> u32 { + std::mem::replace(r, v) +} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff index 691aa01a5..691aa01a5 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.diff diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff index 691aa01a5..691aa01a5 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.diff diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir new file mode 100644 index 000000000..7886bf19e --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.mir @@ -0,0 +1,18 @@ +// MIR for `main` after PreCodegen + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 + scope 1 { + debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + scope 2 { + debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 3 { + debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + } + } + } + + bb0: { + return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir new file mode 100644 index 000000000..7886bf19e --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.mir @@ -0,0 +1,18 @@ +// MIR for `main` after PreCodegen + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 + scope 1 { + debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + scope 2 { + debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 3 { + debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + } + } + } + + bb0: { + return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff index 98cd020da..98cd020da 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff index 98cd020da..98cd020da 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir new file mode 100644 index 000000000..5bea94c7f --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir @@ -0,0 +1,18 @@ +// MIR for `main` after SimplifyLocals-final + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 + scope 1 { + debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + scope 2 { + debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 3 { + debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + } + } + } + + bb0: { + return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir new file mode 100644 index 000000000..5bea94c7f --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir @@ -0,0 +1,18 @@ +// MIR for `main` after SimplifyLocals-final + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 + scope 1 { + debug x => const 4_i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + scope 2 { + debug y => const 3_i32; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 3 { + debug z => const 42_u32; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + } + } + } + + bb0: { + return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs index 5ffa15347..bb32cd3af 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.rs +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs @@ -1,5 +1,4 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test // compile-flags: -C overflow-checks=on struct Point { diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir new file mode 100644 index 000000000..343a4a5a6 --- /dev/null +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir @@ -0,0 +1,91 @@ +// MIR for `forward_loop` after PreCodegen + +fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { + debug start => _1; // in scope 0 at $DIR/range_iter.rs:+0:21: +0:26 + debug end => _2; // in scope 0 at $DIR/range_iter.rs:+0:33: +0:36 + debug f => _3; // in scope 0 at $DIR/range_iter.rs:+0:43: +0:44 + let mut _0: (); // return place in scope 0 at $DIR/range_iter.rs:+0:60: +0:60 + let mut _4: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _5: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let _6: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _8: &mut std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _9: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 + let mut _11: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 + let mut _12: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + let _10: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + scope 2 { + debug x => _10; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 + } + scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { // at $DIR/range_iter.rs:21:14: 21:24 + debug self => _8; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + } + scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) { // at $DIR/range_iter.rs:21:14: 21:24 + debug self => _4; // in scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + _4 = std::ops::Range::<u32> { start: _1, end: _2 }; // scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + StorageLive(_5); // scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + _5 = move _4; // scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 + } + + bb1: { + StorageLive(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + _8 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + _7 = <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next(_8) -> [return: bb9, unwind: bb7]; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<u32>) -> Option<<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) } + } + + bb2: { + _10 = ((_7 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + StorageLive(_11); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + _11 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + StorageLive(_12); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _12 = (_10,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _6 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + // mir::Constant + // + span: $DIR/range_iter.rs:22:9: 22:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> <impl Fn(u32) as FnOnce<(u32,)>>::Output {<impl Fn(u32) as Fn<(u32,)>>::call}, val: Value(<ZST>) } + } + + bb3: { + unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + } + + bb4: { + StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + StorageDead(_5); // scope 0 at $DIR/range_iter.rs:+3:5: +3:6 + drop(_3) -> bb6; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + } + + bb5: { + StorageDead(_12); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_11); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 + } + + bb6: { + return; // scope 0 at $DIR/range_iter.rs:+4:2: +4:2 + } + + bb7 (cleanup): { + drop(_3) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + } + + bb8 (cleanup): { + resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2 + } + + bb9: { + _9 = discriminant(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + } +} diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir new file mode 100644 index 000000000..f45eabba2 --- /dev/null +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.mir @@ -0,0 +1,95 @@ +// MIR for `inclusive_loop` after PreCodegen + +fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { + debug start => _1; // in scope 0 at $DIR/range_iter.rs:+0:23: +0:28 + debug end => _2; // in scope 0 at $DIR/range_iter.rs:+0:35: +0:38 + debug f => _3; // in scope 0 at $DIR/range_iter.rs:+0:45: +0:46 + let mut _0: (); // return place in scope 0 at $DIR/range_iter.rs:+0:62: +0:62 + let mut _4: std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + let mut _5: std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + let _6: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + let mut _7: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + let mut _8: &mut std::ops::RangeInclusive<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + let mut _9: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 + let mut _11: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 + let mut _12: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + let _10: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + scope 2 { + debug x => _10; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 + } + scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { // at $DIR/range_iter.rs:28:14: 28:25 + debug self => _8; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + } + scope 3 (inlined RangeInclusive::<u32>::new) { // at $DIR/range_iter.rs:28:14: 28:25 + debug start => _1; // in scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL + debug end => _2; // in scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL + } + scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { // at $DIR/range_iter.rs:28:14: 28:25 + debug self => _4; // in scope 4 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false }; // scope 3 at $SRC_DIR/core/src/ops/range.rs:LL:COL + StorageLive(_5); // scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + _5 = move _4; // scope 0 at $DIR/range_iter.rs:+1:14: +1:25 + goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 + } + + bb1: { + StorageLive(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + _8 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_8) -> [return: bb9, unwind: bb7]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut RangeInclusive<u32>) -> Option<<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::Item> {<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next}, val: Value(<ZST>) } + } + + bb2: { + _10 = ((_7 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + StorageLive(_11); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + _11 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + StorageLive(_12); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _12 = (_10,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _6 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + // mir::Constant + // + span: $DIR/range_iter.rs:29:9: 29:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> <impl Fn(u32) as FnOnce<(u32,)>>::Output {<impl Fn(u32) as Fn<(u32,)>>::call}, val: Value(<ZST>) } + } + + bb3: { + unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + } + + bb4: { + StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + StorageDead(_5); // scope 0 at $DIR/range_iter.rs:+3:5: +3:6 + drop(_3) -> bb6; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + } + + bb5: { + StorageDead(_12); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_11); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_7); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 + } + + bb6: { + return; // scope 0 at $DIR/range_iter.rs:+4:2: +4:2 + } + + bb7 (cleanup): { + drop(_3) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + } + + bb8 (cleanup): { + resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2 + } + + bb9: { + _9 = discriminant(_7); // scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:25 + } +} diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir new file mode 100644 index 000000000..d013b1b94 --- /dev/null +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.mir @@ -0,0 +1,20 @@ +// MIR for `range_inclusive_iter_next` after PreCodegen + +fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> { + debug it => _1; // in scope 0 at $DIR/range_iter.rs:+0:34: +0:36 + let mut _0: std::option::Option<u32>; // return place in scope 0 at $DIR/range_iter.rs:+0:67: +0:78 + scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { // at $DIR/range_iter.rs:16:8: 16:14 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb0: { + _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> bb1; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut RangeInclusive<u32>) -> Option<<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::Item> {<RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir new file mode 100644 index 000000000..cae46e2b0 --- /dev/null +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir @@ -0,0 +1,20 @@ +// MIR for `range_iter_next` after PreCodegen + +fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { + debug it => _1; // in scope 0 at $DIR/range_iter.rs:+0:24: +0:26 + let mut _0: std::option::Option<u32>; // return place in scope 0 at $DIR/range_iter.rs:+0:48: +0:59 + scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { // at $DIR/range_iter.rs:11:8: 11:14 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb0: { + _0 = <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next(_1) -> bb1; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<u32>) -> Option<<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/range_iter.rs b/tests/mir-opt/pre-codegen/range_iter.rs new file mode 100644 index 000000000..fe21d4dfd --- /dev/null +++ b/tests/mir-opt/pre-codegen/range_iter.rs @@ -0,0 +1,31 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +use std::ops::{Range, RangeInclusive}; + +// EMIT_MIR range_iter.range_iter_next.PreCodegen.after.mir +pub fn range_iter_next(it: &mut Range<u32>) -> Option<u32> { + it.next() +} + +// EMIT_MIR range_iter.range_inclusive_iter_next.PreCodegen.after.mir +pub fn range_inclusive_iter_next(it: &mut RangeInclusive<u32>) -> Option<u32> { + it.next() +} + +// EMIT_MIR range_iter.forward_loop.PreCodegen.after.mir +pub fn forward_loop(start: u32, end: u32, f: impl Fn(u32)) { + for x in start..end { + f(x) + } +} + +// EMIT_MIR range_iter.inclusive_loop.PreCodegen.after.mir +pub fn inclusive_loop(start: u32, end: u32, f: impl Fn(u32)) { + for x in start..=end { + f(x) + } +} diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir new file mode 100644 index 000000000..986ab3588 --- /dev/null +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -0,0 +1,56 @@ +// MIR for `ezmap` after PreCodegen + +fn ezmap(_1: Option<i32>) -> Option<i32> { + debug x => _1; // in scope 0 at $DIR/simple_option_map.rs:+0:14: +0:15 + let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map.rs:+0:33: +0:44 + let mut _6: i32; // in scope 0 at $DIR/simple_option_map.rs:11:25: 11:29 + scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:18:12: 18:15]>) { // at $DIR/simple_option_map.rs:18:5: 18:22 + debug slf => _1; // in scope 1 at $DIR/simple_option_map.rs:6:17: 6:20 + debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; // in scope 1 at $DIR/simple_option_map.rs:6:33: 6:34 + let mut _2: isize; // in scope 1 at $DIR/simple_option_map.rs:11:9: 11:16 + let _3: i32; // in scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 + let mut _4: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 + let mut _5: (i32,); // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 + scope 2 { + debug x => _3; // in scope 2 at $DIR/simple_option_map.rs:11:14: 11:15 + scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map.rs:11:25: 11:29 + debug n => _6; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14 + } + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 + _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14 + switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map.rs:10:5: 10:14 + } + + bb1: { + _0 = Option::<i32>::None; // scope 1 at $DIR/simple_option_map.rs:12:17: 12:21 + goto -> bb4; // scope 1 at $DIR/simple_option_map.rs:12:17: 12:21 + } + + bb2: { + unreachable; // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14 + } + + bb3: { + _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 + StorageLive(_4); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + StorageLive(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + _5 = (move _3,); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + StorageLive(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + _6 = move (_5.0: i32); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + _4 = Add(_6, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21 + StorageDead(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 + StorageDead(_5); // scope 2 at $DIR/simple_option_map.rs:11:28: 11:29 + _0 = Option::<i32>::Some(move _4); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30 + StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30 + goto -> bb4; // scope 1 at $DIR/simple_option_map.rs:14:1: 14:2 + } + + bb4: { + StorageDead(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 + return; // scope 0 at $DIR/simple_option_map.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/simple_option_map_e2e.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index 2acd2a227..fb3da68e4 100644 --- a/tests/mir-opt/simple_option_map_e2e.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -1,3 +1,7 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + #[inline(always)] fn map<T, U, F>(slf: Option<T>, f: F) -> Option<U> where @@ -9,7 +13,7 @@ where } } -// EMIT_MIR simple_option_map_e2e.ezmap.PreCodegen.after.mir +// EMIT_MIR simple_option_map.ezmap.PreCodegen.after.mir pub fn ezmap(x: Option<i32>) -> Option<i32> { map(x, |n| n + 1) } diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs new file mode 100644 index 000000000..44b456276 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_index.rs @@ -0,0 +1,27 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +use std::ops::Range; + +// EMIT_MIR slice_index.slice_index_usize.PreCodegen.after.mir +pub fn slice_index_usize(slice: &[u32], index: usize) -> u32 { + slice[index] +} + +// EMIT_MIR slice_index.slice_get_mut_usize.PreCodegen.after.mir +pub fn slice_get_mut_usize(slice: &mut [u32], index: usize) -> Option<&mut u32> { + slice.get_mut(index) +} + +// EMIT_MIR slice_index.slice_index_range.PreCodegen.after.mir +pub fn slice_index_range(slice: &[u32], index: Range<usize>) -> &[u32] { + &slice[index] +} + +// EMIT_MIR slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir +pub unsafe fn slice_get_unchecked_mut_range(slice: &mut [u32], index: Range<usize>) -> &mut [u32] { + slice.get_unchecked_mut(index) +} diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir new file mode 100644 index 000000000..715a1e3fc --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir @@ -0,0 +1,105 @@ +// MIR for `slice_get_mut_usize` after PreCodegen + +fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { + debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:28: +0:33 + debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:47: +0:52 + let mut _0: std::option::Option<&mut u32>; // return place in scope 0 at $DIR/slice_index.rs:+0:64: +0:80 + scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) { // at $DIR/slice_index.rs:16:11: 16:25 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug self => _2; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug slice => _1; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _3: bool; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _4: usize; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _5: &[u32]; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _6: &mut u32; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _7: *mut u32; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _8: *mut [u32]; // in scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + scope 3 { + scope 4 (inlined <usize as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _2; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug slice => _8; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _9: *mut u32; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _10: usize; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + let mut _11: *mut [u32]; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 5 { + debug this => _2; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + scope 6 { + scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => _10; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _11; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _11; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _12: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _12; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + scope 10 { + } + } + } + } + scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _8; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _9; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug count => _2; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 13 { + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_6); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _5 = &(*_1); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _4 = Len((*_5)); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _3 = Lt(_2, move _4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + } + + bb1: { + StorageLive(_7); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _8 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _9 = _8 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + _7 = Offset(_9, _2); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _6 = &mut (*_7); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _0 = Option::<&mut u32>::Some(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_7); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + goto -> bb3; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + } + + bb2: { + _0 = const Option::<&mut u32>::None; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: Option<&mut u32>, val: Value(Scalar(0x0000000000000000)) } + goto -> bb3; // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + } + + bb3: { + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_6); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir new file mode 100644 index 000000000..7a10b929e --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir @@ -0,0 +1,134 @@ +// MIR for `slice_get_unchecked_mut_range` after PreCodegen + +fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> &mut [u32] { + debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:45: +0:50 + debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:64: +0:69 + let mut _0: &mut [u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:88: +0:98 + scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { // at $DIR/slice_index.rs:26:11: 26:35 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _3: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _4: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + scope 2 { + scope 3 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug slice => _4; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _5: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _7: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _8: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _9: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _10: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _11: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _12: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _13: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + let mut _14: *mut [u32]; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 4 { + debug this => _5; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + scope 5 { + let _6: usize; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + scope 6 { + debug new_len => _6; // in scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _4; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _10; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug count => _11; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 13 { + } + } + scope 14 (inlined slice_from_raw_parts_mut::<u32>) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug data => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug len => _12; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _16: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + scope 15 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug self => _9; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug data_address => _16; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug metadata => _12; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _17: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _18: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _19: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + scope 17 { + } + } + } + } + scope 7 (inlined <std::ops::Range<usize> as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => _13; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _14; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => _14; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _15: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + scope 10 { + } + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _4 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_13); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_7); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _7 = (_2.1: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_8); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _8 = (_2.0: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _6 = unchecked_sub::<usize>(move _7, move _8) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_sub::<usize>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_7); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _10 = _4 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + StorageLive(_11); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _11 = (_2.0: usize); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _9 = Offset(_10, _11); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + StorageDead(_11); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_12); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _12 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_16); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + _16 = _9 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + StorageLive(_17); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_18); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_19); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _19 = _16 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _18 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _19, metadata: _12 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_19); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _17 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _18 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_18); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _3 = (_17.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_17); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_16); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_12); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_13); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _0 = &mut (*_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_3); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir new file mode 100644 index 000000000..dcf79a4a4 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.mir @@ -0,0 +1,26 @@ +// MIR for `slice_index_range` after PreCodegen + +fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] { + debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:26: +0:31 + debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:41: +0:46 + let mut _0: &[u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:65: +0:71 + scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) { // at $DIR/slice_index.rs:21:6: 21:18 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _3: &[u32]; // in scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + } + + bb0: { + StorageLive(_3); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, _1) -> bb1; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL + // + literal: Const { ty: for<'a> fn(std::ops::Range<usize>, &'a [u32]) -> &'a <std::ops::Range<usize> as SliceIndex<[u32]>>::Output {<std::ops::Range<usize> as SliceIndex<[u32]>>::index}, val: Value(<ZST>) } + } + + bb1: { + _0 = _3; // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_3); // scope 1 at $SRC_DIR/core/src/slice/index.rs:LL:COL + return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir new file mode 100644 index 000000000..6cc0ee057 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.mir @@ -0,0 +1,20 @@ +// MIR for `slice_index_usize` after PreCodegen + +fn slice_index_usize(_1: &[u32], _2: usize) -> u32 { + debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:26: +0:31 + debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:41: +0:46 + let mut _0: u32; // return place in scope 0 at $DIR/slice_index.rs:+0:58: +0:61 + let mut _3: usize; // in scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + let mut _4: bool; // in scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + + bb0: { + _3 = Len((*_1)); // scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + _4 = Lt(_2, _3); // scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> bb1; // scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + } + + bb1: { + _0 = (*_1)[_2]; // scope 0 at $DIR/slice_index.rs:+1:5: +1:17 + return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir new file mode 100644 index 000000000..0da7e5536 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir @@ -0,0 +1,203 @@ +// MIR for `forward_loop` after PreCodegen + +fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { + debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:28: +0:33 + debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:44: +0:45 + let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:60: +0:60 + let mut _3: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let mut _4: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let _5: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let mut _6: std::option::Option<&T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let mut _7: &mut std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let mut _8: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +3:6 + let mut _10: &impl Fn(&T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:10 + let mut _11: (&T,); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:13 + scope 1 { + debug iter => _4; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + let _9: &T; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + scope 2 { + debug x => _9; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10 + } + } + scope 3 (inlined core::slice::<impl [T]>::iter) { // at $DIR/slice_iter.rs:28:20: 28:26 + debug self => _1; // in scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + scope 4 (inlined std::slice::Iter::<'_, T>::new) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug slice => _1; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let _12: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _14: bool; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _15: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _16: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _17: std::ptr::NonNull<T>; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _18: *mut T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _19: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 5 { + debug ptr => _12; // in scope 5 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 6 { + let _13: *const T; // in scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 7 { + debug end => _13; // in scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug ptr => _18; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + let mut _21: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + let mut _22: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 14 { + scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _22; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + debug self => _22; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _23: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 17 { + scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _23; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _23; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 20 { + scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _23; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + } + } + } + } + } + } + } + } + } + scope 9 (inlined invalid::<T>) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug addr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + scope 10 { + } + } + scope 11 (inlined ptr::const_ptr::<impl *const T>::add) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _12; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + debug count => _16; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + scope 12 { + } + } + } + } + scope 8 (inlined core::slice::<impl [T]>::as_ptr) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _1; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _20: *const [T]; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + } + } + } + scope 22 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:28:14: 28:26 + debug self => _3; // in scope 22 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_20); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _20 = &raw const (*_1); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _12 = move _20 as *const T (PtrToPtr); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_20); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_13); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _14 = const _; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + switchInt(move _14) -> [0: bb11, otherwise: bb10]; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb1: { + StorageLive(_6); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + _7 = &mut _4; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + _6 = <std::slice::Iter<'_, T> as Iterator>::next(_7) -> [return: bb2, unwind: bb8]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + // mir::Constant + // + span: $DIR/slice_iter.rs:28:14: 28:26 + // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as Iterator>::next}, val: Value(<ZST>) } + } + + bb2: { + _8 = discriminant(_6); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + switchInt(move _8) -> [0: bb5, 1: bb3, otherwise: bb4]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + } + + bb3: { + _9 = ((_6 as Some).0: &T); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + StorageLive(_10); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + _10 = &_2; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + StorageLive(_11); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + _11 = (_9,); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + _5 = <impl Fn(&T) as Fn<(&T,)>>::call(move _10, move _11) -> [return: bb6, unwind: bb8]; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + // mir::Constant + // + span: $DIR/slice_iter.rs:29:9: 29:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(&T), (&T,)) -> <impl Fn(&T) as FnOnce<(&T,)>>::Output {<impl Fn(&T) as Fn<(&T,)>>::call}, val: Value(<ZST>) } + } + + bb4: { + unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:26 + } + + bb5: { + StorageDead(_6); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + StorageDead(_4); // scope 0 at $DIR/slice_iter.rs:+3:5: +3:6 + drop(_2) -> bb7; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb6: { + StorageDead(_11); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13 + StorageDead(_10); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13 + StorageDead(_6); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } + + bb7: { + return; // scope 0 at $DIR/slice_iter.rs:+4:2: +4:2 + } + + bb8 (cleanup): { + drop(_2) -> [return: bb9, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb9 (cleanup): { + resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +4:2 + } + + bb10: { + StorageLive(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _15 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _13 = _15 as *const T (Transmute); // scope 10 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb12; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb11: { + StorageLive(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _16 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _13 = Offset(_12, _16); // scope 12 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + StorageDead(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb12; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb12: { + StorageDead(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_17); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _18 = _12 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_21); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _21 = _18 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + _17 = NonNull::<T> { pointer: _21 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_21); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _19 = _13; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _3 = std::slice::Iter::<'_, T> { ptr: move _17, end: move _19, _marker: const ZeroSized: PhantomData<&T> }; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: PhantomData<&T>, val: Value(<ZST>) } + // adt + // + user_ty: UserType(1) + StorageDead(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_17); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_13); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_4); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + _4 = move _3; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir new file mode 100644 index 000000000..45b41b54c --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir @@ -0,0 +1,220 @@ +// MIR for `reverse_loop` after PreCodegen + +fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { + debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:28: +0:33 + debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:44: +0:45 + let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:60: +0:60 + let mut _3: std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + let mut _4: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + let mut _5: std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + let _6: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + let mut _7: std::option::Option<&T>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + let mut _8: &mut std::iter::Rev<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + let mut _9: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +3:6 + let mut _11: &impl Fn(&T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:10 + let mut _12: (&T,); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:13 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + let _10: &T; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + scope 2 { + debug x => _10; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10 + } + scope 25 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { // at $DIR/slice_iter.rs:35:14: 35:32 + debug self => _8; // in scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + let mut _25: &mut std::slice::Iter<'_, T>; // in scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + } + } + scope 3 (inlined core::slice::<impl [T]>::iter) { // at $DIR/slice_iter.rs:35:20: 35:26 + debug self => _1; // in scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + scope 4 (inlined std::slice::Iter::<'_, T>::new) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug slice => _1; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let _13: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _15: bool; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _16: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _17: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _18: std::ptr::NonNull<T>; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _19: *mut T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _20: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 5 { + debug ptr => _13; // in scope 5 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 6 { + let _14: *const T; // in scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 7 { + debug end => _14; // in scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug ptr => _19; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + let mut _22: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + let mut _23: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 14 { + scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _23; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + debug self => _23; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 17 { + scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 20 { + scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + } + } + } + } + } + } + } + } + } + scope 9 (inlined invalid::<T>) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug addr => _16; // in scope 9 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + scope 10 { + } + } + scope 11 (inlined ptr::const_ptr::<impl *const T>::add) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _13; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + debug count => _17; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + scope 12 { + } + } + } + } + scope 8 (inlined core::slice::<impl [T]>::as_ptr) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _1; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _21: *const [T]; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + } + } + } + scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { // at $DIR/slice_iter.rs:35:27: 35:32 + debug self => _4; // in scope 22 at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + scope 23 (inlined Rev::<std::slice::Iter<'_, T>>::new) { // at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + debug iter => _4; // in scope 23 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + } + } + scope 24 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:35:14: 35:32 + debug self => _3; // in scope 24 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_4); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:26 + StorageLive(_13); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_21); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _21 = &raw const (*_1); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _13 = move _21 as *const T (PtrToPtr); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_21); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _15 = const _; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + switchInt(move _15) -> [0: bb10, otherwise: bb9]; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb1: { + StorageLive(_7); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + _8 = &mut _5; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + StorageLive(_25); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + _25 = &mut ((*_8).0: std::slice::Iter<'_, T>); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + _7 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _25) -> [return: bb12, unwind: bb7]; // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back}, val: Value(<ZST>) } + } + + bb2: { + _10 = ((_7 as Some).0: &T); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + StorageLive(_11); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + _11 = &_2; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + StorageLive(_12); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + _12 = (_10,); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + _6 = <impl Fn(&T) as Fn<(&T,)>>::call(move _11, move _12) -> [return: bb5, unwind: bb7]; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:13 + // mir::Constant + // + span: $DIR/slice_iter.rs:36:9: 36:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(&T), (&T,)) -> <impl Fn(&T) as FnOnce<(&T,)>>::Output {<impl Fn(&T) as Fn<(&T,)>>::call}, val: Value(<ZST>) } + } + + bb3: { + unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + } + + bb4: { + StorageDead(_7); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + StorageDead(_5); // scope 0 at $DIR/slice_iter.rs:+3:5: +3:6 + drop(_2) -> bb6; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb5: { + StorageDead(_12); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13 + StorageDead(_11); // scope 2 at $DIR/slice_iter.rs:+2:12: +2:13 + StorageDead(_7); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } + + bb6: { + return; // scope 0 at $DIR/slice_iter.rs:+4:2: +4:2 + } + + bb7 (cleanup): { + drop(_2) -> [return: bb8, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb8 (cleanup): { + resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +4:2 + } + + bb9: { + StorageLive(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _16 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _14 = _16 as *const T (Transmute); // scope 10 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_16); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb11; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb10: { + StorageLive(_17); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _17 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _14 = Offset(_13, _17); // scope 12 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + StorageDead(_17); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb11; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb11: { + StorageDead(_15); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _19 = _13 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _22 = _19 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + _18 = NonNull::<T> { pointer: _22 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + StorageDead(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_19); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_20); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _20 = _14; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _4 = std::slice::Iter::<'_, T> { ptr: move _18, end: move _20, _marker: const ZeroSized: PhantomData<&T> }; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: PhantomData<&T>, val: Value(<ZST>) } + // adt + // + user_ty: UserType(1) + StorageDead(_20); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_18); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_14); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _3 = Rev::<std::slice::Iter<'_, T>> { iter: move _4 }; // scope 23 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + StorageDead(_4); // scope 0 at $DIR/slice_iter.rs:+1:31: +1:32 + StorageLive(_5); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + _5 = move _3; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:32 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } + + bb12: { + StorageDead(_25); // scope 25 at $SRC_DIR/core/src/iter/adapters/rev.rs:LL:COL + _9 = discriminant(_7); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + switchInt(move _9) -> [0: bb4, 1: bb2, otherwise: bb3]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:32 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs new file mode 100644 index 000000000..ca423ca55 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -0,0 +1,38 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +// When this test was added, the MIR for `next` was 174 lines just for the basic +// blocks -- far more if you counted the scopes. The goal of having this here +// is to hopefully keep it a reasonable size, ideally eventually small enough +// that the mir inliner would actually be willing to inline it, since it's an +// important building block and usually very few *backend* instructions. + +// As such, feel free to `--bless` whatever changes you get here, so long as +// doing so doesn't add substantially more MIR. + +// EMIT_MIR slice_iter.slice_iter_next.PreCodegen.after.mir +pub fn slice_iter_next<'a, T>(it: &mut std::slice::Iter<'a, T>) -> Option<&'a T> { + it.next() +} + +// EMIT_MIR slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir +pub fn slice_iter_mut_next_back<'a, T>(it: &mut std::slice::IterMut<'a, T>) -> Option<&'a mut T> { + it.next_back() +} + +// EMIT_MIR slice_iter.forward_loop.PreCodegen.after.mir +pub fn forward_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { + for x in slice.iter() { + f(x) + } +} + +// EMIT_MIR slice_iter.reverse_loop.PreCodegen.after.mir +pub fn reverse_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { + for x in slice.iter().rev() { + f(x) + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir new file mode 100644 index 000000000..a1431d473 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.mir @@ -0,0 +1,17 @@ +// MIR for `slice_iter_mut_next_back` after PreCodegen + +fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut T> { + debug it => _1; // in scope 0 at $DIR/slice_iter.rs:+0:40: +0:42 + let mut _0: std::option::Option<&mut T>; // return place in scope 0 at $DIR/slice_iter.rs:+0:80: +0:97 + + bb0: { + _0 = <std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back(_1) -> bb1; // scope 0 at $DIR/slice_iter.rs:+1:5: +1:19 + // mir::Constant + // + span: $DIR/slice_iter.rs:23:8: 23:17 + // + literal: Const { ty: for<'a> fn(&'a mut std::slice::IterMut<'_, T>) -> Option<<std::slice::IterMut<'_, T> as Iterator>::Item> {<std::slice::IterMut<'_, T> as DoubleEndedIterator>::next_back}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/slice_iter.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir new file mode 100644 index 000000000..d2a963cad --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.mir @@ -0,0 +1,17 @@ +// MIR for `slice_iter_next` after PreCodegen + +fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { + debug it => _1; // in scope 0 at $DIR/slice_iter.rs:+0:31: +0:33 + let mut _0: std::option::Option<&T>; // return place in scope 0 at $DIR/slice_iter.rs:+0:68: +0:81 + + bb0: { + _0 = <std::slice::Iter<'_, T> as Iterator>::next(_1) -> bb1; // scope 0 at $DIR/slice_iter.rs:+1:5: +1:14 + // mir::Constant + // + span: $DIR/slice_iter.rs:18:8: 18:12 + // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, T>) -> Option<<std::slice::Iter<'_, T> as Iterator>::Item> {<std::slice::Iter<'_, T> as Iterator>::next}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/slice_iter.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir index 935dbb28b..53971b4cf 100644 --- a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir @@ -1,66 +1,70 @@ // MIR for `new` after PreCodegen fn new(_1: Result<T, E>) -> Result<T, E> { - debug x => _1; // in scope 0 at $DIR/try_identity_e2e.rs:+0:14: +0:15 - let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 - let mut _2: std::ops::ControlFlow<E, T>; // in scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - let mut _3: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:22 - let _4: T; // in scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - let _5: E; // in scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - let mut _6: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+8:13: +8:37 - let _7: T; // in scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - let _8: E; // in scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 + debug x => _1; // in scope 0 at $DIR/try_identity.rs:+0:14: +0:15 + let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity.rs:+0:34: +0:46 + let mut _2: std::ops::ControlFlow<E, T>; // in scope 0 at $DIR/try_identity.rs:+2:15: +7:10 + let mut _3: isize; // in scope 0 at $DIR/try_identity.rs:+4:17: +4:22 + let _4: T; // in scope 0 at $DIR/try_identity.rs:+4:20: +4:21 + let _5: E; // in scope 0 at $DIR/try_identity.rs:+5:21: +5:22 + let mut _6: isize; // in scope 0 at $DIR/try_identity.rs:+8:13: +8:37 + let _7: T; // in scope 0 at $DIR/try_identity.rs:+8:35: +8:36 + let _8: E; // in scope 0 at $DIR/try_identity.rs:+9:32: +9:33 scope 1 { - debug v => _4; // in scope 1 at $DIR/try_identity_e2e.rs:+4:20: +4:21 + debug v => _4; // in scope 1 at $DIR/try_identity.rs:+4:20: +4:21 } scope 2 { - debug e => _5; // in scope 2 at $DIR/try_identity_e2e.rs:+5:21: +5:22 + debug e => _5; // in scope 2 at $DIR/try_identity.rs:+5:21: +5:22 } scope 3 { - debug v => _7; // in scope 3 at $DIR/try_identity_e2e.rs:+8:35: +8:36 + debug v => _7; // in scope 3 at $DIR/try_identity.rs:+8:35: +8:36 } scope 4 { - debug e => _8; // in scope 4 at $DIR/try_identity_e2e.rs:+9:32: +9:33 + debug e => _8; // in scope 4 at $DIR/try_identity.rs:+9:32: +9:33 } bb0: { - StorageLive(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - _3 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 + StorageLive(_2); // scope 0 at $DIR/try_identity.rs:+2:15: +7:10 + _3 = discriminant(_1); // scope 0 at $DIR/try_identity.rs:+3:19: +3:20 + switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+3:13: +3:20 } bb1: { - _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - _2 = ControlFlow::<E, T>::Break(move _5); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - goto -> bb4; // scope 0 at $DIR/try_identity_e2e.rs:+5:47: +5:48 + _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity.rs:+5:21: +5:22 + _2 = ControlFlow::<E, T>::Break(move _5); // scope 2 at $DIR/try_identity.rs:+5:27: +5:48 + goto -> bb4; // scope 0 at $DIR/try_identity.rs:+5:47: +5:48 } bb2: { - unreachable; // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 + unreachable; // scope 0 at $DIR/try_identity.rs:+3:19: +3:20 } bb3: { - _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - _2 = ControlFlow::<E, T>::Continue(move _4); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - goto -> bb4; // scope 0 at $DIR/try_identity_e2e.rs:+4:49: +4:50 + _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity.rs:+4:20: +4:21 + _2 = ControlFlow::<E, T>::Continue(move _4); // scope 1 at $DIR/try_identity.rs:+4:26: +4:50 + goto -> bb4; // scope 0 at $DIR/try_identity.rs:+4:49: +4:50 } bb4: { - _6 = discriminant(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + _6 = discriminant(_2); // scope 0 at $DIR/try_identity.rs:+2:15: +7:10 + switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+2:9: +7:10 } bb5: { - _8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 - _0 = Result::<T, E>::Err(move _8); // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 - return; // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 + _8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity.rs:+9:32: +9:33 + _0 = Result::<T, E>::Err(move _8); // scope 4 at $DIR/try_identity.rs:+9:45: +9:51 + StorageDead(_2); // scope 0 at $DIR/try_identity.rs:+12:1: +12:2 + goto -> bb7; // scope 0 at $DIR/try_identity.rs:+12:1: +12:2 } bb6: { - _7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - _0 = Result::<T, E>::Ok(move _7); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 - return; // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 + _7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity.rs:+8:35: +8:36 + _0 = Result::<T, E>::Ok(move _7); // scope 0 at $DIR/try_identity.rs:+1:5: +11:6 + StorageDead(_2); // scope 0 at $DIR/try_identity.rs:+12:1: +12:2 + goto -> bb7; // scope 0 at $DIR/try_identity.rs:+12:1: +12:2 + } + + bb7: { + return; // scope 0 at $DIR/try_identity.rs:+12:2: +12:2 } } diff --git a/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir index d88ae5ac9..e217d1994 100644 --- a/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir @@ -1,36 +1,40 @@ // MIR for `old` after PreCodegen fn old(_1: Result<T, E>) -> Result<T, E> { - debug x => _1; // in scope 0 at $DIR/try_identity_e2e.rs:+0:14: +0:15 - let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 - let mut _2: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:18 - let _3: T; // in scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - let _4: E; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 + debug x => _1; // in scope 0 at $DIR/try_identity.rs:+0:14: +0:15 + let mut _0: std::result::Result<T, E>; // return place in scope 0 at $DIR/try_identity.rs:+0:34: +0:46 + let mut _2: isize; // in scope 0 at $DIR/try_identity.rs:+3:13: +3:18 + let _3: T; // in scope 0 at $DIR/try_identity.rs:+3:16: +3:17 + let _4: E; // in scope 0 at $DIR/try_identity.rs:+4:17: +4:18 scope 1 { - debug v => _3; // in scope 1 at $DIR/try_identity_e2e.rs:+3:16: +3:17 + debug v => _3; // in scope 1 at $DIR/try_identity.rs:+3:16: +3:17 } scope 2 { - debug e => _4; // in scope 2 at $DIR/try_identity_e2e.rs:+4:17: +4:18 + debug e => _4; // in scope 2 at $DIR/try_identity.rs:+4:17: +4:18 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +2:16 - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +2:16 + _2 = discriminant(_1); // scope 0 at $DIR/try_identity.rs:+2:15: +2:16 + switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity.rs:+2:9: +2:16 } bb1: { - _4 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 - _0 = Result::<T, E>::Err(move _4); // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36 - return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 + _4 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity.rs:+4:17: +4:18 + _0 = Result::<T, E>::Err(move _4); // scope 2 at $DIR/try_identity.rs:+4:30: +4:36 + goto -> bb4; // scope 0 at $DIR/try_identity.rs:+7:1: +7:2 } bb2: { - unreachable; // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +2:16 + unreachable; // scope 0 at $DIR/try_identity.rs:+2:15: +2:16 } bb3: { - _3 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - _0 = Result::<T, E>::Ok(move _3); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6 - return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 + _3 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity.rs:+3:16: +3:17 + _0 = Result::<T, E>::Ok(move _3); // scope 0 at $DIR/try_identity.rs:+1:5: +6:6 + goto -> bb4; // scope 0 at $DIR/try_identity.rs:+7:1: +7:2 + } + + bb4: { + return; // scope 0 at $DIR/try_identity.rs:+7:2: +7:2 } } diff --git a/tests/mir-opt/try_identity_e2e.rs b/tests/mir-opt/pre-codegen/try_identity.rs index 00cb80f50..079ecccab 100644 --- a/tests/mir-opt/try_identity_e2e.rs +++ b/tests/mir-opt/pre-codegen/try_identity.rs @@ -1,9 +1,13 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + // Track the status of MIR optimizations simplifying `Ok(res?)` for both the old and new desugarings // of that syntax. use std::ops::ControlFlow; -// EMIT_MIR try_identity_e2e.new.PreCodegen.after.mir +// EMIT_MIR try_identity.new.PreCodegen.after.mir fn new<T, E>(x: Result<T, E>) -> Result<T, E> { Ok( match { @@ -18,7 +22,7 @@ fn new<T, E>(x: Result<T, E>) -> Result<T, E> { ) } -// EMIT_MIR try_identity_e2e.old.PreCodegen.after.mir +// EMIT_MIR try_identity.old.PreCodegen.after.mir fn old<T, E>(x: Result<T, E>) -> Result<T, E> { Ok( match x { diff --git a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff new file mode 100644 index 000000000..07bd48fc8 --- /dev/null +++ b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff @@ -0,0 +1,175 @@ +- // MIR for `debuginfo` before ReferencePropagation ++ // MIR for `debuginfo` after ReferencePropagation + + fn debuginfo() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:16: +0:16 + let _1: &mut u8; // in scope 0 at $DIR/reference_prop.rs:+3:9: +3:19 + let mut _2: u8; // in scope 0 at $DIR/reference_prop.rs:+3:27: +3:31 + let _4: debuginfo::T; // in scope 0 at $DIR/reference_prop.rs:+4:18: +4:22 + let _6: (); // in scope 0 at $DIR/reference_prop.rs:+9:5: +12:6 + let mut _7: std::option::Option<i32>; // in scope 0 at $DIR/reference_prop.rs:+9:11: +9:18 + let mut _8: isize; // in scope 0 at $DIR/reference_prop.rs:+10:9: +10:13 + let _10: (); // in scope 0 at $DIR/reference_prop.rs:+16:5: +17:6 + let mut _11: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:82: +16:94 + let _12: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:94 + let mut _13: &[i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90 + let _14: [i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90 + let mut _15: std::ops::RangeFull; // in scope 0 at $DIR/reference_prop.rs:+16:91: +16:93 + let mut _16: usize; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79 + let mut _17: usize; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79 + let mut _18: bool; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79 + let _23: &&mut u8; // in scope 0 at $DIR/reference_prop.rs:+19:28: +19:40 + let _24: &mut u8; // in scope 0 at $DIR/reference_prop.rs:+19:29: +19:40 + let mut _25: debuginfo::T; // in scope 0 at $DIR/reference_prop.rs:+19:34: +19:38 + scope 1 { +- debug ref_mut_u8 => _1; // in scope 1 at $DIR/reference_prop.rs:+3:9: +3:19 ++ debug ref_mut_u8 => &_2; // in scope 1 at $DIR/reference_prop.rs:+3:9: +3:19 + let _3: &u8; // in scope 1 at $DIR/reference_prop.rs:+4:9: +4:14 + let mut _28: &debuginfo::T; // in scope 1 at $DIR/reference_prop.rs:+4:17: +4:24 + scope 2 { +- debug field => _3; // in scope 2 at $DIR/reference_prop.rs:+4:9: +4:14 ++ debug field => &((*_28).0: u8); // in scope 2 at $DIR/reference_prop.rs:+4:9: +4:14 + let _5: &u8; // in scope 2 at $DIR/reference_prop.rs:+7:9: +7:17 + scope 3 { +- debug reborrow => _5; // in scope 3 at $DIR/reference_prop.rs:+7:9: +7:17 ++ debug reborrow => &_2; // in scope 3 at $DIR/reference_prop.rs:+7:9: +7:17 + let _9: &i32; // in scope 3 at $DIR/reference_prop.rs:+11:14: +11:31 + let _22: &&&mut u8; // in scope 3 at $DIR/reference_prop.rs:+19:9: +19:24 + let mut _27: &std::option::Option<i32>; // in scope 3 at $DIR/reference_prop.rs:+11:14: +11:31 + scope 4 { +- debug variant_field => _9; // in scope 4 at $DIR/reference_prop.rs:+11:14: +11:31 ++ debug variant_field => &(((*_27) as Some).0: i32); // in scope 4 at $DIR/reference_prop.rs:+11:14: +11:31 + } + scope 5 { +- debug constant_index => _19; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34 ++ debug constant_index => &(*_11)[1 of 3]; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34 + debug subslice => _20; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44 + debug constant_index_from_end => _21; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78 + let _19: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34 + let _20: &[i32]; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44 + let _21: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78 + let mut _26: &[i32; 10]; // in scope 5 at $DIR/reference_prop.rs:+16:83: +16:90 + } + scope 6 { +- debug multiple_borrow => _22; // in scope 6 at $DIR/reference_prop.rs:+19:9: +19:24 ++ debug multiple_borrow => &&&(_25.0: u8); // in scope 6 at $DIR/reference_prop.rs:+19:9: +19:24 + } + } + } + } + + bb0: { +- StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+3:9: +3:19 + StorageLive(_2); // scope 0 at $DIR/reference_prop.rs:+3:27: +3:31 + _2 = const 5_u8; // scope 0 at $DIR/reference_prop.rs:+3:27: +3:31 +- _1 = &mut _2; // scope 0 at $DIR/reference_prop.rs:+3:22: +3:31 +- StorageLive(_3); // scope 1 at $DIR/reference_prop.rs:+4:9: +4:14 + _28 = const _; // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24 + // mir::Constant + // + span: $DIR/reference_prop.rs:535:17: 535:24 + // + literal: Const { ty: &T, val: Unevaluated(debuginfo, [], Some(promoted[2])) } +- _3 = &((*_28).0: u8); // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24 +- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+7:9: +7:17 +- _5 = &(*_1); // scope 2 at $DIR/reference_prop.rs:+7:20: +7:32 +- StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+9:5: +12:6 + StorageLive(_7); // scope 3 at $DIR/reference_prop.rs:+9:11: +9:18 + _7 = Option::<i32>::Some(const 0_i32); // scope 3 at $DIR/reference_prop.rs:+9:11: +9:18 + _8 = discriminant(_7); // scope 3 at $DIR/reference_prop.rs:+9:11: +9:18 + switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 3 at $DIR/reference_prop.rs:+9:5: +9:18 + } + + bb1: { +- StorageLive(_9); // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31 + _27 = const _; // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31 + // mir::Constant + // + span: $DIR/reference_prop.rs:542:14: 542:31 + // + literal: Const { ty: &Option<i32>, val: Unevaluated(debuginfo, [], Some(promoted[1])) } +- _9 = &(((*_27) as Some).0: i32); // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31 +- _6 = const (); // scope 4 at $DIR/reference_prop.rs:+11:36: +11:38 +- StorageDead(_9); // scope 3 at $DIR/reference_prop.rs:+11:37: +11:38 + goto -> bb4; // scope 3 at $DIR/reference_prop.rs:+11:37: +11:38 + } + + bb2: { + unreachable; // scope 3 at $DIR/reference_prop.rs:+9:11: +9:18 + } + + bb3: { +- _6 = const (); // scope 3 at $DIR/reference_prop.rs:+10:17: +10:19 + goto -> bb4; // scope 3 at $DIR/reference_prop.rs:+10:17: +10:19 + } + + bb4: { + StorageDead(_7); // scope 3 at $DIR/reference_prop.rs:+12:5: +12:6 +- StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+12:5: +12:6 +- StorageLive(_10); // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6 + StorageLive(_11); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94 + StorageLive(_12); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94 + StorageLive(_13); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90 + _26 = const _; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90 + // mir::Constant + // + span: $DIR/reference_prop.rs:547:83: 547:90 + // + literal: Const { ty: &[i32; 10], val: Unevaluated(debuginfo, [], Some(promoted[0])) } + _13 = &(*_26); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90 + StorageLive(_15); // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93 + _15 = RangeFull; // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93 + _12 = <[i32; 10] as Index<RangeFull>>::index(move _13, move _15) -> bb5; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94 + // mir::Constant + // + span: $DIR/reference_prop.rs:547:83: 547:94 + // + literal: Const { ty: for<'a> fn(&'a [i32; 10], RangeFull) -> &'a <[i32; 10] as Index<RangeFull>>::Output {<[i32; 10] as Index<RangeFull>>::index}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_15); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94 + StorageDead(_13); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94 + _11 = &(*_12); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94 + _16 = Len((*_11)); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79 + _17 = const 3_usize; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79 + _18 = Ge(move _16, move _17); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79 + switchInt(move _18) -> [0: bb7, otherwise: bb6]; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79 + } + + bb6: { +- StorageLive(_19); // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34 +- _19 = &(*_11)[1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34 + StorageLive(_20); // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44 + _20 = &(*_11)[2:-1]; // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44 + StorageLive(_21); // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78 + _21 = &(*_11)[-1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78 +- _10 = const (); // scope 5 at $DIR/reference_prop.rs:+16:95: +17:6 + StorageDead(_21); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 + StorageDead(_20); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 +- StorageDead(_19); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 + goto -> bb8; // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6 + } + + bb7: { +- _10 = const (); // scope 3 at $DIR/reference_prop.rs:+17:6: +17:6 + goto -> bb8; // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6 + } + + bb8: { + StorageDead(_12); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 + StorageDead(_11); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 +- StorageDead(_10); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6 +- StorageLive(_22); // scope 3 at $DIR/reference_prop.rs:+19:9: +19:24 +- StorageLive(_23); // scope 3 at $DIR/reference_prop.rs:+19:28: +19:40 +- StorageLive(_24); // scope 3 at $DIR/reference_prop.rs:+19:29: +19:40 + StorageLive(_25); // scope 3 at $DIR/reference_prop.rs:+19:34: +19:38 + _25 = T(const 6_u8); // scope 3 at $DIR/reference_prop.rs:+19:34: +19:38 +- _24 = &mut (_25.0: u8); // scope 3 at $DIR/reference_prop.rs:+19:29: +19:40 +- _23 = &_24; // scope 3 at $DIR/reference_prop.rs:+19:28: +19:40 +- _22 = &_23; // scope 3 at $DIR/reference_prop.rs:+19:27: +19:40 + _0 = const (); // scope 0 at $DIR/reference_prop.rs:+0:16: +20:2 + StorageDead(_25); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_24); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_23); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_22); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_3); // scope 1 at $DIR/reference_prop.rs:+20:1: +20:2 + StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+20:1: +20:2 +- StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+20:1: +20:2 + return; // scope 0 at $DIR/reference_prop.rs:+20:2: +20:2 + } + } + diff --git a/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff b/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff new file mode 100644 index 000000000..e158f64e9 --- /dev/null +++ b/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff @@ -0,0 +1,38 @@ +- // MIR for `dominate_storage` before ReferencePropagation ++ // MIR for `dominate_storage` after ReferencePropagation + + fn dominate_storage() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:23: +0:23 + let mut _1: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _6: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + goto -> bb1; // scope 0 at $DIR/reference_prop.rs:+8:11: +8:20 + } + + bb1: { + _1 = const 5_i32; // scope 0 at $DIR/reference_prop.rs:+10:13: +10:18 + _2 = &_1; // scope 0 at $DIR/reference_prop.rs:+11:13: +11:19 + goto -> bb2; // scope 0 at $DIR/reference_prop.rs:+12:13: +12:22 + } + + bb2: { + _5 = (*_2); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = opaque::<i32>(_5) -> bb3; // scope 0 at $DIR/reference_prop.rs:+16:13: +16:38 + // mir::Constant + // + span: $DIR/reference_prop.rs:455:28: 455:34 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+19:13: +19:27 + StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+20:13: +20:27 + _6 = const true; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + switchInt(_6) -> [0: bb3, otherwise: bb1]; // scope 0 at $DIR/reference_prop.rs:+22:13: +22:47 + } + } + diff --git a/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff b/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff new file mode 100644 index 000000000..38ab16ced --- /dev/null +++ b/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff @@ -0,0 +1,56 @@ +- // MIR for `maybe_dead` before ReferencePropagation ++ // MIR for `maybe_dead` after ReferencePropagation + + fn maybe_dead(_1: bool) -> () { + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:24: +0:24 + let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: &mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _6: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _7: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _8: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + StorageLive(_2); // scope 0 at $DIR/reference_prop.rs:+7:13: +7:27 + StorageLive(_3); // scope 0 at $DIR/reference_prop.rs:+8:13: +8:27 + _2 = const 5_i32; // scope 0 at $DIR/reference_prop.rs:+9:13: +9:18 + _3 = const 5_i32; // scope 0 at $DIR/reference_prop.rs:+10:13: +10:18 + _4 = &_2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _5 = &mut _3; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + (*_5) = const 7_i32; // scope 0 at $DIR/reference_prop.rs:+14:13: +14:19 +- _6 = (*_4); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _6 = _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + switchInt(_1) -> [1: bb1, otherwise: bb2]; // scope 0 at $DIR/reference_prop.rs:+17:13: +17:46 + } + + bb1: { + StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+20:13: +20:27 + StorageDead(_3); // scope 0 at $DIR/reference_prop.rs:+21:13: +21:27 + _0 = opaque::<i32>(_6) -> bb2; // scope 0 at $DIR/reference_prop.rs:+22:13: +22:38 + // mir::Constant + // + span: $DIR/reference_prop.rs:489:28: 489:34 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb2: { + _7 = (*_4); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = opaque::<i32>(_7) -> bb3; // scope 0 at $DIR/reference_prop.rs:+27:13: +27:38 + // mir::Constant + // + span: $DIR/reference_prop.rs:494:28: 494:34 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb3: { + _8 = (*_5); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = opaque::<i32>(_8) -> bb4; // scope 0 at $DIR/reference_prop.rs:+33:13: +33:43 + // mir::Constant + // + span: $DIR/reference_prop.rs:500:33: 500:39 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb4: { + return; // scope 0 at $DIR/reference_prop.rs:+36:13: +36:21 + } + } + diff --git a/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff b/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff new file mode 100644 index 000000000..6e4517868 --- /dev/null +++ b/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff @@ -0,0 +1,27 @@ +- // MIR for `multiple_storage` before ReferencePropagation ++ // MIR for `multiple_storage` after ReferencePropagation + + fn multiple_storage() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:23: +0:23 + let mut _1: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+6:13: +6:27 + _1 = const 5_i32; // scope 0 at $DIR/reference_prop.rs:+7:13: +7:18 + _2 = &_1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+9:13: +9:27 + StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+10:13: +10:27 + _3 = (*_2); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = opaque::<i32>(_3) -> bb1; // scope 0 at $DIR/reference_prop.rs:+14:13: +14:43 + // mir::Constant + // + span: $DIR/reference_prop.rs:429:33: 429:39 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb1: { + return; // scope 0 at $DIR/reference_prop.rs:+18:13: +18:21 + } + } + diff --git a/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff new file mode 100644 index 000000000..d99e11035 --- /dev/null +++ b/tests/mir-opt/reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff @@ -0,0 +1,75 @@ +- // MIR for `mut_raw_then_mut_shr` before ReferencePropagation ++ // MIR for `mut_raw_then_mut_shr` after ReferencePropagation + + fn mut_raw_then_mut_shr() -> (i32, i32) { + let mut _0: (i32, i32); // return place in scope 0 at $DIR/reference_prop.rs:+0:30: +0:40 + let mut _1: i32; // in scope 0 at $DIR/reference_prop.rs:+1:9: +1:14 + let mut _4: *mut i32; // in scope 0 at $DIR/reference_prop.rs:+3:16: +3:36 + let mut _5: &mut i32; // in scope 0 at $DIR/reference_prop.rs:+3:16: +3:26 + let _8: (); // in scope 0 at $DIR/reference_prop.rs:+7:5: +7:26 + let mut _9: i32; // in scope 0 at $DIR/reference_prop.rs:+8:6: +8:7 + let mut _10: i32; // in scope 0 at $DIR/reference_prop.rs:+8:9: +8:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/reference_prop.rs:+1:9: +1:14 + let _2: &mut i32; // in scope 1 at $DIR/reference_prop.rs:+2:9: +2:13 + scope 2 { +- debug xref => _2; // in scope 2 at $DIR/reference_prop.rs:+2:9: +2:13 ++ debug xref => &_1; // in scope 2 at $DIR/reference_prop.rs:+2:9: +2:13 + let _3: *mut i32; // in scope 2 at $DIR/reference_prop.rs:+3:9: +3:13 + scope 3 { +- debug xraw => _3; // in scope 3 at $DIR/reference_prop.rs:+3:9: +3:13 ++ debug xraw => &_1; // in scope 3 at $DIR/reference_prop.rs:+3:9: +3:13 + let _6: &i32; // in scope 3 at $DIR/reference_prop.rs:+4:9: +4:13 + scope 4 { +- debug xshr => _6; // in scope 4 at $DIR/reference_prop.rs:+4:9: +4:13 ++ debug xshr => &_1; // in scope 4 at $DIR/reference_prop.rs:+4:9: +4:13 + let _7: i32; // in scope 4 at $DIR/reference_prop.rs:+6:9: +6:10 + scope 5 { + debug a => _7; // in scope 5 at $DIR/reference_prop.rs:+6:9: +6:10 + scope 6 { + } + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+1:9: +1:14 + _1 = const 2_i32; // scope 0 at $DIR/reference_prop.rs:+1:17: +1:18 +- StorageLive(_2); // scope 1 at $DIR/reference_prop.rs:+2:9: +2:13 +- _2 = &mut _1; // scope 1 at $DIR/reference_prop.rs:+2:16: +2:22 +- StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:9: +3:13 +- StorageLive(_4); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36 +- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26 +- _5 = &mut (*_2); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26 +- _4 = &raw mut (*_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26 +- _3 = _4; // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36 +- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37 +- StorageDead(_4); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37 +- StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+4:9: +4:13 +- _6 = &(*_2); // scope 3 at $DIR/reference_prop.rs:+4:16: +4:22 + StorageLive(_7); // scope 4 at $DIR/reference_prop.rs:+6:9: +6:10 +- _7 = (*_6); // scope 4 at $DIR/reference_prop.rs:+6:13: +6:18 +- StorageLive(_8); // scope 5 at $DIR/reference_prop.rs:+7:5: +7:26 +- (*_3) = const 4_i32; // scope 6 at $DIR/reference_prop.rs:+7:14: +7:23 +- _8 = const (); // scope 6 at $DIR/reference_prop.rs:+7:5: +7:26 +- StorageDead(_8); // scope 5 at $DIR/reference_prop.rs:+7:25: +7:26 ++ _7 = _1; // scope 4 at $DIR/reference_prop.rs:+6:13: +6:18 ++ _1 = const 4_i32; // scope 6 at $DIR/reference_prop.rs:+7:14: +7:23 + StorageLive(_9); // scope 5 at $DIR/reference_prop.rs:+8:6: +8:7 + _9 = _7; // scope 5 at $DIR/reference_prop.rs:+8:6: +8:7 + StorageLive(_10); // scope 5 at $DIR/reference_prop.rs:+8:9: +8:10 + _10 = _1; // scope 5 at $DIR/reference_prop.rs:+8:9: +8:10 + _0 = (move _9, move _10); // scope 5 at $DIR/reference_prop.rs:+8:5: +8:11 + StorageDead(_10); // scope 5 at $DIR/reference_prop.rs:+8:10: +8:11 + StorageDead(_9); // scope 5 at $DIR/reference_prop.rs:+8:10: +8:11 + StorageDead(_7); // scope 4 at $DIR/reference_prop.rs:+9:1: +9:2 +- StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+9:1: +9:2 +- StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+9:1: +9:2 +- StorageDead(_2); // scope 1 at $DIR/reference_prop.rs:+9:1: +9:2 + StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+9:1: +9:2 + return; // scope 0 at $DIR/reference_prop.rs:+9:2: +9:2 + } + } + diff --git a/tests/mir-opt/reference_prop.read_through_raw.ReferencePropagation.diff b/tests/mir-opt/reference_prop.read_through_raw.ReferencePropagation.diff new file mode 100644 index 000000000..75c1f8f57 --- /dev/null +++ b/tests/mir-opt/reference_prop.read_through_raw.ReferencePropagation.diff @@ -0,0 +1,23 @@ +- // MIR for `read_through_raw` before ReferencePropagation ++ // MIR for `read_through_raw` after ReferencePropagation + + fn read_through_raw(_1: &mut usize) -> usize { + let mut _0: usize; // return place in scope 0 at $DIR/reference_prop.rs:+0:39: +0:44 + let mut _2: &mut usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: &mut usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: *mut usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: *mut usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _2 = &mut (*_1); // scope 0 at $DIR/reference_prop.rs:+10:13: +10:25 +- _3 = &mut (*_2); // scope 0 at $DIR/reference_prop.rs:+11:13: +11:26 +- _4 = &raw mut (*_2); // scope 0 at $DIR/reference_prop.rs:+12:13: +12:30 +- _5 = &raw mut (*_3); // scope 0 at $DIR/reference_prop.rs:+13:13: +13:30 +- _0 = (*_4); // scope 0 at $DIR/reference_prop.rs:+15:13: +15:22 +- _0 = (*_5); // scope 0 at $DIR/reference_prop.rs:+16:13: +16:22 ++ _0 = (*_1); // scope 0 at $DIR/reference_prop.rs:+15:13: +15:22 ++ _0 = (*_1); // scope 0 at $DIR/reference_prop.rs:+16:13: +16:22 + return; // scope 0 at $DIR/reference_prop.rs:+17:13: +17:21 + } + } + diff --git a/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff new file mode 100644 index 000000000..7b31ee695 --- /dev/null +++ b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff @@ -0,0 +1,475 @@ +- // MIR for `reference_propagation` before ReferencePropagation ++ // MIR for `reference_propagation` after ReferencePropagation + + fn reference_propagation(_1: &T, _2: &T) -> () { + debug single => _1; // in scope 0 at $DIR/reference_prop.rs:+0:39: +0:45 + debug multiple => _2; // in scope 0 at $DIR/reference_prop.rs:+0:54: +0:66 + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:75: +0:75 + let _3: (); // in scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + let _4: usize; // in scope 0 at $DIR/reference_prop.rs:+3:13: +3:14 + let _7: (); // in scope 0 at $DIR/reference_prop.rs:+6:9: +6:19 + let mut _8: (); // in scope 0 at $DIR/reference_prop.rs:+6:16: +6:18 + let _9: (); // in scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + let _10: usize; // in scope 0 at $DIR/reference_prop.rs:+11:13: +11:14 + let mut _13: &usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:16 + let _14: &usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:16 + let _16: (); // in scope 0 at $DIR/reference_prop.rs:+17:9: +17:19 + let mut _17: (); // in scope 0 at $DIR/reference_prop.rs:+17:16: +17:18 + let _18: (); // in scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + let _19: usize; // in scope 0 at $DIR/reference_prop.rs:+22:13: +22:14 + let _23: (); // in scope 0 at $DIR/reference_prop.rs:+26:9: +26:18 + let mut _24: &&usize; // in scope 0 at $DIR/reference_prop.rs:+26:16: +26:17 + let _25: (); // in scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + let _26: usize; // in scope 0 at $DIR/reference_prop.rs:+31:13: +31:14 + let _30: (); // in scope 0 at $DIR/reference_prop.rs:+35:9: +35:18 + let mut _31: *mut &usize; // in scope 0 at $DIR/reference_prop.rs:+35:16: +35:17 + let _32: (); // in scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + let _33: usize; // in scope 0 at $DIR/reference_prop.rs:+40:13: +40:14 + let _36: (); // in scope 0 at $DIR/reference_prop.rs:+43:9: +43:18 + let mut _37: &usize; // in scope 0 at $DIR/reference_prop.rs:+43:16: +43:17 + let _38: (); // in scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + let _39: usize; // in scope 0 at $DIR/reference_prop.rs:+48:13: +48:14 + let _45: (); // in scope 0 at $DIR/reference_prop.rs:+56:9: +56:19 + let mut _46: &usize; // in scope 0 at $DIR/reference_prop.rs:+56:16: +56:18 + let _47: (); // in scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + let _48: &T; // in scope 0 at $DIR/reference_prop.rs:+61:13: +61:14 + let _50: (); // in scope 0 at $DIR/reference_prop.rs:+63:9: +63:19 + let mut _51: (); // in scope 0 at $DIR/reference_prop.rs:+63:16: +63:18 + let _52: (); // in scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + let _53: &T; // in scope 0 at $DIR/reference_prop.rs:+68:13: +68:14 + let mut _54: &T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:28 + let _55: &T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:28 + let _57: (); // in scope 0 at $DIR/reference_prop.rs:+71:9: +71:19 + let mut _58: (); // in scope 0 at $DIR/reference_prop.rs:+71:16: +71:18 + let _59: (); // in scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + let _60: usize; // in scope 0 at $DIR/reference_prop.rs:+76:13: +76:14 + let _64: (); // in scope 0 at $DIR/reference_prop.rs:+80:9: +80:19 + let mut _65: (); // in scope 0 at $DIR/reference_prop.rs:+80:16: +80:18 + let _66: usize; // in scope 0 at $DIR/reference_prop.rs:+85:13: +85:14 + let _70: (); // in scope 0 at $DIR/reference_prop.rs:+89:9: +89:19 + let mut _71: (); // in scope 0 at $DIR/reference_prop.rs:+89:16: +89:18 + scope 1 { + debug a => _4; // in scope 1 at $DIR/reference_prop.rs:+3:13: +3:14 + let _5: &usize; // in scope 1 at $DIR/reference_prop.rs:+4:13: +4:14 + scope 2 { +- debug b => _5; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 ++ debug b => &_4; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 + let _6: usize; // in scope 2 at $DIR/reference_prop.rs:+5:13: +5:14 + scope 3 { + debug c => _6; // in scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 + } + } + } + scope 4 { + debug a => _10; // in scope 4 at $DIR/reference_prop.rs:+11:13: +11:14 + let _11: usize; // in scope 4 at $DIR/reference_prop.rs:+12:13: +12:15 + scope 5 { + debug a2 => _11; // in scope 5 at $DIR/reference_prop.rs:+12:13: +12:15 + let mut _12: &usize; // in scope 5 at $DIR/reference_prop.rs:+13:13: +13:18 + scope 6 { + debug b => _12; // in scope 6 at $DIR/reference_prop.rs:+13:13: +13:18 + let _15: usize; // in scope 6 at $DIR/reference_prop.rs:+16:13: +16:14 + scope 7 { + debug c => _15; // in scope 7 at $DIR/reference_prop.rs:+16:13: +16:14 + } + } + } + } + scope 8 { + debug a => _19; // in scope 8 at $DIR/reference_prop.rs:+22:13: +22:14 + let _20: &usize; // in scope 8 at $DIR/reference_prop.rs:+23:13: +23:14 + scope 9 { + debug b => _20; // in scope 9 at $DIR/reference_prop.rs:+23:13: +23:14 + let _21: &&usize; // in scope 9 at $DIR/reference_prop.rs:+24:13: +24:14 + scope 10 { + debug d => _21; // in scope 10 at $DIR/reference_prop.rs:+24:13: +24:14 + let _22: usize; // in scope 10 at $DIR/reference_prop.rs:+25:13: +25:14 + scope 11 { + debug c => _22; // in scope 11 at $DIR/reference_prop.rs:+25:13: +25:14 + } + } + } + } + scope 12 { + debug a => _26; // in scope 12 at $DIR/reference_prop.rs:+31:13: +31:14 + let mut _27: &usize; // in scope 12 at $DIR/reference_prop.rs:+32:13: +32:18 + scope 13 { + debug b => _27; // in scope 13 at $DIR/reference_prop.rs:+32:13: +32:18 + let _28: *mut &usize; // in scope 13 at $DIR/reference_prop.rs:+33:13: +33:14 + scope 14 { + debug d => _28; // in scope 14 at $DIR/reference_prop.rs:+33:13: +33:14 + let _29: usize; // in scope 14 at $DIR/reference_prop.rs:+34:13: +34:14 + scope 15 { + debug c => _29; // in scope 15 at $DIR/reference_prop.rs:+34:13: +34:14 + } + } + } + } + scope 16 { + debug a => _33; // in scope 16 at $DIR/reference_prop.rs:+40:13: +40:14 + let _34: &usize; // in scope 16 at $DIR/reference_prop.rs:+41:13: +41:14 + scope 17 { + debug b => _34; // in scope 17 at $DIR/reference_prop.rs:+41:13: +41:14 + let _35: usize; // in scope 17 at $DIR/reference_prop.rs:+42:13: +42:14 + scope 18 { + debug c => _35; // in scope 18 at $DIR/reference_prop.rs:+42:13: +42:14 + } + } + } + scope 19 { + debug a => _39; // in scope 19 at $DIR/reference_prop.rs:+48:13: +48:14 + let _40: &usize; // in scope 19 at $DIR/reference_prop.rs:+49:13: +49:15 + scope 20 { + debug b1 => _40; // in scope 20 at $DIR/reference_prop.rs:+49:13: +49:15 + let _41: usize; // in scope 20 at $DIR/reference_prop.rs:+50:13: +50:14 + scope 21 { + debug c => _41; // in scope 21 at $DIR/reference_prop.rs:+50:13: +50:14 + let _42: &usize; // in scope 21 at $DIR/reference_prop.rs:+51:13: +51:15 + scope 22 { + debug b2 => _42; // in scope 22 at $DIR/reference_prop.rs:+51:13: +51:15 + let _43: usize; // in scope 22 at $DIR/reference_prop.rs:+52:13: +52:15 + scope 23 { + debug c2 => _43; // in scope 23 at $DIR/reference_prop.rs:+52:13: +52:15 + let _44: &usize; // in scope 23 at $DIR/reference_prop.rs:+53:13: +53:15 + scope 24 { + debug b3 => _44; // in scope 24 at $DIR/reference_prop.rs:+53:13: +53:15 + } + } + } + } + } + } + scope 25 { +- debug a => _48; // in scope 25 at $DIR/reference_prop.rs:+61:13: +61:14 ++ debug a => _1; // in scope 25 at $DIR/reference_prop.rs:+61:13: +61:14 + let _49: T; // in scope 25 at $DIR/reference_prop.rs:+62:13: +62:14 + scope 26 { + debug b => _49; // in scope 26 at $DIR/reference_prop.rs:+62:13: +62:14 + } + } + scope 27 { + debug a => _53; // in scope 27 at $DIR/reference_prop.rs:+68:13: +68:14 + let _56: T; // in scope 27 at $DIR/reference_prop.rs:+70:13: +70:14 + scope 28 { + debug b => _56; // in scope 28 at $DIR/reference_prop.rs:+70:13: +70:14 + } + } + scope 29 { + debug a => _60; // in scope 29 at $DIR/reference_prop.rs:+76:13: +76:14 + let _61: &usize; // in scope 29 at $DIR/reference_prop.rs:+77:13: +77:14 + scope 30 { +- debug b => _61; // in scope 30 at $DIR/reference_prop.rs:+77:13: +77:14 ++ debug b => &_60; // in scope 30 at $DIR/reference_prop.rs:+77:13: +77:14 + let _62: &&usize; // in scope 30 at $DIR/reference_prop.rs:+78:13: +78:14 + scope 31 { +- debug d => _62; // in scope 31 at $DIR/reference_prop.rs:+78:13: +78:14 ++ debug d => &&_60; // in scope 31 at $DIR/reference_prop.rs:+78:13: +78:14 + let _63: usize; // in scope 31 at $DIR/reference_prop.rs:+79:13: +79:14 + scope 32 { + debug c => _63; // in scope 32 at $DIR/reference_prop.rs:+79:13: +79:14 + } + } + } + } + scope 33 { + debug a => _66; // in scope 33 at $DIR/reference_prop.rs:+85:13: +85:14 + let mut _67: &usize; // in scope 33 at $DIR/reference_prop.rs:+86:13: +86:18 + scope 34 { +- debug b => _67; // in scope 34 at $DIR/reference_prop.rs:+86:13: +86:18 ++ debug b => &_66; // in scope 34 at $DIR/reference_prop.rs:+86:13: +86:18 + let _68: &mut &usize; // in scope 34 at $DIR/reference_prop.rs:+87:13: +87:14 + scope 35 { +- debug d => _68; // in scope 35 at $DIR/reference_prop.rs:+87:13: +87:14 ++ debug d => &&_66; // in scope 35 at $DIR/reference_prop.rs:+87:13: +87:14 + let _69: usize; // in scope 35 at $DIR/reference_prop.rs:+88:13: +88:14 + scope 36 { + debug c => _69; // in scope 36 at $DIR/reference_prop.rs:+88:13: +88:14 + } + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageLive(_4); // scope 0 at $DIR/reference_prop.rs:+3:13: +3:14 + _4 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+3:17: +3:24 +- StorageLive(_5); // scope 1 at $DIR/reference_prop.rs:+4:13: +4:14 +- _5 = &_4; // scope 1 at $DIR/reference_prop.rs:+4:17: +4:19 + StorageLive(_6); // scope 2 at $DIR/reference_prop.rs:+5:13: +5:14 +- _6 = (*_5); // scope 2 at $DIR/reference_prop.rs:+5:17: +5:19 ++ _6 = _4; // scope 2 at $DIR/reference_prop.rs:+5:17: +5:19 + StorageLive(_7); // scope 3 at $DIR/reference_prop.rs:+6:9: +6:19 + StorageLive(_8); // scope 3 at $DIR/reference_prop.rs:+6:16: +6:18 + _8 = (); // scope 3 at $DIR/reference_prop.rs:+6:16: +6:18 + _7 = opaque::<()>(move _8) -> bb1; // scope 3 at $DIR/reference_prop.rs:+6:9: +6:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:16:9: 16:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 3 at $DIR/reference_prop.rs:+6:18: +6:19 + StorageDead(_7); // scope 3 at $DIR/reference_prop.rs:+6:19: +6:20 +- _3 = const (); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageDead(_6); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_5); // scope 1 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageDead(_4); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_3); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageLive(_9); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageLive(_10); // scope 0 at $DIR/reference_prop.rs:+11:13: +11:14 + _10 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+11:17: +11:24 + StorageLive(_11); // scope 4 at $DIR/reference_prop.rs:+12:13: +12:15 + _11 = const 7_usize; // scope 4 at $DIR/reference_prop.rs:+12:18: +12:25 + StorageLive(_12); // scope 5 at $DIR/reference_prop.rs:+13:13: +13:18 + _12 = &_10; // scope 5 at $DIR/reference_prop.rs:+13:21: +13:23 + StorageLive(_13); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:16 +- StorageLive(_14); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:16 +- _14 = &_11; // scope 6 at $DIR/reference_prop.rs:+14:13: +14:16 +- _13 = &(*_14); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:16 ++ _13 = &_11; // scope 6 at $DIR/reference_prop.rs:+14:13: +14:16 + _12 = move _13; // scope 6 at $DIR/reference_prop.rs:+14:9: +14:16 + StorageDead(_13); // scope 6 at $DIR/reference_prop.rs:+14:15: +14:16 +- StorageDead(_14); // scope 6 at $DIR/reference_prop.rs:+14:16: +14:17 + StorageLive(_15); // scope 6 at $DIR/reference_prop.rs:+16:13: +16:14 + _15 = (*_12); // scope 6 at $DIR/reference_prop.rs:+16:17: +16:19 + StorageLive(_16); // scope 7 at $DIR/reference_prop.rs:+17:9: +17:19 + StorageLive(_17); // scope 7 at $DIR/reference_prop.rs:+17:16: +17:18 + _17 = (); // scope 7 at $DIR/reference_prop.rs:+17:16: +17:18 + _16 = opaque::<()>(move _17) -> bb2; // scope 7 at $DIR/reference_prop.rs:+17:9: +17:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:27:9: 27:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_17); // scope 7 at $DIR/reference_prop.rs:+17:18: +17:19 + StorageDead(_16); // scope 7 at $DIR/reference_prop.rs:+17:19: +17:20 +- _9 = const (); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageDead(_15); // scope 6 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_12); // scope 5 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_11); // scope 4 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_10); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageDead(_9); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageLive(_18); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageLive(_19); // scope 0 at $DIR/reference_prop.rs:+22:13: +22:14 + _19 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+22:17: +22:24 + StorageLive(_20); // scope 8 at $DIR/reference_prop.rs:+23:13: +23:14 + _20 = &_19; // scope 8 at $DIR/reference_prop.rs:+23:17: +23:19 + StorageLive(_21); // scope 9 at $DIR/reference_prop.rs:+24:13: +24:14 + _21 = &_20; // scope 9 at $DIR/reference_prop.rs:+24:17: +24:19 + StorageLive(_22); // scope 10 at $DIR/reference_prop.rs:+25:13: +25:14 + _22 = (*_20); // scope 10 at $DIR/reference_prop.rs:+25:17: +25:19 + StorageLive(_23); // scope 11 at $DIR/reference_prop.rs:+26:9: +26:18 + StorageLive(_24); // scope 11 at $DIR/reference_prop.rs:+26:16: +26:17 + _24 = _21; // scope 11 at $DIR/reference_prop.rs:+26:16: +26:17 + _23 = opaque::<&&usize>(move _24) -> bb3; // scope 11 at $DIR/reference_prop.rs:+26:9: +26:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:36:9: 36:15 + // + literal: Const { ty: fn(&&usize) {opaque::<&&usize>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_24); // scope 11 at $DIR/reference_prop.rs:+26:17: +26:18 + StorageDead(_23); // scope 11 at $DIR/reference_prop.rs:+26:18: +26:19 +- _18 = const (); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageDead(_22); // scope 10 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_21); // scope 9 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_20); // scope 8 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_19); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageDead(_18); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageLive(_25); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageLive(_26); // scope 0 at $DIR/reference_prop.rs:+31:13: +31:14 + _26 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+31:17: +31:24 + StorageLive(_27); // scope 12 at $DIR/reference_prop.rs:+32:13: +32:18 + _27 = &_26; // scope 12 at $DIR/reference_prop.rs:+32:21: +32:23 + StorageLive(_28); // scope 13 at $DIR/reference_prop.rs:+33:13: +33:14 + _28 = &raw mut _27; // scope 13 at $DIR/reference_prop.rs:+33:17: +33:27 + StorageLive(_29); // scope 14 at $DIR/reference_prop.rs:+34:13: +34:14 + _29 = (*_27); // scope 14 at $DIR/reference_prop.rs:+34:17: +34:19 + StorageLive(_30); // scope 15 at $DIR/reference_prop.rs:+35:9: +35:18 + StorageLive(_31); // scope 15 at $DIR/reference_prop.rs:+35:16: +35:17 + _31 = _28; // scope 15 at $DIR/reference_prop.rs:+35:16: +35:17 + _30 = opaque::<*mut &usize>(move _31) -> bb4; // scope 15 at $DIR/reference_prop.rs:+35:9: +35:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:45:9: 45:15 + // + literal: Const { ty: fn(*mut &usize) {opaque::<*mut &usize>}, val: Value(<ZST>) } + } + + bb4: { + StorageDead(_31); // scope 15 at $DIR/reference_prop.rs:+35:17: +35:18 + StorageDead(_30); // scope 15 at $DIR/reference_prop.rs:+35:18: +35:19 +- _25 = const (); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageDead(_29); // scope 14 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_28); // scope 13 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_27); // scope 12 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_26); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageDead(_25); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageLive(_32); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageLive(_33); // scope 0 at $DIR/reference_prop.rs:+40:13: +40:14 + _33 = const 7_usize; // scope 0 at $DIR/reference_prop.rs:+40:17: +40:24 + StorageLive(_34); // scope 16 at $DIR/reference_prop.rs:+41:13: +41:14 + _34 = &_33; // scope 16 at $DIR/reference_prop.rs:+41:17: +41:19 + StorageLive(_35); // scope 17 at $DIR/reference_prop.rs:+42:13: +42:14 +- _35 = (*_34); // scope 17 at $DIR/reference_prop.rs:+42:17: +42:19 ++ _35 = _33; // scope 17 at $DIR/reference_prop.rs:+42:17: +42:19 + StorageLive(_36); // scope 18 at $DIR/reference_prop.rs:+43:9: +43:18 + StorageLive(_37); // scope 18 at $DIR/reference_prop.rs:+43:16: +43:17 + _37 = _34; // scope 18 at $DIR/reference_prop.rs:+43:16: +43:17 + _36 = opaque::<&usize>(move _37) -> bb5; // scope 18 at $DIR/reference_prop.rs:+43:9: +43:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:53:9: 53:15 + // + literal: Const { ty: fn(&usize) {opaque::<&usize>}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_37); // scope 18 at $DIR/reference_prop.rs:+43:17: +43:18 + StorageDead(_36); // scope 18 at $DIR/reference_prop.rs:+43:18: +43:19 +- _32 = const (); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageDead(_35); // scope 17 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_34); // scope 16 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_33); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageDead(_32); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageLive(_38); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageLive(_39); // scope 0 at $DIR/reference_prop.rs:+48:13: +48:14 + _39 = const 7_usize; // scope 0 at $DIR/reference_prop.rs:+48:17: +48:24 + StorageLive(_40); // scope 19 at $DIR/reference_prop.rs:+49:13: +49:15 + _40 = &_39; // scope 19 at $DIR/reference_prop.rs:+49:18: +49:20 + StorageLive(_41); // scope 20 at $DIR/reference_prop.rs:+50:13: +50:14 +- _41 = (*_40); // scope 20 at $DIR/reference_prop.rs:+50:17: +50:20 ++ _41 = _39; // scope 20 at $DIR/reference_prop.rs:+50:17: +50:20 + StorageLive(_42); // scope 21 at $DIR/reference_prop.rs:+51:13: +51:15 + _42 = _40; // scope 21 at $DIR/reference_prop.rs:+51:18: +51:20 + StorageLive(_43); // scope 22 at $DIR/reference_prop.rs:+52:13: +52:15 +- _43 = (*_42); // scope 22 at $DIR/reference_prop.rs:+52:18: +52:21 ++ _43 = _39; // scope 22 at $DIR/reference_prop.rs:+52:18: +52:21 + StorageLive(_44); // scope 23 at $DIR/reference_prop.rs:+53:13: +53:15 + _44 = _42; // scope 23 at $DIR/reference_prop.rs:+53:18: +53:20 + StorageLive(_45); // scope 24 at $DIR/reference_prop.rs:+56:9: +56:19 + StorageLive(_46); // scope 24 at $DIR/reference_prop.rs:+56:16: +56:18 + _46 = _44; // scope 24 at $DIR/reference_prop.rs:+56:16: +56:18 + _45 = opaque::<&usize>(move _46) -> bb6; // scope 24 at $DIR/reference_prop.rs:+56:9: +56:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:66:9: 66:15 + // + literal: Const { ty: fn(&usize) {opaque::<&usize>}, val: Value(<ZST>) } + } + + bb6: { + StorageDead(_46); // scope 24 at $DIR/reference_prop.rs:+56:18: +56:19 + StorageDead(_45); // scope 24 at $DIR/reference_prop.rs:+56:19: +56:20 +- _38 = const (); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageDead(_44); // scope 23 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_43); // scope 22 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_42); // scope 21 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_41); // scope 20 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_40); // scope 19 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_39); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageDead(_38); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageLive(_47); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 +- StorageLive(_48); // scope 0 at $DIR/reference_prop.rs:+61:13: +61:14 +- _48 = &(*_1); // scope 0 at $DIR/reference_prop.rs:+61:17: +61:25 + StorageLive(_49); // scope 25 at $DIR/reference_prop.rs:+62:13: +62:14 +- _49 = (*_48); // scope 25 at $DIR/reference_prop.rs:+62:17: +62:19 ++ _49 = (*_1); // scope 25 at $DIR/reference_prop.rs:+62:17: +62:19 + StorageLive(_50); // scope 26 at $DIR/reference_prop.rs:+63:9: +63:19 + StorageLive(_51); // scope 26 at $DIR/reference_prop.rs:+63:16: +63:18 + _51 = (); // scope 26 at $DIR/reference_prop.rs:+63:16: +63:18 + _50 = opaque::<()>(move _51) -> bb7; // scope 26 at $DIR/reference_prop.rs:+63:9: +63:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:73:9: 73:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_51); // scope 26 at $DIR/reference_prop.rs:+63:18: +63:19 + StorageDead(_50); // scope 26 at $DIR/reference_prop.rs:+63:19: +63:20 +- _47 = const (); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + StorageDead(_49); // scope 25 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_48); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_47); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageLive(_52); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageLive(_53); // scope 0 at $DIR/reference_prop.rs:+68:13: +68:14 + _53 = &(*_2); // scope 0 at $DIR/reference_prop.rs:+68:17: +68:27 + StorageLive(_54); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:28 +- StorageLive(_55); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:28 +- _55 = &(*_1); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:28 +- _54 = &(*_55); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:28 ++ _54 = &(*_1); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:28 + _2 = move _54; // scope 27 at $DIR/reference_prop.rs:+69:9: +69:28 + StorageDead(_54); // scope 27 at $DIR/reference_prop.rs:+69:27: +69:28 +- StorageDead(_55); // scope 27 at $DIR/reference_prop.rs:+69:28: +69:29 + StorageLive(_56); // scope 27 at $DIR/reference_prop.rs:+70:13: +70:14 + _56 = (*_53); // scope 27 at $DIR/reference_prop.rs:+70:17: +70:19 + StorageLive(_57); // scope 28 at $DIR/reference_prop.rs:+71:9: +71:19 + StorageLive(_58); // scope 28 at $DIR/reference_prop.rs:+71:16: +71:18 + _58 = (); // scope 28 at $DIR/reference_prop.rs:+71:16: +71:18 + _57 = opaque::<()>(move _58) -> bb8; // scope 28 at $DIR/reference_prop.rs:+71:9: +71:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:81:9: 81:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb8: { + StorageDead(_58); // scope 28 at $DIR/reference_prop.rs:+71:18: +71:19 + StorageDead(_57); // scope 28 at $DIR/reference_prop.rs:+71:19: +71:20 +- _52 = const (); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageDead(_56); // scope 27 at $DIR/reference_prop.rs:+72:5: +72:6 + StorageDead(_53); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageDead(_52); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageLive(_59); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageLive(_60); // scope 0 at $DIR/reference_prop.rs:+76:13: +76:14 + _60 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+76:17: +76:24 +- StorageLive(_61); // scope 29 at $DIR/reference_prop.rs:+77:13: +77:14 +- _61 = &_60; // scope 29 at $DIR/reference_prop.rs:+77:17: +77:19 +- StorageLive(_62); // scope 30 at $DIR/reference_prop.rs:+78:13: +78:14 +- _62 = &_61; // scope 30 at $DIR/reference_prop.rs:+78:17: +78:19 + StorageLive(_63); // scope 31 at $DIR/reference_prop.rs:+79:13: +79:14 +- _63 = (*_61); // scope 31 at $DIR/reference_prop.rs:+79:17: +79:19 ++ _63 = _60; // scope 31 at $DIR/reference_prop.rs:+79:17: +79:19 + StorageLive(_64); // scope 32 at $DIR/reference_prop.rs:+80:9: +80:19 + StorageLive(_65); // scope 32 at $DIR/reference_prop.rs:+80:16: +80:18 + _65 = (); // scope 32 at $DIR/reference_prop.rs:+80:16: +80:18 + _64 = opaque::<()>(move _65) -> bb9; // scope 32 at $DIR/reference_prop.rs:+80:9: +80:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:90:9: 90:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb9: { + StorageDead(_65); // scope 32 at $DIR/reference_prop.rs:+80:18: +80:19 + StorageDead(_64); // scope 32 at $DIR/reference_prop.rs:+80:19: +80:20 +- _59 = const (); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageDead(_63); // scope 31 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_62); // scope 30 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_61); // scope 29 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageDead(_60); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_59); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageLive(_66); // scope 0 at $DIR/reference_prop.rs:+85:13: +85:14 + _66 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+85:17: +85:24 +- StorageLive(_67); // scope 33 at $DIR/reference_prop.rs:+86:13: +86:18 +- _67 = &_66; // scope 33 at $DIR/reference_prop.rs:+86:21: +86:23 +- StorageLive(_68); // scope 34 at $DIR/reference_prop.rs:+87:13: +87:14 +- _68 = &mut _67; // scope 34 at $DIR/reference_prop.rs:+87:17: +87:23 + StorageLive(_69); // scope 35 at $DIR/reference_prop.rs:+88:13: +88:14 +- _69 = (*_67); // scope 35 at $DIR/reference_prop.rs:+88:17: +88:19 ++ _69 = _66; // scope 35 at $DIR/reference_prop.rs:+88:17: +88:19 + StorageLive(_70); // scope 36 at $DIR/reference_prop.rs:+89:9: +89:19 + StorageLive(_71); // scope 36 at $DIR/reference_prop.rs:+89:16: +89:18 + _71 = (); // scope 36 at $DIR/reference_prop.rs:+89:16: +89:18 + _70 = opaque::<()>(move _71) -> bb10; // scope 36 at $DIR/reference_prop.rs:+89:9: +89:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:99:9: 99:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb10: { + StorageDead(_71); // scope 36 at $DIR/reference_prop.rs:+89:18: +89:19 + StorageDead(_70); // scope 36 at $DIR/reference_prop.rs:+89:19: +89:20 + _0 = const (); // scope 0 at $DIR/reference_prop.rs:+84:5: +90:6 + StorageDead(_69); // scope 35 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_68); // scope 34 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_67); // scope 33 at $DIR/reference_prop.rs:+90:5: +90:6 + StorageDead(_66); // scope 0 at $DIR/reference_prop.rs:+90:5: +90:6 + return; // scope 0 at $DIR/reference_prop.rs:+91:2: +91:2 + } + } + diff --git a/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff new file mode 100644 index 000000000..ddeb04e50 --- /dev/null +++ b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff @@ -0,0 +1,536 @@ +- // MIR for `reference_propagation_const_ptr` before ReferencePropagation ++ // MIR for `reference_propagation_const_ptr` after ReferencePropagation + + fn reference_propagation_const_ptr(_1: *const T, _2: *const T) -> () { + debug single => _1; // in scope 0 at $DIR/reference_prop.rs:+0:45: +0:51 + debug multiple => _2; // in scope 0 at $DIR/reference_prop.rs:+0:63: +0:75 + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:87: +0:87 + let _3: (); // in scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + let _7: (); // in scope 0 at $DIR/reference_prop.rs:+6:9: +6:19 + let mut _8: (); // in scope 0 at $DIR/reference_prop.rs:+6:16: +6:18 + let _9: (); // in scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + let mut _13: *const usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:26 + let _15: (); // in scope 0 at $DIR/reference_prop.rs:+17:9: +17:19 + let mut _16: (); // in scope 0 at $DIR/reference_prop.rs:+17:16: +17:18 + let _17: (); // in scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + let _22: (); // in scope 0 at $DIR/reference_prop.rs:+26:9: +26:18 + let mut _23: &*const usize; // in scope 0 at $DIR/reference_prop.rs:+26:16: +26:17 + let _24: (); // in scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + let _29: (); // in scope 0 at $DIR/reference_prop.rs:+35:9: +35:18 + let mut _30: *mut *const usize; // in scope 0 at $DIR/reference_prop.rs:+35:16: +35:17 + let _31: (); // in scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + let _35: (); // in scope 0 at $DIR/reference_prop.rs:+43:9: +43:18 + let mut _36: *const usize; // in scope 0 at $DIR/reference_prop.rs:+43:16: +43:17 + let _37: (); // in scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + let _44: (); // in scope 0 at $DIR/reference_prop.rs:+56:9: +56:19 + let mut _45: *const usize; // in scope 0 at $DIR/reference_prop.rs:+56:16: +56:18 + let _46: (); // in scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + let _49: (); // in scope 0 at $DIR/reference_prop.rs:+63:9: +63:19 + let mut _50: (); // in scope 0 at $DIR/reference_prop.rs:+63:16: +63:18 + let _51: (); // in scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + let mut _53: *const T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:38 + let _55: (); // in scope 0 at $DIR/reference_prop.rs:+71:9: +71:19 + let mut _56: (); // in scope 0 at $DIR/reference_prop.rs:+71:16: +71:18 + let _57: (); // in scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + let _62: (); // in scope 0 at $DIR/reference_prop.rs:+80:9: +80:19 + let mut _63: (); // in scope 0 at $DIR/reference_prop.rs:+80:16: +80:18 + let _64: (); // in scope 0 at $DIR/reference_prop.rs:+84:5: +90:6 + let _69: (); // in scope 0 at $DIR/reference_prop.rs:+89:9: +89:19 + let mut _70: (); // in scope 0 at $DIR/reference_prop.rs:+89:16: +89:18 + let _75: (); // in scope 0 at $DIR/reference_prop.rs:+98:9: +98:19 + let mut _76: (); // in scope 0 at $DIR/reference_prop.rs:+98:16: +98:18 + scope 1 { + let _4: usize; // in scope 1 at $DIR/reference_prop.rs:+3:13: +3:14 + scope 2 { + debug a => _4; // in scope 2 at $DIR/reference_prop.rs:+3:13: +3:14 + let _5: *const usize; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 + scope 3 { +- debug b => _5; // in scope 3 at $DIR/reference_prop.rs:+4:13: +4:14 ++ debug b => &_4; // in scope 3 at $DIR/reference_prop.rs:+4:13: +4:14 + let _6: usize; // in scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 + scope 4 { + debug c => _6; // in scope 4 at $DIR/reference_prop.rs:+5:13: +5:14 + } + } + } + } + scope 5 { + let _10: usize; // in scope 5 at $DIR/reference_prop.rs:+11:13: +11:14 + scope 6 { + debug a => _10; // in scope 6 at $DIR/reference_prop.rs:+11:13: +11:14 + let _11: usize; // in scope 6 at $DIR/reference_prop.rs:+12:13: +12:15 + scope 7 { + debug a2 => _11; // in scope 7 at $DIR/reference_prop.rs:+12:13: +12:15 + let mut _12: *const usize; // in scope 7 at $DIR/reference_prop.rs:+13:13: +13:18 + scope 8 { + debug b => _12; // in scope 8 at $DIR/reference_prop.rs:+13:13: +13:18 + let _14: usize; // in scope 8 at $DIR/reference_prop.rs:+16:13: +16:14 + scope 9 { + debug c => _14; // in scope 9 at $DIR/reference_prop.rs:+16:13: +16:14 + } + } + } + } + } + scope 10 { + let _18: usize; // in scope 10 at $DIR/reference_prop.rs:+22:13: +22:14 + scope 11 { + debug a => _18; // in scope 11 at $DIR/reference_prop.rs:+22:13: +22:14 + let _19: *const usize; // in scope 11 at $DIR/reference_prop.rs:+23:13: +23:14 + scope 12 { + debug b => _19; // in scope 12 at $DIR/reference_prop.rs:+23:13: +23:14 + let _20: &*const usize; // in scope 12 at $DIR/reference_prop.rs:+24:13: +24:14 + scope 13 { + debug d => _20; // in scope 13 at $DIR/reference_prop.rs:+24:13: +24:14 + let _21: usize; // in scope 13 at $DIR/reference_prop.rs:+25:13: +25:14 + scope 14 { + debug c => _21; // in scope 14 at $DIR/reference_prop.rs:+25:13: +25:14 + } + } + } + } + } + scope 15 { + let _25: usize; // in scope 15 at $DIR/reference_prop.rs:+31:13: +31:14 + scope 16 { + debug a => _25; // in scope 16 at $DIR/reference_prop.rs:+31:13: +31:14 + let mut _26: *const usize; // in scope 16 at $DIR/reference_prop.rs:+32:13: +32:18 + scope 17 { + debug b => _26; // in scope 17 at $DIR/reference_prop.rs:+32:13: +32:18 + let _27: *mut *const usize; // in scope 17 at $DIR/reference_prop.rs:+33:13: +33:14 + scope 18 { + debug d => _27; // in scope 18 at $DIR/reference_prop.rs:+33:13: +33:14 + let _28: usize; // in scope 18 at $DIR/reference_prop.rs:+34:13: +34:14 + scope 19 { + debug c => _28; // in scope 19 at $DIR/reference_prop.rs:+34:13: +34:14 + } + } + } + } + } + scope 20 { + let _32: usize; // in scope 20 at $DIR/reference_prop.rs:+40:13: +40:14 + scope 21 { + debug a => _32; // in scope 21 at $DIR/reference_prop.rs:+40:13: +40:14 + let _33: *const usize; // in scope 21 at $DIR/reference_prop.rs:+41:13: +41:14 + scope 22 { + debug b => _33; // in scope 22 at $DIR/reference_prop.rs:+41:13: +41:14 + let _34: usize; // in scope 22 at $DIR/reference_prop.rs:+42:13: +42:14 + scope 23 { + debug c => _34; // in scope 23 at $DIR/reference_prop.rs:+42:13: +42:14 + } + } + } + } + scope 24 { + let _38: usize; // in scope 24 at $DIR/reference_prop.rs:+48:13: +48:14 + scope 25 { + debug a => _38; // in scope 25 at $DIR/reference_prop.rs:+48:13: +48:14 + let _39: *const usize; // in scope 25 at $DIR/reference_prop.rs:+49:13: +49:15 + scope 26 { + debug b1 => _39; // in scope 26 at $DIR/reference_prop.rs:+49:13: +49:15 + let _40: usize; // in scope 26 at $DIR/reference_prop.rs:+50:13: +50:14 + scope 27 { + debug c => _40; // in scope 27 at $DIR/reference_prop.rs:+50:13: +50:14 + let _41: *const usize; // in scope 27 at $DIR/reference_prop.rs:+51:13: +51:15 + scope 28 { + debug b2 => _41; // in scope 28 at $DIR/reference_prop.rs:+51:13: +51:15 + let _42: usize; // in scope 28 at $DIR/reference_prop.rs:+52:13: +52:15 + scope 29 { + debug c2 => _42; // in scope 29 at $DIR/reference_prop.rs:+52:13: +52:15 + let _43: *const usize; // in scope 29 at $DIR/reference_prop.rs:+53:13: +53:15 + scope 30 { + debug b3 => _43; // in scope 30 at $DIR/reference_prop.rs:+53:13: +53:15 + } + } + } + } + } + } + } + scope 31 { + let _47: *const T; // in scope 31 at $DIR/reference_prop.rs:+61:13: +61:14 + scope 32 { +- debug a => _47; // in scope 32 at $DIR/reference_prop.rs:+61:13: +61:14 ++ debug a => _1; // in scope 32 at $DIR/reference_prop.rs:+61:13: +61:14 + let _48: T; // in scope 32 at $DIR/reference_prop.rs:+62:13: +62:14 + scope 33 { + debug b => _48; // in scope 33 at $DIR/reference_prop.rs:+62:13: +62:14 + } + } + } + scope 34 { + let _52: *const T; // in scope 34 at $DIR/reference_prop.rs:+68:13: +68:14 + scope 35 { + debug a => _52; // in scope 35 at $DIR/reference_prop.rs:+68:13: +68:14 + let _54: T; // in scope 35 at $DIR/reference_prop.rs:+70:13: +70:14 + scope 36 { + debug b => _54; // in scope 36 at $DIR/reference_prop.rs:+70:13: +70:14 + } + } + } + scope 37 { + let _58: usize; // in scope 37 at $DIR/reference_prop.rs:+76:13: +76:14 + scope 38 { + debug a => _58; // in scope 38 at $DIR/reference_prop.rs:+76:13: +76:14 + let _59: *const usize; // in scope 38 at $DIR/reference_prop.rs:+77:13: +77:14 + scope 39 { +- debug b => _59; // in scope 39 at $DIR/reference_prop.rs:+77:13: +77:14 ++ debug b => &_58; // in scope 39 at $DIR/reference_prop.rs:+77:13: +77:14 + let _60: *const usize; // in scope 39 at $DIR/reference_prop.rs:+78:13: +78:14 + scope 40 { +- debug c => _60; // in scope 40 at $DIR/reference_prop.rs:+78:13: +78:14 ++ debug c => &_58; // in scope 40 at $DIR/reference_prop.rs:+78:13: +78:14 + let _61: usize; // in scope 40 at $DIR/reference_prop.rs:+79:13: +79:14 + scope 41 { + debug e => _61; // in scope 41 at $DIR/reference_prop.rs:+79:13: +79:14 + } + } + } + } + } + scope 42 { + let _65: usize; // in scope 42 at $DIR/reference_prop.rs:+85:13: +85:14 + scope 43 { + debug a => _65; // in scope 43 at $DIR/reference_prop.rs:+85:13: +85:14 + let _66: *const usize; // in scope 43 at $DIR/reference_prop.rs:+86:13: +86:14 + scope 44 { +- debug b => _66; // in scope 44 at $DIR/reference_prop.rs:+86:13: +86:14 ++ debug b => &_65; // in scope 44 at $DIR/reference_prop.rs:+86:13: +86:14 + let _67: &*const usize; // in scope 44 at $DIR/reference_prop.rs:+87:13: +87:14 + scope 45 { +- debug d => _67; // in scope 45 at $DIR/reference_prop.rs:+87:13: +87:14 ++ debug d => &&_65; // in scope 45 at $DIR/reference_prop.rs:+87:13: +87:14 + let _68: usize; // in scope 45 at $DIR/reference_prop.rs:+88:13: +88:14 + scope 46 { + debug c => _68; // in scope 46 at $DIR/reference_prop.rs:+88:13: +88:14 + } + } + } + } + } + scope 47 { + let _71: usize; // in scope 47 at $DIR/reference_prop.rs:+94:13: +94:14 + scope 48 { + debug a => _71; // in scope 48 at $DIR/reference_prop.rs:+94:13: +94:14 + let mut _72: *const usize; // in scope 48 at $DIR/reference_prop.rs:+95:13: +95:18 + scope 49 { +- debug b => _72; // in scope 49 at $DIR/reference_prop.rs:+95:13: +95:18 ++ debug b => &_71; // in scope 49 at $DIR/reference_prop.rs:+95:13: +95:18 + let _73: &mut *const usize; // in scope 49 at $DIR/reference_prop.rs:+96:13: +96:14 + scope 50 { +- debug d => _73; // in scope 50 at $DIR/reference_prop.rs:+96:13: +96:14 ++ debug d => &&_71; // in scope 50 at $DIR/reference_prop.rs:+96:13: +96:14 + let _74: usize; // in scope 50 at $DIR/reference_prop.rs:+97:13: +97:14 + scope 51 { + debug c => _74; // in scope 51 at $DIR/reference_prop.rs:+97:13: +97:14 + } + } + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageLive(_4); // scope 1 at $DIR/reference_prop.rs:+3:13: +3:14 + _4 = const 5_usize; // scope 1 at $DIR/reference_prop.rs:+3:17: +3:24 +- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 +- _5 = &raw const _4; // scope 2 at $DIR/reference_prop.rs:+4:17: +4:29 + StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 +- _6 = (*_5); // scope 3 at $DIR/reference_prop.rs:+5:17: +5:19 ++ _6 = _4; // scope 3 at $DIR/reference_prop.rs:+5:17: +5:19 + StorageLive(_7); // scope 4 at $DIR/reference_prop.rs:+6:9: +6:19 + StorageLive(_8); // scope 4 at $DIR/reference_prop.rs:+6:16: +6:18 + _8 = (); // scope 4 at $DIR/reference_prop.rs:+6:16: +6:18 + _7 = opaque::<()>(move _8) -> bb1; // scope 4 at $DIR/reference_prop.rs:+6:9: +6:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:202:9: 202:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 4 at $DIR/reference_prop.rs:+6:18: +6:19 + StorageDead(_7); // scope 4 at $DIR/reference_prop.rs:+6:19: +6:20 +- _3 = const (); // scope 1 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageDead(_4); // scope 1 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_3); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageLive(_9); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageLive(_10); // scope 5 at $DIR/reference_prop.rs:+11:13: +11:14 + _10 = const 5_usize; // scope 5 at $DIR/reference_prop.rs:+11:17: +11:24 + StorageLive(_11); // scope 6 at $DIR/reference_prop.rs:+12:13: +12:15 + _11 = const 7_usize; // scope 6 at $DIR/reference_prop.rs:+12:18: +12:25 + StorageLive(_12); // scope 7 at $DIR/reference_prop.rs:+13:13: +13:18 + _12 = &raw const _10; // scope 7 at $DIR/reference_prop.rs:+13:21: +13:33 + StorageLive(_13); // scope 8 at $DIR/reference_prop.rs:+14:13: +14:26 + _13 = &raw const _11; // scope 8 at $DIR/reference_prop.rs:+14:13: +14:26 + _12 = move _13; // scope 8 at $DIR/reference_prop.rs:+14:9: +14:26 + StorageDead(_13); // scope 8 at $DIR/reference_prop.rs:+14:25: +14:26 + StorageLive(_14); // scope 8 at $DIR/reference_prop.rs:+16:13: +16:14 + _14 = (*_12); // scope 8 at $DIR/reference_prop.rs:+16:17: +16:19 + StorageLive(_15); // scope 9 at $DIR/reference_prop.rs:+17:9: +17:19 + StorageLive(_16); // scope 9 at $DIR/reference_prop.rs:+17:16: +17:18 + _16 = (); // scope 9 at $DIR/reference_prop.rs:+17:16: +17:18 + _15 = opaque::<()>(move _16) -> bb2; // scope 9 at $DIR/reference_prop.rs:+17:9: +17:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:213:9: 213:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_16); // scope 9 at $DIR/reference_prop.rs:+17:18: +17:19 + StorageDead(_15); // scope 9 at $DIR/reference_prop.rs:+17:19: +17:20 +- _9 = const (); // scope 5 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageDead(_14); // scope 8 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_12); // scope 7 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_11); // scope 6 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_10); // scope 5 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageDead(_9); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageLive(_17); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageLive(_18); // scope 10 at $DIR/reference_prop.rs:+22:13: +22:14 + _18 = const 5_usize; // scope 10 at $DIR/reference_prop.rs:+22:17: +22:24 + StorageLive(_19); // scope 11 at $DIR/reference_prop.rs:+23:13: +23:14 + _19 = &raw const _18; // scope 11 at $DIR/reference_prop.rs:+23:17: +23:29 + StorageLive(_20); // scope 12 at $DIR/reference_prop.rs:+24:13: +24:14 + _20 = &_19; // scope 12 at $DIR/reference_prop.rs:+24:17: +24:19 + StorageLive(_21); // scope 13 at $DIR/reference_prop.rs:+25:13: +25:14 + _21 = (*_19); // scope 13 at $DIR/reference_prop.rs:+25:17: +25:19 + StorageLive(_22); // scope 14 at $DIR/reference_prop.rs:+26:9: +26:18 + StorageLive(_23); // scope 14 at $DIR/reference_prop.rs:+26:16: +26:17 + _23 = _20; // scope 14 at $DIR/reference_prop.rs:+26:16: +26:17 + _22 = opaque::<&*const usize>(move _23) -> bb3; // scope 14 at $DIR/reference_prop.rs:+26:9: +26:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:222:9: 222:15 + // + literal: Const { ty: fn(&*const usize) {opaque::<&*const usize>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_23); // scope 14 at $DIR/reference_prop.rs:+26:17: +26:18 + StorageDead(_22); // scope 14 at $DIR/reference_prop.rs:+26:18: +26:19 +- _17 = const (); // scope 10 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageDead(_21); // scope 13 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_20); // scope 12 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_19); // scope 11 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_18); // scope 10 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageDead(_17); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageLive(_24); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageLive(_25); // scope 15 at $DIR/reference_prop.rs:+31:13: +31:14 + _25 = const 5_usize; // scope 15 at $DIR/reference_prop.rs:+31:17: +31:24 + StorageLive(_26); // scope 16 at $DIR/reference_prop.rs:+32:13: +32:18 + _26 = &raw const _25; // scope 16 at $DIR/reference_prop.rs:+32:21: +32:33 + StorageLive(_27); // scope 17 at $DIR/reference_prop.rs:+33:13: +33:14 + _27 = &raw mut _26; // scope 17 at $DIR/reference_prop.rs:+33:17: +33:27 + StorageLive(_28); // scope 18 at $DIR/reference_prop.rs:+34:13: +34:14 + _28 = (*_26); // scope 18 at $DIR/reference_prop.rs:+34:17: +34:19 + StorageLive(_29); // scope 19 at $DIR/reference_prop.rs:+35:9: +35:18 + StorageLive(_30); // scope 19 at $DIR/reference_prop.rs:+35:16: +35:17 + _30 = _27; // scope 19 at $DIR/reference_prop.rs:+35:16: +35:17 + _29 = opaque::<*mut *const usize>(move _30) -> bb4; // scope 19 at $DIR/reference_prop.rs:+35:9: +35:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:231:9: 231:15 + // + literal: Const { ty: fn(*mut *const usize) {opaque::<*mut *const usize>}, val: Value(<ZST>) } + } + + bb4: { + StorageDead(_30); // scope 19 at $DIR/reference_prop.rs:+35:17: +35:18 + StorageDead(_29); // scope 19 at $DIR/reference_prop.rs:+35:18: +35:19 +- _24 = const (); // scope 15 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageDead(_28); // scope 18 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_27); // scope 17 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_26); // scope 16 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_25); // scope 15 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageDead(_24); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageLive(_31); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageLive(_32); // scope 20 at $DIR/reference_prop.rs:+40:13: +40:14 + _32 = const 7_usize; // scope 20 at $DIR/reference_prop.rs:+40:17: +40:24 + StorageLive(_33); // scope 21 at $DIR/reference_prop.rs:+41:13: +41:14 + _33 = &raw const _32; // scope 21 at $DIR/reference_prop.rs:+41:17: +41:29 + StorageLive(_34); // scope 22 at $DIR/reference_prop.rs:+42:13: +42:14 +- _34 = (*_33); // scope 22 at $DIR/reference_prop.rs:+42:17: +42:19 ++ _34 = _32; // scope 22 at $DIR/reference_prop.rs:+42:17: +42:19 + StorageLive(_35); // scope 23 at $DIR/reference_prop.rs:+43:9: +43:18 + StorageLive(_36); // scope 23 at $DIR/reference_prop.rs:+43:16: +43:17 + _36 = _33; // scope 23 at $DIR/reference_prop.rs:+43:16: +43:17 + _35 = opaque::<*const usize>(move _36) -> bb5; // scope 23 at $DIR/reference_prop.rs:+43:9: +43:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:239:9: 239:15 + // + literal: Const { ty: fn(*const usize) {opaque::<*const usize>}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_36); // scope 23 at $DIR/reference_prop.rs:+43:17: +43:18 + StorageDead(_35); // scope 23 at $DIR/reference_prop.rs:+43:18: +43:19 +- _31 = const (); // scope 20 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageDead(_34); // scope 22 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_33); // scope 21 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_32); // scope 20 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageDead(_31); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageLive(_37); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageLive(_38); // scope 24 at $DIR/reference_prop.rs:+48:13: +48:14 + _38 = const 7_usize; // scope 24 at $DIR/reference_prop.rs:+48:17: +48:24 + StorageLive(_39); // scope 25 at $DIR/reference_prop.rs:+49:13: +49:15 + _39 = &raw const _38; // scope 25 at $DIR/reference_prop.rs:+49:18: +49:30 + StorageLive(_40); // scope 26 at $DIR/reference_prop.rs:+50:13: +50:14 +- _40 = (*_39); // scope 26 at $DIR/reference_prop.rs:+50:17: +50:20 ++ _40 = _38; // scope 26 at $DIR/reference_prop.rs:+50:17: +50:20 + StorageLive(_41); // scope 27 at $DIR/reference_prop.rs:+51:13: +51:15 + _41 = _39; // scope 27 at $DIR/reference_prop.rs:+51:18: +51:20 + StorageLive(_42); // scope 28 at $DIR/reference_prop.rs:+52:13: +52:15 +- _42 = (*_41); // scope 28 at $DIR/reference_prop.rs:+52:18: +52:21 ++ _42 = _38; // scope 28 at $DIR/reference_prop.rs:+52:18: +52:21 + StorageLive(_43); // scope 29 at $DIR/reference_prop.rs:+53:13: +53:15 + _43 = _41; // scope 29 at $DIR/reference_prop.rs:+53:18: +53:20 + StorageLive(_44); // scope 30 at $DIR/reference_prop.rs:+56:9: +56:19 + StorageLive(_45); // scope 30 at $DIR/reference_prop.rs:+56:16: +56:18 + _45 = _43; // scope 30 at $DIR/reference_prop.rs:+56:16: +56:18 + _44 = opaque::<*const usize>(move _45) -> bb6; // scope 30 at $DIR/reference_prop.rs:+56:9: +56:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:252:9: 252:15 + // + literal: Const { ty: fn(*const usize) {opaque::<*const usize>}, val: Value(<ZST>) } + } + + bb6: { + StorageDead(_45); // scope 30 at $DIR/reference_prop.rs:+56:18: +56:19 + StorageDead(_44); // scope 30 at $DIR/reference_prop.rs:+56:19: +56:20 +- _37 = const (); // scope 24 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageDead(_43); // scope 29 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_42); // scope 28 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_41); // scope 27 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_40); // scope 26 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_39); // scope 25 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_38); // scope 24 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageDead(_37); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageLive(_46); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 +- StorageLive(_47); // scope 31 at $DIR/reference_prop.rs:+61:13: +61:14 +- _47 = &raw const (*_1); // scope 31 at $DIR/reference_prop.rs:+61:17: +61:35 + StorageLive(_48); // scope 32 at $DIR/reference_prop.rs:+62:13: +62:14 +- _48 = (*_47); // scope 32 at $DIR/reference_prop.rs:+62:17: +62:19 ++ _48 = (*_1); // scope 32 at $DIR/reference_prop.rs:+62:17: +62:19 + StorageLive(_49); // scope 33 at $DIR/reference_prop.rs:+63:9: +63:19 + StorageLive(_50); // scope 33 at $DIR/reference_prop.rs:+63:16: +63:18 + _50 = (); // scope 33 at $DIR/reference_prop.rs:+63:16: +63:18 + _49 = opaque::<()>(move _50) -> bb7; // scope 33 at $DIR/reference_prop.rs:+63:9: +63:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:259:9: 259:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_50); // scope 33 at $DIR/reference_prop.rs:+63:18: +63:19 + StorageDead(_49); // scope 33 at $DIR/reference_prop.rs:+63:19: +63:20 +- _46 = const (); // scope 31 at $DIR/reference_prop.rs:+60:5: +64:6 + StorageDead(_48); // scope 32 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_47); // scope 31 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_46); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageLive(_51); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageLive(_52); // scope 34 at $DIR/reference_prop.rs:+68:13: +68:14 + _52 = &raw const (*_2); // scope 34 at $DIR/reference_prop.rs:+68:17: +68:37 + StorageLive(_53); // scope 35 at $DIR/reference_prop.rs:+69:20: +69:38 + _53 = &raw const (*_1); // scope 35 at $DIR/reference_prop.rs:+69:20: +69:38 + _2 = move _53; // scope 35 at $DIR/reference_prop.rs:+69:9: +69:38 + StorageDead(_53); // scope 35 at $DIR/reference_prop.rs:+69:37: +69:38 + StorageLive(_54); // scope 35 at $DIR/reference_prop.rs:+70:13: +70:14 + _54 = (*_52); // scope 35 at $DIR/reference_prop.rs:+70:17: +70:19 + StorageLive(_55); // scope 36 at $DIR/reference_prop.rs:+71:9: +71:19 + StorageLive(_56); // scope 36 at $DIR/reference_prop.rs:+71:16: +71:18 + _56 = (); // scope 36 at $DIR/reference_prop.rs:+71:16: +71:18 + _55 = opaque::<()>(move _56) -> bb8; // scope 36 at $DIR/reference_prop.rs:+71:9: +71:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:267:9: 267:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb8: { + StorageDead(_56); // scope 36 at $DIR/reference_prop.rs:+71:18: +71:19 + StorageDead(_55); // scope 36 at $DIR/reference_prop.rs:+71:19: +71:20 +- _51 = const (); // scope 34 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageDead(_54); // scope 35 at $DIR/reference_prop.rs:+72:5: +72:6 + StorageDead(_52); // scope 34 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageDead(_51); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageLive(_57); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageLive(_58); // scope 37 at $DIR/reference_prop.rs:+76:13: +76:14 + _58 = const 13_usize; // scope 37 at $DIR/reference_prop.rs:+76:17: +76:25 +- StorageLive(_59); // scope 38 at $DIR/reference_prop.rs:+77:13: +77:14 +- _59 = &raw const _58; // scope 38 at $DIR/reference_prop.rs:+77:17: +77:29 +- StorageLive(_60); // scope 39 at $DIR/reference_prop.rs:+78:13: +78:14 +- _60 = &raw const (*_59); // scope 39 at $DIR/reference_prop.rs:+78:17: +78:30 + StorageLive(_61); // scope 40 at $DIR/reference_prop.rs:+79:13: +79:14 +- _61 = (*_60); // scope 40 at $DIR/reference_prop.rs:+79:17: +79:19 ++ _61 = _58; // scope 40 at $DIR/reference_prop.rs:+79:17: +79:19 + StorageLive(_62); // scope 41 at $DIR/reference_prop.rs:+80:9: +80:19 + StorageLive(_63); // scope 41 at $DIR/reference_prop.rs:+80:16: +80:18 + _63 = (); // scope 41 at $DIR/reference_prop.rs:+80:16: +80:18 + _62 = opaque::<()>(move _63) -> bb9; // scope 41 at $DIR/reference_prop.rs:+80:9: +80:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:276:9: 276:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb9: { + StorageDead(_63); // scope 41 at $DIR/reference_prop.rs:+80:18: +80:19 + StorageDead(_62); // scope 41 at $DIR/reference_prop.rs:+80:19: +80:20 +- _57 = const (); // scope 37 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageDead(_61); // scope 40 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_60); // scope 39 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_59); // scope 38 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageDead(_58); // scope 37 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_57); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageLive(_64); // scope 0 at $DIR/reference_prop.rs:+84:5: +90:6 + StorageLive(_65); // scope 42 at $DIR/reference_prop.rs:+85:13: +85:14 + _65 = const 5_usize; // scope 42 at $DIR/reference_prop.rs:+85:17: +85:24 +- StorageLive(_66); // scope 43 at $DIR/reference_prop.rs:+86:13: +86:14 +- _66 = &raw const _65; // scope 43 at $DIR/reference_prop.rs:+86:17: +86:29 +- StorageLive(_67); // scope 44 at $DIR/reference_prop.rs:+87:13: +87:14 +- _67 = &_66; // scope 44 at $DIR/reference_prop.rs:+87:17: +87:19 + StorageLive(_68); // scope 45 at $DIR/reference_prop.rs:+88:13: +88:14 +- _68 = (*_66); // scope 45 at $DIR/reference_prop.rs:+88:17: +88:19 ++ _68 = _65; // scope 45 at $DIR/reference_prop.rs:+88:17: +88:19 + StorageLive(_69); // scope 46 at $DIR/reference_prop.rs:+89:9: +89:19 + StorageLive(_70); // scope 46 at $DIR/reference_prop.rs:+89:16: +89:18 + _70 = (); // scope 46 at $DIR/reference_prop.rs:+89:16: +89:18 + _69 = opaque::<()>(move _70) -> bb10; // scope 46 at $DIR/reference_prop.rs:+89:9: +89:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:285:9: 285:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb10: { + StorageDead(_70); // scope 46 at $DIR/reference_prop.rs:+89:18: +89:19 + StorageDead(_69); // scope 46 at $DIR/reference_prop.rs:+89:19: +89:20 +- _64 = const (); // scope 42 at $DIR/reference_prop.rs:+84:5: +90:6 + StorageDead(_68); // scope 45 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_67); // scope 44 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_66); // scope 43 at $DIR/reference_prop.rs:+90:5: +90:6 + StorageDead(_65); // scope 42 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_64); // scope 0 at $DIR/reference_prop.rs:+90:5: +90:6 + StorageLive(_71); // scope 47 at $DIR/reference_prop.rs:+94:13: +94:14 + _71 = const 5_usize; // scope 47 at $DIR/reference_prop.rs:+94:17: +94:24 +- StorageLive(_72); // scope 48 at $DIR/reference_prop.rs:+95:13: +95:18 +- _72 = &raw const _71; // scope 48 at $DIR/reference_prop.rs:+95:21: +95:33 +- StorageLive(_73); // scope 49 at $DIR/reference_prop.rs:+96:13: +96:14 +- _73 = &mut _72; // scope 49 at $DIR/reference_prop.rs:+96:17: +96:23 + StorageLive(_74); // scope 50 at $DIR/reference_prop.rs:+97:13: +97:14 +- _74 = (*_72); // scope 50 at $DIR/reference_prop.rs:+97:17: +97:19 ++ _74 = _71; // scope 50 at $DIR/reference_prop.rs:+97:17: +97:19 + StorageLive(_75); // scope 51 at $DIR/reference_prop.rs:+98:9: +98:19 + StorageLive(_76); // scope 51 at $DIR/reference_prop.rs:+98:16: +98:18 + _76 = (); // scope 51 at $DIR/reference_prop.rs:+98:16: +98:18 + _75 = opaque::<()>(move _76) -> bb11; // scope 51 at $DIR/reference_prop.rs:+98:9: +98:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:294:9: 294:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb11: { + StorageDead(_76); // scope 51 at $DIR/reference_prop.rs:+98:18: +98:19 + StorageDead(_75); // scope 51 at $DIR/reference_prop.rs:+98:19: +98:20 + _0 = const (); // scope 47 at $DIR/reference_prop.rs:+93:5: +99:6 + StorageDead(_74); // scope 50 at $DIR/reference_prop.rs:+99:5: +99:6 +- StorageDead(_73); // scope 49 at $DIR/reference_prop.rs:+99:5: +99:6 +- StorageDead(_72); // scope 48 at $DIR/reference_prop.rs:+99:5: +99:6 + StorageDead(_71); // scope 47 at $DIR/reference_prop.rs:+99:5: +99:6 + return; // scope 0 at $DIR/reference_prop.rs:+100:2: +100:2 + } + } + diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff new file mode 100644 index 000000000..8d059de5b --- /dev/null +++ b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff @@ -0,0 +1,472 @@ +- // MIR for `reference_propagation_mut` before ReferencePropagation ++ // MIR for `reference_propagation_mut` after ReferencePropagation + + fn reference_propagation_mut(_1: &mut T, _2: &mut T) -> () { + debug single => _1; // in scope 0 at $DIR/reference_prop.rs:+0:43: +0:49 + debug multiple => _2; // in scope 0 at $DIR/reference_prop.rs:+0:62: +0:74 + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:87: +0:87 + let _3: (); // in scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + let mut _4: usize; // in scope 0 at $DIR/reference_prop.rs:+3:13: +3:18 + let _7: (); // in scope 0 at $DIR/reference_prop.rs:+6:9: +6:19 + let mut _8: (); // in scope 0 at $DIR/reference_prop.rs:+6:16: +6:18 + let _9: (); // in scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + let mut _10: usize; // in scope 0 at $DIR/reference_prop.rs:+11:13: +11:18 + let mut _13: &mut usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:20 + let mut _14: &mut usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:20 + let _16: (); // in scope 0 at $DIR/reference_prop.rs:+17:9: +17:19 + let mut _17: (); // in scope 0 at $DIR/reference_prop.rs:+17:16: +17:18 + let _18: (); // in scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + let mut _19: usize; // in scope 0 at $DIR/reference_prop.rs:+22:13: +22:18 + let _23: (); // in scope 0 at $DIR/reference_prop.rs:+26:9: +26:18 + let mut _24: &&mut usize; // in scope 0 at $DIR/reference_prop.rs:+26:16: +26:17 + let _25: (); // in scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + let mut _26: usize; // in scope 0 at $DIR/reference_prop.rs:+31:13: +31:18 + let _30: (); // in scope 0 at $DIR/reference_prop.rs:+35:9: +35:18 + let mut _31: *mut &mut usize; // in scope 0 at $DIR/reference_prop.rs:+35:16: +35:17 + let _32: (); // in scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + let mut _33: usize; // in scope 0 at $DIR/reference_prop.rs:+40:13: +40:18 + let _36: (); // in scope 0 at $DIR/reference_prop.rs:+43:9: +43:18 + let mut _37: &mut usize; // in scope 0 at $DIR/reference_prop.rs:+43:16: +43:17 + let _38: (); // in scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + let mut _39: usize; // in scope 0 at $DIR/reference_prop.rs:+48:13: +48:18 + let _45: (); // in scope 0 at $DIR/reference_prop.rs:+56:9: +56:19 + let mut _46: &mut usize; // in scope 0 at $DIR/reference_prop.rs:+56:16: +56:18 + let _47: (); // in scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + let _48: &mut T; // in scope 0 at $DIR/reference_prop.rs:+61:13: +61:14 + let _50: (); // in scope 0 at $DIR/reference_prop.rs:+63:9: +63:19 + let mut _51: (); // in scope 0 at $DIR/reference_prop.rs:+63:16: +63:18 + let _52: (); // in scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + let _53: &mut T; // in scope 0 at $DIR/reference_prop.rs:+68:13: +68:14 + let mut _54: &mut T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:32 + let mut _55: &mut T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:32 + let _57: (); // in scope 0 at $DIR/reference_prop.rs:+71:9: +71:19 + let mut _58: (); // in scope 0 at $DIR/reference_prop.rs:+71:16: +71:18 + let _59: (); // in scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + let mut _60: usize; // in scope 0 at $DIR/reference_prop.rs:+76:13: +76:18 + let _64: (); // in scope 0 at $DIR/reference_prop.rs:+80:9: +80:19 + let mut _65: (); // in scope 0 at $DIR/reference_prop.rs:+80:16: +80:18 + let mut _66: usize; // in scope 0 at $DIR/reference_prop.rs:+85:13: +85:18 + let _70: (); // in scope 0 at $DIR/reference_prop.rs:+89:9: +89:19 + let mut _71: (); // in scope 0 at $DIR/reference_prop.rs:+89:16: +89:18 + scope 1 { + debug a => _4; // in scope 1 at $DIR/reference_prop.rs:+3:13: +3:18 + let _5: &mut usize; // in scope 1 at $DIR/reference_prop.rs:+4:13: +4:14 + scope 2 { +- debug b => _5; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 ++ debug b => &_4; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 + let _6: usize; // in scope 2 at $DIR/reference_prop.rs:+5:13: +5:14 + scope 3 { + debug c => _6; // in scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 + } + } + } + scope 4 { + debug a => _10; // in scope 4 at $DIR/reference_prop.rs:+11:13: +11:18 + let mut _11: usize; // in scope 4 at $DIR/reference_prop.rs:+12:13: +12:19 + scope 5 { + debug a2 => _11; // in scope 5 at $DIR/reference_prop.rs:+12:13: +12:19 + let mut _12: &mut usize; // in scope 5 at $DIR/reference_prop.rs:+13:13: +13:18 + scope 6 { + debug b => _12; // in scope 6 at $DIR/reference_prop.rs:+13:13: +13:18 + let _15: usize; // in scope 6 at $DIR/reference_prop.rs:+16:13: +16:14 + scope 7 { + debug c => _15; // in scope 7 at $DIR/reference_prop.rs:+16:13: +16:14 + } + } + } + } + scope 8 { + debug a => _19; // in scope 8 at $DIR/reference_prop.rs:+22:13: +22:18 + let _20: &mut usize; // in scope 8 at $DIR/reference_prop.rs:+23:13: +23:14 + scope 9 { + debug b => _20; // in scope 9 at $DIR/reference_prop.rs:+23:13: +23:14 + let _21: &&mut usize; // in scope 9 at $DIR/reference_prop.rs:+24:13: +24:14 + scope 10 { + debug d => _21; // in scope 10 at $DIR/reference_prop.rs:+24:13: +24:14 + let _22: usize; // in scope 10 at $DIR/reference_prop.rs:+25:13: +25:14 + scope 11 { + debug c => _22; // in scope 11 at $DIR/reference_prop.rs:+25:13: +25:14 + } + } + } + } + scope 12 { + debug a => _26; // in scope 12 at $DIR/reference_prop.rs:+31:13: +31:18 + let mut _27: &mut usize; // in scope 12 at $DIR/reference_prop.rs:+32:13: +32:18 + scope 13 { + debug b => _27; // in scope 13 at $DIR/reference_prop.rs:+32:13: +32:18 + let _28: *mut &mut usize; // in scope 13 at $DIR/reference_prop.rs:+33:13: +33:14 + scope 14 { + debug d => _28; // in scope 14 at $DIR/reference_prop.rs:+33:13: +33:14 + let _29: usize; // in scope 14 at $DIR/reference_prop.rs:+34:13: +34:14 + scope 15 { + debug c => _29; // in scope 15 at $DIR/reference_prop.rs:+34:13: +34:14 + } + } + } + } + scope 16 { + debug a => _33; // in scope 16 at $DIR/reference_prop.rs:+40:13: +40:18 + let _34: &mut usize; // in scope 16 at $DIR/reference_prop.rs:+41:13: +41:14 + scope 17 { + debug b => _34; // in scope 17 at $DIR/reference_prop.rs:+41:13: +41:14 + let _35: usize; // in scope 17 at $DIR/reference_prop.rs:+42:13: +42:14 + scope 18 { + debug c => _35; // in scope 18 at $DIR/reference_prop.rs:+42:13: +42:14 + } + } + } + scope 19 { + debug a => _39; // in scope 19 at $DIR/reference_prop.rs:+48:13: +48:18 + let _40: &mut usize; // in scope 19 at $DIR/reference_prop.rs:+49:13: +49:15 + scope 20 { + debug b1 => _40; // in scope 20 at $DIR/reference_prop.rs:+49:13: +49:15 + let _41: usize; // in scope 20 at $DIR/reference_prop.rs:+50:13: +50:14 + scope 21 { + debug c => _41; // in scope 21 at $DIR/reference_prop.rs:+50:13: +50:14 + let _42: &mut usize; // in scope 21 at $DIR/reference_prop.rs:+51:13: +51:15 + scope 22 { + debug b2 => _42; // in scope 22 at $DIR/reference_prop.rs:+51:13: +51:15 + let _43: usize; // in scope 22 at $DIR/reference_prop.rs:+52:13: +52:15 + scope 23 { + debug c2 => _43; // in scope 23 at $DIR/reference_prop.rs:+52:13: +52:15 + let _44: &mut usize; // in scope 23 at $DIR/reference_prop.rs:+53:13: +53:15 + scope 24 { + debug b3 => _44; // in scope 24 at $DIR/reference_prop.rs:+53:13: +53:15 + } + } + } + } + } + } + scope 25 { +- debug a => _48; // in scope 25 at $DIR/reference_prop.rs:+61:13: +61:14 ++ debug a => _1; // in scope 25 at $DIR/reference_prop.rs:+61:13: +61:14 + let _49: T; // in scope 25 at $DIR/reference_prop.rs:+62:13: +62:14 + scope 26 { + debug b => _49; // in scope 26 at $DIR/reference_prop.rs:+62:13: +62:14 + } + } + scope 27 { + debug a => _53; // in scope 27 at $DIR/reference_prop.rs:+68:13: +68:14 + let _56: T; // in scope 27 at $DIR/reference_prop.rs:+70:13: +70:14 + scope 28 { + debug b => _56; // in scope 28 at $DIR/reference_prop.rs:+70:13: +70:14 + } + } + scope 29 { + debug a => _60; // in scope 29 at $DIR/reference_prop.rs:+76:13: +76:18 + let _61: &mut usize; // in scope 29 at $DIR/reference_prop.rs:+77:13: +77:14 + scope 30 { +- debug b => _61; // in scope 30 at $DIR/reference_prop.rs:+77:13: +77:14 ++ debug b => &_60; // in scope 30 at $DIR/reference_prop.rs:+77:13: +77:14 + let _62: &&mut usize; // in scope 30 at $DIR/reference_prop.rs:+78:13: +78:14 + scope 31 { +- debug d => _62; // in scope 31 at $DIR/reference_prop.rs:+78:13: +78:14 ++ debug d => &&_60; // in scope 31 at $DIR/reference_prop.rs:+78:13: +78:14 + let _63: usize; // in scope 31 at $DIR/reference_prop.rs:+79:13: +79:14 + scope 32 { + debug c => _63; // in scope 32 at $DIR/reference_prop.rs:+79:13: +79:14 + } + } + } + } + scope 33 { + debug a => _66; // in scope 33 at $DIR/reference_prop.rs:+85:13: +85:18 + let mut _67: &mut usize; // in scope 33 at $DIR/reference_prop.rs:+86:13: +86:18 + scope 34 { +- debug b => _67; // in scope 34 at $DIR/reference_prop.rs:+86:13: +86:18 ++ debug b => &_66; // in scope 34 at $DIR/reference_prop.rs:+86:13: +86:18 + let _68: &mut &mut usize; // in scope 34 at $DIR/reference_prop.rs:+87:13: +87:14 + scope 35 { +- debug d => _68; // in scope 35 at $DIR/reference_prop.rs:+87:13: +87:14 ++ debug d => &&_66; // in scope 35 at $DIR/reference_prop.rs:+87:13: +87:14 + let _69: usize; // in scope 35 at $DIR/reference_prop.rs:+88:13: +88:14 + scope 36 { + debug c => _69; // in scope 36 at $DIR/reference_prop.rs:+88:13: +88:14 + } + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageLive(_4); // scope 0 at $DIR/reference_prop.rs:+3:13: +3:18 + _4 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+3:21: +3:28 +- StorageLive(_5); // scope 1 at $DIR/reference_prop.rs:+4:13: +4:14 +- _5 = &mut _4; // scope 1 at $DIR/reference_prop.rs:+4:17: +4:23 + StorageLive(_6); // scope 2 at $DIR/reference_prop.rs:+5:13: +5:14 +- _6 = (*_5); // scope 2 at $DIR/reference_prop.rs:+5:17: +5:19 ++ _6 = _4; // scope 2 at $DIR/reference_prop.rs:+5:17: +5:19 + StorageLive(_7); // scope 3 at $DIR/reference_prop.rs:+6:9: +6:19 + StorageLive(_8); // scope 3 at $DIR/reference_prop.rs:+6:16: +6:18 + _8 = (); // scope 3 at $DIR/reference_prop.rs:+6:16: +6:18 + _7 = opaque::<()>(move _8) -> bb1; // scope 3 at $DIR/reference_prop.rs:+6:9: +6:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:109:9: 109:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 3 at $DIR/reference_prop.rs:+6:18: +6:19 + StorageDead(_7); // scope 3 at $DIR/reference_prop.rs:+6:19: +6:20 +- _3 = const (); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageDead(_6); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_5); // scope 1 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageDead(_4); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_3); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageLive(_9); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageLive(_10); // scope 0 at $DIR/reference_prop.rs:+11:13: +11:18 + _10 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+11:21: +11:28 + StorageLive(_11); // scope 4 at $DIR/reference_prop.rs:+12:13: +12:19 + _11 = const 7_usize; // scope 4 at $DIR/reference_prop.rs:+12:22: +12:29 + StorageLive(_12); // scope 5 at $DIR/reference_prop.rs:+13:13: +13:18 + _12 = &mut _10; // scope 5 at $DIR/reference_prop.rs:+13:21: +13:27 + StorageLive(_13); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:20 +- StorageLive(_14); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:20 +- _14 = &mut _11; // scope 6 at $DIR/reference_prop.rs:+14:13: +14:20 +- _13 = &mut (*_14); // scope 6 at $DIR/reference_prop.rs:+14:13: +14:20 ++ _13 = &mut _11; // scope 6 at $DIR/reference_prop.rs:+14:13: +14:20 + _12 = move _13; // scope 6 at $DIR/reference_prop.rs:+14:9: +14:20 + StorageDead(_13); // scope 6 at $DIR/reference_prop.rs:+14:19: +14:20 +- StorageDead(_14); // scope 6 at $DIR/reference_prop.rs:+14:20: +14:21 + StorageLive(_15); // scope 6 at $DIR/reference_prop.rs:+16:13: +16:14 + _15 = (*_12); // scope 6 at $DIR/reference_prop.rs:+16:17: +16:19 + StorageLive(_16); // scope 7 at $DIR/reference_prop.rs:+17:9: +17:19 + StorageLive(_17); // scope 7 at $DIR/reference_prop.rs:+17:16: +17:18 + _17 = (); // scope 7 at $DIR/reference_prop.rs:+17:16: +17:18 + _16 = opaque::<()>(move _17) -> bb2; // scope 7 at $DIR/reference_prop.rs:+17:9: +17:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:120:9: 120:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_17); // scope 7 at $DIR/reference_prop.rs:+17:18: +17:19 + StorageDead(_16); // scope 7 at $DIR/reference_prop.rs:+17:19: +17:20 +- _9 = const (); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageDead(_15); // scope 6 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_12); // scope 5 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_11); // scope 4 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_10); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageDead(_9); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageLive(_18); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageLive(_19); // scope 0 at $DIR/reference_prop.rs:+22:13: +22:18 + _19 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+22:21: +22:28 + StorageLive(_20); // scope 8 at $DIR/reference_prop.rs:+23:13: +23:14 + _20 = &mut _19; // scope 8 at $DIR/reference_prop.rs:+23:17: +23:23 + StorageLive(_21); // scope 9 at $DIR/reference_prop.rs:+24:13: +24:14 + _21 = &_20; // scope 9 at $DIR/reference_prop.rs:+24:17: +24:19 + StorageLive(_22); // scope 10 at $DIR/reference_prop.rs:+25:13: +25:14 + _22 = (*_20); // scope 10 at $DIR/reference_prop.rs:+25:17: +25:19 + StorageLive(_23); // scope 11 at $DIR/reference_prop.rs:+26:9: +26:18 + StorageLive(_24); // scope 11 at $DIR/reference_prop.rs:+26:16: +26:17 + _24 = _21; // scope 11 at $DIR/reference_prop.rs:+26:16: +26:17 + _23 = opaque::<&&mut usize>(move _24) -> bb3; // scope 11 at $DIR/reference_prop.rs:+26:9: +26:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:129:9: 129:15 + // + literal: Const { ty: fn(&&mut usize) {opaque::<&&mut usize>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_24); // scope 11 at $DIR/reference_prop.rs:+26:17: +26:18 + StorageDead(_23); // scope 11 at $DIR/reference_prop.rs:+26:18: +26:19 +- _18 = const (); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageDead(_22); // scope 10 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_21); // scope 9 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_20); // scope 8 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_19); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageDead(_18); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageLive(_25); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageLive(_26); // scope 0 at $DIR/reference_prop.rs:+31:13: +31:18 + _26 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+31:21: +31:28 + StorageLive(_27); // scope 12 at $DIR/reference_prop.rs:+32:13: +32:18 + _27 = &mut _26; // scope 12 at $DIR/reference_prop.rs:+32:21: +32:27 + StorageLive(_28); // scope 13 at $DIR/reference_prop.rs:+33:13: +33:14 + _28 = &raw mut _27; // scope 13 at $DIR/reference_prop.rs:+33:17: +33:27 + StorageLive(_29); // scope 14 at $DIR/reference_prop.rs:+34:13: +34:14 + _29 = (*_27); // scope 14 at $DIR/reference_prop.rs:+34:17: +34:19 + StorageLive(_30); // scope 15 at $DIR/reference_prop.rs:+35:9: +35:18 + StorageLive(_31); // scope 15 at $DIR/reference_prop.rs:+35:16: +35:17 + _31 = _28; // scope 15 at $DIR/reference_prop.rs:+35:16: +35:17 + _30 = opaque::<*mut &mut usize>(move _31) -> bb4; // scope 15 at $DIR/reference_prop.rs:+35:9: +35:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:138:9: 138:15 + // + literal: Const { ty: fn(*mut &mut usize) {opaque::<*mut &mut usize>}, val: Value(<ZST>) } + } + + bb4: { + StorageDead(_31); // scope 15 at $DIR/reference_prop.rs:+35:17: +35:18 + StorageDead(_30); // scope 15 at $DIR/reference_prop.rs:+35:18: +35:19 +- _25 = const (); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageDead(_29); // scope 14 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_28); // scope 13 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_27); // scope 12 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_26); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageDead(_25); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageLive(_32); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageLive(_33); // scope 0 at $DIR/reference_prop.rs:+40:13: +40:18 + _33 = const 7_usize; // scope 0 at $DIR/reference_prop.rs:+40:21: +40:28 + StorageLive(_34); // scope 16 at $DIR/reference_prop.rs:+41:13: +41:14 + _34 = &mut _33; // scope 16 at $DIR/reference_prop.rs:+41:17: +41:23 + StorageLive(_35); // scope 17 at $DIR/reference_prop.rs:+42:13: +42:14 + _35 = (*_34); // scope 17 at $DIR/reference_prop.rs:+42:17: +42:19 + StorageLive(_36); // scope 18 at $DIR/reference_prop.rs:+43:9: +43:18 + StorageLive(_37); // scope 18 at $DIR/reference_prop.rs:+43:16: +43:17 + _37 = move _34; // scope 18 at $DIR/reference_prop.rs:+43:16: +43:17 + _36 = opaque::<&mut usize>(move _37) -> bb5; // scope 18 at $DIR/reference_prop.rs:+43:9: +43:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:146:9: 146:15 + // + literal: Const { ty: fn(&mut usize) {opaque::<&mut usize>}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_37); // scope 18 at $DIR/reference_prop.rs:+43:17: +43:18 + StorageDead(_36); // scope 18 at $DIR/reference_prop.rs:+43:18: +43:19 +- _32 = const (); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageDead(_35); // scope 17 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_34); // scope 16 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_33); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageDead(_32); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageLive(_38); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageLive(_39); // scope 0 at $DIR/reference_prop.rs:+48:13: +48:18 + _39 = const 7_usize; // scope 0 at $DIR/reference_prop.rs:+48:21: +48:28 + StorageLive(_40); // scope 19 at $DIR/reference_prop.rs:+49:13: +49:15 + _40 = &mut _39; // scope 19 at $DIR/reference_prop.rs:+49:18: +49:24 + StorageLive(_41); // scope 20 at $DIR/reference_prop.rs:+50:13: +50:14 + _41 = (*_40); // scope 20 at $DIR/reference_prop.rs:+50:17: +50:20 + StorageLive(_42); // scope 21 at $DIR/reference_prop.rs:+51:13: +51:15 + _42 = move _40; // scope 21 at $DIR/reference_prop.rs:+51:18: +51:20 + StorageLive(_43); // scope 22 at $DIR/reference_prop.rs:+52:13: +52:15 + _43 = (*_42); // scope 22 at $DIR/reference_prop.rs:+52:18: +52:21 + StorageLive(_44); // scope 23 at $DIR/reference_prop.rs:+53:13: +53:15 + _44 = move _42; // scope 23 at $DIR/reference_prop.rs:+53:18: +53:20 + StorageLive(_45); // scope 24 at $DIR/reference_prop.rs:+56:9: +56:19 + StorageLive(_46); // scope 24 at $DIR/reference_prop.rs:+56:16: +56:18 + _46 = move _44; // scope 24 at $DIR/reference_prop.rs:+56:16: +56:18 + _45 = opaque::<&mut usize>(move _46) -> bb6; // scope 24 at $DIR/reference_prop.rs:+56:9: +56:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:159:9: 159:15 + // + literal: Const { ty: fn(&mut usize) {opaque::<&mut usize>}, val: Value(<ZST>) } + } + + bb6: { + StorageDead(_46); // scope 24 at $DIR/reference_prop.rs:+56:18: +56:19 + StorageDead(_45); // scope 24 at $DIR/reference_prop.rs:+56:19: +56:20 +- _38 = const (); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageDead(_44); // scope 23 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_43); // scope 22 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_42); // scope 21 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_41); // scope 20 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_40); // scope 19 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_39); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageDead(_38); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageLive(_47); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 +- StorageLive(_48); // scope 0 at $DIR/reference_prop.rs:+61:13: +61:14 +- _48 = &mut (*_1); // scope 0 at $DIR/reference_prop.rs:+61:17: +61:29 + StorageLive(_49); // scope 25 at $DIR/reference_prop.rs:+62:13: +62:14 +- _49 = (*_48); // scope 25 at $DIR/reference_prop.rs:+62:17: +62:19 ++ _49 = (*_1); // scope 25 at $DIR/reference_prop.rs:+62:17: +62:19 + StorageLive(_50); // scope 26 at $DIR/reference_prop.rs:+63:9: +63:19 + StorageLive(_51); // scope 26 at $DIR/reference_prop.rs:+63:16: +63:18 + _51 = (); // scope 26 at $DIR/reference_prop.rs:+63:16: +63:18 + _50 = opaque::<()>(move _51) -> bb7; // scope 26 at $DIR/reference_prop.rs:+63:9: +63:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:166:9: 166:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_51); // scope 26 at $DIR/reference_prop.rs:+63:18: +63:19 + StorageDead(_50); // scope 26 at $DIR/reference_prop.rs:+63:19: +63:20 +- _47 = const (); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + StorageDead(_49); // scope 25 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_48); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_47); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageLive(_52); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageLive(_53); // scope 0 at $DIR/reference_prop.rs:+68:13: +68:14 + _53 = &mut (*_2); // scope 0 at $DIR/reference_prop.rs:+68:17: +68:31 + StorageLive(_54); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:32 +- StorageLive(_55); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:32 +- _55 = &mut (*_1); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:32 +- _54 = &mut (*_55); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:32 ++ _54 = &mut (*_1); // scope 27 at $DIR/reference_prop.rs:+69:20: +69:32 + _2 = move _54; // scope 27 at $DIR/reference_prop.rs:+69:9: +69:32 + StorageDead(_54); // scope 27 at $DIR/reference_prop.rs:+69:31: +69:32 +- StorageDead(_55); // scope 27 at $DIR/reference_prop.rs:+69:32: +69:33 + StorageLive(_56); // scope 27 at $DIR/reference_prop.rs:+70:13: +70:14 + _56 = (*_53); // scope 27 at $DIR/reference_prop.rs:+70:17: +70:19 + StorageLive(_57); // scope 28 at $DIR/reference_prop.rs:+71:9: +71:19 + StorageLive(_58); // scope 28 at $DIR/reference_prop.rs:+71:16: +71:18 + _58 = (); // scope 28 at $DIR/reference_prop.rs:+71:16: +71:18 + _57 = opaque::<()>(move _58) -> bb8; // scope 28 at $DIR/reference_prop.rs:+71:9: +71:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:174:9: 174:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb8: { + StorageDead(_58); // scope 28 at $DIR/reference_prop.rs:+71:18: +71:19 + StorageDead(_57); // scope 28 at $DIR/reference_prop.rs:+71:19: +71:20 +- _52 = const (); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageDead(_56); // scope 27 at $DIR/reference_prop.rs:+72:5: +72:6 + StorageDead(_53); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageDead(_52); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageLive(_59); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageLive(_60); // scope 0 at $DIR/reference_prop.rs:+76:13: +76:18 + _60 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+76:21: +76:28 +- StorageLive(_61); // scope 29 at $DIR/reference_prop.rs:+77:13: +77:14 +- _61 = &mut _60; // scope 29 at $DIR/reference_prop.rs:+77:17: +77:23 +- StorageLive(_62); // scope 30 at $DIR/reference_prop.rs:+78:13: +78:14 +- _62 = &_61; // scope 30 at $DIR/reference_prop.rs:+78:17: +78:19 + StorageLive(_63); // scope 31 at $DIR/reference_prop.rs:+79:13: +79:14 +- _63 = (*_61); // scope 31 at $DIR/reference_prop.rs:+79:17: +79:19 ++ _63 = _60; // scope 31 at $DIR/reference_prop.rs:+79:17: +79:19 + StorageLive(_64); // scope 32 at $DIR/reference_prop.rs:+80:9: +80:19 + StorageLive(_65); // scope 32 at $DIR/reference_prop.rs:+80:16: +80:18 + _65 = (); // scope 32 at $DIR/reference_prop.rs:+80:16: +80:18 + _64 = opaque::<()>(move _65) -> bb9; // scope 32 at $DIR/reference_prop.rs:+80:9: +80:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:183:9: 183:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb9: { + StorageDead(_65); // scope 32 at $DIR/reference_prop.rs:+80:18: +80:19 + StorageDead(_64); // scope 32 at $DIR/reference_prop.rs:+80:19: +80:20 +- _59 = const (); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageDead(_63); // scope 31 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_62); // scope 30 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_61); // scope 29 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageDead(_60); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_59); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageLive(_66); // scope 0 at $DIR/reference_prop.rs:+85:13: +85:18 + _66 = const 5_usize; // scope 0 at $DIR/reference_prop.rs:+85:21: +85:28 +- StorageLive(_67); // scope 33 at $DIR/reference_prop.rs:+86:13: +86:18 +- _67 = &mut _66; // scope 33 at $DIR/reference_prop.rs:+86:21: +86:27 +- StorageLive(_68); // scope 34 at $DIR/reference_prop.rs:+87:13: +87:14 +- _68 = &mut _67; // scope 34 at $DIR/reference_prop.rs:+87:17: +87:23 + StorageLive(_69); // scope 35 at $DIR/reference_prop.rs:+88:13: +88:14 +- _69 = (*_67); // scope 35 at $DIR/reference_prop.rs:+88:17: +88:19 ++ _69 = _66; // scope 35 at $DIR/reference_prop.rs:+88:17: +88:19 + StorageLive(_70); // scope 36 at $DIR/reference_prop.rs:+89:9: +89:19 + StorageLive(_71); // scope 36 at $DIR/reference_prop.rs:+89:16: +89:18 + _71 = (); // scope 36 at $DIR/reference_prop.rs:+89:16: +89:18 + _70 = opaque::<()>(move _71) -> bb10; // scope 36 at $DIR/reference_prop.rs:+89:9: +89:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:192:9: 192:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb10: { + StorageDead(_71); // scope 36 at $DIR/reference_prop.rs:+89:18: +89:19 + StorageDead(_70); // scope 36 at $DIR/reference_prop.rs:+89:19: +89:20 + _0 = const (); // scope 0 at $DIR/reference_prop.rs:+84:5: +90:6 + StorageDead(_69); // scope 35 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_68); // scope 34 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_67); // scope 33 at $DIR/reference_prop.rs:+90:5: +90:6 + StorageDead(_66); // scope 0 at $DIR/reference_prop.rs:+90:5: +90:6 + return; // scope 0 at $DIR/reference_prop.rs:+91:2: +91:2 + } + } + diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff new file mode 100644 index 000000000..c93aa52be --- /dev/null +++ b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff @@ -0,0 +1,482 @@ +- // MIR for `reference_propagation_mut_ptr` before ReferencePropagation ++ // MIR for `reference_propagation_mut_ptr` after ReferencePropagation + + fn reference_propagation_mut_ptr(_1: *mut T, _2: *mut T) -> () { + debug single => _1; // in scope 0 at $DIR/reference_prop.rs:+0:43: +0:49 + debug multiple => _2; // in scope 0 at $DIR/reference_prop.rs:+0:59: +0:71 + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:81: +0:81 + let _3: (); // in scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + let _7: (); // in scope 0 at $DIR/reference_prop.rs:+6:9: +6:19 + let mut _8: (); // in scope 0 at $DIR/reference_prop.rs:+6:16: +6:18 + let _9: (); // in scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + let mut _13: *mut usize; // in scope 0 at $DIR/reference_prop.rs:+14:13: +14:24 + let _15: (); // in scope 0 at $DIR/reference_prop.rs:+17:9: +17:19 + let mut _16: (); // in scope 0 at $DIR/reference_prop.rs:+17:16: +17:18 + let _17: (); // in scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + let _22: (); // in scope 0 at $DIR/reference_prop.rs:+26:9: +26:18 + let mut _23: &*mut usize; // in scope 0 at $DIR/reference_prop.rs:+26:16: +26:17 + let _24: (); // in scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + let _29: (); // in scope 0 at $DIR/reference_prop.rs:+35:9: +35:18 + let mut _30: *mut *mut usize; // in scope 0 at $DIR/reference_prop.rs:+35:16: +35:17 + let _31: (); // in scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + let _35: (); // in scope 0 at $DIR/reference_prop.rs:+43:9: +43:18 + let mut _36: *mut usize; // in scope 0 at $DIR/reference_prop.rs:+43:16: +43:17 + let _37: (); // in scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + let _44: (); // in scope 0 at $DIR/reference_prop.rs:+56:9: +56:19 + let mut _45: *mut usize; // in scope 0 at $DIR/reference_prop.rs:+56:16: +56:18 + let _46: (); // in scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 + let _49: (); // in scope 0 at $DIR/reference_prop.rs:+63:9: +63:19 + let mut _50: (); // in scope 0 at $DIR/reference_prop.rs:+63:16: +63:18 + let _51: (); // in scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + let mut _53: *mut T; // in scope 0 at $DIR/reference_prop.rs:+69:20: +69:36 + let _55: (); // in scope 0 at $DIR/reference_prop.rs:+71:9: +71:19 + let mut _56: (); // in scope 0 at $DIR/reference_prop.rs:+71:16: +71:18 + let _57: (); // in scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + let _62: (); // in scope 0 at $DIR/reference_prop.rs:+80:9: +80:19 + let mut _63: (); // in scope 0 at $DIR/reference_prop.rs:+80:16: +80:18 + let _68: (); // in scope 0 at $DIR/reference_prop.rs:+89:9: +89:19 + let mut _69: (); // in scope 0 at $DIR/reference_prop.rs:+89:16: +89:18 + scope 1 { + let mut _4: usize; // in scope 1 at $DIR/reference_prop.rs:+3:13: +3:18 + scope 2 { + debug a => _4; // in scope 2 at $DIR/reference_prop.rs:+3:13: +3:18 + let _5: *mut usize; // in scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 + scope 3 { +- debug b => _5; // in scope 3 at $DIR/reference_prop.rs:+4:13: +4:14 ++ debug b => &_4; // in scope 3 at $DIR/reference_prop.rs:+4:13: +4:14 + let _6: usize; // in scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 + scope 4 { + debug c => _6; // in scope 4 at $DIR/reference_prop.rs:+5:13: +5:14 + } + } + } + } + scope 5 { + let mut _10: usize; // in scope 5 at $DIR/reference_prop.rs:+11:13: +11:18 + scope 6 { + debug a => _10; // in scope 6 at $DIR/reference_prop.rs:+11:13: +11:18 + let mut _11: usize; // in scope 6 at $DIR/reference_prop.rs:+12:13: +12:19 + scope 7 { + debug a2 => _11; // in scope 7 at $DIR/reference_prop.rs:+12:13: +12:19 + let mut _12: *mut usize; // in scope 7 at $DIR/reference_prop.rs:+13:13: +13:18 + scope 8 { + debug b => _12; // in scope 8 at $DIR/reference_prop.rs:+13:13: +13:18 + let _14: usize; // in scope 8 at $DIR/reference_prop.rs:+16:13: +16:14 + scope 9 { + debug c => _14; // in scope 9 at $DIR/reference_prop.rs:+16:13: +16:14 + } + } + } + } + } + scope 10 { + let mut _18: usize; // in scope 10 at $DIR/reference_prop.rs:+22:13: +22:18 + scope 11 { + debug a => _18; // in scope 11 at $DIR/reference_prop.rs:+22:13: +22:18 + let _19: *mut usize; // in scope 11 at $DIR/reference_prop.rs:+23:13: +23:14 + scope 12 { + debug b => _19; // in scope 12 at $DIR/reference_prop.rs:+23:13: +23:14 + let _20: &*mut usize; // in scope 12 at $DIR/reference_prop.rs:+24:13: +24:14 + scope 13 { + debug d => _20; // in scope 13 at $DIR/reference_prop.rs:+24:13: +24:14 + let _21: usize; // in scope 13 at $DIR/reference_prop.rs:+25:13: +25:14 + scope 14 { + debug c => _21; // in scope 14 at $DIR/reference_prop.rs:+25:13: +25:14 + } + } + } + } + } + scope 15 { + let mut _25: usize; // in scope 15 at $DIR/reference_prop.rs:+31:13: +31:18 + scope 16 { + debug a => _25; // in scope 16 at $DIR/reference_prop.rs:+31:13: +31:18 + let mut _26: *mut usize; // in scope 16 at $DIR/reference_prop.rs:+32:13: +32:18 + scope 17 { + debug b => _26; // in scope 17 at $DIR/reference_prop.rs:+32:13: +32:18 + let _27: *mut *mut usize; // in scope 17 at $DIR/reference_prop.rs:+33:13: +33:14 + scope 18 { + debug d => _27; // in scope 18 at $DIR/reference_prop.rs:+33:13: +33:14 + let _28: usize; // in scope 18 at $DIR/reference_prop.rs:+34:13: +34:14 + scope 19 { + debug c => _28; // in scope 19 at $DIR/reference_prop.rs:+34:13: +34:14 + } + } + } + } + } + scope 20 { + let mut _32: usize; // in scope 20 at $DIR/reference_prop.rs:+40:13: +40:18 + scope 21 { + debug a => _32; // in scope 21 at $DIR/reference_prop.rs:+40:13: +40:18 + let _33: *mut usize; // in scope 21 at $DIR/reference_prop.rs:+41:13: +41:14 + scope 22 { + debug b => _33; // in scope 22 at $DIR/reference_prop.rs:+41:13: +41:14 + let _34: usize; // in scope 22 at $DIR/reference_prop.rs:+42:13: +42:14 + scope 23 { + debug c => _34; // in scope 23 at $DIR/reference_prop.rs:+42:13: +42:14 + } + } + } + } + scope 24 { + let mut _38: usize; // in scope 24 at $DIR/reference_prop.rs:+48:13: +48:18 + scope 25 { + debug a => _38; // in scope 25 at $DIR/reference_prop.rs:+48:13: +48:18 + let _39: *mut usize; // in scope 25 at $DIR/reference_prop.rs:+49:13: +49:15 + scope 26 { + debug b1 => _39; // in scope 26 at $DIR/reference_prop.rs:+49:13: +49:15 + let _40: usize; // in scope 26 at $DIR/reference_prop.rs:+50:13: +50:14 + scope 27 { + debug c => _40; // in scope 27 at $DIR/reference_prop.rs:+50:13: +50:14 + let _41: *mut usize; // in scope 27 at $DIR/reference_prop.rs:+51:13: +51:15 + scope 28 { + debug b2 => _41; // in scope 28 at $DIR/reference_prop.rs:+51:13: +51:15 + let _42: usize; // in scope 28 at $DIR/reference_prop.rs:+52:13: +52:15 + scope 29 { + debug c2 => _42; // in scope 29 at $DIR/reference_prop.rs:+52:13: +52:15 + let _43: *mut usize; // in scope 29 at $DIR/reference_prop.rs:+53:13: +53:15 + scope 30 { + debug b3 => _43; // in scope 30 at $DIR/reference_prop.rs:+53:13: +53:15 + } + } + } + } + } + } + } + scope 31 { + let _47: *mut T; // in scope 31 at $DIR/reference_prop.rs:+61:13: +61:14 + scope 32 { +- debug a => _47; // in scope 32 at $DIR/reference_prop.rs:+61:13: +61:14 ++ debug a => _1; // in scope 32 at $DIR/reference_prop.rs:+61:13: +61:14 + let _48: T; // in scope 32 at $DIR/reference_prop.rs:+62:13: +62:14 + scope 33 { + debug b => _48; // in scope 33 at $DIR/reference_prop.rs:+62:13: +62:14 + } + } + } + scope 34 { + let _52: *mut T; // in scope 34 at $DIR/reference_prop.rs:+68:13: +68:14 + scope 35 { + debug a => _52; // in scope 35 at $DIR/reference_prop.rs:+68:13: +68:14 + let _54: T; // in scope 35 at $DIR/reference_prop.rs:+70:13: +70:14 + scope 36 { + debug b => _54; // in scope 36 at $DIR/reference_prop.rs:+70:13: +70:14 + } + } + } + scope 37 { + let mut _58: usize; // in scope 37 at $DIR/reference_prop.rs:+76:13: +76:18 + scope 38 { + debug a => _58; // in scope 38 at $DIR/reference_prop.rs:+76:13: +76:18 + let _59: *mut usize; // in scope 38 at $DIR/reference_prop.rs:+77:13: +77:14 + scope 39 { +- debug b => _59; // in scope 39 at $DIR/reference_prop.rs:+77:13: +77:14 ++ debug b => &_58; // in scope 39 at $DIR/reference_prop.rs:+77:13: +77:14 + let _60: &*mut usize; // in scope 39 at $DIR/reference_prop.rs:+78:13: +78:14 + scope 40 { +- debug d => _60; // in scope 40 at $DIR/reference_prop.rs:+78:13: +78:14 ++ debug d => &&_58; // in scope 40 at $DIR/reference_prop.rs:+78:13: +78:14 + let _61: usize; // in scope 40 at $DIR/reference_prop.rs:+79:13: +79:14 + scope 41 { + debug c => _61; // in scope 41 at $DIR/reference_prop.rs:+79:13: +79:14 + } + } + } + } + } + scope 42 { + let mut _64: usize; // in scope 42 at $DIR/reference_prop.rs:+85:13: +85:18 + scope 43 { + debug a => _64; // in scope 43 at $DIR/reference_prop.rs:+85:13: +85:18 + let mut _65: *mut usize; // in scope 43 at $DIR/reference_prop.rs:+86:13: +86:18 + scope 44 { +- debug b => _65; // in scope 44 at $DIR/reference_prop.rs:+86:13: +86:18 ++ debug b => &_64; // in scope 44 at $DIR/reference_prop.rs:+86:13: +86:18 + let _66: &mut *mut usize; // in scope 44 at $DIR/reference_prop.rs:+87:13: +87:14 + scope 45 { +- debug d => _66; // in scope 45 at $DIR/reference_prop.rs:+87:13: +87:14 ++ debug d => &&_64; // in scope 45 at $DIR/reference_prop.rs:+87:13: +87:14 + let _67: usize; // in scope 45 at $DIR/reference_prop.rs:+88:13: +88:14 + scope 46 { + debug c => _67; // in scope 46 at $DIR/reference_prop.rs:+88:13: +88:14 + } + } + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageLive(_4); // scope 1 at $DIR/reference_prop.rs:+3:13: +3:18 + _4 = const 5_usize; // scope 1 at $DIR/reference_prop.rs:+3:21: +3:28 +- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+4:13: +4:14 +- _5 = &raw mut _4; // scope 2 at $DIR/reference_prop.rs:+4:17: +4:27 + StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+5:13: +5:14 +- _6 = (*_5); // scope 3 at $DIR/reference_prop.rs:+5:17: +5:19 ++ _6 = _4; // scope 3 at $DIR/reference_prop.rs:+5:17: +5:19 + StorageLive(_7); // scope 4 at $DIR/reference_prop.rs:+6:9: +6:19 + StorageLive(_8); // scope 4 at $DIR/reference_prop.rs:+6:16: +6:18 + _8 = (); // scope 4 at $DIR/reference_prop.rs:+6:16: +6:18 + _7 = opaque::<()>(move _8) -> bb1; // scope 4 at $DIR/reference_prop.rs:+6:9: +6:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:304:9: 304:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 4 at $DIR/reference_prop.rs:+6:18: +6:19 + StorageDead(_7); // scope 4 at $DIR/reference_prop.rs:+6:19: +6:20 +- _3 = const (); // scope 1 at $DIR/reference_prop.rs:+2:5: +7:6 + StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageDead(_4); // scope 1 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageDead(_3); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 +- StorageLive(_9); // scope 0 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageLive(_10); // scope 5 at $DIR/reference_prop.rs:+11:13: +11:18 + _10 = const 5_usize; // scope 5 at $DIR/reference_prop.rs:+11:21: +11:28 + StorageLive(_11); // scope 6 at $DIR/reference_prop.rs:+12:13: +12:19 + _11 = const 7_usize; // scope 6 at $DIR/reference_prop.rs:+12:22: +12:29 + StorageLive(_12); // scope 7 at $DIR/reference_prop.rs:+13:13: +13:18 + _12 = &raw mut _10; // scope 7 at $DIR/reference_prop.rs:+13:21: +13:31 + StorageLive(_13); // scope 8 at $DIR/reference_prop.rs:+14:13: +14:24 + _13 = &raw mut _11; // scope 8 at $DIR/reference_prop.rs:+14:13: +14:24 + _12 = move _13; // scope 8 at $DIR/reference_prop.rs:+14:9: +14:24 + StorageDead(_13); // scope 8 at $DIR/reference_prop.rs:+14:23: +14:24 + StorageLive(_14); // scope 8 at $DIR/reference_prop.rs:+16:13: +16:14 + _14 = (*_12); // scope 8 at $DIR/reference_prop.rs:+16:17: +16:19 + StorageLive(_15); // scope 9 at $DIR/reference_prop.rs:+17:9: +17:19 + StorageLive(_16); // scope 9 at $DIR/reference_prop.rs:+17:16: +17:18 + _16 = (); // scope 9 at $DIR/reference_prop.rs:+17:16: +17:18 + _15 = opaque::<()>(move _16) -> bb2; // scope 9 at $DIR/reference_prop.rs:+17:9: +17:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:315:9: 315:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_16); // scope 9 at $DIR/reference_prop.rs:+17:18: +17:19 + StorageDead(_15); // scope 9 at $DIR/reference_prop.rs:+17:19: +17:20 +- _9 = const (); // scope 5 at $DIR/reference_prop.rs:+10:5: +18:6 + StorageDead(_14); // scope 8 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_12); // scope 7 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_11); // scope 6 at $DIR/reference_prop.rs:+18:5: +18:6 + StorageDead(_10); // scope 5 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageDead(_9); // scope 0 at $DIR/reference_prop.rs:+18:5: +18:6 +- StorageLive(_17); // scope 0 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageLive(_18); // scope 10 at $DIR/reference_prop.rs:+22:13: +22:18 + _18 = const 5_usize; // scope 10 at $DIR/reference_prop.rs:+22:21: +22:28 + StorageLive(_19); // scope 11 at $DIR/reference_prop.rs:+23:13: +23:14 + _19 = &raw mut _18; // scope 11 at $DIR/reference_prop.rs:+23:17: +23:27 + StorageLive(_20); // scope 12 at $DIR/reference_prop.rs:+24:13: +24:14 + _20 = &_19; // scope 12 at $DIR/reference_prop.rs:+24:17: +24:19 + StorageLive(_21); // scope 13 at $DIR/reference_prop.rs:+25:13: +25:14 + _21 = (*_19); // scope 13 at $DIR/reference_prop.rs:+25:17: +25:19 + StorageLive(_22); // scope 14 at $DIR/reference_prop.rs:+26:9: +26:18 + StorageLive(_23); // scope 14 at $DIR/reference_prop.rs:+26:16: +26:17 + _23 = _20; // scope 14 at $DIR/reference_prop.rs:+26:16: +26:17 + _22 = opaque::<&*mut usize>(move _23) -> bb3; // scope 14 at $DIR/reference_prop.rs:+26:9: +26:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:324:9: 324:15 + // + literal: Const { ty: fn(&*mut usize) {opaque::<&*mut usize>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_23); // scope 14 at $DIR/reference_prop.rs:+26:17: +26:18 + StorageDead(_22); // scope 14 at $DIR/reference_prop.rs:+26:18: +26:19 +- _17 = const (); // scope 10 at $DIR/reference_prop.rs:+21:5: +27:6 + StorageDead(_21); // scope 13 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_20); // scope 12 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_19); // scope 11 at $DIR/reference_prop.rs:+27:5: +27:6 + StorageDead(_18); // scope 10 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageDead(_17); // scope 0 at $DIR/reference_prop.rs:+27:5: +27:6 +- StorageLive(_24); // scope 0 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageLive(_25); // scope 15 at $DIR/reference_prop.rs:+31:13: +31:18 + _25 = const 5_usize; // scope 15 at $DIR/reference_prop.rs:+31:21: +31:28 + StorageLive(_26); // scope 16 at $DIR/reference_prop.rs:+32:13: +32:18 + _26 = &raw mut _25; // scope 16 at $DIR/reference_prop.rs:+32:21: +32:31 + StorageLive(_27); // scope 17 at $DIR/reference_prop.rs:+33:13: +33:14 + _27 = &raw mut _26; // scope 17 at $DIR/reference_prop.rs:+33:17: +33:27 + StorageLive(_28); // scope 18 at $DIR/reference_prop.rs:+34:13: +34:14 + _28 = (*_26); // scope 18 at $DIR/reference_prop.rs:+34:17: +34:19 + StorageLive(_29); // scope 19 at $DIR/reference_prop.rs:+35:9: +35:18 + StorageLive(_30); // scope 19 at $DIR/reference_prop.rs:+35:16: +35:17 + _30 = _27; // scope 19 at $DIR/reference_prop.rs:+35:16: +35:17 + _29 = opaque::<*mut *mut usize>(move _30) -> bb4; // scope 19 at $DIR/reference_prop.rs:+35:9: +35:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:333:9: 333:15 + // + literal: Const { ty: fn(*mut *mut usize) {opaque::<*mut *mut usize>}, val: Value(<ZST>) } + } + + bb4: { + StorageDead(_30); // scope 19 at $DIR/reference_prop.rs:+35:17: +35:18 + StorageDead(_29); // scope 19 at $DIR/reference_prop.rs:+35:18: +35:19 +- _24 = const (); // scope 15 at $DIR/reference_prop.rs:+30:5: +36:6 + StorageDead(_28); // scope 18 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_27); // scope 17 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_26); // scope 16 at $DIR/reference_prop.rs:+36:5: +36:6 + StorageDead(_25); // scope 15 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageDead(_24); // scope 0 at $DIR/reference_prop.rs:+36:5: +36:6 +- StorageLive(_31); // scope 0 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageLive(_32); // scope 20 at $DIR/reference_prop.rs:+40:13: +40:18 + _32 = const 7_usize; // scope 20 at $DIR/reference_prop.rs:+40:21: +40:28 + StorageLive(_33); // scope 21 at $DIR/reference_prop.rs:+41:13: +41:14 + _33 = &raw mut _32; // scope 21 at $DIR/reference_prop.rs:+41:17: +41:27 + StorageLive(_34); // scope 22 at $DIR/reference_prop.rs:+42:13: +42:14 + _34 = (*_33); // scope 22 at $DIR/reference_prop.rs:+42:17: +42:19 + StorageLive(_35); // scope 23 at $DIR/reference_prop.rs:+43:9: +43:18 + StorageLive(_36); // scope 23 at $DIR/reference_prop.rs:+43:16: +43:17 + _36 = _33; // scope 23 at $DIR/reference_prop.rs:+43:16: +43:17 + _35 = opaque::<*mut usize>(move _36) -> bb5; // scope 23 at $DIR/reference_prop.rs:+43:9: +43:18 + // mir::Constant + // + span: $DIR/reference_prop.rs:341:9: 341:15 + // + literal: Const { ty: fn(*mut usize) {opaque::<*mut usize>}, val: Value(<ZST>) } + } + + bb5: { + StorageDead(_36); // scope 23 at $DIR/reference_prop.rs:+43:17: +43:18 + StorageDead(_35); // scope 23 at $DIR/reference_prop.rs:+43:18: +43:19 +- _31 = const (); // scope 20 at $DIR/reference_prop.rs:+39:5: +44:6 + StorageDead(_34); // scope 22 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_33); // scope 21 at $DIR/reference_prop.rs:+44:5: +44:6 + StorageDead(_32); // scope 20 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageDead(_31); // scope 0 at $DIR/reference_prop.rs:+44:5: +44:6 +- StorageLive(_37); // scope 0 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageLive(_38); // scope 24 at $DIR/reference_prop.rs:+48:13: +48:18 + _38 = const 7_usize; // scope 24 at $DIR/reference_prop.rs:+48:21: +48:28 + StorageLive(_39); // scope 25 at $DIR/reference_prop.rs:+49:13: +49:15 + _39 = &raw mut _38; // scope 25 at $DIR/reference_prop.rs:+49:18: +49:28 + StorageLive(_40); // scope 26 at $DIR/reference_prop.rs:+50:13: +50:14 + _40 = (*_39); // scope 26 at $DIR/reference_prop.rs:+50:17: +50:20 + StorageLive(_41); // scope 27 at $DIR/reference_prop.rs:+51:13: +51:15 + _41 = _39; // scope 27 at $DIR/reference_prop.rs:+51:18: +51:20 + StorageLive(_42); // scope 28 at $DIR/reference_prop.rs:+52:13: +52:15 + _42 = (*_41); // scope 28 at $DIR/reference_prop.rs:+52:18: +52:21 + StorageLive(_43); // scope 29 at $DIR/reference_prop.rs:+53:13: +53:15 + _43 = _41; // scope 29 at $DIR/reference_prop.rs:+53:18: +53:20 + StorageLive(_44); // scope 30 at $DIR/reference_prop.rs:+56:9: +56:19 + StorageLive(_45); // scope 30 at $DIR/reference_prop.rs:+56:16: +56:18 + _45 = _43; // scope 30 at $DIR/reference_prop.rs:+56:16: +56:18 + _44 = opaque::<*mut usize>(move _45) -> bb6; // scope 30 at $DIR/reference_prop.rs:+56:9: +56:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:354:9: 354:15 + // + literal: Const { ty: fn(*mut usize) {opaque::<*mut usize>}, val: Value(<ZST>) } + } + + bb6: { + StorageDead(_45); // scope 30 at $DIR/reference_prop.rs:+56:18: +56:19 + StorageDead(_44); // scope 30 at $DIR/reference_prop.rs:+56:19: +56:20 +- _37 = const (); // scope 24 at $DIR/reference_prop.rs:+47:5: +57:6 + StorageDead(_43); // scope 29 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_42); // scope 28 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_41); // scope 27 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_40); // scope 26 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_39); // scope 25 at $DIR/reference_prop.rs:+57:5: +57:6 + StorageDead(_38); // scope 24 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageDead(_37); // scope 0 at $DIR/reference_prop.rs:+57:5: +57:6 +- StorageLive(_46); // scope 0 at $DIR/reference_prop.rs:+60:5: +64:6 +- StorageLive(_47); // scope 31 at $DIR/reference_prop.rs:+61:13: +61:14 +- _47 = &raw mut (*_1); // scope 31 at $DIR/reference_prop.rs:+61:17: +61:33 + StorageLive(_48); // scope 32 at $DIR/reference_prop.rs:+62:13: +62:14 +- _48 = (*_47); // scope 32 at $DIR/reference_prop.rs:+62:17: +62:19 ++ _48 = (*_1); // scope 32 at $DIR/reference_prop.rs:+62:17: +62:19 + StorageLive(_49); // scope 33 at $DIR/reference_prop.rs:+63:9: +63:19 + StorageLive(_50); // scope 33 at $DIR/reference_prop.rs:+63:16: +63:18 + _50 = (); // scope 33 at $DIR/reference_prop.rs:+63:16: +63:18 + _49 = opaque::<()>(move _50) -> bb7; // scope 33 at $DIR/reference_prop.rs:+63:9: +63:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:361:9: 361:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_50); // scope 33 at $DIR/reference_prop.rs:+63:18: +63:19 + StorageDead(_49); // scope 33 at $DIR/reference_prop.rs:+63:19: +63:20 +- _46 = const (); // scope 31 at $DIR/reference_prop.rs:+60:5: +64:6 + StorageDead(_48); // scope 32 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_47); // scope 31 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageDead(_46); // scope 0 at $DIR/reference_prop.rs:+64:5: +64:6 +- StorageLive(_51); // scope 0 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageLive(_52); // scope 34 at $DIR/reference_prop.rs:+68:13: +68:14 + _52 = &raw mut (*_2); // scope 34 at $DIR/reference_prop.rs:+68:17: +68:35 + StorageLive(_53); // scope 35 at $DIR/reference_prop.rs:+69:20: +69:36 + _53 = &raw mut (*_1); // scope 35 at $DIR/reference_prop.rs:+69:20: +69:36 + _2 = move _53; // scope 35 at $DIR/reference_prop.rs:+69:9: +69:36 + StorageDead(_53); // scope 35 at $DIR/reference_prop.rs:+69:35: +69:36 + StorageLive(_54); // scope 35 at $DIR/reference_prop.rs:+70:13: +70:14 + _54 = (*_52); // scope 35 at $DIR/reference_prop.rs:+70:17: +70:19 + StorageLive(_55); // scope 36 at $DIR/reference_prop.rs:+71:9: +71:19 + StorageLive(_56); // scope 36 at $DIR/reference_prop.rs:+71:16: +71:18 + _56 = (); // scope 36 at $DIR/reference_prop.rs:+71:16: +71:18 + _55 = opaque::<()>(move _56) -> bb8; // scope 36 at $DIR/reference_prop.rs:+71:9: +71:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:369:9: 369:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb8: { + StorageDead(_56); // scope 36 at $DIR/reference_prop.rs:+71:18: +71:19 + StorageDead(_55); // scope 36 at $DIR/reference_prop.rs:+71:19: +71:20 +- _51 = const (); // scope 34 at $DIR/reference_prop.rs:+67:5: +72:6 + StorageDead(_54); // scope 35 at $DIR/reference_prop.rs:+72:5: +72:6 + StorageDead(_52); // scope 34 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageDead(_51); // scope 0 at $DIR/reference_prop.rs:+72:5: +72:6 +- StorageLive(_57); // scope 0 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageLive(_58); // scope 37 at $DIR/reference_prop.rs:+76:13: +76:18 + _58 = const 5_usize; // scope 37 at $DIR/reference_prop.rs:+76:21: +76:28 +- StorageLive(_59); // scope 38 at $DIR/reference_prop.rs:+77:13: +77:14 +- _59 = &raw mut _58; // scope 38 at $DIR/reference_prop.rs:+77:17: +77:27 +- StorageLive(_60); // scope 39 at $DIR/reference_prop.rs:+78:13: +78:14 +- _60 = &_59; // scope 39 at $DIR/reference_prop.rs:+78:17: +78:19 + StorageLive(_61); // scope 40 at $DIR/reference_prop.rs:+79:13: +79:14 +- _61 = (*_59); // scope 40 at $DIR/reference_prop.rs:+79:17: +79:19 ++ _61 = _58; // scope 40 at $DIR/reference_prop.rs:+79:17: +79:19 + StorageLive(_62); // scope 41 at $DIR/reference_prop.rs:+80:9: +80:19 + StorageLive(_63); // scope 41 at $DIR/reference_prop.rs:+80:16: +80:18 + _63 = (); // scope 41 at $DIR/reference_prop.rs:+80:16: +80:18 + _62 = opaque::<()>(move _63) -> bb9; // scope 41 at $DIR/reference_prop.rs:+80:9: +80:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:378:9: 378:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb9: { + StorageDead(_63); // scope 41 at $DIR/reference_prop.rs:+80:18: +80:19 + StorageDead(_62); // scope 41 at $DIR/reference_prop.rs:+80:19: +80:20 +- _57 = const (); // scope 37 at $DIR/reference_prop.rs:+75:5: +81:6 + StorageDead(_61); // scope 40 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_60); // scope 39 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_59); // scope 38 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageDead(_58); // scope 37 at $DIR/reference_prop.rs:+81:5: +81:6 +- StorageDead(_57); // scope 0 at $DIR/reference_prop.rs:+81:5: +81:6 + StorageLive(_64); // scope 42 at $DIR/reference_prop.rs:+85:13: +85:18 + _64 = const 5_usize; // scope 42 at $DIR/reference_prop.rs:+85:21: +85:28 +- StorageLive(_65); // scope 43 at $DIR/reference_prop.rs:+86:13: +86:18 +- _65 = &raw mut _64; // scope 43 at $DIR/reference_prop.rs:+86:21: +86:31 +- StorageLive(_66); // scope 44 at $DIR/reference_prop.rs:+87:13: +87:14 +- _66 = &mut _65; // scope 44 at $DIR/reference_prop.rs:+87:17: +87:23 + StorageLive(_67); // scope 45 at $DIR/reference_prop.rs:+88:13: +88:14 +- _67 = (*_65); // scope 45 at $DIR/reference_prop.rs:+88:17: +88:19 ++ _67 = _64; // scope 45 at $DIR/reference_prop.rs:+88:17: +88:19 + StorageLive(_68); // scope 46 at $DIR/reference_prop.rs:+89:9: +89:19 + StorageLive(_69); // scope 46 at $DIR/reference_prop.rs:+89:16: +89:18 + _69 = (); // scope 46 at $DIR/reference_prop.rs:+89:16: +89:18 + _68 = opaque::<()>(move _69) -> bb10; // scope 46 at $DIR/reference_prop.rs:+89:9: +89:19 + // mir::Constant + // + span: $DIR/reference_prop.rs:387:9: 387:15 + // + literal: Const { ty: fn(()) {opaque::<()>}, val: Value(<ZST>) } + } + + bb10: { + StorageDead(_69); // scope 46 at $DIR/reference_prop.rs:+89:18: +89:19 + StorageDead(_68); // scope 46 at $DIR/reference_prop.rs:+89:19: +89:20 + _0 = const (); // scope 42 at $DIR/reference_prop.rs:+84:5: +90:6 + StorageDead(_67); // scope 45 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_66); // scope 44 at $DIR/reference_prop.rs:+90:5: +90:6 +- StorageDead(_65); // scope 43 at $DIR/reference_prop.rs:+90:5: +90:6 + StorageDead(_64); // scope 42 at $DIR/reference_prop.rs:+90:5: +90:6 + return; // scope 0 at $DIR/reference_prop.rs:+91:2: +91:2 + } + } + diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs new file mode 100644 index 000000000..4083b4547 --- /dev/null +++ b/tests/mir-opt/reference_prop.rs @@ -0,0 +1,592 @@ +// unit-test: ReferencePropagation +// needs-unwind + +#![feature(raw_ref_op)] +#![feature(core_intrinsics, custom_mir)] + +#[inline(never)] +fn opaque(_: impl Sized) {} + +fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) { + // Propagation through a reference. + { + let a = 5_usize; + let b = &a; // This borrow is only used once. + let c = *b; // This should be optimized. + opaque(()); // We use opaque to separate cases into basic blocks in the MIR. + } + + // Propagation through a two references. + { + let a = 5_usize; + let a2 = 7_usize; + let mut b = &a; + b = &a2; + // `b` is assigned twice, so we cannot propagate it. + let c = *b; + opaque(()); + } + + // Propagation through a borrowed reference. + { + let a = 5_usize; + let b = &a; + let d = &b; + let c = *b; // `b` is immutably borrowed, we know its value, but do not propagate it + opaque(d); // prevent `d` from being removed. + } + + // Propagation through a borrowed reference. + { + let a = 5_usize; + let mut b = &a; + let d = &raw mut b; + let c = *b; // `b` is mutably borrowed, we cannot know its value. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through an escaping borrow. + { + let a = 7_usize; + let b = &a; + let c = *b; + opaque(b); // `b` escapes here, but we can still replace immutable borrow + } + + // Propagation through a transitively escaping borrow. + { + let a = 7_usize; + let b1 = &a; + let c = *b1; + let b2 = b1; + let c2 = *b2; + let b3 = b2; + // `b3` escapes here, so we can only replace immutable borrow, + // for either `b`, `b2` or `b3`. + opaque(b3); + } + + // Propagation a reborrow of an argument. + { + let a = &*single; + let b = *a; // This should be optimized as `*single`. + opaque(()); + } + + // Propagation a reborrow of a mutated argument. + { + let a = &*multiple; + multiple = &*single; + let b = *a; // This should not be optimized. + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + { + let a = 5_usize; + let b = &a; + let d = &b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + { + let a = 5_usize; + let mut b = &a; + let d = &mut b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } +} + +fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a mut T) { + // Propagation through a reference. + { + let mut a = 5_usize; + let b = &mut a; // This borrow is only used once. + let c = *b; // This should be optimized. + opaque(()); + } + + // Propagation through a two references. + { + let mut a = 5_usize; + let mut a2 = 7_usize; + let mut b = &mut a; + b = &mut a2; + // `b` is assigned twice, so we cannot propagate it. + let c = *b; + opaque(()); + } + + // Propagation through a borrowed reference. + { + let mut a = 5_usize; + let b = &mut a; + let d = &b; + let c = *b; // `b` is immutably borrowed, we know its value, but cannot be removed. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through a borrowed reference. + { + let mut a = 5_usize; + let mut b = &mut a; + let d = &raw mut b; + let c = *b; // `b` is mutably borrowed, we cannot know its value. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through an escaping borrow. + { + let mut a = 7_usize; + let b = &mut a; + let c = *b; + opaque(b); // `b` escapes here, so we can only replace immutable borrow + } + + // Propagation through a transitively escaping borrow. + { + let mut a = 7_usize; + let b1 = &mut a; + let c = *b1; + let b2 = b1; + let c2 = *b2; + let b3 = b2; + // `b3` escapes here, so we can only replace immutable borrow, + // for either `b`, `b2` or `b3`. + opaque(b3); + } + + // Propagation a reborrow of an argument. + { + let a = &mut *single; + let b = *a; // This should be optimized as `*single`. + opaque(()); + } + + // Propagation a reborrow of a mutated argument. + { + let a = &mut *multiple; + multiple = &mut *single; + let b = *a; // This should not be optimized. + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + { + let mut a = 5_usize; + let b = &mut a; + let d = &b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + { + let mut a = 5_usize; + let mut b = &mut a; + let d = &mut b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } +} + +fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *const T) { + // Propagation through a reference. + unsafe { + let a = 5_usize; + let b = &raw const a; // This borrow is only used once. + let c = *b; // This should be optimized. + opaque(()); + } + + // Propagation through a two references. + unsafe { + let a = 5_usize; + let a2 = 7_usize; + let mut b = &raw const a; + b = &raw const a2; + // `b` is assigned twice, so we cannot propagate it. + let c = *b; + opaque(()); + } + + // Propagation through a borrowed reference. + unsafe { + let a = 5_usize; + let b = &raw const a; + let d = &b; + let c = *b; // `b` is immutably borrowed, we know its value, but cannot be removed. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through a borrowed reference. + unsafe { + let a = 5_usize; + let mut b = &raw const a; + let d = &raw mut b; + let c = *b; // `b` is mutably borrowed, we cannot know its value. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through an escaping borrow. + unsafe { + let a = 7_usize; + let b = &raw const a; + let c = *b; + opaque(b); // `b` escapes here, so we can only replace immutable borrow + } + + // Propagation through a transitively escaping borrow. + unsafe { + let a = 7_usize; + let b1 = &raw const a; + let c = *b1; + let b2 = b1; + let c2 = *b2; + let b3 = b2; + // `b3` escapes here, so we can only replace immutable borrow, + // for either `b`, `b2` or `b3`. + opaque(b3); + } + + // Propagation a reborrow of an argument. + unsafe { + let a = &raw const *single; + let b = *a; // This should be optimized as `*single`. + opaque(()); + } + + // Propagation a reborrow of a mutated argument. + unsafe { + let a = &raw const *multiple; + multiple = &raw const *single; + let b = *a; // This should not be optimized. + opaque(()); + } + + // Propagation through a reborrow. + unsafe { + let a = 13_usize; + let b = &raw const a; + let c = &raw const *b; + let e = *c; + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + unsafe { + let a = 5_usize; + let b = &raw const a; + let d = &b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + unsafe { + let a = 5_usize; + let mut b = &raw const a; + let d = &mut b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } +} + +fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T) { + // Propagation through a reference. + unsafe { + let mut a = 5_usize; + let b = &raw mut a; // This borrow is only used once. + let c = *b; // This should be optimized. + opaque(()); + } + + // Propagation through a two references. + unsafe { + let mut a = 5_usize; + let mut a2 = 7_usize; + let mut b = &raw mut a; + b = &raw mut a2; + // `b` is assigned twice, so we cannot propagate it. + let c = *b; + opaque(()); + } + + // Propagation through a borrowed reference. + unsafe { + let mut a = 5_usize; + let b = &raw mut a; + let d = &b; + let c = *b; // `b` is immutably borrowed, we know its value, but cannot be removed. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through a borrowed reference. + unsafe { + let mut a = 5_usize; + let mut b = &raw mut a; + let d = &raw mut b; + let c = *b; // `b` is mutably borrowed, we cannot know its value. + opaque(d); // prevent `d` from being removed. + } + + // Propagation through an escaping borrow. + unsafe { + let mut a = 7_usize; + let b = &raw mut a; + let c = *b; + opaque(b); // `b` escapes here, so we can only replace immutable borrow + } + + // Propagation through a transitively escaping borrow. + unsafe { + let mut a = 7_usize; + let b1 = &raw mut a; + let c = *b1; + let b2 = b1; + let c2 = *b2; + let b3 = b2; + // `b3` escapes here, so we can only replace immutable borrow, + // for either `b`, `b2` or `b3`. + opaque(b3); + } + + // Propagation a reborrow of an argument. + unsafe { + let a = &raw mut *single; + let b = *a; // This should be optimized as `*single`. + opaque(()); + } + + // Propagation a reborrow of a mutated argument. + unsafe { + let a = &raw mut *multiple; + multiple = &raw mut *single; + let b = *a; // This should not be optimized. + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + unsafe { + let mut a = 5_usize; + let b = &raw mut a; + let d = &b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } + + // Fixed-point propagation through a borrowed reference. + unsafe { + let mut a = 5_usize; + let mut b = &raw mut a; + let d = &mut b; // first round promotes debuginfo for `d` + let c = *b; // second round propagates this dereference + opaque(()); + } +} + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +fn read_through_raw(x: &mut usize) -> usize { + use std::intrinsics::mir::*; + + mir!( + let r1: &mut usize; + let r2: &mut usize; + let p1: *mut usize; + let p2: *mut usize; + + { + r1 = &mut *x; + r2 = &mut *r1; + p1 = &raw mut *r1; + p2 = &raw mut *r2; + + RET = *p1; + RET = *p2; + Return() + } + ) +} + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +fn multiple_storage() { + use std::intrinsics::mir::*; + + mir!( + let x: i32; + { + StorageLive(x); + x = 5; + let z = &x; + StorageDead(x); + StorageLive(x); + // As there are multiple `StorageLive` statements for `x`, we cannot know if this `z`'s + // pointer address is the address of `x`, so do nothing. + let y = *z; + Call(RET, retblock, opaque(y)) + } + + retblock = { + Return() + } + ) +} + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +fn dominate_storage() { + use std::intrinsics::mir::*; + + mir!( + let x: i32; + let r: &i32; + let c: i32; + let d: bool; + { Goto(bb0) } + bb0 = { + x = 5; + r = &x; + Goto(bb1) + } + bb1 = { + let c = *r; + Call(RET, bb2, opaque(c)) + } + bb2 = { + StorageDead(x); + StorageLive(x); + let d = true; + match d { false => bb2, _ => bb0 } + } + ) +} + +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +fn maybe_dead(m: bool) { + use std::intrinsics::mir::*; + + mir!( + let x: i32; + let y: i32; + { + StorageLive(x); + StorageLive(y); + x = 5; + y = 5; + let a = &x; + let b = &mut y; + // As we don't replace `b` in `bb2`, we cannot replace it here either. + *b = 7; + // But this can still be replaced. + let u = *a; + match m { true => bb1, _ => bb2 } + } + bb1 = { + StorageDead(x); + StorageDead(y); + Call(RET, bb2, opaque(u)) + } + bb2 = { + // As `x` may be `StorageDead`, `a` may be dangling, so we do nothing. + let z = *a; + Call(RET, bb3, opaque(z)) + } + bb3 = { + // As `y` may be `StorageDead`, `b` may be dangling, so we do nothing. + // This implies that we also do not substitute `b` in `bb0`. + let t = *b; + Call(RET, retblock, opaque(t)) + } + retblock = { + Return() + } + ) +} + +fn mut_raw_then_mut_shr() -> (i32, i32) { + let mut x = 2; + let xref = &mut x; + let xraw = &mut *xref as *mut _; + let xshr = &*xref; + // Verify that we completely replace with `x` in both cases. + let a = *xshr; + unsafe { *xraw = 4; } + (a, x) +} + +fn unique_with_copies() { + let y = { + let mut a = 0; + let x = &raw mut a; + // `*y` is not replacable below, so we must not replace `*x`. + unsafe { opaque(*x) }; + x + }; + // But rewriting as `*x` is ok. + unsafe { opaque(*y) }; +} + +fn debuginfo() { + struct T(u8); + + let ref_mut_u8 = &mut 5_u8; + let field = &T(0).0; + + // Verify that we don't emit `&*` in debuginfo. + let reborrow = &*ref_mut_u8; + + match Some(0) { + None => {} + Some(ref variant_field) => {} + } + + // `constant_index_from_end` and `subslice` should not be promoted, as their value depends + // on the slice length. + if let [_, ref constant_index, subslice @ .., ref constant_index_from_end] = &[6; 10][..] { + } + + let multiple_borrow = &&&mut T(6).0; +} + +fn many_debuginfo() { + let a = 0; + + // Verify that we do not ICE on deeply nested borrows. + let many_borrow = + &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&a; +} + +fn main() { + let mut x = 5_usize; + let mut y = 7_usize; + reference_propagation(&x, &y); + reference_propagation_mut(&mut x, &mut y); + reference_propagation_const_ptr(&raw const x, &raw const y); + reference_propagation_mut_ptr(&raw mut x, &raw mut y); + read_through_raw(&mut x); + multiple_storage(); + dominate_storage(); + maybe_dead(true); + mut_raw_then_mut_shr(); + unique_with_copies(); + debuginfo(); + many_debuginfo(); +} + +// EMIT_MIR reference_prop.reference_propagation.ReferencePropagation.diff +// EMIT_MIR reference_prop.reference_propagation_mut.ReferencePropagation.diff +// EMIT_MIR reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff +// EMIT_MIR reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff +// EMIT_MIR reference_prop.read_through_raw.ReferencePropagation.diff +// EMIT_MIR reference_prop.multiple_storage.ReferencePropagation.diff +// EMIT_MIR reference_prop.dominate_storage.ReferencePropagation.diff +// EMIT_MIR reference_prop.maybe_dead.ReferencePropagation.diff +// EMIT_MIR reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff +// EMIT_MIR reference_prop.unique_with_copies.ReferencePropagation.diff +// EMIT_MIR reference_prop.debuginfo.ReferencePropagation.diff diff --git a/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff b/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff new file mode 100644 index 000000000..b754aff47 --- /dev/null +++ b/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff @@ -0,0 +1,67 @@ +- // MIR for `unique_with_copies` before ReferencePropagation ++ // MIR for `unique_with_copies` after ReferencePropagation + + fn unique_with_copies() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:25: +0:25 + let _1: *mut i32; // in scope 0 at $DIR/reference_prop.rs:+1:9: +1:10 + let mut _2: i32; // in scope 0 at $DIR/reference_prop.rs:+2:13: +2:18 + let _4: (); // in scope 0 at $DIR/reference_prop.rs:+5:18: +5:28 + let mut _5: i32; // in scope 0 at $DIR/reference_prop.rs:+5:25: +5:27 + let _6: (); // in scope 0 at $DIR/reference_prop.rs:+9:14: +9:24 + let mut _7: i32; // in scope 0 at $DIR/reference_prop.rs:+9:21: +9:23 + scope 1 { +- debug y => _1; // in scope 1 at $DIR/reference_prop.rs:+1:9: +1:10 ++ debug y => _3; // in scope 1 at $DIR/reference_prop.rs:+1:9: +1:10 + scope 5 { + } + } + scope 2 { + debug a => _2; // in scope 2 at $DIR/reference_prop.rs:+2:13: +2:18 + let _3: *mut i32; // in scope 2 at $DIR/reference_prop.rs:+3:13: +3:14 + scope 3 { + debug x => _3; // in scope 3 at $DIR/reference_prop.rs:+3:13: +3:14 + scope 4 { + } + } + } + + bb0: { +- StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/reference_prop.rs:+2:13: +2:18 + _2 = const 0_i32; // scope 0 at $DIR/reference_prop.rs:+2:21: +2:22 +- StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:13: +3:14 + _3 = &raw mut _2; // scope 2 at $DIR/reference_prop.rs:+3:17: +3:27 + StorageLive(_4); // scope 3 at $DIR/reference_prop.rs:+5:9: +5:30 + StorageLive(_5); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27 + _5 = (*_3); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27 + _4 = opaque::<i32>(move _5) -> bb1; // scope 4 at $DIR/reference_prop.rs:+5:18: +5:28 + // mir::Constant + // + span: $DIR/reference_prop.rs:524:18: 524:24 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_5); // scope 4 at $DIR/reference_prop.rs:+5:27: +5:28 + StorageDead(_4); // scope 3 at $DIR/reference_prop.rs:+5:30: +5:31 +- _1 = _3; // scope 3 at $DIR/reference_prop.rs:+6:9: +6:10 +- StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6 + StorageLive(_6); // scope 1 at $DIR/reference_prop.rs:+9:5: +9:26 + StorageLive(_7); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23 +- _7 = (*_1); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23 ++ _7 = (*_3); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23 + _6 = opaque::<i32>(move _7) -> bb2; // scope 5 at $DIR/reference_prop.rs:+9:14: +9:24 + // mir::Constant + // + span: $DIR/reference_prop.rs:528:14: 528:20 + // + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) } + } + + bb2: { + StorageDead(_7); // scope 5 at $DIR/reference_prop.rs:+9:23: +9:24 + StorageDead(_6); // scope 1 at $DIR/reference_prop.rs:+9:26: +9:27 + _0 = const (); // scope 0 at $DIR/reference_prop.rs:+0:25: +10:2 +- StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+10:1: +10:2 + return; // scope 0 at $DIR/reference_prop.rs:+10:2: +10:2 + } + } + diff --git a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir b/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir deleted file mode 100644 index cae89fb17..000000000 --- a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir +++ /dev/null @@ -1,42 +0,0 @@ -// MIR for `ezmap` after PreCodegen - -fn ezmap(_1: Option<i32>) -> Option<i32> { - debug x => _1; // in scope 0 at $DIR/simple_option_map_e2e.rs:+0:14: +0:15 - let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map_e2e.rs:+0:33: +0:44 - scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]>) { // at $DIR/simple_option_map_e2e.rs:14:5: 14:22 - debug slf => _1; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:17: 2:20 - debug f => const ZeroSized: [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34 - let mut _2: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16 - let _3: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - let mut _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - scope 2 { - debug x => _3; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - debug n => _3; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14 - } - } - } - - bb0: { - _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14 - switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map_e2e.rs:6:5: 6:14 - } - - bb1: { - _0 = Option::<i32>::None; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 - return; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 - } - - bb2: { - unreachable; // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14 - } - - bb3: { - _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - StorageLive(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - _4 = Add(_3, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21 - _0 = Option::<i32>::Some(move _4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 - StorageDead(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30 - return; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2 - } -} diff --git a/tests/mir-opt/simplify_arm.rs b/tests/mir-opt/simplify_arm.rs index c247872e2..4c471ce04 100644 --- a/tests/mir-opt/simplify_arm.rs +++ b/tests/mir-opt/simplify_arm.rs @@ -6,8 +6,7 @@ // EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff // EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff -// This pass is broken since deaggregation changed -// ignore-test +// ignore-test This pass is broken since deaggregation changed fn id(o: Option<u8>) -> Option<u8> { match o { diff --git a/tests/mir-opt/simplify_arm_identity.rs b/tests/mir-opt/simplify_arm_identity.rs index cf6ff57aa..e122cd50e 100644 --- a/tests/mir-opt/simplify_arm_identity.rs +++ b/tests/mir-opt/simplify_arm_identity.rs @@ -4,8 +4,7 @@ // compile-flags: -Zmir-opt-level=3 // EMIT_MIR_FOR_EACH_BIT_WIDTH -// This pass is broken since deaggregation changed -// ignore-test +// ignore-test This pass is broken since deaggregation changed enum Src { Foo(u8), diff --git a/tests/mir-opt/slice_filter.rs b/tests/mir-opt/slice_filter.rs index 97c18af31..be32f40f1 100644 --- a/tests/mir-opt/slice_filter.rs +++ b/tests/mir-opt/slice_filter.rs @@ -12,7 +12,9 @@ pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize { input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() } +// EMIT_MIR slice_filter.variant_a-{closure#0}.ReferencePropagation.diff // EMIT_MIR slice_filter.variant_a-{closure#0}.CopyProp.diff // EMIT_MIR slice_filter.variant_a-{closure#0}.DestinationPropagation.diff // EMIT_MIR slice_filter.variant_b-{closure#0}.CopyProp.diff +// EMIT_MIR slice_filter.variant_b-{closure#0}.ReferencePropagation.diff // EMIT_MIR slice_filter.variant_b-{closure#0}.DestinationPropagation.diff diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff index 3bb0358ff..60e5056c7 100644 --- a/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff +++ b/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff @@ -101,16 +101,16 @@ } bb0: { -- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 -- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 -- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 -- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 @@ -184,10 +184,10 @@ bb3: { StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 } diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff index 294c3272f..afdcf5781 100644 --- a/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff +++ b/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff @@ -3,118 +3,79 @@ fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 - let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 - let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 - let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 - let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 - let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 - let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 - let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 - let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 - let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 - let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _3: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 + let mut _4: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 + let mut _5: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 + let mut _6: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 + let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _10: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _11: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _12: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 scope 1 { - debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 - debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 - debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 - debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 + debug a => &((*_9).0: usize); // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 + debug b => &((*_10).1: usize); // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 + debug c => &((*_11).2: usize); // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 + debug d => &((*_12).3: usize); // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:40: 8:46 - debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &&((*_9).0: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &&((*_11).2: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _31: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _32: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &((*_9).0: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &((*_11).2: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _13: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _14: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL } } scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:60: 8:66 - debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _33: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _34: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &&((*_11).2: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &&((*_9).0: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => _33; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _34; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _35: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _36: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &((*_11).2: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &((*_9).0: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _15: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _16: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL } } scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:50: 8:56 - debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _37: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _38: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &&((*_12).3: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &&((*_10).1: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => _37; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _38; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _39: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _40: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &((*_12).3: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &((*_10).1: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _17: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _18: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL } } scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:70: 8:76 - debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _41: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _42: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &&((*_10).1: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &&((*_12).3: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => _41; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _42; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _43: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _44: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => &((*_10).1: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => &((*_12).3: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _19: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _20: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL } } } bb0: { - _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 -- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + _9 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _10 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _11 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _12 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 +- StorageLive(_3); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 - StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 - _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 - StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _31 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _32 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _8 = Le(move _31, move _32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageLive(_4); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 + StorageLive(_13); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _13 = ((*_9).0: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _14 = ((*_11).2: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _4 = Le(move _13, move _14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + switchInt(move _4) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 } bb1: { @@ -123,113 +84,80 @@ } bb2: { -- StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 +- StorageLive(_6); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 - StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 - _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 - StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _33 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - _34 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _35 = (*_33); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _36 = (*_34); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _17 = Le(move _35, move _36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 + StorageLive(_15); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _15 = ((*_11).2: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _16 = ((*_9).0: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _7 = Le(move _15, move _16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_15); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + switchInt(move _7) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 } bb3: { -- StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_6); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_3); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 } bb4: { -- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- StorageDead(_5); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_4); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 } bb5: { -- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 +- StorageLive(_5); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 + nop; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 - StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 - _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 - StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _37 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - _38 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_39); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _39 = (*_37); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _40 = (*_38); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _12 = Le(move _39, move _40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_39); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 -- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageLive(_17); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _17 = ((*_12).3: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _18 = ((*_10).1: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _5 = Le(move _17, move _18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_17); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _3 = move _5; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 +- StorageDead(_5); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 -+ switchInt(move _12) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + StorageDead(_4); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 ++ switchInt(move _5) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 } bb6: { -- _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 +- _6 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + _0 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 } bb7: { -- StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 +- StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 - StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 - _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 - StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _41 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - _42 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _43 = (*_41); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _44 = (*_42); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _21 = Le(move _43, move _44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _0 = Le(move _43, move _44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_19); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _19 = ((*_10).1: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _20 = ((*_12).3: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _8 = Le(move _19, move _20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _0 = Le(move _19, move _20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_19); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _6 = move _8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 } bb8: { -- StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _0 = move _6; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 } diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff new file mode 100644 index 000000000..2534eeef4 --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff @@ -0,0 +1,267 @@ +- // MIR for `variant_a::{closure#0}` before ReferencePropagation ++ // MIR for `variant_a::{closure#0}` after ReferencePropagation + + fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 + let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 + let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 + let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 + let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 + let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 + let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 + let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 + let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 + let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 + let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _31: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _37: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _38: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _43: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _44: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _49: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _50: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 1 { +- debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 +- debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 +- debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 +- debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 ++ debug a => &((*_25).0: usize); // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 ++ debug b => &((*_26).1: usize); // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 ++ debug c => &((*_27).2: usize); // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 ++ debug d => &((*_28).3: usize); // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 + scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:40: 8:46 +- debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &&((*_25).0: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &&((*_27).2: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &((*_25).0: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &((*_27).2: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _33: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _34: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:60: 8:66 +- debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &&((*_27).2: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &&((*_25).0: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _35: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _36: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _35; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _36; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &((*_27).2: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &((*_25).0: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _39: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _40: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:50: 8:56 +- debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &&((*_28).3: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &&((*_26).1: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _41: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _42: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _41; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _42; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &((*_28).3: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &((*_26).1: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _45: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _46: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:70: 8:76 +- debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &&((*_26).1: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &&((*_28).3: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _47: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _48: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _47; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _48; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => &((*_26).1: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => &((*_28).3: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _51: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _52: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 +- _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 +- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 +- _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 +- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 +- _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 +- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 +- _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 +- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 +- _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 +- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _33 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _33 = ((*_25).0: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _34 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _34 = ((*_27).2: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _8 = Le(move _33, move _34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 +- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb2: { + StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 +- StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 +- _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 +- StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- _35 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _36 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _39 = (*_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _39 = ((*_27).2: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _40 = (*_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _40 = ((*_25).0: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _17 = Le(move _39, move _40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 +- StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb3: { + StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 + } + + bb4: { + _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb5: { + StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 +- StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 +- _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 +- StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- _41 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _42 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _45 = (*_41); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _45 = ((*_28).3: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _46 = (*_42); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _46 = ((*_26).1: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _12 = Le(move _45, move _46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb6: { + _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb7: { + StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 +- StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 +- _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 +- StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _47 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _48 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _51 = (*_47); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _51 = ((*_26).1: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _52 = (*_48); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _52 = ((*_28).3: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _21 = Le(move _51, move _52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb8: { + StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + } + diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff new file mode 100644 index 000000000..d1241c6b0 --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff @@ -0,0 +1,103 @@ +- // MIR for `variant_b::{closure#0}` before ReferencePropagation ++ // MIR for `variant_b::{closure#0}` after ReferencePropagation + + fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 + let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 + let mut _9: usize; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:43 + let mut _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:47: +0:48 + let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 + let mut _12: usize; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:53 + let mut _13: usize; // in scope 0 at $DIR/slice_filter.rs:+0:57: +0:58 + let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 + let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 + let mut _16: usize; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:63 + let mut _17: usize; // in scope 0 at $DIR/slice_filter.rs:+0:67: +0:68 + let mut _18: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 + let mut _19: usize; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:73 + let mut _20: usize; // in scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 + let mut _21: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _22: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _23: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _24: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + scope 1 { + debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 + debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 + debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 + debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 + } + + bb0: { + _21 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _3 = ((*_21).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _22 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _4 = ((*_22).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _23 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _5 = ((*_23).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _24 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + _6 = ((*_24).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb2: { + StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + _15 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + switchInt(move _15) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb3: { + StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 + } + + bb4: { + _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb5: { + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _11 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _7 = move _11; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb6: { + _14 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb7: { + StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 + _18 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 + _14 = move _18; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb8: { + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + _0 = move _14; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + } + diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 579587a43..9bda5f575 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -15,14 +15,14 @@ let mut _13: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 let _14: &[&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 let _15: [&str; 3]; // in scope 0 at $DIR/lifetimes.rs:+10:19: +10:28 - let mut _16: &[core::fmt::ArgumentV1<'_>]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _17: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _18: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _19: [core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _20: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let mut _16: &[core::fmt::rt::Argument<'_>]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _17: &[core::fmt::rt::Argument<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _18: &[core::fmt::rt::Argument<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let _19: [core::fmt::rt::Argument<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _20: core::fmt::rt::Argument<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 let mut _21: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 let _22: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 - let mut _23: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let mut _23: core::fmt::rt::Argument<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 let mut _24: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 let _25: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 let mut _27: bool; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 @@ -113,11 +113,11 @@ StorageLive(_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 _22 = &_8; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 _21 = &(*_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 - _20 = core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _21) -> [return: bb3, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _20 = core::fmt::rt::Argument::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _21) -> [return: bb3, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 // mir::Constant // + span: $DIR/lifetimes.rs:27:20: 27:23 // + user_ty: UserType(4) - // + literal: Const { ty: for<'b> fn(&'b Box<dyn std::fmt::Display>) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>}, val: Value(<ZST>) } + // + literal: Const { ty: for<'b> fn(&'b Box<dyn std::fmt::Display>) -> core::fmt::rt::Argument<'b> {core::fmt::rt::Argument::<'_>::new_display::<Box<dyn std::fmt::Display>>}, val: Value(<ZST>) } } bb3: { @@ -127,11 +127,11 @@ StorageLive(_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 _25 = &_6; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 _24 = &(*_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 - _23 = core::fmt::ArgumentV1::<'_>::new_display::<u32>(move _24) -> [return: bb4, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _23 = core::fmt::rt::Argument::<'_>::new_display::<u32>(move _24) -> [return: bb4, unwind unreachable]; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 // mir::Constant // + span: $DIR/lifetimes.rs:27:24: 27:27 // + user_ty: UserType(5) - // + literal: Const { ty: for<'b> fn(&'b u32) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<u32>}, val: Value(<ZST>) } + // + literal: Const { ty: for<'b> fn(&'b u32) -> core::fmt::rt::Argument<'b> {core::fmt::rt::Argument::<'_>::new_display::<u32>}, val: Value(<ZST>) } } bb4: { @@ -141,13 +141,13 @@ StorageDead(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _18 = &_19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _17 = &(*_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _16 = move _17 as &[core::fmt::ArgumentV1<'_>] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _16 = move _17 as &[core::fmt::rt::Argument<'_>] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_17); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL _11 = Arguments::<'_>::new_v1(move _12, move _16) -> [return: bb5, unwind unreachable]; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/std/src/macros.rs:LL:COL // + user_ty: UserType(3) - // + literal: Const { ty: fn(&[&'static str], &[core::fmt::ArgumentV1<'_>]) -> Arguments<'_> {Arguments::<'_>::new_v1}, val: Value(<ZST>) } + // + literal: Const { ty: fn(&[&'static str], &[core::fmt::rt::Argument<'_>]) -> Arguments<'_> {Arguments::<'_>::new_v1}, val: Value(<ZST>) } } bb5: { diff --git a/tests/mir-opt/storage_ranges.main.nll.0.mir b/tests/mir-opt/storage_ranges.main.nll.0.mir index 8e10e70f1..5bb1a7bf0 100644 --- a/tests/mir-opt/storage_ranges.main.nll.0.mir +++ b/tests/mir-opt/storage_ranges.main.nll.0.mir @@ -1,21 +1,21 @@ // MIR for `main` 0 nll | Free Region Mapping -| '_#0r | Global | ['_#0r, '_#1r] -| '_#1r | Local | ['_#1r] +| '?0 | Global | ['?0, '?1] +| '?1 | Local | ['?1] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=22], '_#0r, '_#1r} -| '_#1r | U0 | {bb0[0..=22], '_#1r} -| '_#2r | U0 | {bb0[10..=11]} -| '_#3r | U0 | {bb0[11]} +| '?0 | U0 | {bb0[0..=22], '?0, '?1} +| '?1 | U0 | {bb0[0..=22], '?1} +| '?2 | U0 | {bb0[10..=11]} +| '?3 | U0 | {bb0[11]} | | Inference Constraints -| '_#0r live at {bb0[0..=22]} -| '_#1r live at {bb0[0..=22]} -| '_#2r live at {bb0[10]} -| '_#3r live at {bb0[11]} -| '_#2r: '_#3r due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:6:17: 6:25 (#0) +| '?0 live at {bb0[0..=22]} +| '?1 live at {bb0[0..=22]} +| '?2 live at {bb0[10]} +| '?3 live at {bb0[11]} +| '?2: '?3 due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:6:17: 6:25 (#0) | fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/storage_ranges.rs:+0:11: +0:11 diff --git a/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir b/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir index 2af864998..4b2a16b50 100644 --- a/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir +++ b/tests/mir-opt/uninhabited_enum.process_void.SimplifyLocals-final.after.mir @@ -3,16 +3,13 @@ fn process_void(_1: *const Void) -> () { debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:21: +0:26 let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum.rs:+0:41: +0:41 - let _2: &Void; // in scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 scope 1 { - debug _input => _2; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 + debug _input => _1; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 } scope 2 { } bb0: { - StorageLive(_2); // scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 - StorageDead(_2); // scope 0 at $DIR/uninhabited_enum.rs:+4:1: +4:2 return; // scope 0 at $DIR/uninhabited_enum.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/while_let_loops.change_loop_body.PreCodegen.after.mir b/tests/mir-opt/while_let_loops.change_loop_body.PreCodegen.after.mir deleted file mode 100644 index 15b0aece8..000000000 --- a/tests/mir-opt/while_let_loops.change_loop_body.PreCodegen.after.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `change_loop_body` after PreCodegen - -fn change_loop_body() -> () { - let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27 - let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - scope 1 { - debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15 - scope 2 { - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 - StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 - return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 - } -} diff --git a/tests/pretty/offset_of.rs b/tests/pretty/offset_of.rs new file mode 100644 index 000000000..e17834328 --- /dev/null +++ b/tests/pretty/offset_of.rs @@ -0,0 +1,4 @@ +// pp-exact +#![feature(offset_of)] + +fn main() { std::mem::offset_of!(std :: ops :: Range < usize >, end); } diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index 58f746f2e..7d7f68213 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -79,6 +79,7 @@ pub const a_test: test::TestDescAndFn = }; fn a_test() {} #[rustc_main] +#[no_coverage] pub fn main() -> () { extern crate test; test::test_main_static(&[&a_test, &m_test, &z_test]) diff --git a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 8dac53c2a..7db100a08 100644 --- a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -67,7 +67,7 @@ impl CodegenBackend for TheBackend { let crate_name = codegen_results.crate_info.local_crate_name; for &crate_type in sess.opts.crate_types.iter() { if crate_type != CrateType::Rlib { - sess.fatal(&format!("Crate type is {:?}", crate_type)); + sess.fatal(format!("Crate type is {:?}", crate_type)); } let output_name = out_filename(sess, crate_type, &outputs, crate_name); let mut out_file = ::std::fs::File::create(output_name).unwrap(); diff --git a/tests/run-make-fulldeps/obtain-borrowck/driver.rs b/tests/run-make-fulldeps/obtain-borrowck/driver.rs index 9cd504f00..b59a65a71 100644 --- a/tests/run-make-fulldeps/obtain-borrowck/driver.rs +++ b/tests/run-make-fulldeps/obtain-borrowck/driver.rs @@ -18,15 +18,15 @@ extern crate rustc_interface; extern crate rustc_middle; extern crate rustc_session; -use rustc_borrowck::consumers::BodyWithBorrowckFacts; +use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions}; use rustc_driver::Compilation; -use rustc_hir::def_id::LocalDefId; use rustc_hir::def::DefKind; +use rustc_hir::def_id::LocalDefId; use rustc_interface::interface::Compiler; use rustc_interface::{Config, Queries}; -use rustc_middle::ty::query::query_values::mir_borrowck; -use rustc_middle::ty::query::{ExternProviders, Providers}; -use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::query::queries::mir_borrowck::ProvidedValue; +use rustc_middle::query::{ExternProviders, Providers}; +use rustc_middle::ty::TyCtxt; use rustc_session::Session; use std::cell::RefCell; use std::collections::HashMap; @@ -102,7 +102,7 @@ impl rustc_driver::Callbacks for CompilerCalls { println!("Bodies retrieved for:"); for (def_id, body) in bodies { println!("{}", def_id); - assert!(body.input_facts.cfg_edge.len() > 0); + assert!(body.input_facts.unwrap().cfg_edge.len() > 0); } }); @@ -126,11 +126,9 @@ thread_local! { RefCell::new(HashMap::new()); } -fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> mir_borrowck<'tcx> { - let body_with_facts = rustc_borrowck::consumers::get_body_with_borrowck_facts( - tcx, - ty::WithOptConstParam::unknown(def_id), - ); +fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> { + let opts = ConsumerOptions::PoloniusInputFacts; + let body_with_facts = consumers::get_body_with_borrowck_facts(tcx, def_id, opts); // SAFETY: The reader casts the 'static lifetime to 'tcx before using it. let body_with_facts: BodyWithBorrowckFacts<'static> = unsafe { std::mem::transmute(body_with_facts) }; diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/Makefile b/tests/run-make/CURRENT_RUSTC_VERSION/Makefile new file mode 100644 index 000000000..7940dae20 --- /dev/null +++ b/tests/run-make/CURRENT_RUSTC_VERSION/Makefile @@ -0,0 +1,6 @@ +include ../tools.mk + +all: + $(RUSTC) --emit=metadata --crate-type lib stable.rs + $(RUSTC) --emit=metadata --extern stable=$(TMPDIR)/libstable.rmeta main.rs 2>&1 >/dev/null \ + | $(CGREP) -e "stable since $$(cat $(S)/src/version)(-[a-zA-Z]+)?" diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/main.rs b/tests/run-make/CURRENT_RUSTC_VERSION/main.rs new file mode 100644 index 000000000..466aaa82b --- /dev/null +++ b/tests/run-make/CURRENT_RUSTC_VERSION/main.rs @@ -0,0 +1,4 @@ +#![feature(foo)] +extern crate stable; + +fn main() {} diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/stable.rs b/tests/run-make/CURRENT_RUSTC_VERSION/stable.rs new file mode 100644 index 000000000..2fd09aded --- /dev/null +++ b/tests/run-make/CURRENT_RUSTC_VERSION/stable.rs @@ -0,0 +1,5 @@ +#![feature(staged_api)] +#![stable(since = "1.0.0", feature = "rust1")] + +#[stable(since = "CURRENT_RUSTC_VERSION", feature = "foo")] +pub fn foo() {} diff --git a/tests/run-make/allocator-shim-circular-deps/Makefile b/tests/run-make/allocator-shim-circular-deps/Makefile new file mode 100644 index 000000000..4624b8468 --- /dev/null +++ b/tests/run-make/allocator-shim-circular-deps/Makefile @@ -0,0 +1,7 @@ +# ignore-cross-compile +include ../tools.mk + +all: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) my_lib.rs + $(RUSTC) main.rs --test --extern my_lib=$(TMPDIR)/libmy_lib.rlib diff --git a/tests/run-make/allocator-shim-circular-deps/main.rs b/tests/run-make/allocator-shim-circular-deps/main.rs new file mode 100644 index 000000000..e317c6571 --- /dev/null +++ b/tests/run-make/allocator-shim-circular-deps/main.rs @@ -0,0 +1,5 @@ +#![crate_type = "bin"] + +fn main() { + my_lib::do_something(); +} diff --git a/tests/run-make/allocator-shim-circular-deps/my_lib.rs b/tests/run-make/allocator-shim-circular-deps/my_lib.rs new file mode 100644 index 000000000..095b10361 --- /dev/null +++ b/tests/run-make/allocator-shim-circular-deps/my_lib.rs @@ -0,0 +1,10 @@ +#![crate_type = "lib"] + +use std::alloc::System; + +#[global_allocator] +static ALLOCATOR: System = System; + +pub fn do_something() { + format!("allocating a string!"); +} diff --git a/tests/run-make/branch-protection-check-IBT/Makefile b/tests/run-make/branch-protection-check-IBT/Makefile new file mode 100644 index 000000000..cabe951e1 --- /dev/null +++ b/tests/run-make/branch-protection-check-IBT/Makefile @@ -0,0 +1,15 @@ +# Check for GNU Property Note + +include ../tools.mk + +# How to run this +# python3 x.py test --target x86_64-unknown-linux-gnu tests/run-make/branch-protection-check-IBT/ + +# only-x86_64 + +all: +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86_64) + $(RUSTC) --target x86_64-unknown-linux-gnu -Z cf-protection=branch -L$(TMPDIR) -C link-args='-nostartfiles' -C save-temps ./main.rs -o $(TMPDIR)/rsmain + readelf -nW $(TMPDIR)/rsmain | $(CGREP) -e ".note.gnu.property" +endif + diff --git a/tests/run-make/branch-protection-check-IBT/main.rs b/tests/run-make/branch-protection-check-IBT/main.rs new file mode 100644 index 000000000..ad379d6ea --- /dev/null +++ b/tests/run-make/branch-protection-check-IBT/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("hello world"); +} diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile b/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile index 9c41a5a71..b8e0e9483 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: archive diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs index 78a71219c..42d3efa82 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs @@ -2,7 +2,6 @@ //! //! This test triggers a panic in a Rust library that our foreign function invokes. This shows //! that we can unwind through the C code in that library, and catch the underlying panic. -#![feature(c_unwind)] use std::panic::{catch_unwind, AssertUnwindSafe}; diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs index a99a04d5c..9e7bc3e53 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs @@ -1,5 +1,4 @@ #![crate_type = "staticlib"] -#![feature(c_unwind)] /// This function will panic if `x` is greater than 10. /// diff --git a/tests/run-make/c-unwind-abi-catch-panic/Makefile b/tests/run-make/c-unwind-abi-catch-panic/Makefile index 4398ac2ee..1760ddb30 100644 --- a/tests/run-make/c-unwind-abi-catch-panic/Makefile +++ b/tests/run-make/c-unwind-abi-catch-panic/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: $(call NATIVE_STATICLIB,add) diff --git a/tests/run-make/c-unwind-abi-catch-panic/main.rs b/tests/run-make/c-unwind-abi-catch-panic/main.rs index 15d38d721..1903be956 100644 --- a/tests/run-make/c-unwind-abi-catch-panic/main.rs +++ b/tests/run-make/c-unwind-abi-catch-panic/main.rs @@ -1,7 +1,6 @@ //! A test for calling `C-unwind` functions across foreign function boundaries. //! //! This test triggers a panic when calling a foreign function that calls *back* into Rust. -#![feature(c_unwind)] use std::panic::{catch_unwind, AssertUnwindSafe}; diff --git a/tests/run-make/const-prop-lint/Makefile b/tests/run-make/const-prop-lint/Makefile new file mode 100644 index 000000000..f29f282f7 --- /dev/null +++ b/tests/run-make/const-prop-lint/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +# Test that emitting an error because of arithmetic +# overflow lint does not leave .o files around +# because of interrupted codegen. + +all: + $(RUSTC) input.rs; test $$? -eq 1 + ls *.o; test $$? -ne 0 diff --git a/tests/run-make/const-prop-lint/input.rs b/tests/run-make/const-prop-lint/input.rs new file mode 100644 index 000000000..ccbdfb8d5 --- /dev/null +++ b/tests/run-make/const-prop-lint/input.rs @@ -0,0 +1,5 @@ +#![deny(arithmetic_overflow)] + +fn main() { + let x = 255u8 + 1; +} diff --git a/tests/run-make/const_fn_mir/Makefile b/tests/run-make/const_fn_mir/Makefile index b2c268f04..6d72c1227 100644 --- a/tests/run-make/const_fn_mir/Makefile +++ b/tests/run-make/const_fn_mir/Makefile @@ -1,3 +1,4 @@ +# needs-unwind -Cpanic=abort gives different MIR output include ../tools.mk all: diff --git a/tests/run-make/core-no-oom-handling/Makefile b/tests/run-make/core-no-oom-handling/Makefile new file mode 100644 index 000000000..28c5261ff --- /dev/null +++ b/tests/run-make/core-no-oom-handling/Makefile @@ -0,0 +1,6 @@ +include ../tools.mk + +FAKEROOT=$(TMPDIR)/fakeroot + +all: + $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --sysroot=$(FAKEROOT) --cfg no_global_oom_handling diff --git a/tests/run-make/coverage-llvmir/filecheck.testprog.txt b/tests/run-make/coverage-llvmir/filecheck.testprog.txt index c943261d7..b3a8808df 100644 --- a/tests/run-make/coverage-llvmir/filecheck.testprog.txt +++ b/tests/run-make/coverage-llvmir/filecheck.testprog.txt @@ -36,7 +36,7 @@ CHECK-SAME: section "llvm.metadata" CHECK: [[DEFINE_INTERNAL]] { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} { CHECK-NEXT: start: CHECK-NOT: [[DEFINE_INTERNAL]] -CHECK: %pgocount = load i64, {{i64\*|ptr}} +CHECK: atomicrmw add ptr CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] diff --git a/tests/run-make/coverage-reports/Makefile b/tests/run-make/coverage-reports/Makefile index d06cd9c6a..0ae409c41 100644 --- a/tests/run-make/coverage-reports/Makefile +++ b/tests/run-make/coverage-reports/Makefile @@ -138,6 +138,7 @@ endif ) \ 2> "$(TMPDIR)"/show_coverage_stderr.$@.txt \ | "$(PYTHON)" $(BASEDIR)/normalize_paths.py \ + | "$(PYTHON)" $(BASEDIR)/sort_subviews.py \ > "$(TMPDIR)"/actual_show_coverage.$@.txt || \ ( status=$$? ; \ >&2 cat "$(TMPDIR)"/show_coverage_stderr.$@.txt ; \ @@ -158,23 +159,15 @@ ifdef RUSTC_BLESS_TEST else # Compare the show coverage output (`--bless` refreshes `typical` files). # - # FIXME(richkadel): None of the Rust test source samples have the - # `// ignore-llvm-cov-show-diffs` anymore. This directive exists to work around a limitation - # with `llvm-cov show`. When reporting coverage for multiple instantiations of a generic function, - # with different type substitutions, `llvm-cov show` prints these in a non-deterministic order, - # breaking the `diff` comparison. + # `llvm-cov show` normally prints instantiation groups in an unpredictable + # order, but we have used `sort_subviews.py` to sort them, so we can still + # check the output directly with `diff`. # - # A partial workaround is implemented below, with `diff --ignore-matching-lines=RE` - # to ignore each line prefixing each generic instantiation coverage code region. - # - # This workaround only works if the coverage counts are identical across all reported - # instantiations. If there is no way to ensure this, you may need to apply the - # `// ignore-llvm-cov-show-diffs` directive, and check for differences using the - # `.json` files to validate that results have not changed. (Until then, the JSON - # files are redundant, so there is no need to generate `expected_*.json` files or - # compare actual JSON results.) - - $(DIFF) --ignore-matching-lines='^ | .*::<.*>.*:$$' --ignore-matching-lines='^ | <.*>::.*:$$' \ + # Some of the test cases are currently not working (since #110393) and have + # been marked with `// ignore-llvm-cov-show-diffs` so that they don't fail + # the build. + + $(DIFF) \ expected_show_coverage.$@.txt "$(TMPDIR)"/actual_show_coverage.$@.txt || \ ( grep -q '^\/\/ ignore-llvm-cov-show-diffs' $(SOURCEDIR)/$@.rs && \ >&2 echo 'diff failed, but suppressed with `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs' \ diff --git a/tests/run-make/coverage-reports/expected_show_coverage.async.txt b/tests/run-make/coverage-reports/expected_show_coverage.async.txt index 87ccb6c43..93c1535b0 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.async.txt +++ b/tests/run-make/coverage-reports/expected_show_coverage.async.txt @@ -41,9 +41,9 @@ 41| 1| // executed asynchronously. 42| 1| match x { 43| 1| y if c(x).await == y + 1 => { d().await; } - ^0 ^0 ^0 ^0 + ^0 ^0 ^0 ^0 44| 1| y if f().await == y + 1 => (), - ^0 ^0 ^0 + ^0 ^0 ^0 45| 1| _ => (), 46| | } 47| 1|} diff --git a/tests/run-make/coverage-reports/expected_show_coverage.generics.txt b/tests/run-make/coverage-reports/expected_show_coverage.generics.txt index 48983ba43..7eb33a29a 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.generics.txt +++ b/tests/run-make/coverage-reports/expected_show_coverage.generics.txt @@ -11,16 +11,16 @@ 11| 3| self.strength = new_strength; 12| 3| } ------------------ - | <generics::Firework<i32>>::set_strength: - | 10| 1| fn set_strength(&mut self, new_strength: T) { - | 11| 1| self.strength = new_strength; - | 12| 1| } - ------------------ | <generics::Firework<f64>>::set_strength: | 10| 2| fn set_strength(&mut self, new_strength: T) { | 11| 2| self.strength = new_strength; | 12| 2| } ------------------ + | <generics::Firework<i32>>::set_strength: + | 10| 1| fn set_strength(&mut self, new_strength: T) { + | 11| 1| self.strength = new_strength; + | 12| 1| } + ------------------ 13| |} 14| | 15| |impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display { diff --git a/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt b/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt new file mode 100644 index 000000000..81468cb35 --- /dev/null +++ b/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt @@ -0,0 +1,49 @@ + 1| |// compile-flags: --edition=2021 + 2| | + 3| |// Demonstrate that `sort_subviews.py` can sort instantiation groups into a + 4| |// predictable order, while preserving their heterogeneous contents. + 5| | + 6| 1|fn main() { + 7| 1| let cond = std::env::args().len() > 1; + 8| 1| generic_fn::<()>(cond); + 9| 1| generic_fn::<&'static str>(!cond); + 10| 1| if false { + 11| 0| generic_fn::<char>(cond); + 12| 1| } + 13| 1| generic_fn::<i32>(cond); + 14| 1| other_fn(); + 15| 1|} + 16| | + 17| 3|fn generic_fn<T>(cond: bool) { + 18| 3| if cond { + 19| 1| println!("{}", std::any::type_name::<T>()); + 20| 2| } + 21| 3|} + ------------------ + | Unexecuted instantiation: sort_groups::generic_fn::<char> + ------------------ + | sort_groups::generic_fn::<&str>: + | 17| 1|fn generic_fn<T>(cond: bool) { + | 18| 1| if cond { + | 19| 1| println!("{}", std::any::type_name::<T>()); + | 20| 1| } + | ^0 + | 21| 1|} + ------------------ + | sort_groups::generic_fn::<()>: + | 17| 1|fn generic_fn<T>(cond: bool) { + | 18| 1| if cond { + | 19| 0| println!("{}", std::any::type_name::<T>()); + | 20| 1| } + | 21| 1|} + ------------------ + | sort_groups::generic_fn::<i32>: + | 17| 1|fn generic_fn<T>(cond: bool) { + | 18| 1| if cond { + | 19| 0| println!("{}", std::any::type_name::<T>()); + | 20| 1| } + | 21| 1|} + ------------------ + 22| | + 23| 1|fn other_fn() {} + diff --git a/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt new file mode 100644 index 000000000..93bd1cfcb --- /dev/null +++ b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt @@ -0,0 +1,11 @@ + 1| |// Verify that the entry point injected by the test harness doesn't cause + 2| |// weird artifacts in the coverage report (e.g. issue #10749). + 3| | + 4| |// compile-flags: --test + 5| | + 6| |#[allow(dead_code)] + 7| 0|fn unused() {} + 8| | + 9| 1|#[test] + 10| 1|fn my_test() {} + diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt b/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt index 65eb1008d..412f4a93b 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt @@ -19,29 +19,29 @@ 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); 19| 2|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&str>: + | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> + ------------------ + | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>: | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>: + | used_crate::used_only_from_bin_crate_generic_function::<&str>: | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} ------------------ - | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> - ------------------ 20| |// Expect for above function: `Unexecuted instantiation` (see below) 21| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { 22| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); 23| 2|} ------------------ - | used_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>: + | used_crate::used_only_from_this_lib_crate_generic_function::<&str>: | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); | 23| 1|} ------------------ - | used_crate::used_only_from_this_lib_crate_generic_function::<&str>: + | used_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>: | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); | 23| 1|} @@ -51,12 +51,12 @@ 26| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); 27| 2|} ------------------ - | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>: + | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>: | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); | 27| 1|} ------------------ - | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>: + | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>: | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); | 27| 1|} diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt b/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt index 748343885..66ca9e80a 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt +++ b/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt @@ -42,6 +42,8 @@ 40| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); 41| 2|} ------------------ + | Unexecuted instantiation: used_inline_crate::used_only_from_bin_crate_generic_function::<_> + ------------------ | used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>: | 39| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); @@ -52,8 +54,6 @@ | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 41| 1|} ------------------ - | Unexecuted instantiation: used_inline_crate::used_only_from_bin_crate_generic_function::<_> - ------------------ 42| |// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`) 43| | 44| |#[inline(always)] @@ -77,16 +77,16 @@ 51| 3| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); 52| 3|} ------------------ - | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>: - | 50| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { - | 51| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); - | 52| 1|} - ------------------ | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>: | 50| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { | 51| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); | 52| 2|} ------------------ + | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>: + | 50| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { + | 51| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); + | 52| 1|} + ------------------ 53| | 54| |#[inline(always)] 55| 3|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { diff --git a/tests/run-make/coverage-reports/sort_subviews.py b/tests/run-make/coverage-reports/sort_subviews.py new file mode 100644 index 000000000..10cfc51d4 --- /dev/null +++ b/tests/run-make/coverage-reports/sort_subviews.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +# `llvm-cov show` prints grouped subviews (e.g. for generic functions) in an +# unstable order, which is inconvenient when checking output snapshots with +# `diff`. To work around that, this script detects consecutive subviews in its +# piped input, and sorts them while preserving their contents. + +from __future__ import print_function + +import sys + + +def main(): + subviews = [] + + def flush_subviews(): + if not subviews: + return + + # The last "subview" should be just a boundary line on its own, so + # temporarily remove it before sorting the accumulated subviews. + terminator = subviews.pop() + subviews.sort() + subviews.append(terminator) + + for view in subviews: + for line in view: + print(line, end="") + + subviews.clear() + + for line in sys.stdin: + if line.startswith(" ------------------"): + # This is a subview boundary line, so start a new subview. + subviews.append([line]) + elif line.startswith(" |"): + # Add this line to the current subview. + subviews[-1].append(line) + else: + # This line is not part of a subview, so sort and print any + # accumulated subviews, and then print the line as-is. + flush_subviews() + print(line, end="") + + flush_subviews() + assert not subviews + + +if __name__ == "__main__": + main() diff --git a/tests/run-make/coverage/sort_groups.rs b/tests/run-make/coverage/sort_groups.rs new file mode 100644 index 000000000..f89f9f3ec --- /dev/null +++ b/tests/run-make/coverage/sort_groups.rs @@ -0,0 +1,23 @@ +// compile-flags: --edition=2021 + +// Demonstrate that `sort_subviews.py` can sort instantiation groups into a +// predictable order, while preserving their heterogeneous contents. + +fn main() { + let cond = std::env::args().len() > 1; + generic_fn::<()>(cond); + generic_fn::<&'static str>(!cond); + if false { + generic_fn::<char>(cond); + } + generic_fn::<i32>(cond); + other_fn(); +} + +fn generic_fn<T>(cond: bool) { + if cond { + println!("{}", std::any::type_name::<T>()); + } +} + +fn other_fn() {} diff --git a/tests/run-make/coverage/test_harness.rs b/tests/run-make/coverage/test_harness.rs new file mode 100644 index 000000000..12a755734 --- /dev/null +++ b/tests/run-make/coverage/test_harness.rs @@ -0,0 +1,10 @@ +// Verify that the entry point injected by the test harness doesn't cause +// weird artifacts in the coverage report (e.g. issue #10749). + +// compile-flags: --test + +#[allow(dead_code)] +fn unused() {} + +#[test] +fn my_test() {} diff --git a/tests/run-make/coverage/uses_crate.rs b/tests/run-make/coverage/uses_crate.rs index 20cb05fe5..1ee8037a1 100644 --- a/tests/run-make/coverage/uses_crate.rs +++ b/tests/run-make/coverage/uses_crate.rs @@ -1,3 +1,6 @@ +// FIXME #110395 +// ignore-llvm-cov-show-diffs + #![allow(unused_assignments, unused_variables)] // compile-flags: -C opt-level=3 # validates coverage now works with optimizations extern crate used_crate; diff --git a/tests/run-make/coverage/uses_inline_crate.rs b/tests/run-make/coverage/uses_inline_crate.rs index a7fe8532b..f7aff3c3f 100644 --- a/tests/run-make/coverage/uses_inline_crate.rs +++ b/tests/run-make/coverage/uses_inline_crate.rs @@ -1,3 +1,6 @@ +// FIXME #110395 +// ignore-llvm-cov-show-diffs + #![allow(unused_assignments, unused_variables)] // compile-flags: -C opt-level=3 # validates coverage now works with optimizations diff --git a/tests/run-make/debug-assertions/Makefile b/tests/run-make/debug-assertions/Makefile index e83337c59..4501459e9 100644 --- a/tests/run-make/debug-assertions/Makefile +++ b/tests/run-make/debug-assertions/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: diff --git a/tests/run-make/debugger-visualizer-dep-info/Makefile b/tests/run-make/debugger-visualizer-dep-info/Makefile new file mode 100644 index 000000000..0877998a7 --- /dev/null +++ b/tests/run-make/debugger-visualizer-dep-info/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +# This test makes sure that files referenced via #[debugger_visualizer] are +# included in `--emit dep-info` output. + +all: + $(RUSTC) --emit dep-info main.rs + $(CGREP) "foo.py" < $(TMPDIR)/main.d + $(CGREP) "my_visualizers/bar.natvis" < $(TMPDIR)/main.d diff --git a/tests/run-make/debugger-visualizer-dep-info/foo.py b/tests/run-make/debugger-visualizer-dep-info/foo.py new file mode 100644 index 000000000..1bb8bf6d7 --- /dev/null +++ b/tests/run-make/debugger-visualizer-dep-info/foo.py @@ -0,0 +1 @@ +# empty diff --git a/tests/run-make/debugger-visualizer-dep-info/main.rs b/tests/run-make/debugger-visualizer-dep-info/main.rs new file mode 100644 index 000000000..3aede2215 --- /dev/null +++ b/tests/run-make/debugger-visualizer-dep-info/main.rs @@ -0,0 +1,12 @@ +#![debugger_visualizer(gdb_script_file = "foo.py")] + +fn main() { + const _UNUSED: u32 = { + mod inner { + #![debugger_visualizer(natvis_file = "my_visualizers/bar.natvis")] + pub const XYZ: u32 = 123; + } + + inner::XYZ + 1 + }; +} diff --git a/tests/run-make/debugger-visualizer-dep-info/my_visualizers/bar.natvis b/tests/run-make/debugger-visualizer-dep-info/my_visualizers/bar.natvis new file mode 100644 index 000000000..c341a4039 --- /dev/null +++ b/tests/run-make/debugger-visualizer-dep-info/my_visualizers/bar.natvis @@ -0,0 +1 @@ +<!-- empty --> diff --git a/tests/run-make/forced-unwind-terminate-pof/Makefile b/tests/run-make/forced-unwind-terminate-pof/Makefile new file mode 100644 index 000000000..871621520 --- /dev/null +++ b/tests/run-make/forced-unwind-terminate-pof/Makefile @@ -0,0 +1,9 @@ +# ignore-cross-compile +# only-linux +include ../tools.mk + +all: foo + $(call RUN,foo) | $(CGREP) -v "cannot unwind" + +foo: foo.rs + $(RUSTC) $< diff --git a/tests/run-make/forced-unwind-terminate-pof/foo.rs b/tests/run-make/forced-unwind-terminate-pof/foo.rs new file mode 100644 index 000000000..0a5128731 --- /dev/null +++ b/tests/run-make/forced-unwind-terminate-pof/foo.rs @@ -0,0 +1,17 @@ +// Tests that forced unwind through POF Rust frames wouldn't trigger our terminating guards. + +#![feature(c_unwind)] +#![no_main] + +extern "C-unwind" { + fn pthread_exit(v: *mut core::ffi::c_void) -> !; +} + +unsafe extern "C" fn call_pthread_exit() { + pthread_exit(core::ptr::null_mut()); +} + +#[no_mangle] +unsafe extern "C-unwind" fn main(_argc: core::ffi::c_int, _argv: *mut *mut core::ffi::c_char) { + call_pthread_exit(); +} diff --git a/tests/run-make/foreign-double-unwind/Makefile b/tests/run-make/foreign-double-unwind/Makefile index f20fe3ce6..b5e52808d 100644 --- a/tests/run-make/foreign-double-unwind/Makefile +++ b/tests/run-make/foreign-double-unwind/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: foo diff --git a/tests/run-make/foreign-double-unwind/foo.rs b/tests/run-make/foreign-double-unwind/foo.rs index cae8aa940..c085480b4 100644 --- a/tests/run-make/foreign-double-unwind/foo.rs +++ b/tests/run-make/foreign-double-unwind/foo.rs @@ -1,8 +1,6 @@ // Tests that C++ double unwinding through Rust code will be properly guarded // against instead of exhibiting undefined behaviour. -#![feature(c_unwind)] - extern "C-unwind" { fn throw_cxx_exception(); fn cxx_catch_callback(cb: extern "C-unwind" fn()); diff --git a/tests/run-make/foreign-exceptions/Makefile b/tests/run-make/foreign-exceptions/Makefile index a8e20ffb1..56c41b274 100644 --- a/tests/run-make/foreign-exceptions/Makefile +++ b/tests/run-make/foreign-exceptions/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: foo diff --git a/tests/run-make/foreign-exceptions/foo.rs b/tests/run-make/foreign-exceptions/foo.rs index dd3b7c76f..ccf858d85 100644 --- a/tests/run-make/foreign-exceptions/foo.rs +++ b/tests/run-make/foreign-exceptions/foo.rs @@ -2,8 +2,6 @@ // are caught by catch_unwind. Also tests that Rust panics can unwind through // C++ code. -#![feature(c_unwind)] - use std::panic::{catch_unwind, AssertUnwindSafe}; struct DropCheck<'a>(&'a mut bool); diff --git a/tests/run-make/foreign-rust-exceptions/Makefile b/tests/run-make/foreign-rust-exceptions/Makefile index 0d007bf1c..59cee2842 100644 --- a/tests/run-make/foreign-rust-exceptions/Makefile +++ b/tests/run-make/foreign-rust-exceptions/Makefile @@ -1,5 +1,6 @@ # ignore-cross-compile # ignore-i686-pc-windows-gnu +# needs-unwind # This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder # so cross-DLL unwinding does not work. diff --git a/tests/run-make/foreign-rust-exceptions/bar.rs b/tests/run-make/foreign-rust-exceptions/bar.rs index 5f9efe323..1d865b429 100644 --- a/tests/run-make/foreign-rust-exceptions/bar.rs +++ b/tests/run-make/foreign-rust-exceptions/bar.rs @@ -1,5 +1,4 @@ #![crate_type = "cdylib"] -#![feature(c_unwind)] #[no_mangle] extern "C-unwind" fn panic() { diff --git a/tests/run-make/foreign-rust-exceptions/foo.rs b/tests/run-make/foreign-rust-exceptions/foo.rs index 266987c5b..38942c55b 100644 --- a/tests/run-make/foreign-rust-exceptions/foo.rs +++ b/tests/run-make/foreign-rust-exceptions/foo.rs @@ -1,5 +1,3 @@ -#![feature(c_unwind)] - #[cfg_attr(not(windows), link(name = "bar"))] #[cfg_attr(windows, link(name = "bar.dll"))] extern "C-unwind" { diff --git a/tests/run-make/inaccessible-temp-dir/Makefile b/tests/run-make/inaccessible-temp-dir/Makefile new file mode 100644 index 000000000..abdba4eb8 --- /dev/null +++ b/tests/run-make/inaccessible-temp-dir/Makefile @@ -0,0 +1,32 @@ +# only-linux +# ignore-arm - linker error on `armhf-gnu` + +include ../tools.mk + +# Issue #66530: We would ICE if someone compiled with `-o /dev/null`, +# because we would try to generate auxiliary files in `/dev/` (which +# at least the OS X file system rejects). +# +# An attempt to `-Ztemps-dir` into a directory we cannot write into should +# indeed be an error; but not an ICE. +# +# However, some folks run tests as root, which can write `/dev/` and end +# up clobbering `/dev/null`. Instead we'll use an inaccessible path, which +# also used to ICE, but even root can't magically write there. +# +# Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to +# use a directory with non-existing parent like `/does-not-exist/output`. + +all: + # Create an inaccessible directory + mkdir $(TMPDIR)/inaccessible + chmod 000 $(TMPDIR)/inaccessible + + # Run rustc with `-Ztemps-dir` set to a directory + # *inside* the inaccessible one, so that it can't create it + $(RUSTC) program.rs -Ztemps-dir=$(TMPDIR)/inaccessible/tmp 2>&1 \ + | $(CGREP) 'failed to find or create the directory specified by `--temps-dir`' + + # Make the inaccessible directory accessible, + # so that compiletest can delete the temp dir + chmod +rw $(TMPDIR)/inaccessible diff --git a/tests/run-make/inaccessible-temp-dir/program.rs b/tests/run-make/inaccessible-temp-dir/program.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/tests/run-make/inaccessible-temp-dir/program.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/incremental-debugger-visualizer/Makefile b/tests/run-make/incremental-debugger-visualizer/Makefile new file mode 100644 index 000000000..8cfe41597 --- /dev/null +++ b/tests/run-make/incremental-debugger-visualizer/Makefile @@ -0,0 +1,49 @@ +include ../tools.mk + +# This test makes sure that changes to files referenced via #[debugger_visualizer] +# are picked up when compiling incrementally. + +# We have to copy the source to $(TMPDIR) because Github CI mounts the source +# directory as readonly. We need to apply modifications to some of the source +# file. +SRC_DIR := $(TMPDIR)/src +INCR_CACHE_DIR := $(TMPDIR)/incremental + +all: + rm -rf $(TMPDIR)/* + mkdir $(SRC_DIR) + cp ./foo.rs $(SRC_DIR) + echo "GDB script v1" > $(SRC_DIR)/foo.py + echo "Natvis v1" > $(SRC_DIR)/foo.natvis + $(RUSTC) $(SRC_DIR)/foo.rs \ + --crate-type=rlib \ + --emit metadata \ + -C incremental=$(INCR_CACHE_DIR) \ + -Z incremental-verify-ich + $(CGREP) "GDB script v1" < $(TMPDIR)/libfoo.rmeta + $(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta + + # Change only the GDB script and check that the change has been picked up + echo "GDB script v2" > $(SRC_DIR)/foo.py + $(RUSTC) $(SRC_DIR)/foo.rs \ + --crate-type=rlib \ + --emit metadata \ + -C incremental=$(INCR_CACHE_DIR) \ + -Z incremental-verify-ich + + $(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta + $(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta + $(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta + + # Now change the Natvis version and check that the change has been picked up + echo "Natvis v2" > $(SRC_DIR)/foo.natvis + $(RUSTC) $(SRC_DIR)/foo.rs \ + --crate-type=rlib \ + --emit metadata \ + -C incremental=$(INCR_CACHE_DIR) \ + -Z incremental-verify-ich + + $(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta + $(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta + $(CGREP) "Natvis v2" < $(TMPDIR)/libfoo.rmeta + $(CGREP) -v "Natvis v1" < $(TMPDIR)/libfoo.rmeta diff --git a/tests/run-make/incremental-debugger-visualizer/foo.rs b/tests/run-make/incremental-debugger-visualizer/foo.rs new file mode 100644 index 000000000..8daa36a12 --- /dev/null +++ b/tests/run-make/incremental-debugger-visualizer/foo.rs @@ -0,0 +1,6 @@ +#![debugger_visualizer(natvis_file = "./foo.natvis")] +#![debugger_visualizer(gdb_script_file = "./foo.py")] + +pub struct Foo { + pub x: u32, +} diff --git a/tests/run-make/issue-107094/Makefile b/tests/run-make/issue-107094/Makefile new file mode 100644 index 000000000..d614e3e10 --- /dev/null +++ b/tests/run-make/issue-107094/Makefile @@ -0,0 +1,7 @@ +# needs-git-hash + +include ../tools.mk + +all: + $(BARE_RUSTC) --version --verbose | $(CGREP) -i -e "commit-hash: [0-9a-f]{40}" "commit-date: [0-9]{4}-[0-9]{2}-[0-9]{2}" + $(BARE_RUSTDOC) --version --verbose | $(CGREP) -i -e "commit-hash: [0-9a-f]{40}" "commit-date: [0-9]{4}-[0-9]{2}-[0-9]{2}" diff --git a/tests/run-make/issue-83045/Makefile b/tests/run-make/issue-83045/Makefile index 7053da00f..b76e184b6 100644 --- a/tests/run-make/issue-83045/Makefile +++ b/tests/run-make/issue-83045/Makefile @@ -29,5 +29,5 @@ all: --crate-type=rlib \ --edition=2018 \ c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0 - $(CGREP) E0519 < $(TMPDIR)/output.txt + $(CGREP) E0463 < $(TMPDIR)/output.txt $(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt diff --git a/tests/run-make/libtest-json/Makefile b/tests/run-make/libtest-json/Makefile index 417637cf0..c8bc7b5dd 100644 --- a/tests/run-make/libtest-json/Makefile +++ b/tests/run-make/libtest-json/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk # Test expected libtest's JSON output diff --git a/tests/run-make/libtest-junit/Makefile b/tests/run-make/libtest-junit/Makefile new file mode 100644 index 000000000..d97cafccf --- /dev/null +++ b/tests/run-make/libtest-junit/Makefile @@ -0,0 +1,19 @@ +# ignore-cross-compile +include ../tools.mk + +# Test expected libtest's junit output + +OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-junit-output-default.xml +OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-junit-output-stdout-success.xml + +all: f.rs validate_junit.py output-default.xml output-stdout-success.xml + $(RUSTC) --test f.rs + RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=junit > $(OUTPUT_FILE_DEFAULT) || true + RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=junit --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true + + cat $(OUTPUT_FILE_DEFAULT) | "$(PYTHON)" validate_junit.py + cat $(OUTPUT_FILE_STDOUT_SUCCESS) | "$(PYTHON)" validate_junit.py + + # Normalize the actual output and compare to expected output file + cat $(OUTPUT_FILE_DEFAULT) | sed 's/time="[0-9.]*"/time="$$TIME"/g' | diff output-default.xml - + cat $(OUTPUT_FILE_STDOUT_SUCCESS) | sed 's/time="[0-9.]*"/time="$$TIME"/g' | diff output-stdout-success.xml - diff --git a/tests/run-make/libtest-junit/f.rs b/tests/run-make/libtest-junit/f.rs new file mode 100644 index 000000000..d360d7731 --- /dev/null +++ b/tests/run-make/libtest-junit/f.rs @@ -0,0 +1,23 @@ +#[test] +fn a() { + println!("print from successful test"); + // Should pass +} + +#[test] +fn b() { + println!("print from failing test"); + assert!(false); +} + +#[test] +#[should_panic] +fn c() { + assert!(false); +} + +#[test] +#[ignore = "msg"] +fn d() { + assert!(false); +} diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml new file mode 100644 index 000000000..d59e07b8a --- /dev/null +++ b/tests/run-make/libtest-junit/output-default.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>
<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml new file mode 100644 index 000000000..0c300611e --- /dev/null +++ b/tests/run-make/libtest-junit/output-stdout-success.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>
<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at 'assertion failed: false', f.rs:16:5]]>
<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/validate_junit.py b/tests/run-make/libtest-junit/validate_junit.py new file mode 100755 index 000000000..47a8e70cc --- /dev/null +++ b/tests/run-make/libtest-junit/validate_junit.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +import sys +import xml.etree.ElementTree as ET + +# Try to decode line in order to ensure it is a valid XML document +for line in sys.stdin: + try: + ET.fromstring(line) + except ET.ParseError as pe: + print("Invalid xml: %r" % line) + raise diff --git a/tests/run-make/no-alloc-shim/Makefile b/tests/run-make/no-alloc-shim/Makefile new file mode 100644 index 000000000..568e3f9ba --- /dev/null +++ b/tests/run-make/no-alloc-shim/Makefile @@ -0,0 +1,24 @@ +include ../tools.mk + +# ignore-cross-compile +# ignore-msvc FIXME(bjorn3) can't figure out how to link with the MSVC toolchain + +TARGET_LIBDIR = $$($(RUSTC) --print target-libdir) + +all: + $(RUSTC) foo.rs --crate-type bin --emit obj -Cpanic=abort +ifdef IS_MSVC + $(CC) $(CFLAGS) $(TMPDIR)/foo.o $(call OUT_EXE,foo) /link $(TARGET_LIBDIR)/liballoc-*.rlib $(TARGET_LIBDIR)/libcore-*.rlib $(TARGET_LIBDIR)/libcompiler_builtins-*.rlib + $(call OUT_EXE,foo) +else + $(CC) $(CFLAGS) $(TMPDIR)/foo.o $(TARGET_LIBDIR)/liballoc-*.rlib $(TARGET_LIBDIR)/libcore-*.rlib $(TARGET_LIBDIR)/libcompiler_builtins-*.rlib -o $(call RUN_BINFILE,foo) + $(call RUN_BINFILE,foo) +endif + + # Check that linking without __rust_no_alloc_shim_is_unstable defined fails + $(RUSTC) foo.rs --crate-type bin --emit obj -Cpanic=abort --cfg check_feature_gate +ifdef IS_MSVC + $(CC) $(CFLAGS) $(TMPDIR)/foo.o $(call OUT_EXE,foo) /link $(TARGET_LIBDIR)/liballoc-*.rlib $(TARGET_LIBDIR)/libcore-*.rlib $(TARGET_LIBDIR)/libcompiler_builtins-*.rlib || exit 0 && exit 1 +else + $(CC) $(CFLAGS) $(TMPDIR)/foo.o $(TARGET_LIBDIR)/liballoc-*.rlib $(TARGET_LIBDIR)/libcore-*.rlib $(TARGET_LIBDIR)/libcompiler_builtins-*.rlib -o $(call RUN_BINFILE,foo) || exit 0 && exit 1 +endif diff --git a/tests/run-make/no-alloc-shim/foo.rs b/tests/run-make/no-alloc-shim/foo.rs new file mode 100644 index 000000000..a3daec3db --- /dev/null +++ b/tests/run-make/no-alloc-shim/foo.rs @@ -0,0 +1,44 @@ +#![feature(default_alloc_error_handler)] +#![no_std] +#![no_main] + +extern crate alloc; + +use alloc::alloc::{GlobalAlloc, Layout}; + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo) -> ! { + loop {} +} + +#[no_mangle] +extern "C" fn rust_eh_personality() { + loop {} +} + +#[global_allocator] +static ALLOC: Alloc = Alloc; + +struct Alloc; + +unsafe impl GlobalAlloc for Alloc { + unsafe fn alloc(&self, _: Layout) -> *mut u8 { + core::ptr::null_mut() + } + unsafe fn dealloc(&self, _: *mut u8, _: Layout) { + todo!() + } +} + +#[cfg(not(check_feature_gate))] +#[no_mangle] +static __rust_no_alloc_shim_is_unstable: u8 = 0; + +#[no_mangle] +extern "C" fn main(_argc: usize, _argv: *const *const i8) -> i32 { + unsafe { + assert_eq!(alloc::alloc::alloc(Layout::new::<()>()), core::ptr::null_mut()); + } + + 0 +} diff --git a/tests/run-make/pointer-auth-link-with-c/Makefile b/tests/run-make/pointer-auth-link-with-c/Makefile index 7acea0380..dffbd3035 100644 --- a/tests/run-make/pointer-auth-link-with-c/Makefile +++ b/tests/run-make/pointer-auth-link-with-c/Makefile @@ -5,10 +5,10 @@ include ../tools.mk all: $(COMPILE_OBJ) $(TMPDIR)/test.o test.c $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o - $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs + $(RUSTC) --target $(TARGET) -Z branch-protection=bti,pac-ret,leaf test.rs $(call RUN,test) $(COMPILE_OBJ) $(TMPDIR)/test.o test.c -mbranch-protection=bti+pac-ret+leaf $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o - $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs + $(RUSTC) --target $(TARGET) -Z branch-protection=bti,pac-ret,leaf test.rs $(call RUN,test) diff --git a/tests/run-make/print-native-static-libs/Makefile b/tests/run-make/print-native-static-libs/Makefile new file mode 100644 index 000000000..98e72d769 --- /dev/null +++ b/tests/run-make/print-native-static-libs/Makefile @@ -0,0 +1,15 @@ +include ../tools.mk + +# ignore-cross-compile +# ignore-wasm + +all: + $(RUSTC) --crate-type rlib -lbar_cli bar.rs + $(RUSTC) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \ + | grep 'note: native-static-libs: ' \ + | sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt + + cat $(TMPDIR)/libs.txt | grep -F "glib-2.0" # in bar.rs + cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs + cat $(TMPDIR)/libs.txt | grep -F "bar_cli" + cat $(TMPDIR)/libs.txt | grep -F "foo_cli" diff --git a/tests/run-make/print-native-static-libs/bar.rs b/tests/run-make/print-native-static-libs/bar.rs new file mode 100644 index 000000000..a563bbc2a --- /dev/null +++ b/tests/run-make/print-native-static-libs/bar.rs @@ -0,0 +1,13 @@ +#[no_mangle] +pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 { + // Obviously makes no sense but... + unsafe { + g_free(std::ptr::null_mut()); + } + left + right +} + +#[link(name = "glib-2.0")] +extern "C" { + fn g_free(p: *mut ()); +} diff --git a/tests/run-make/print-native-static-libs/foo.rs b/tests/run-make/print-native-static-libs/foo.rs new file mode 100644 index 000000000..6acaee20e --- /dev/null +++ b/tests/run-make/print-native-static-libs/foo.rs @@ -0,0 +1,15 @@ +extern crate bar; + +#[no_mangle] +pub extern "C" fn my_foo_add(left: i32, right: i32) -> i32 { + // Obviously makes no sense but... + unsafe { + init(std::ptr::null_mut()); + } + bar::my_bar_add(left, right) +} + +#[link(name = "systemd")] +extern "C" { + fn init(p: *mut ()); +} diff --git a/tests/run-make/raw-dylib-alt-calling-convention/lib.rs b/tests/run-make/raw-dylib-alt-calling-convention/lib.rs index 22f222c12..dcb5fee9e 100644 --- a/tests/run-make/raw-dylib-alt-calling-convention/lib.rs +++ b/tests/run-make/raw-dylib-alt-calling-convention/lib.rs @@ -1,5 +1,4 @@ #![feature(abi_vectorcall)] -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] #[repr(C)] #[derive(Clone)] diff --git a/tests/run-make/raw-dylib-c/lib.rs b/tests/run-make/raw-dylib-c/lib.rs index 5fb120403..f17125f30 100644 --- a/tests/run-make/raw-dylib-c/lib.rs +++ b/tests/run-make/raw-dylib-c/lib.rs @@ -1,5 +1,3 @@ -#![feature(raw_dylib)] - #[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")] extern { fn extern_fn_1(); diff --git a/tests/run-make/raw-dylib-cross-compilation/lib.rs b/tests/run-make/raw-dylib-cross-compilation/lib.rs index 51bf2ec6b..3338ac0a0 100644 --- a/tests/run-make/raw-dylib-cross-compilation/lib.rs +++ b/tests/run-make/raw-dylib-cross-compilation/lib.rs @@ -1,4 +1,3 @@ -#![feature(raw_dylib)] #![feature(no_core, lang_items)] #![no_std] #![no_core] diff --git a/tests/run-make/raw-dylib-custom-dlltool/Makefile b/tests/run-make/raw-dylib-custom-dlltool/Makefile new file mode 100644 index 000000000..f5d5360a3 --- /dev/null +++ b/tests/run-make/raw-dylib-custom-dlltool/Makefile @@ -0,0 +1,11 @@ +# Test using -Cdlltool to change where raw-dylib looks for the dlltool binary. + +# only-windows +# only-gnu +# needs-dlltool + +include ../tools.mk + +all: + $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs -Cdlltool=$(CURDIR)/script.cmd + $(DIFF) output.txt "$(TMPDIR)"/output.txt diff --git a/tests/run-make/raw-dylib-custom-dlltool/lib.rs b/tests/run-make/raw-dylib-custom-dlltool/lib.rs new file mode 100644 index 000000000..2f3f497a0 --- /dev/null +++ b/tests/run-make/raw-dylib-custom-dlltool/lib.rs @@ -0,0 +1,10 @@ +#[link(name = "extern_1", kind = "raw-dylib")] +extern { + fn extern_fn_1(); +} + +pub fn library_function() { + unsafe { + extern_fn_1(); + } +} diff --git a/tests/run-make/raw-dylib-custom-dlltool/output.txt b/tests/run-make/raw-dylib-custom-dlltool/output.txt new file mode 100644 index 000000000..6dd9466d2 --- /dev/null +++ b/tests/run-make/raw-dylib-custom-dlltool/output.txt @@ -0,0 +1 @@ +Called dlltool via script.cmd diff --git a/tests/run-make/raw-dylib-custom-dlltool/script.cmd b/tests/run-make/raw-dylib-custom-dlltool/script.cmd new file mode 100644 index 000000000..95f85c61c --- /dev/null +++ b/tests/run-make/raw-dylib-custom-dlltool/script.cmd @@ -0,0 +1,2 @@ +echo Called dlltool via script.cmd> %TMPDIR%\output.txt +dlltool.exe %* diff --git a/tests/run-make/raw-dylib-import-name-type/driver.rs b/tests/run-make/raw-dylib-import-name-type/driver.rs index 9a3cd9ebe..6c1c212f1 100644 --- a/tests/run-make/raw-dylib-import-name-type/driver.rs +++ b/tests/run-make/raw-dylib-import-name-type/driver.rs @@ -1,4 +1,3 @@ -#![feature(raw_dylib)] #![feature(abi_vectorcall)] #[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")] diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/driver.rs b/tests/run-make/raw-dylib-inline-cross-dylib/driver.rs index f72ded7d9..0c3125be6 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/driver.rs +++ b/tests/run-make/raw-dylib-inline-cross-dylib/driver.rs @@ -1,5 +1,3 @@ -#![feature(raw_dylib)] - extern crate raw_dylib_test; extern crate raw_dylib_test_wrapper; diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/lib.rs b/tests/run-make/raw-dylib-inline-cross-dylib/lib.rs index 00c2c1c42..4877cb80a 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/lib.rs +++ b/tests/run-make/raw-dylib-inline-cross-dylib/lib.rs @@ -1,5 +1,3 @@ -#![feature(raw_dylib)] - #[link(name = "extern_1", kind = "raw-dylib")] extern { fn extern_fn_1(); diff --git a/tests/run-make/raw-dylib-link-ordinal/lib.rs b/tests/run-make/raw-dylib-link-ordinal/lib.rs index bb25ac64c..1bbb45bbc 100644 --- a/tests/run-make/raw-dylib-link-ordinal/lib.rs +++ b/tests/run-make/raw-dylib-link-ordinal/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "exporter", kind = "raw-dylib")] extern { #[link_ordinal(13)] diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs b/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs index b7921396a..74c5c7f82 100644 --- a/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs +++ b/tests/run-make/raw-dylib-stdcall-ordinal/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "exporter", kind = "raw-dylib")] extern "stdcall" { #[link_ordinal(15)] diff --git a/tests/run-make/short-ice/Makefile b/tests/run-make/short-ice/Makefile new file mode 100644 index 000000000..4f33d5902 --- /dev/null +++ b/tests/run-make/short-ice/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +# ignore-windows + +export RUSTC := $(RUSTC_ORIGINAL) +export TMPDIR := $(TMPDIR) + +all: + bash check.sh diff --git a/tests/run-make/short-ice/check.sh b/tests/run-make/short-ice/check.sh new file mode 100644 index 000000000..96cd8fe86 --- /dev/null +++ b/tests/run-make/short-ice/check.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +RUST_BACKTRACE=1 $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-1.log 2>&1 +RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-2.log 2>&1 + +short=$(cat $TMPDIR/rust-test-1.log | wc -l) +full=$(cat $TMPDIR/rust-test-2.log | wc -l) +rustc_query_count=$(cat $TMPDIR/rust-test-1.log | grep rustc_query_ | wc -l) +rustc_query_count_full=$(cat $TMPDIR/rust-test-2.log | grep rustc_query_ | wc -l) + +begin_count=$(cat $TMPDIR/rust-test-2.log | grep __rust_begin_short_backtrace | wc -l) +end_count=$(cat $TMPDIR/rust-test-2.log | grep __rust_end_short_backtrace | wc -l) + +cat $TMPDIR/rust-test-1.log +echo "=====================" +cat $TMPDIR/rust-test-2.log +echo "=====================" + +echo "short backtrace: $short" +echo "full backtrace: $full" +echo "begin_count: $begin_count" +echo "end_count : $end_count" +echo "rustc_query_count: $rustc_query_count" +echo "rustc_query_count_full: $rustc_query_count_full" + +## backtraces to vary a bit depending on platform and configuration options, +## here we make sure that the short backtrace of rustc_query is shorter than the full, +## and marks are in pairs. +if [ $short -lt $full ] && + [ $begin_count -eq $end_count ] && + [ $(($rustc_query_count + 10)) -lt $rustc_query_count_full ] && + [ $rustc_query_count_full -gt 10 ]; then + exit 0 +else + exit 1 +fi diff --git a/tests/run-make/short-ice/src/lib.rs b/tests/run-make/short-ice/src/lib.rs new file mode 100644 index 000000000..b23b7f830 --- /dev/null +++ b/tests/run-make/short-ice/src/lib.rs @@ -0,0 +1,7 @@ +fn func(s: &str) { + println!("{}", s); +} + +fn main() { + func(1); +} diff --git a/tests/run-make/static-unwinding/Makefile b/tests/run-make/static-unwinding/Makefile index dec94fb16..4b093f936 100644 --- a/tests/run-make/static-unwinding/Makefile +++ b/tests/run-make/static-unwinding/Makefile @@ -1,4 +1,5 @@ # ignore-cross-compile +# needs-unwind include ../tools.mk all: diff --git a/tests/run-make/staticlib-dylib-linkage/Makefile b/tests/run-make/staticlib-dylib-linkage/Makefile new file mode 100644 index 000000000..a1e86a7ce --- /dev/null +++ b/tests/run-make/staticlib-dylib-linkage/Makefile @@ -0,0 +1,21 @@ +include ../tools.mk + +# ignore-cross-compile +# ignore-msvc FIXME(bjorn3) can't figure out how to link with the MSVC toolchain +# ignore-wasm wasm doesn't support dynamic libraries + +all: + $(RUSTC) -C prefer-dynamic bar.rs + $(RUSTC) foo.rs --crate-type staticlib --print native-static-libs \ + -Z staticlib-allow-rdylib-deps 2>&1 | grep 'note: native-static-libs: ' \ + | sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt + cat $(TMPDIR)/libs.txt + +ifdef IS_MSVC + $(CC) $(CFLAGS) /c foo.c /Fo:$(TMPDIR)/foo.o + $(RUSTC_LINKER) $(TMPDIR)/foo.o $(TMPDIR)/foo.lib $$(cat $(TMPDIR)/libs.txt) $(call OUT_EXE,foo) +else + $(CC) $(CFLAGS) foo.c -L $(TMPDIR) -lfoo $$(cat $(TMPDIR)/libs.txt) -o $(call RUN_BINFILE,foo) +endif + + $(call RUN,foo) diff --git a/tests/run-make/staticlib-dylib-linkage/bar.rs b/tests/run-make/staticlib-dylib-linkage/bar.rs new file mode 100644 index 000000000..b3a7539ab --- /dev/null +++ b/tests/run-make/staticlib-dylib-linkage/bar.rs @@ -0,0 +1,5 @@ +#![crate_type = "dylib"] + +pub fn bar() { + println!("hello!"); +} diff --git a/tests/run-make/staticlib-dylib-linkage/foo.c b/tests/run-make/staticlib-dylib-linkage/foo.c new file mode 100644 index 000000000..154f9682e --- /dev/null +++ b/tests/run-make/staticlib-dylib-linkage/foo.c @@ -0,0 +1,10 @@ +#include <assert.h> + +extern void foo(); +extern unsigned bar(unsigned a, unsigned b); + +int main() { + foo(); + assert(bar(1, 2) == 3); + return 0; +} diff --git a/tests/run-make/staticlib-dylib-linkage/foo.rs b/tests/run-make/staticlib-dylib-linkage/foo.rs new file mode 100644 index 000000000..af439391c --- /dev/null +++ b/tests/run-make/staticlib-dylib-linkage/foo.rs @@ -0,0 +1,13 @@ +#![crate_type = "staticlib"] + +extern crate bar; + +#[no_mangle] +pub extern "C" fn foo() { + bar::bar(); +} + +#[no_mangle] +pub extern "C" fn bar(a: u32, b: u32) -> u32 { + a + b +} diff --git a/tests/run-make/test-benches/Makefile b/tests/run-make/test-benches/Makefile index 0253a5263..11aed2e4c 100644 --- a/tests/run-make/test-benches/Makefile +++ b/tests/run-make/test-benches/Makefile @@ -1,6 +1,7 @@ include ../tools.mk # ignore-cross-compile +# needs-unwind #[bench] and -Zpanic-abort-tests can't be combined all: # Smoke-test that `#[bench]` isn't entirely broken. diff --git a/tests/run-make/translation/Makefile b/tests/run-make/translation/Makefile index 0acf64e5d..07e0547cf 100644 --- a/tests/run-make/translation/Makefile +++ b/tests/run-make/translation/Makefile @@ -46,6 +46,8 @@ sysroot: test.rs working.ftl rm -f $(FAKEROOT)/lib/rustlib/src mkdir $(FAKEROOT)/lib/rustlib/src ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src + # When download-rustc is enabled, `$(SYSROOT)` will have a share directory. Delete the link to it. + rm -f $(FAKEROOT)/share mkdir -p $(FAKEROOT)/share/locale/zh-CN/ ln -s $(CURDIR)/working.ftl $(FAKEROOT)/share/locale/zh-CN/basic-translation.ftl $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | $(CGREP) "this is a test message" diff --git a/tests/run-make/valid-print-requests/valid-print-requests.stderr b/tests/run-make/valid-print-requests/valid-print-requests.stderr index bea6ce067..4f57550c2 100644 --- a/tests/run-make/valid-print-requests/valid-print-requests.stderr +++ b/tests/run-make/valid-print-requests/valid-print-requests.stderr @@ -1,2 +1,2 @@ -error: unknown print request `uwu`. Valid print requests are: `crate-name`, `file-names`, `sysroot`, `target-libdir`, `cfg`, `calling-conventions`, `target-list`, `target-cpus`, `target-features`, `relocation-models`, `code-models`, `tls-models`, `native-static-libs`, `stack-protector-strategies`, `target-spec-json`, `all-target-specs-json`, `link-args`, `split-debuginfo` +error: unknown print request `uwu`. Valid print requests are: `crate-name`, `file-names`, `sysroot`, `target-libdir`, `cfg`, `calling-conventions`, `target-list`, `target-cpus`, `target-features`, `relocation-models`, `code-models`, `tls-models`, `native-static-libs`, `stack-protector-strategies`, `target-spec-json`, `all-target-specs-json`, `link-args`, `split-debuginfo`, `deployment-target` diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml index 0904aa90e..e9b772969 100644 --- a/tests/rustdoc-gui/anchors.goml +++ b/tests/rustdoc-gui/anchors.goml @@ -75,35 +75,35 @@ call-function: ( "check-colors", { "theme": "ayu", - "main_color": "rgb(197, 197, 197)", - "title_color": "rgb(255, 255, 255)", - "main_heading_color": "rgb(255, 255, 255)", - "main_heading_type_color": "rgb(255, 160, 165)", - "src_link_color": "rgb(57, 175, 215)", - "sidebar_link_color": "rgb(83, 177, 219)", + "main_color": "#c5c5c5", + "title_color": "#fff", + "main_heading_color": "#fff", + "main_heading_type_color": "#ffa0a5", + "src_link_color": "#39afd7", + "sidebar_link_color": "#53b1db", }, ) call-function: ( "check-colors", { "theme": "dark", - "main_color": "rgb(221, 221, 221)", - "title_color": "rgb(221, 221, 221)", - "main_heading_color": "rgb(221, 221, 221)", - "main_heading_type_color": "rgb(45, 191, 184)", - "src_link_color": "rgb(210, 153, 29)", - "sidebar_link_color": "rgb(253, 191, 53)", + "main_color": "#ddd", + "title_color": "#ddd", + "main_heading_color": "#ddd", + "main_heading_type_color": "#2dbfb8", + "src_link_color": "#d2991d", + "sidebar_link_color": "#fdbf35", }, ) call-function: ( "check-colors", { "theme": "light", - "main_color": "rgb(0, 0, 0)", - "title_color": "rgb(0, 0, 0)", - "main_heading_color": "rgb(0, 0, 0)", - "main_heading_type_color": "rgb(173, 55, 138)", - "src_link_color": "rgb(56, 115, 173)", - "sidebar_link_color": "rgb(53, 109, 164)", + "main_color": "black", + "title_color": "black", + "main_heading_color": "black", + "main_heading_type_color": "#ad378a", + "src_link_color": "#3873ad", + "sidebar_link_color": "#356da4", }, ) diff --git a/tests/rustdoc-gui/check-stab-in-docblock.goml b/tests/rustdoc-gui/check-stab-in-docblock.goml index 2f6263621..f25c88690 100644 --- a/tests/rustdoc-gui/check-stab-in-docblock.goml +++ b/tests/rustdoc-gui/check-stab-in-docblock.goml @@ -7,20 +7,26 @@ set-window-size: (786, 600) // Confirms that there 3 paragraphs. assert-count: (".top-doc .docblock p", 3) // Checking that there is no scrollable content. -store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(1)", "clientHeight") -store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(1)", "clientWidth") +store-property: (".top-doc .docblock p:nth-of-type(1)", { + "clientHeight": clientHeight, + "clientWidth": clientWidth, +}) assert-property: ( ".top-doc .docblock p:nth-of-type(1)", {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, ) -store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(2)", "clientHeight") -store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(2)", "clientWidth") +store-property: (".top-doc .docblock p:nth-of-type(2)", { + "clientHeight": clientHeight, + "clientWidth": clientWidth, +}) assert-property: ( ".top-doc .docblock p:nth-of-type(2)", {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, ) -store-property: (clientHeight, ".top-doc .docblock p:nth-of-type(3)", "clientHeight") -store-property: (clientWidth, ".top-doc .docblock p:nth-of-type(3)", "clientWidth") +store-property: (".top-doc .docblock p:nth-of-type(3)", { + "clientHeight": clientHeight, + "clientWidth": clientWidth, +}) assert-property: ( ".top-doc .docblock p:nth-of-type(3)", {"scrollHeight": |clientHeight|, "scrollWidth": |clientWidth|}, diff --git a/tests/rustdoc-gui/codeblock-sub.goml b/tests/rustdoc-gui/codeblock-sub.goml index 03575cc6a..a4b055876 100644 --- a/tests/rustdoc-gui/codeblock-sub.goml +++ b/tests/rustdoc-gui/codeblock-sub.goml @@ -1,5 +1,5 @@ // Test that code blocks nested within <sub> do not have a line height of 0. go-to: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html" -store-property: (codeblock_sub_1, "#codeblock-sub-1", "offsetHeight") +store-property: ("#codeblock-sub-1", {"offsetHeight": codeblock_sub_1}) assert-property-false: ("#codeblock-sub-3", { "offsetHeight": |codeblock_sub_1| }) diff --git a/tests/rustdoc-gui/codeblock-tooltip.goml b/tests/rustdoc-gui/codeblock-tooltip.goml index 2ed0579d3..e1c81ed79 100644 --- a/tests/rustdoc-gui/codeblock-tooltip.goml +++ b/tests/rustdoc-gui/codeblock-tooltip.goml @@ -109,19 +109,19 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "background": "rgb(15, 20, 25)", - "color": "rgb(197, 197, 197)", - "border": "rgb(92, 103, 115)", + "background": "#0f1419", + "color": "#c5c5c5", + "border": "#5c6773", }) call-function: ("check-colors", { "theme": "dark", - "background": "rgb(53, 53, 53)", - "color": "rgb(221, 221, 221)", - "border": "rgb(224, 224, 224)", + "background": "#353535", + "color": "#ddd", + "border": "#e0e0e0", }) call-function: ("check-colors", { "theme": "light", - "background": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - "border": "rgb(224, 224, 224)", + "background": "white", + "color": "black", + "border": "#e0e0e0", }) diff --git a/tests/rustdoc-gui/docblock-details.goml b/tests/rustdoc-gui/docblock-details.goml index 58ff17619..8e6d2ba82 100644 --- a/tests/rustdoc-gui/docblock-details.goml +++ b/tests/rustdoc-gui/docblock-details.goml @@ -9,7 +9,7 @@ reload: assert-text: (".top-doc .docblock > h3", "Hello") assert-css: ( ".top-doc .docblock > h3", - {"border-bottom": "1px solid rgb(210, 210, 210)"}, + {"border-bottom": "1px solid #d2d2d2"}, ) // We now check that the `<summary>` doesn't have a bottom border and has the correct display. assert-css: ( diff --git a/tests/rustdoc-gui/highlight-colors.goml b/tests/rustdoc-gui/highlight-colors.goml index 4f5e1c110..d162674fa 100644 --- a/tests/rustdoc-gui/highlight-colors.goml +++ b/tests/rustdoc-gui/highlight-colors.goml @@ -43,52 +43,52 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "kw": "rgb(255, 119, 51)", - "kw2": "rgb(255, 119, 51)", - "prelude_ty": "rgb(105, 242, 223)", - "prelude_val": "rgb(255, 119, 51)", - "lifetime": "rgb(255, 119, 51)", - "number": "rgb(184, 204, 82)", - "string": "rgb(184, 204, 82)", - "bool_val": "rgb(255, 119, 51)", - "self": "rgb(54, 163, 217)", - "attr": "rgb(230, 225, 207)", - "macro": "rgb(163, 122, 204)", - "question_mark": "rgb(255, 144, 17)", - "comment": "rgb(120, 135, 151)", - "doc_comment": "rgb(161, 172, 136)", + "kw": "#ff7733", + "kw2": "#ff7733", + "prelude_ty": "#69f2df", + "prelude_val": "#ff7733", + "lifetime": "#ff7733", + "number": "#b8cc52", + "string": "#b8cc52", + "bool_val": "#ff7733", + "self": "#36a3d9", + "attr": "#e6e1cf", + "macro": "#a37acc", + "question_mark": "#ff9011", + "comment": "#788797", + "doc_comment": "#a1ac88", }) call-function: ("check-colors", { "theme": "dark", - "kw": "rgb(171, 138, 193)", - "kw2": "rgb(118, 154, 203)", - "prelude_ty": "rgb(118, 154, 203)", - "prelude_val": "rgb(238, 104, 104)", - "lifetime": "rgb(217, 127, 38)", - "number": "rgb(131, 163, 0)", - "string": "rgb(131, 163, 0)", - "bool_val": "rgb(238, 104, 104)", - "self": "rgb(238, 104, 104)", - "attr": "rgb(238, 104, 104)", - "macro": "rgb(62, 153, 159)", - "question_mark": "rgb(255, 144, 17)", - "comment": "rgb(141, 141, 139)", - "doc_comment": "rgb(140, 163, 117)", + "kw": "#ab8ac1", + "kw2": "#769acb", + "prelude_ty": "#769acb", + "prelude_val": "#ee6868", + "lifetime": "#d97f26", + "number": "#83a300", + "string": "#83a300", + "bool_val": "#ee6868", + "self": "#ee6868", + "attr": "#ee6868", + "macro": "#3e999f", + "question_mark": "#ff9011", + "comment": "#8d8d8b", + "doc_comment": "#8ca375", }) call-function: ("check-colors", { "theme": "light", - "kw": "rgb(137, 89, 168)", - "kw2": "rgb(66, 113, 174)", - "prelude_ty": "rgb(66, 113, 174)", - "prelude_val": "rgb(200, 40, 41)", - "lifetime": "rgb(183, 101, 20)", - "number": "rgb(113, 140, 0)", - "string": "rgb(113, 140, 0)", - "bool_val": "rgb(200, 40, 41)", - "self": "rgb(200, 40, 41)", - "attr": "rgb(200, 40, 41)", - "macro": "rgb(62, 153, 159)", - "question_mark": "rgb(255, 144, 17)", - "comment": "rgb(142, 144, 140)", - "doc_comment": "rgb(77, 77, 76)", + "kw": "#8959a8", + "kw2": "#4271ae", + "prelude_ty": "#4271ae", + "prelude_val": "#c82829", + "lifetime": "#b76514", + "number": "#718c00", + "string": "#718c00", + "bool_val": "#c82829", + "self": "#c82829", + "attr": "#c82829", + "macro": "#3e999f", + "question_mark": "#ff9011", + "comment": "#8e908c", + "doc_comment": "#4d4d4c", }) diff --git a/tests/rustdoc-gui/item-info.goml b/tests/rustdoc-gui/item-info.goml index 60fd7c4e1..030ff8f8a 100644 --- a/tests/rustdoc-gui/item-info.goml +++ b/tests/rustdoc-gui/item-info.goml @@ -4,8 +4,8 @@ go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html" // We set a fixed size so there is no chance of "random" resize. set-window-size: (1100, 800) // We check that ".item-info" is bigger than its content. -assert-css: (".item-info", {"width": "840px"}) -assert-css: (".item-info .stab", {"width": "289px"}) +assert-size: (".item-info", {"width": 840}) +assert-size: (".item-info .stab", {"width": 289}) assert-position: (".item-info .stab", {"x": 245}) // Now we ensure that they're not rendered on the same line. diff --git a/tests/rustdoc-gui/jump-to-def-background.goml b/tests/rustdoc-gui/jump-to-def-background.goml index 3a7d48284..6adc36b0e 100644 --- a/tests/rustdoc-gui/jump-to-def-background.goml +++ b/tests/rustdoc-gui/jump-to-def-background.goml @@ -17,6 +17,6 @@ define-function: ( }, ) -call-function: ("check-background-color", ("ayu", "rgb(51, 51, 51)")) -call-function: ("check-background-color", ("dark", "rgb(51, 51, 51)")) -call-function: ("check-background-color", ("light", "rgb(238, 238, 238)")) +call-function: ("check-background-color", ("ayu", "#333")) +call-function: ("check-background-color", ("dark", "#333")) +call-function: ("check-background-color", ("light", "#eee")) diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index f65da5774..ecb57c274 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -225,12 +225,12 @@ assert: "#method\.create_an_iterator_from_read .tooltip:focus" // Now we check that the focus isn't given back to the wrong item when opening // another popover. -store-window-property: (scroll, "scrollY") +store-window-property: {"scrollY": scroll} click: "#method\.create_an_iterator_from_read .fn" // We ensure that the scroll position changed. assert-window-property-false: {"scrollY": |scroll|} // Store the new position. -store-window-property: (scroll, "scrollY") +store-window-property: {"scrollY": scroll} click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" wait-for: "//*[@class='tooltip popover']" click: "#settings-menu a" @@ -239,12 +239,12 @@ click: ".search-input" assert-window-property-false: {"scrollY": |scroll|} // Same but with Escape handling. -store-window-property: (scroll, "scrollY") +store-window-property: {"scrollY": scroll} click: "#method\.create_an_iterator_from_read .fn" // We ensure that the scroll position changed. assert-window-property-false: {"scrollY": |scroll|} // Store the new position. -store-window-property: (scroll, "scrollY") +store-window-property: {"scrollY": scroll} click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" wait-for: "//*[@class='tooltip popover']" click: "#settings-menu a" diff --git a/tests/rustdoc-gui/scrape-examples-button-focus.goml b/tests/rustdoc-gui/scrape-examples-button-focus.goml index 77061ea2a..af4293dfc 100644 --- a/tests/rustdoc-gui/scrape-examples-button-focus.goml +++ b/tests/rustdoc-gui/scrape-examples-button-focus.goml @@ -3,7 +3,7 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" // The next/prev buttons vertically scroll the code viewport between examples -store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre", "scrollTop") +store-property: (".scraped-example-list > .scraped-example pre", {"scrollTop": initialScrollTop}) focus: ".scraped-example-list > .scraped-example .next" press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { @@ -16,7 +16,7 @@ assert-property: (".scraped-example-list > .scraped-example pre", { }, NEAR) // The expand button increases the scrollHeight of the minimized code viewport -store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") +store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight}) assert-property-false: (".scraped-example-list > .scraped-example pre", { "scrollHeight": |smallOffsetHeight| }, NEAR) @@ -25,7 +25,7 @@ press-key: "Enter" assert-property-false: (".scraped-example-list > .scraped-example pre", { "offsetHeight": |smallOffsetHeight| }, NEAR) -store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight") +store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": fullOffsetHeight}) assert-property: (".scraped-example-list > .scraped-example pre", { "scrollHeight": |fullOffsetHeight| }, NEAR) diff --git a/tests/rustdoc-gui/scrape-examples-color.goml b/tests/rustdoc-gui/scrape-examples-color.goml index 8ddb06fcc..0052d18dc 100644 --- a/tests/rustdoc-gui/scrape-examples-color.goml +++ b/tests/rustdoc-gui/scrape-examples-color.goml @@ -33,30 +33,30 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "highlight": "rgb(91, 59, 1)", - "highlight_focus": "rgb(124, 75, 15)", - "help_border": "rgb(170, 170, 170)", - "help_color": "rgb(238, 238, 238)", - "help_hover_border": "rgb(255, 255, 255)", - "help_hover_color": "rgb(255, 255, 255)", + "highlight": "#5b3b01", + "highlight_focus": "#7c4b0f", + "help_border": "#aaa", + "help_color": "#eee", + "help_hover_border": "#fff", + "help_hover_color": "#fff", }) call-function: ("check-colors", { "theme": "dark", - "highlight": "rgb(91, 59, 1)", - "highlight_focus": "rgb(124, 75, 15)", - "help_border": "rgb(170, 170, 170)", - "help_color": "rgb(238, 238, 238)", - "help_hover_border": "rgb(255, 255, 255)", - "help_hover_color": "rgb(255, 255, 255)", + "highlight": "#5b3b01", + "highlight_focus": "#7c4b0f", + "help_border": "#aaa", + "help_color": "#eee", + "help_hover_border": "#fff", + "help_hover_color": "#fff", }) call-function: ("check-colors", { "theme": "light", - "highlight": "rgb(252, 255, 214)", - "highlight_focus": "rgb(246, 253, 176)", - "help_border": "rgb(85, 85, 85)", - "help_color": "rgb(51, 51, 51)", - "help_hover_border": "rgb(0, 0, 0)", - "help_hover_color": "rgb(0, 0, 0)", + "highlight": "#fcffd6", + "highlight_focus": "#f6fdb0", + "help_border": "#555", + "help_color": "#333", + "help_hover_border": "#000", + "help_hover_color": "#000", }) // Now testing the top and bottom background in case there is only one scraped examples. @@ -81,16 +81,16 @@ define-function: ( call-function: ("check-background", { "theme": "ayu", - "background_color_start": "rgb(15, 20, 25)", + "background_color_start": "rgba(15, 20, 25, 1)", "background_color_end": "rgba(15, 20, 25, 0)", }) call-function: ("check-background", { "theme": "dark", - "background_color_start": "rgb(53, 53, 53)", + "background_color_start": "rgba(53, 53, 53, 1)", "background_color_end": "rgba(53, 53, 53, 0)", }) call-function: ("check-background", { "theme": "light", - "background_color_start": "rgb(255, 255, 255)", + "background_color_start": "rgba(255, 255, 255, 1)", "background_color_end": "rgba(255, 255, 255, 0)", }) diff --git a/tests/rustdoc-gui/scrape-examples-layout.goml b/tests/rustdoc-gui/scrape-examples-layout.goml index 160056d6d..4fc1c1ac0 100644 --- a/tests/rustdoc-gui/scrape-examples-layout.goml +++ b/tests/rustdoc-gui/scrape-examples-layout.goml @@ -9,9 +9,8 @@ assert-property-false: ( // Check that examples with very long lines have the same width as ones that don't. store-property: ( - clientWidth, ".more-scraped-examples .scraped-example:nth-child(2) .code-wrapper .src-line-numbers", - "clientWidth" + {"clientWidth": clientWidth}, ) assert-property: ( @@ -40,8 +39,8 @@ assert-property: ( store-value: (offset_y, 4) // First with desktop -assert-position: (".scraped-example .code-wrapper", {"y": 253}) -assert-position: (".scraped-example .code-wrapper .prev", {"y": 253 + |offset_y|}) +assert-position: (".scraped-example .code-wrapper", {"y": 226}) +assert-position: (".scraped-example .code-wrapper .prev", {"y": 226 + |offset_y|}) // Then with mobile set-window-size: (600, 600) diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml new file mode 100644 index 000000000..5d1b83b35 --- /dev/null +++ b/tests/rustdoc-gui/search-corrections.goml @@ -0,0 +1,56 @@ +// ignore-tidy-linelength + +// Checks that the search tab result tell the user about corrections +// First, try a search-by-name +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Intentionally wrong spelling of "NotableStructWithLongName" +write: (".search-input", "NotableStructWithLongNamr") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" + +// Corrections aren't shown on the "In Names" tab. +assert: "#search-tabs button.selected:first-child" +assert-css: (".search-corrections", { + "display": "none" +}) + +// Corrections do get shown on the "In Parameters" tab. +click: "#search-tabs button:nth-child(2)" +assert: "#search-tabs button.selected:nth-child(2)" +assert-css: (".search-corrections", { + "display": "block" +}) +assert-text: ( + ".search-corrections", + "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." +) + +// Corrections do get shown on the "In Return Type" tab. +click: "#search-tabs button:nth-child(3)" +assert: "#search-tabs button.selected:nth-child(3)" +assert-css: (".search-corrections", { + "display": "block" +}) +assert-text: ( + ".search-corrections", + "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." +) + +// Now, explicit return values +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// Intentionally wrong spelling of "NotableStructWithLongName" +write: (".search-input", "-> NotableStructWithLongNamr") +// To be SURE that the search will be run. +press-key: 'Enter' +// Waiting for the search results to appear... +wait-for: "#search-tabs" + +assert-css: (".search-corrections", { + "display": "block" +}) +assert-text: ( + ".search-corrections", + "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." +) diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index da46a90df..90f7160b7 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -47,89 +47,89 @@ reload: wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", - {"color": "rgb(136, 136, 136)"}, + {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", - {"color": "rgb(197, 197, 197)"}, + {"color": "#c5c5c5"}, ) assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']", - {"color": "rgb(0, 150, 207)"}, + {"color": "#0096cf"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", - {"border-bottom-color": "rgba(170, 170, 170, 0.2)"} + {"border-bottom-color": "#aaa3"} ) // Checking the color of "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "rgb(120, 135, 151)"}, + {"color": "#788797"}, ) -store-value: (entry_color, "rgb(0, 150, 207)") // color of the search entry -store-value: (hover_entry_color, "rgb(255, 255, 255)") // color of the hovered/focused search entry -store-value: (background_color, "rgba(0, 0, 0, 0)") // background color -store-value: (hover_background_color, "rgb(60, 60, 60)") // hover background color +store-value: (entry_color, "#0096cf") // color of the search entry +store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry +store-value: (background_color, "transparent") // background color +store-value: (hover_background_color, "#3c3c3c") // hover background color call-function: ( "check-result-color", ( "keyword", // item kind - "rgb(57, 175, 215)", // color of item kind - "rgb(57, 175, 215)", // color of hovered/focused item kind + "#39afd7", // color of item kind + "#39afd7", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "struct", // item kind - "rgb(255, 160, 165)", // color of item kind - "rgb(255, 160, 165)", // color of hovered/focused item kind + "#ffa0a5", // color of item kind + "#ffa0a5", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "associatedtype", // item kind - "rgb(57, 175, 215)", // color of item kind - "rgb(57, 175, 215)", // color of hovered/focused item kind + "#39afd7", // color of item kind + "#39afd7", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "tymethod", // item kind - "rgb(253, 214, 135)", // color of item kind - "rgb(253, 214, 135)", // color of hovered/focused item kind + "#fdd687", // color of item kind + "#fdd687", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "method", // item kind - "rgb(253, 214, 135)", // color of item kind - "rgb(253, 214, 135)", // color of hovered/focused item kind + "#fdd687", // color of item kind + "#fdd687", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "structfield", // item kind - "rgb(0, 150, 207)", // color of item kind - "rgb(255, 255, 255)", // color of hovered/focused item kind + "#0096cf", // color of item kind + "#fff", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "macro", // item kind - "rgb(163, 122, 204)", // color of item kind - "rgb(163, 122, 204)", // color of hovered/focused item kind + "#a37acc", // color of item kind + "#a37acc", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "fn", // item kind - "rgb(253, 214, 135)", // color of item kind - "rgb(253, 214, 135)", // color of hovered/focused item kind + "#fdd687", // color of item kind + "#fdd687", // color of hovered/focused item kind ), ) @@ -138,7 +138,7 @@ move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", - {"color": "rgb(0, 150, 207)", "background-color": "rgba(0, 0, 0, 0)"}, + {"color": "#0096cf", "background-color": "transparent"}, ALL, ) @@ -146,11 +146,11 @@ assert-css: ( move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']" assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']", - {"color": "rgb(255, 255, 255)"}, + {"color": "#fff"}, ) assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", - {"color": "rgb(255, 255, 255)", "background-color": "rgb(60, 60, 60)"}, + {"color": "#fff", "background-color": "rgb(60, 60, 60)"}, ) // Dark theme @@ -164,89 +164,89 @@ reload: wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", - {"color": "rgb(136, 136, 136)"}, + {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", - {"color": "rgb(221, 221, 221)"}, + {"color": "#ddd"}, ) assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']", - {"color": "rgb(221, 221, 221)"}, + {"color": "#ddd"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", - {"border-bottom-color": "rgba(170, 170, 170, 0.2)"} + {"border-bottom-color": "#aaa3"} ) // Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "rgb(221, 221, 221)"}, + {"color": "#ddd"}, ) -store-value: (entry_color, "rgb(221, 221, 221)") // color of the search entry -store-value: (hover_entry_color, "rgb(221, 221, 221)") // color of the hovered/focused search entry -store-value: (background_color, "rgba(0, 0, 0, 0)") // background color -store-value: (hover_background_color, "rgb(97, 97, 97)") // hover background color +store-value: (entry_color, "#ddd") // color of the search entry +store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry +store-value: (background_color, "transparent") // background color +store-value: (hover_background_color, "#616161") // hover background color call-function: ( "check-result-color", ( "keyword", // item kind - "rgb(210, 153, 29)", // color of item kind - "rgb(210, 153, 29)", // color of hovered/focused item kind + "#d2991d", // color of item kind + "#d2991d", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "struct", // item kind - "rgb(45, 191, 184)", // color of item kind - "rgb(45, 191, 184)", // color of hovered/focused item kind + "#2dbfb8", // color of item kind + "#2dbfb8", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "associatedtype", // item kind - "rgb(210, 153, 29)", // color of item kind - "rgb(210, 153, 29)", // color of hovered/focused item kind + "#d2991d", // color of item kind + "#d2991d", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "tymethod", // item kind - "rgb(43, 171, 99)", // color of item kind - "rgb(43, 171, 99)", // color of hovered/focused item kind + "#2bab63", // color of item kind + "#2bab63", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "method", // item kind - "rgb(43, 171, 99)", // color of item kind - "rgb(43, 171, 99)", // color of hovered/focused item kind + "#2bab63", // color of item kind + "#2bab63", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "structfield", // item kind - "rgb(221, 221, 221)", // color of item kind - "rgb(221, 221, 221)", // color of hovered/focused item kind + "#ddd", // color of item kind + "#ddd", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "macro", // item kind - "rgb(9, 189, 0)", // color of item kind - "rgb(9, 189, 0)", // color of hovered/focused item kind + "#09bd00", // color of item kind + "#09bd00", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "fn", // item kind - "rgb(43, 171, 99)", // color of item kind - "rgb(43, 171, 99)", // color of hovered/focused item kind + "#2bab63", // color of item kind + "#2bab63", // color of hovered/focused item kind ), ) @@ -255,7 +255,7 @@ move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", - {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, + {"color": "#ddd", "background-color": "transparent"}, ) // Light theme @@ -266,89 +266,89 @@ reload: wait-for: "#search-tabs" assert-css: ( "#search-tabs > button > .count", - {"color": "rgb(136, 136, 136)"}, + {"color": "#888"}, ALL, ) assert-css: ( "//*[@class='desc'][text()='Just a normal struct.']", - {"color": "rgb(0, 0, 0)"}, + {"color": "#000"}, ) assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']", - {"color": "rgb(0, 0, 0)"}, + {"color": "#000"}, ) // Checking the color of the bottom border. assert-css: ( ".search-results > a", - {"border-bottom-color": "rgba(170, 170, 170, 0.2)"} + {"border-bottom-color": "#aaa3"} ) // Checking the color for "keyword" text. assert-css: ( "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "rgb(0, 0, 0)"}, + {"color": "#000"}, ) -store-value: (entry_color, "rgb(0, 0, 0)") // color of the search entry -store-value: (hover_entry_color, "rgb(0, 0, 0)") // color of the hovered/focused search entry -store-value: (background_color, "rgba(0, 0, 0, 0)") // background color -store-value: (hover_background_color, "rgb(204, 204, 204)") // hover background color +store-value: (entry_color, "#000") // color of the search entry +store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry +store-value: (background_color, "transparent") // background color +store-value: (hover_background_color, "#ccc") // hover background color call-function: ( "check-result-color", ( "keyword", // item kind - "rgb(56, 115, 173)", // color of item kind - "rgb(56, 115, 173)", // color of hovered/focused item kind + "#3873ad", // color of item kind + "#3873ad", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "struct", // item kind - "rgb(173, 55, 138)", // color of item kind - "rgb(173, 55, 138)", // color of hovered/focused item kind + "#ad378a", // color of item kind + "#ad378a", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "associatedtype", // item kind - "rgb(56, 115, 173)", // color of item kind - "rgb(56, 115, 173)", // color of hovered/focused item kind + "#3873ad", // color of item kind + "#3873ad", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "tymethod", // item kind - "rgb(173, 124, 55)", // color of item kind - "rgb(173, 124, 55)", // color of hovered/focused item kind + "#ad7c37", // color of item kind + "#ad7c37", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "method", // item kind - "rgb(173, 124, 55)", // color of item kind - "rgb(173, 124, 55)", // color of hovered/focused item kind + "#ad7c37", // color of item kind + "#ad7c37", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "structfield", // item kind - "rgb(0, 0, 0)", // color of item kind - "rgb(0, 0, 0)", // color of hovered/focused item kind + "#000", // color of item kind + "#000", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "macro", // item kind - "rgb(6, 128, 0)", // color of item kind - "rgb(6, 128, 0)", // color of hovered/focused item kind + "#068000", // color of item kind + "#068000", // color of hovered/focused item kind ), ) call-function: ( "check-result-color", ( "fn", // item kind - "rgb(173, 124, 55)", // color of item kind - "rgb(173, 124, 55)", // color of hovered/focused item kind + "#ad7c37", // color of item kind + "#ad7c37", // color of hovered/focused item kind ), ) @@ -357,7 +357,7 @@ move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", - {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, + {"color": "#000", "background-color": "transparent"}, ) // Check the alias. @@ -386,16 +386,16 @@ define-function: ( call-function: ("check-alias", { "theme": "ayu", - "alias": "rgb(197, 197, 197)", - "grey": "rgb(153, 153, 153)", + "alias": "#c5c5c5", + "grey": "#999", }) call-function: ("check-alias", { "theme": "dark", - "alias": "rgb(255, 255, 255)", - "grey": "rgb(204, 204, 204)", + "alias": "#fff", + "grey": "#ccc", }) call-function: ("check-alias", { "theme": "light", - "alias": "rgb(0, 0, 0)", - "grey": "rgb(153, 153, 153)", + "alias": "#000", + "grey": "#999", }) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index 93c71f23f..ee5598e4b 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -32,8 +32,8 @@ set-text: ( ) // Then we compare again to confirm the height didn't change. -assert-css: ("#crate-search", {"width": "527px"}) -assert-css: (".search-results-title", {"height": "50px", "width": "640px"}) +assert-size: ("#crate-search", {"width": 527}) +assert-size: (".search-results-title", {"height": 50, "width": 640}) // And we check that the `<select>` isn't bigger than its container (".search-results-title"). assert-css: ("#search", {"width": "640px"}) diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index 733be9beb..c37d96932 100644 --- a/tests/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -10,7 +10,7 @@ wait-for: "#settings" assert-css: ("#settings", {"display": "block"}) // Store the line margin to compare with the settings.html later. -store-css: (setting_line_margin, ".setting-line", "margin") +store-css: (".setting-line", {"margin": setting_line_margin}) // Let's close it by clicking on the same button. click: "#settings-menu" @@ -256,6 +256,15 @@ set-local-storage: {"rustdoc-disable-shortcuts": "false"} click: ".setting-line:last-child .setting-check span" assert-local-storage: {"rustdoc-disable-shortcuts": "true"} +// We now check that focusing a toggle and pressing Space is like clicking on it. +assert-local-storage: {"rustdoc-disable-shortcuts": "true"} +focus: ".setting-line:last-child .setting-check input" +press-key: "Space" +assert-local-storage: {"rustdoc-disable-shortcuts": "false"} +focus: ".setting-line:last-child .setting-check input" +press-key: "Space" +assert-local-storage: {"rustdoc-disable-shortcuts": "true"} + // Make sure that "Disable keyboard shortcuts" actually took effect. press-key: "Escape" press-key: "?" @@ -292,7 +301,7 @@ wait-for-css: ("#help-button .popover", {"display": "block"}) // Now we go to the settings page to check that the CSS is loaded as expected. go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" -assert-css: (".setting-line", {"position": "relative"}) +assert-css: (".setting-radio", {"cursor": "pointer"}) assert-attribute-false: ("#settings", {"class": "popover"}, CONTAINS) compare-elements-position: (".sub form", "#settings", ("x")) @@ -313,4 +322,4 @@ reload: set-window-size: (300, 1000) click: "#settings-menu" wait-for: "#settings" -assert-css: (".setting-line", {"position": "relative"}) +assert-css: (".setting-radio", {"cursor": "pointer"}) diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml index 20bf0596f..0c680bcc9 100644 --- a/tests/rustdoc-gui/sidebar-source-code-display.goml +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -121,28 +121,28 @@ define-function: ( call-function: ("check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "color_hover": "rgb(0, 0, 0)", - "background": "rgb(255, 255, 255)", - "background_hover": "rgb(224, 224, 224)", + "color": "black", + "color_hover": "#000", + "background": "#fff", + "background_hover": "#e0e0e0", "background_toggle": "rgba(0, 0, 0, 0)", - "background_toggle_hover": "rgb(224, 224, 224)", + "background_toggle_hover": "#e0e0e0", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "color_hover": "rgb(221, 221, 221)", - "background": "rgb(51, 51, 51)", - "background_hover": "rgb(68, 68, 68)", + "color": "#ddd", + "color_hover": "#ddd", + "background": "#333", + "background_hover": "#444", "background_toggle": "rgba(0, 0, 0, 0)", - "background_toggle_hover": "rgb(103, 103, 103)", + "background_toggle_hover": "#676767", }) call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "color_hover": "rgb(255, 180, 76)", + "color": "#c5c5c5", + "color_hover": "#ffb44c", "background": "rgb(20, 25, 31)", - "background_hover": "rgb(20, 25, 31)", + "background_hover": "#14191f", "background_toggle": "rgba(0, 0, 0, 0)", "background_toggle_hover": "rgba(70, 70, 70, 0.33)", }) diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 3c1ed009a..574cc629a 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -152,14 +152,16 @@ assert-property: (".sidebar", {"clientWidth": "200"}) // Checks that all.html and index.html have their sidebar link in the same place. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -store-property: (index_sidebar_width, ".sidebar .location a", "clientWidth") -store-property: (index_sidebar_height, ".sidebar .location a", "clientHeight") -store-property: (index_sidebar_x, ".sidebar .location a", "offsetTop") -store-property: (index_sidebar_y, ".sidebar .location a", "offsetLeft") +store-property: (".sidebar .location a", { + "clientWidth": index_sidebar_width, + "clientHeight": index_sidebar_height, + "offsetTop": index_sidebar_y, + "offsetLeft": index_sidebar_x, +}) go-to: "file://" + |DOC_PATH| + "/test_docs/all.html" assert-property: (".sidebar .location a", { "clientWidth": |index_sidebar_width|, "clientHeight": |index_sidebar_height|, - "offsetTop": |index_sidebar_x|, - "offsetLeft": |index_sidebar_y|, + "offsetTop": |index_sidebar_y|, + "offsetLeft": |index_sidebar_x|, }) diff --git a/tests/rustdoc-gui/source-anchor-scroll.goml b/tests/rustdoc-gui/source-anchor-scroll.goml index 3d88d5619..67f1497e7 100644 --- a/tests/rustdoc-gui/source-anchor-scroll.goml +++ b/tests/rustdoc-gui/source-anchor-scroll.goml @@ -8,13 +8,13 @@ set-window-size: (600, 800) assert-property: ("html", {"scrollTop": "0"}) click: '//a[text() = "barbar"]' -assert-property: ("html", {"scrollTop": "125"}) +assert-property: ("html", {"scrollTop": "149"}) click: '//a[text() = "bar"]' -assert-property: ("html", {"scrollTop": "156"}) +assert-property: ("html", {"scrollTop": "180"}) click: '//a[text() = "sub_fn"]' -assert-property: ("html", {"scrollTop": "53"}) +assert-property: ("html", {"scrollTop": "77"}) // We now check that clicking on lines doesn't change the scroll // Extra information: the "sub_fn" function header is on line 1. click: '//*[@id="6"]' -assert-property: ("html", {"scrollTop": "53"}) +assert-property: ("html", {"scrollTop": "77"}) diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index 42f3200e9..d5dd511b1 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -40,24 +40,24 @@ define-function: ( call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(92, 103, 115)", - "background_color": "rgba(0, 0, 0, 0)", - "highlight_color": "rgb(112, 128, 144)", + "color": "#5c6773", + "background_color": "transparent", + "highlight_color": "#708090", "highlight_background_color": "rgba(255, 236, 164, 0.06)", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(59, 145, 226)", - "background_color": "rgba(0, 0, 0, 0)", - "highlight_color": "rgb(59, 145, 226)", - "highlight_background_color": "rgb(10, 4, 47)", + "color": "#3b91e2", + "background_color": "transparent", + "highlight_color": "#3b91e2", + "highlight_background_color": "#0a042f", }) call-function: ("check-colors", { "theme": "light", - "color": "rgb(198, 126, 45)", - "background_color": "rgba(0, 0, 0, 0)", - "highlight_color": "rgb(198, 126, 45)", - "highlight_background_color": "rgb(253, 255, 211)", + "color": "#c67e2d", + "background_color": "transparent", + "highlight_color": "#c67e2d", + "highlight_background_color": "#fdffd3", }) // This is to ensure that the content is correctly align with the line numbers. @@ -117,9 +117,8 @@ assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) // Check the sidebar directory entries have a marker and spacing (desktop). store-property: ( - link_height, "#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", - "offsetHeight" + {"offsetHeight": link_height}, ) define-function: ( "check-sidebar-dir-entry", @@ -147,16 +146,10 @@ define-function: ( ) } ) -store-property: ( - source_sidebar_title_height, - "#source-sidebar > .title", - "offsetHeight" -) -store-property: ( - source_sidebar_title_y, - "#source-sidebar > .title", - "offsetTop" -) +store-property: ("#source-sidebar > .title", { + "offsetHeight": source_sidebar_title_height, + "offsetTop": source_sidebar_title_y, +}) call-function: ("check-sidebar-dir-entry", { "x": 0, // border + margin = 6 @@ -182,16 +175,10 @@ assert-property: ("#main-content", {"offsetTop": 76}) // 21 = 76 - 34 - 21 // Check the sidebar directory entries have a marker and spacing (tablet). -store-property: ( - source_sidebar_title_height, - "#source-sidebar > .title", - "offsetHeight" -) -store-property: ( - source_sidebar_title_y, - "#source-sidebar > .title", - "offsetTop" -) +store-property: ("#source-sidebar > .title", { + "offsetHeight": source_sidebar_title_height, + "offsetTop": source_sidebar_title_y, +}) call-function: ("check-sidebar-dir-entry", { "x": 0, "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, @@ -202,16 +189,10 @@ set-window-size: (450, 700) assert-css: ("nav.sub", {"flex-direction": "column"}) // Check the sidebar directory entries have a marker and spacing (phone). -store-property: ( - source_sidebar_title_height, - "#source-sidebar > .title", - "offsetHeight" -) -store-property: ( - source_sidebar_title_y, - "#source-sidebar > .title", - "offsetTop" -) +store-property: ("#source-sidebar > .title", { + "offsetHeight": source_sidebar_title_height, + "offsetTop": source_sidebar_title_y, +}) call-function: ("check-sidebar-dir-entry", { "x": 0, "y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6, @@ -219,5 +200,5 @@ call-function: ("check-sidebar-dir-entry", { // Now we check that the logo has a bottom margin so it's not stuck to the search input. assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"}) -store-property: (logo_height, ".sub-logo-container", "clientHeight") +store-property: (".sub-logo-container", {"clientHeight": logo_height}) assert-position: (".search-form", {"y": |logo_height| + 8}) diff --git a/tests/rustdoc-gui/src-font-size.goml b/tests/rustdoc-gui/src-font-size.goml index 790aeba52..ff30bcdf2 100644 --- a/tests/rustdoc-gui/src-font-size.goml +++ b/tests/rustdoc-gui/src-font-size.goml @@ -11,6 +11,6 @@ assert-css: (".impl-items .srclink", {"font-size": "16px", "font-weight": 400}, assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL) // Check that we can click on source link -store-document-property: (url, "URL") +store-document-property: {"URL": url} click: ".impl-items .srclink" assert-document-property-false: {"URL": |url|} diff --git a/tests/rustdoc-gui/src/extend_css/lib.rs b/tests/rustdoc-gui/src/extend_css/lib.rs index 3a3babf89..2308c0932 100644 --- a/tests/rustdoc-gui/src/extend_css/lib.rs +++ b/tests/rustdoc-gui/src/extend_css/lib.rs @@ -1 +1,2 @@ +// compile-flags: --extend-css extra.css //! <div class="extend">text in red</div> diff --git a/tests/rustdoc-gui/src/link_to_definition/lib.rs b/tests/rustdoc-gui/src/link_to_definition/lib.rs index 419a9ccee..6fed79aed 100644 --- a/tests/rustdoc-gui/src/link_to_definition/lib.rs +++ b/tests/rustdoc-gui/src/link_to_definition/lib.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zunstable-options --generate-link-to-definition pub fn sub_fn() { barbar(); } diff --git a/tests/rustdoc-gui/src/scrape_examples/src/lib.rs b/tests/rustdoc-gui/src/scrape_examples/src/lib.rs index 88b03cf26..6666587ad 100644 --- a/tests/rustdoc-gui/src/scrape_examples/src/lib.rs +++ b/tests/rustdoc-gui/src/scrape_examples/src/lib.rs @@ -1,3 +1,4 @@ +// run-flags:-Zrustdoc-scrape-examples /// # Examples /// /// ``` diff --git a/tests/rustdoc-gui/stab-badge.goml b/tests/rustdoc-gui/stab-badge.goml index e23404188..bb3d2aaa3 100644 --- a/tests/rustdoc-gui/stab-badge.goml +++ b/tests/rustdoc-gui/stab-badge.goml @@ -26,16 +26,16 @@ define-function: ( call-function: ("check-badge", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background": "rgb(49, 69, 89)", + "color": "#c5c5c5", + "background": "#314559", }) call-function: ("check-badge", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "background": "rgb(49, 69, 89)", + "color": "#ddd", + "background": "#314559", }) call-function: ("check-badge", { "theme": "light", - "color": "rgb(0, 0, 0)", - "background": "rgb(255, 245, 214)", + "color": "black", + "background": "#fff5d6", }) diff --git a/tests/rustdoc-gui/struct-fields.goml b/tests/rustdoc-gui/struct-fields.goml index da0467de1..3c87a4cd6 100644 --- a/tests/rustdoc-gui/struct-fields.goml +++ b/tests/rustdoc-gui/struct-fields.goml @@ -1,5 +1,5 @@ // This test ensures that each field is on its own line (In other words, they have display: block). go-to: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html" -store-property: (first_top, "//*[@id='structfield.first']", "offsetTop") +store-property: ("//*[@id='structfield.first']", {"offsetTop": first_top}) assert-property-false: ("//*[@id='structfield.second']", { "offsetTop": |first_top| }) diff --git a/tests/rustdoc-gui/type-declation-overflow.goml b/tests/rustdoc-gui/type-declation-overflow.goml index e8e42e400..f212781e9 100644 --- a/tests/rustdoc-gui/type-declation-overflow.goml +++ b/tests/rustdoc-gui/type-declation-overflow.goml @@ -39,7 +39,7 @@ assert-property: ("pre.item-decl", {"scrollWidth": "950"}) set-window-size: (600, 600) go-to: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" // It shouldn't have an overflow in the topbar either. -store-property: (scrollWidth, ".mobile-topbar h2", "scrollWidth") +store-property: (".mobile-topbar h2", {"scrollWidth": scrollWidth}) assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|}) assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"}) diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js index 787662243..0e8475160 100644 --- a/tests/rustdoc-js/generics-trait.js +++ b/tests/rustdoc-js/generics-trait.js @@ -1,9 +1,21 @@ +// exact-check + const QUERY = [ 'Result<SomeTrait>', + 'Result<SomeTraiz>', + 'OtherThingxxxxxxxx', + 'OtherThingxxxxxxxy', +]; + +const CORRECTIONS = [ + null, + null, + null, 'OtherThingxxxxxxxx', ]; const EXPECTED = [ + // Result<SomeTrait> { 'in_args': [ { 'path': 'generics_trait', 'name': 'beta' }, @@ -12,6 +24,21 @@ const EXPECTED = [ { 'path': 'generics_trait', 'name': 'bet' }, ], }, + // Result<SomeTraiz> + { + 'in_args': [], + 'returned': [], + }, + // OtherThingxxxxxxxx + { + 'in_args': [ + { 'path': 'generics_trait', 'name': 'alpha' }, + ], + 'returned': [ + { 'path': 'generics_trait', 'name': 'alef' }, + ], + }, + // OtherThingxxxxxxxy { 'in_args': [ { 'path': 'generics_trait', 'name': 'alpha' }, diff --git a/tests/rustdoc-js/slice-array.js b/tests/rustdoc-js/slice-array.js new file mode 100644 index 000000000..8c21e06dc --- /dev/null +++ b/tests/rustdoc-js/slice-array.js @@ -0,0 +1,65 @@ +// exact-check + +const QUERY = [ + 'R<primitive:slice<P>>', + 'primitive:slice<R<P>>', + 'R<primitive:slice<Q>>', + 'primitive:slice<R<Q>>', + 'R<primitive:array<Q>>', + 'primitive:array<R<Q>>', + 'primitive:array<TraitCat>', + 'primitive:array<TraitDog>', +]; + +const EXPECTED = [ + { + // R<primitive:slice<P>> + 'returned': [], + 'in_args': [ + { 'path': 'slice_array', 'name': 'alpha' }, + ], + }, + { + // primitive:slice<R<P>> + 'returned': [ + { 'path': 'slice_array', 'name': 'alef' }, + ], + 'in_args': [], + }, + { + // R<primitive:slice<Q>> + 'returned': [], + 'in_args': [], + }, + { + // primitive:slice<R<Q>> + 'returned': [], + 'in_args': [], + }, + { + // R<primitive:array<Q>> + 'returned': [ + { 'path': 'slice_array', 'name': 'bet' }, + ], + 'in_args': [], + }, + { + // primitive:array<R<Q>> + 'returned': [], + 'in_args': [ + { 'path': 'slice_array', 'name': 'beta' }, + ], + }, + { + // primitive::array<TraitCat> + 'in_args': [ + { 'path': 'slice_array', 'name': 'gamma' }, + ], + }, + { + // primitive::array<TraitDog> + 'in_args': [ + { 'path': 'slice_array', 'name': 'gamma' }, + ], + }, +]; diff --git a/tests/rustdoc-js/slice-array.rs b/tests/rustdoc-js/slice-array.rs new file mode 100644 index 000000000..2523b21cf --- /dev/null +++ b/tests/rustdoc-js/slice-array.rs @@ -0,0 +1,16 @@ +pub struct P; +pub struct Q; +pub struct R<T>(T); + +// returns test +pub fn alef() -> &'static [R<P>] { loop {} } +pub fn bet() -> R<[Q; 32]> { loop {} } + +// in_args test +pub fn alpha(_x: R<&'static [P]>) { loop {} } +pub fn beta(_x: [R<Q>; 32]) { loop {} } + +pub trait TraitCat {} +pub trait TraitDog {} + +pub fn gamma<T: TraitCat + TraitDog>(t: [T; 32]) {} diff --git a/tests/rustdoc-json/assoc_items.rs b/tests/rustdoc-json/assoc_items.rs index 6d7f6bb96..05c2d4283 100644 --- a/tests/rustdoc-json/assoc_items.rs +++ b/tests/rustdoc-json/assoc_items.rs @@ -3,35 +3,32 @@ pub struct Simple; impl Simple { - // @is "$.index[*][?(@.name=='CONSTANT')].kind" \"assoc_const\" + // @has "$.index[*][?(@.name=='CONSTANT')].inner.assoc_const" pub const CONSTANT: usize = 0; } pub trait EasyToImpl { - // @is "$.index[*][?(@.docs=='ToDeclare trait')].kind" \"assoc_type\" - // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.default" null - // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.bounds" [] + // @has "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type" + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.default" null + // @is "$.index[*][?(@.docs=='ToDeclare trait')].inner.assoc_type.bounds" [] /// ToDeclare trait type ToDeclare; - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].kind" \"assoc_const\" - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.default" null - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.kind" '"primitive"' - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.type.inner" '"usize"' + // @has "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.default" null + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE trait')].inner.assoc_const.type.primitive" '"usize"' /// AN_ATTRIBUTE trait const AN_ATTRIBUTE: usize; } impl EasyToImpl for Simple { - // @is "$.index[*][?(@.docs=='ToDeclare impl')].kind" '"assoc_type"' - // @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.kind" \"primitive\" - // @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.default.inner" \"usize\" + // @has "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type" + // @is "$.index[*][?(@.docs=='ToDeclare impl')].inner.assoc_type.default.primitive" \"usize\" /// ToDeclare impl type ToDeclare = usize; - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].kind" '"assoc_const"' - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.kind" \"primitive\" - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.type.inner" \"usize\" - // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.default" \"12\" + // @has "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.type.primitive" \"usize\" + // @is "$.index[*][?(@.docs=='AN_ATTRIBUTE impl')].inner.assoc_const.default" \"12\" /// AN_ATTRIBUTE impl const AN_ATTRIBUTE: usize = 12; } diff --git a/tests/rustdoc-json/blanket_impls.rs b/tests/rustdoc-json/blanket_impls.rs index c5cc87ca1..a2a5c4a71 100644 --- a/tests/rustdoc-json/blanket_impls.rs +++ b/tests/rustdoc-json/blanket_impls.rs @@ -2,7 +2,7 @@ #![no_std] -// @has "$.index[*][?(@.name=='Error')].kind" \"assoc_type\" -// @has "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" -// @has "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" +// @has "$.index[*][?(@.name=='Error')].inner.assoc_type" +// @has "$.index[*][?(@.name=='Error')].inner.assoc_type.default.resolved_path" +// @has "$.index[*][?(@.name=='Error')].inner.assoc_type.default.resolved_path.name" \"Infallible\" pub struct ForBlanketTryFromImpl; diff --git a/tests/rustdoc-json/enums/discriminant/basic.rs b/tests/rustdoc-json/enums/discriminant/basic.rs index 06906df3b..dbfc5c2cf 100644 --- a/tests/rustdoc-json/enums/discriminant/basic.rs +++ b/tests/rustdoc-json/enums/discriminant/basic.rs @@ -1,12 +1,12 @@ #[repr(i8)] pub enum Ordering { - // @is "$.index[*][?(@.name=='Less')].inner.discriminant.expr" '"-1"' - // @is "$.index[*][?(@.name=='Less')].inner.discriminant.value" '"-1"' + // @is "$.index[*][?(@.name=='Less')].inner.variant.discriminant.expr" '"-1"' + // @is "$.index[*][?(@.name=='Less')].inner.variant.discriminant.value" '"-1"' Less = -1, - // @is "$.index[*][?(@.name=='Equal')].inner.discriminant.expr" '"0"' - // @is "$.index[*][?(@.name=='Equal')].inner.discriminant.value" '"0"' + // @is "$.index[*][?(@.name=='Equal')].inner.variant.discriminant.expr" '"0"' + // @is "$.index[*][?(@.name=='Equal')].inner.variant.discriminant.value" '"0"' Equal = 0, - // @is "$.index[*][?(@.name=='Greater')].inner.discriminant.expr" '"1"' - // @is "$.index[*][?(@.name=='Greater')].inner.discriminant.value" '"1"' + // @is "$.index[*][?(@.name=='Greater')].inner.variant.discriminant.expr" '"1"' + // @is "$.index[*][?(@.name=='Greater')].inner.variant.discriminant.value" '"1"' Greater = 1, } diff --git a/tests/rustdoc-json/enums/discriminant/expr.rs b/tests/rustdoc-json/enums/discriminant/expr.rs index e639965e7..ddcad58a5 100644 --- a/tests/rustdoc-json/enums/discriminant/expr.rs +++ b/tests/rustdoc-json/enums/discriminant/expr.rs @@ -1,30 +1,30 @@ pub enum Foo { - // @is "$.index[*][?(@.name=='Addition')].inner.discriminant.value" '"0"' - // @is "$.index[*][?(@.name=='Addition')].inner.discriminant.expr" '"{ _ }"' + // @is "$.index[*][?(@.name=='Addition')].inner.variant.discriminant.value" '"0"' + // @is "$.index[*][?(@.name=='Addition')].inner.variant.discriminant.expr" '"{ _ }"' Addition = 0 + 0, - // @is "$.index[*][?(@.name=='Bin')].inner.discriminant.value" '"1"' - // @is "$.index[*][?(@.name=='Bin')].inner.discriminant.expr" '"0b1"' + // @is "$.index[*][?(@.name=='Bin')].inner.variant.discriminant.value" '"1"' + // @is "$.index[*][?(@.name=='Bin')].inner.variant.discriminant.expr" '"0b1"' Bin = 0b1, - // @is "$.index[*][?(@.name=='Oct')].inner.discriminant.value" '"2"' - // @is "$.index[*][?(@.name=='Oct')].inner.discriminant.expr" '"0o2"' + // @is "$.index[*][?(@.name=='Oct')].inner.variant.discriminant.value" '"2"' + // @is "$.index[*][?(@.name=='Oct')].inner.variant.discriminant.expr" '"0o2"' Oct = 0o2, - // @is "$.index[*][?(@.name=='PubConst')].inner.discriminant.value" '"3"' - // @is "$.index[*][?(@.name=='PubConst')].inner.discriminant.expr" '"THREE"' + // @is "$.index[*][?(@.name=='PubConst')].inner.variant.discriminant.value" '"3"' + // @is "$.index[*][?(@.name=='PubConst')].inner.variant.discriminant.expr" '"THREE"' PubConst = THREE, - // @is "$.index[*][?(@.name=='Hex')].inner.discriminant.value" '"4"' - // @is "$.index[*][?(@.name=='Hex')].inner.discriminant.expr" '"0x4"' + // @is "$.index[*][?(@.name=='Hex')].inner.variant.discriminant.value" '"4"' + // @is "$.index[*][?(@.name=='Hex')].inner.variant.discriminant.expr" '"0x4"' Hex = 0x4, - // @is "$.index[*][?(@.name=='Cast')].inner.discriminant.value" '"5"' - // @is "$.index[*][?(@.name=='Cast')].inner.discriminant.expr" '"{ _ }"' + // @is "$.index[*][?(@.name=='Cast')].inner.variant.discriminant.value" '"5"' + // @is "$.index[*][?(@.name=='Cast')].inner.variant.discriminant.expr" '"{ _ }"' Cast = 5 as isize, - // @is "$.index[*][?(@.name=='PubCall')].inner.discriminant.value" '"6"' - // @is "$.index[*][?(@.name=='PubCall')].inner.discriminant.expr" '"{ _ }"' + // @is "$.index[*][?(@.name=='PubCall')].inner.variant.discriminant.value" '"6"' + // @is "$.index[*][?(@.name=='PubCall')].inner.variant.discriminant.expr" '"{ _ }"' PubCall = six(), - // @is "$.index[*][?(@.name=='PrivCall')].inner.discriminant.value" '"7"' - // @is "$.index[*][?(@.name=='PrivCall')].inner.discriminant.expr" '"{ _ }"' + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant.discriminant.value" '"7"' + // @is "$.index[*][?(@.name=='PrivCall')].inner.variant.discriminant.expr" '"{ _ }"' PrivCall = seven(), - // @is "$.index[*][?(@.name=='PrivConst')].inner.discriminant.value" '"8"' - // @is "$.index[*][?(@.name=='PrivConst')].inner.discriminant.expr" '"EIGHT"' + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant.discriminant.value" '"8"' + // @is "$.index[*][?(@.name=='PrivConst')].inner.variant.discriminant.expr" '"EIGHT"' PrivConst = EIGHT, } diff --git a/tests/rustdoc-json/enums/discriminant/limits.rs b/tests/rustdoc-json/enums/discriminant/limits.rs index e56d5594f..47fb70408 100644 --- a/tests/rustdoc-json/enums/discriminant/limits.rs +++ b/tests/rustdoc-json/enums/discriminant/limits.rs @@ -4,40 +4,40 @@ #[repr(u64)] pub enum U64 { - // @is "$.index[*][?(@.name=='U64Min')].inner.discriminant.value" '"0"' - // @is "$.index[*][?(@.name=='U64Min')].inner.discriminant.expr" '"u64::MIN"' + // @is "$.index[*][?(@.name=='U64Min')].inner.variant.discriminant.value" '"0"' + // @is "$.index[*][?(@.name=='U64Min')].inner.variant.discriminant.expr" '"u64::MIN"' U64Min = u64::MIN, - // @is "$.index[*][?(@.name=='U64Max')].inner.discriminant.value" '"18446744073709551615"' - // @is "$.index[*][?(@.name=='U64Max')].inner.discriminant.expr" '"u64::MAX"' + // @is "$.index[*][?(@.name=='U64Max')].inner.variant.discriminant.value" '"18446744073709551615"' + // @is "$.index[*][?(@.name=='U64Max')].inner.variant.discriminant.expr" '"u64::MAX"' U64Max = u64::MAX, } #[repr(i64)] pub enum I64 { - // @is "$.index[*][?(@.name=='I64Min')].inner.discriminant.value" '"-9223372036854775808"' - // @is "$.index[*][?(@.name=='I64Min')].inner.discriminant.expr" '"i64::MIN"' + // @is "$.index[*][?(@.name=='I64Min')].inner.variant.discriminant.value" '"-9223372036854775808"' + // @is "$.index[*][?(@.name=='I64Min')].inner.variant.discriminant.expr" '"i64::MIN"' I64Min = i64::MIN, - // @is "$.index[*][?(@.name=='I64Max')].inner.discriminant.value" '"9223372036854775807"' - // @is "$.index[*][?(@.name=='I64Max')].inner.discriminant.expr" '"i64::MAX"' + // @is "$.index[*][?(@.name=='I64Max')].inner.variant.discriminant.value" '"9223372036854775807"' + // @is "$.index[*][?(@.name=='I64Max')].inner.variant.discriminant.expr" '"i64::MAX"' I64Max = i64::MAX, } #[repr(u128)] pub enum U128 { - // @is "$.index[*][?(@.name=='U128Min')].inner.discriminant.value" '"0"' - // @is "$.index[*][?(@.name=='U128Min')].inner.discriminant.expr" '"u128::MIN"' + // @is "$.index[*][?(@.name=='U128Min')].inner.variant.discriminant.value" '"0"' + // @is "$.index[*][?(@.name=='U128Min')].inner.variant.discriminant.expr" '"u128::MIN"' U128Min = u128::MIN, - // @is "$.index[*][?(@.name=='U128Max')].inner.discriminant.value" '"340282366920938463463374607431768211455"' - // @is "$.index[*][?(@.name=='U128Max')].inner.discriminant.expr" '"u128::MAX"' + // @is "$.index[*][?(@.name=='U128Max')].inner.variant.discriminant.value" '"340282366920938463463374607431768211455"' + // @is "$.index[*][?(@.name=='U128Max')].inner.variant.discriminant.expr" '"u128::MAX"' U128Max = u128::MAX, } #[repr(i128)] pub enum I128 { - // @is "$.index[*][?(@.name=='I128Min')].inner.discriminant.value" '"-170141183460469231731687303715884105728"' - // @is "$.index[*][?(@.name=='I128Min')].inner.discriminant.expr" '"i128::MIN"' + // @is "$.index[*][?(@.name=='I128Min')].inner.variant.discriminant.value" '"-170141183460469231731687303715884105728"' + // @is "$.index[*][?(@.name=='I128Min')].inner.variant.discriminant.expr" '"i128::MIN"' I128Min = i128::MIN, - // @is "$.index[*][?(@.name=='I128Max')].inner.discriminant.value" '"170141183460469231731687303715884105727"' - // @is "$.index[*][?(@.name=='I128Max')].inner.discriminant.expr" '"i128::MAX"' + // @is "$.index[*][?(@.name=='I128Max')].inner.variant.discriminant.value" '"170141183460469231731687303715884105727"' + // @is "$.index[*][?(@.name=='I128Max')].inner.variant.discriminant.expr" '"i128::MAX"' I128Max = i128::MAX, } diff --git a/tests/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs b/tests/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs index 6889b305f..9c3db81c6 100644 --- a/tests/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs +++ b/tests/rustdoc-json/enums/discriminant/num_underscore_and_suffix.rs @@ -1,15 +1,17 @@ +// ignore-tidy-linelength + #[repr(u32)] pub enum Foo { - // @is "$.index[*][?(@.name=='Basic')].inner.discriminant.value" '"0"' - // @is "$.index[*][?(@.name=='Basic')].inner.discriminant.expr" '"0"' + // @is "$.index[*][?(@.name=='Basic')].inner.variant.discriminant.value" '"0"' + // @is "$.index[*][?(@.name=='Basic')].inner.variant.discriminant.expr" '"0"' Basic = 0, - // @is "$.index[*][?(@.name=='Suffix')].inner.discriminant.value" '"10"' - // @is "$.index[*][?(@.name=='Suffix')].inner.discriminant.expr" '"10u32"' + // @is "$.index[*][?(@.name=='Suffix')].inner.variant.discriminant.value" '"10"' + // @is "$.index[*][?(@.name=='Suffix')].inner.variant.discriminant.expr" '"10u32"' Suffix = 10u32, - // @is "$.index[*][?(@.name=='Underscore')].inner.discriminant.value" '"100"' - // @is "$.index[*][?(@.name=='Underscore')].inner.discriminant.expr" '"1_0_0"' + // @is "$.index[*][?(@.name=='Underscore')].inner.variant.discriminant.value" '"100"' + // @is "$.index[*][?(@.name=='Underscore')].inner.variant.discriminant.expr" '"1_0_0"' Underscore = 1_0_0, - // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.discriminant.value" '"1000"' - // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.discriminant.expr" '"1_0_0_0u32"' + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant.discriminant.value" '"1000"' + // @is "$.index[*][?(@.name=='SuffixUnderscore')].inner.variant.discriminant.expr" '"1_0_0_0u32"' SuffixUnderscore = 1_0_0_0u32, } diff --git a/tests/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs b/tests/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs index 6a4f54de6..38ba1caf1 100644 --- a/tests/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs +++ b/tests/rustdoc-json/enums/discriminant/only_some_have_discriminant.rs @@ -1,10 +1,12 @@ +// ignore-tidy-linelength + pub enum Foo { - // @is "$.index[*][?(@.name=='Has')].inner.discriminant" '{"expr":"0", "value":"0"}' + // @is "$.index[*][?(@.name=='Has')].inner.variant.discriminant" '{"expr":"0", "value":"0"}' Has = 0, - // @is "$.index[*][?(@.name=='Doesnt')].inner.discriminant" null + // @is "$.index[*][?(@.name=='Doesnt')].inner.variant.discriminant" null Doesnt, - // @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.discriminant" null + // @is "$.index[*][?(@.name=='AlsoDoesnt')].inner.variant.discriminant" null AlsoDoesnt, - // @is "$.index[*][?(@.name=='AlsoHas')].inner.discriminant" '{"expr":"44", "value":"44"}' + // @is "$.index[*][?(@.name=='AlsoHas')].inner.variant.discriminant" '{"expr":"44", "value":"44"}' AlsoHas = 44, } diff --git a/tests/rustdoc-json/enums/discriminant/struct.rs b/tests/rustdoc-json/enums/discriminant/struct.rs index e91a632a3..c4b087c36 100644 --- a/tests/rustdoc-json/enums/discriminant/struct.rs +++ b/tests/rustdoc-json/enums/discriminant/struct.rs @@ -3,13 +3,13 @@ #[repr(i32)] // @is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(i32)]"]' pub enum Foo { - // @is "$.index[*][?(@.name=='Struct')].inner.discriminant" null - // @count "$.index[*][?(@.name=='Struct')].inner.kind.struct.fields[*]" 0 + // @is "$.index[*][?(@.name=='Struct')].inner.variant.discriminant" null + // @count "$.index[*][?(@.name=='Struct')].inner.variant.kind.struct.fields[*]" 0 Struct {}, - // @is "$.index[*][?(@.name=='StructWithDiscr')].inner.discriminant" '{"expr": "42", "value": "42"}' - // @count "$.index[*][?(@.name=='StructWithDiscr')].inner.kind.struct.fields[*]" 1 + // @is "$.index[*][?(@.name=='StructWithDiscr')].inner.variant.discriminant" '{"expr": "42", "value": "42"}' + // @count "$.index[*][?(@.name=='StructWithDiscr')].inner.variant.kind.struct.fields[*]" 1 StructWithDiscr { x: i32 } = 42, - // @is "$.index[*][?(@.name=='StructWithHexDiscr')].inner.discriminant" '{"expr": "0x42", "value": "66"}' - // @count "$.index[*][?(@.name=='StructWithHexDiscr')].inner.kind.struct.fields[*]" 2 + // @is "$.index[*][?(@.name=='StructWithHexDiscr')].inner.variant.discriminant" '{"expr": "0x42", "value": "66"}' + // @count "$.index[*][?(@.name=='StructWithHexDiscr')].inner.variant.kind.struct.fields[*]" 2 StructWithHexDiscr { x: i32, y: bool } = 0x42, } diff --git a/tests/rustdoc-json/enums/discriminant/tuple.rs b/tests/rustdoc-json/enums/discriminant/tuple.rs index b94d5739e..7da82ec8e 100644 --- a/tests/rustdoc-json/enums/discriminant/tuple.rs +++ b/tests/rustdoc-json/enums/discriminant/tuple.rs @@ -3,13 +3,13 @@ #[repr(u32)] // @is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(u32)]"]' pub enum Foo { - // @is "$.index[*][?(@.name=='Tuple')].inner.discriminant" null - // @count "$.index[*][?(@.name=='Tuple')].inner.kind.tuple[*]" 0 + // @is "$.index[*][?(@.name=='Tuple')].inner.variant.discriminant" null + // @count "$.index[*][?(@.name=='Tuple')].inner.variant.kind.tuple[*]" 0 Tuple(), - // @is "$.index[*][?(@.name=='TupleWithDiscr')].inner.discriminant" '{"expr": "1", "value": "1"}' - // @count "$.index[*][?(@.name=='TupleWithDiscr')].inner.kind.tuple[*]" 1 + // @is "$.index[*][?(@.name=='TupleWithDiscr')].inner.variant.discriminant" '{"expr": "1", "value": "1"}' + // @count "$.index[*][?(@.name=='TupleWithDiscr')].inner.variant.kind.tuple[*]" 1 TupleWithDiscr(i32) = 1, - // @is "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.discriminant" '{"expr": "0b10", "value": "2"}' - // @count "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.kind.tuple[*]" 2 + // @is "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.variant.discriminant" '{"expr": "0b10", "value": "2"}' + // @count "$.index[*][?(@.name=='TupleWithBinDiscr')].inner.variant.kind.tuple[*]" 2 TupleWithBinDiscr(i32, i32) = 0b10, } diff --git a/tests/rustdoc-json/enums/doc_link_to_foreign_variant.rs b/tests/rustdoc-json/enums/doc_link_to_foreign_variant.rs index 470b195a2..b00156124 100644 --- a/tests/rustdoc-json/enums/doc_link_to_foreign_variant.rs +++ b/tests/rustdoc-json/enums/doc_link_to_foreign_variant.rs @@ -5,7 +5,7 @@ extern crate color; use color::Color::Red; -// @set red = "$.index[*][?(@.inner.is_crate == true)].links.Red" +// @set red = "$.index[*][?(@.inner.module.is_crate)].links.Red" // @!has "$.index[*][?(@.name == 'Red')]" // @!has "$.index[*][?(@.name == 'Color')]" diff --git a/tests/rustdoc-json/enums/field_hidden.rs b/tests/rustdoc-json/enums/field_hidden.rs index 78a054314..5c0d0ffd3 100644 --- a/tests/rustdoc-json/enums/field_hidden.rs +++ b/tests/rustdoc-json/enums/field_hidden.rs @@ -5,8 +5,8 @@ // @has "$.index[*][?(@.name=='ParseError')]" // @has "$.index[*][?(@.name=='UnexpectedEndTag')]" -// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.kind.tuple" [null] -// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.discriminant" null +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.kind.tuple" [null] +// @is "$.index[*][?(@.name=='UnexpectedEndTag')].inner.variant.discriminant" null pub enum ParseError { UnexpectedEndTag(#[doc(hidden)] u32), diff --git a/tests/rustdoc-json/enums/kind.rs b/tests/rustdoc-json/enums/kind.rs index 1787a859c..e283c0740 100644 --- a/tests/rustdoc-json/enums/kind.rs +++ b/tests/rustdoc-json/enums/kind.rs @@ -5,28 +5,28 @@ pub enum Foo { // @set Unit = "$.index[*][?(@.name=='Unit')].id" - // @is "$.index[*][?(@.name=='Unit')].inner.kind" '"plain"' + // @is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"' Unit, // @set Named = "$.index[*][?(@.name=='Named')].id" - // @is "$.index[*][?(@.name=='Named')].inner.kind.struct" '{"fields": [], "fields_stripped": false}' + // @is "$.index[*][?(@.name=='Named')].inner.variant.kind.struct" '{"fields": [], "fields_stripped": false}' Named {}, // @set Tuple = "$.index[*][?(@.name=='Tuple')].id" - // @is "$.index[*][?(@.name=='Tuple')].inner.kind.tuple" [] + // @is "$.index[*][?(@.name=='Tuple')].inner.variant.kind.tuple" [] Tuple(), // @set NamedField = "$.index[*][?(@.name=='NamedField')].id" - // @set x = "$.index[*][?(@.name=='x' && @.kind=='struct_field')].id" - // @is "$.index[*][?(@.name=='NamedField')].inner.kind.struct.fields[*]" $x - // @is "$.index[*][?(@.name=='NamedField')].inner.kind.struct.fields_stripped" false + // @set x = "$.index[*][?(@.name=='x' && @.inner.struct_field)].id" + // @is "$.index[*][?(@.name=='NamedField')].inner.variant.kind.struct.fields[*]" $x + // @is "$.index[*][?(@.name=='NamedField')].inner.variant.kind.struct.fields_stripped" false NamedField { x: i32 }, // @set TupleField = "$.index[*][?(@.name=='TupleField')].id" - // @set tup_field = "$.index[*][?(@.name=='0' && @.kind=='struct_field')].id" - // @is "$.index[*][?(@.name=='TupleField')].inner.kind.tuple[*]" $tup_field + // @set tup_field = "$.index[*][?(@.name=='0' && @.inner.struct_field)].id" + // @is "$.index[*][?(@.name=='TupleField')].inner.variant.kind.tuple[*]" $tup_field TupleField(i32), } -// @is "$.index[*][?(@.name=='Foo')].inner.variants[0]" $Unit -// @is "$.index[*][?(@.name=='Foo')].inner.variants[1]" $Named -// @is "$.index[*][?(@.name=='Foo')].inner.variants[2]" $Tuple -// @is "$.index[*][?(@.name=='Foo')].inner.variants[3]" $NamedField -// @is "$.index[*][?(@.name=='Foo')].inner.variants[4]" $TupleField -// @count "$.index[*][?(@.name=='Foo')].inner.variants[*]" 5 +// @is "$.index[*][?(@.name=='Foo')].inner.enum.variants[0]" $Unit +// @is "$.index[*][?(@.name=='Foo')].inner.enum.variants[1]" $Named +// @is "$.index[*][?(@.name=='Foo')].inner.enum.variants[2]" $Tuple +// @is "$.index[*][?(@.name=='Foo')].inner.enum.variants[3]" $NamedField +// @is "$.index[*][?(@.name=='Foo')].inner.enum.variants[4]" $TupleField +// @count "$.index[*][?(@.name=='Foo')].inner.enum.variants[*]" 5 diff --git a/tests/rustdoc-json/enums/struct_field_hidden.rs b/tests/rustdoc-json/enums/struct_field_hidden.rs index de939cde2..2676c4e41 100644 --- a/tests/rustdoc-json/enums/struct_field_hidden.rs +++ b/tests/rustdoc-json/enums/struct_field_hidden.rs @@ -9,8 +9,8 @@ pub enum Foo { // @set y = "$.index[*][?(@.name=='y')].id" y: i32, }, - // @is "$.index[*][?(@.name=='Variant')].inner.kind.struct.fields_stripped" true - // @is "$.index[*][?(@.name=='Variant')].inner.kind.struct.fields[0]" $b - // @is "$.index[*][?(@.name=='Variant')].inner.kind.struct.fields[1]" $y - // @count "$.index[*][?(@.name=='Variant')].inner.kind.struct.fields[*]" 2 + // @is "$.index[*][?(@.name=='Variant')].inner.variant.kind.struct.fields_stripped" true + // @is "$.index[*][?(@.name=='Variant')].inner.variant.kind.struct.fields[0]" $b + // @is "$.index[*][?(@.name=='Variant')].inner.variant.kind.struct.fields[1]" $y + // @count "$.index[*][?(@.name=='Variant')].inner.variant.kind.struct.fields[*]" 2 } diff --git a/tests/rustdoc-json/enums/tuple_fields_hidden.rs b/tests/rustdoc-json/enums/tuple_fields_hidden.rs index 70bfbb818..3aeb03564 100644 --- a/tests/rustdoc-json/enums/tuple_fields_hidden.rs +++ b/tests/rustdoc-json/enums/tuple_fields_hidden.rs @@ -14,47 +14,47 @@ // @set 3.3.1 = "$.index[*][?(@.docs=='3.3.1')].id" pub enum EnumWithStrippedTupleVariants { - // @count "$.index[*][?(@.name=='None')].inner.kind.tuple[*]" 0 + // @count "$.index[*][?(@.name=='None')].inner.variant.kind.tuple[*]" 0 None(), - // @count "$.index[*][?(@.name=='One')].inner.kind.tuple[*]" 1 - // @is "$.index[*][?(@.name=='One')].inner.kind.tuple[0]" $1.1.0 + // @count "$.index[*][?(@.name=='One')].inner.variant.kind.tuple[*]" 1 + // @is "$.index[*][?(@.name=='One')].inner.variant.kind.tuple[0]" $1.1.0 One(/** 1.1.0*/ bool), - // @count "$.index[*][?(@.name=='OneHidden')].inner.kind.tuple[*]" 1 - // @is "$.index[*][?(@.name=='OneHidden')].inner.kind.tuple[0]" null + // @count "$.index[*][?(@.name=='OneHidden')].inner.variant.kind.tuple[*]" 1 + // @is "$.index[*][?(@.name=='OneHidden')].inner.variant.kind.tuple[0]" null OneHidden(#[doc(hidden)] bool), - // @count "$.index[*][?(@.name=='Two')].inner.kind.tuple[*]" 2 - // @is "$.index[*][?(@.name=='Two')].inner.kind.tuple[0]" $2.1.0 - // @is "$.index[*][?(@.name=='Two')].inner.kind.tuple[1]" $2.1.1 + // @count "$.index[*][?(@.name=='Two')].inner.variant.kind.tuple[*]" 2 + // @is "$.index[*][?(@.name=='Two')].inner.variant.kind.tuple[0]" $2.1.0 + // @is "$.index[*][?(@.name=='Two')].inner.variant.kind.tuple[1]" $2.1.1 Two(/** 2.1.0*/ bool, /** 2.1.1*/ bool), - // @count "$.index[*][?(@.name=='TwoLeftHidden')].inner.kind.tuple[*]" 2 - // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.kind.tuple[0]" null - // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.kind.tuple[1]" $2.2.1 + // @count "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant.kind.tuple[*]" 2 + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant.kind.tuple[0]" null + // @is "$.index[*][?(@.name=='TwoLeftHidden')].inner.variant.kind.tuple[1]" $2.2.1 TwoLeftHidden(#[doc(hidden)] bool, /** 2.2.1*/ bool), - // @count "$.index[*][?(@.name=='TwoRightHidden')].inner.kind.tuple[*]" 2 - // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.kind.tuple[0]" $2.3.0 - // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.kind.tuple[1]" null + // @count "$.index[*][?(@.name=='TwoRightHidden')].inner.variant.kind.tuple[*]" 2 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant.kind.tuple[0]" $2.3.0 + // @is "$.index[*][?(@.name=='TwoRightHidden')].inner.variant.kind.tuple[1]" null TwoRightHidden(/** 2.3.0*/ bool, #[doc(hidden)] bool), - // @count "$.index[*][?(@.name=='TwoBothHidden')].inner.kind.tuple[*]" 2 - // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.kind.tuple[0]" null - // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.kind.tuple[1]" null + // @count "$.index[*][?(@.name=='TwoBothHidden')].inner.variant.kind.tuple[*]" 2 + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant.kind.tuple[0]" null + // @is "$.index[*][?(@.name=='TwoBothHidden')].inner.variant.kind.tuple[1]" null TwoBothHidden(#[doc(hidden)] bool, #[doc(hidden)] bool), - // @count "$.index[*][?(@.name=='Three1')].inner.kind.tuple[*]" 3 - // @is "$.index[*][?(@.name=='Three1')].inner.kind.tuple[0]" null - // @is "$.index[*][?(@.name=='Three1')].inner.kind.tuple[1]" $3.1.1 - // @is "$.index[*][?(@.name=='Three1')].inner.kind.tuple[2]" $3.1.2 + // @count "$.index[*][?(@.name=='Three1')].inner.variant.kind.tuple[*]" 3 + // @is "$.index[*][?(@.name=='Three1')].inner.variant.kind.tuple[0]" null + // @is "$.index[*][?(@.name=='Three1')].inner.variant.kind.tuple[1]" $3.1.1 + // @is "$.index[*][?(@.name=='Three1')].inner.variant.kind.tuple[2]" $3.1.2 Three1(#[doc(hidden)] bool, /** 3.1.1*/ bool, /** 3.1.2*/ bool), - // @count "$.index[*][?(@.name=='Three2')].inner.kind.tuple[*]" 3 - // @is "$.index[*][?(@.name=='Three2')].inner.kind.tuple[0]" $3.2.0 - // @is "$.index[*][?(@.name=='Three2')].inner.kind.tuple[1]" null - // @is "$.index[*][?(@.name=='Three2')].inner.kind.tuple[2]" $3.2.2 + // @count "$.index[*][?(@.name=='Three2')].inner.variant.kind.tuple[*]" 3 + // @is "$.index[*][?(@.name=='Three2')].inner.variant.kind.tuple[0]" $3.2.0 + // @is "$.index[*][?(@.name=='Three2')].inner.variant.kind.tuple[1]" null + // @is "$.index[*][?(@.name=='Three2')].inner.variant.kind.tuple[2]" $3.2.2 Three2(/** 3.2.0*/ bool, #[doc(hidden)] bool, /** 3.2.2*/ bool), - // @count "$.index[*][?(@.name=='Three3')].inner.kind.tuple[*]" 3 - // @is "$.index[*][?(@.name=='Three3')].inner.kind.tuple[0]" $3.3.0 - // @is "$.index[*][?(@.name=='Three3')].inner.kind.tuple[1]" $3.3.1 - // @is "$.index[*][?(@.name=='Three3')].inner.kind.tuple[2]" null + // @count "$.index[*][?(@.name=='Three3')].inner.variant.kind.tuple[*]" 3 + // @is "$.index[*][?(@.name=='Three3')].inner.variant.kind.tuple[0]" $3.3.0 + // @is "$.index[*][?(@.name=='Three3')].inner.variant.kind.tuple[1]" $3.3.1 + // @is "$.index[*][?(@.name=='Three3')].inner.variant.kind.tuple[2]" null Three3(/** 3.3.0*/ bool, /** 3.3.1*/ bool, #[doc(hidden)] bool), } @@ -70,14 +70,14 @@ pub enum EnumWithStrippedTupleVariants { // @is "$.index[*][?(@.docs=='3.3.0')].name" '"0"' // @is "$.index[*][?(@.docs=='3.3.1')].name" '"1"' -// @is "$.index[*][?(@.docs=='1.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='2.1.0')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='2.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='2.2.1')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='2.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.1.1')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.1.2')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.2.0')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.2.2')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.3.0')].inner" '{"kind": "primitive", "inner": "bool"}' -// @is "$.index[*][?(@.docs=='3.3.1')].inner" '{"kind": "primitive", "inner": "bool"}' +// @is "$.index[*][?(@.docs=='1.1.0')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.0')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='2.1.1')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='2.2.1')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='2.3.0')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.1')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.1.2')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.0')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.2.2')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.0')].inner.struct_field" '{"primitive": "bool"}' +// @is "$.index[*][?(@.docs=='3.3.1')].inner.struct_field" '{"primitive": "bool"}' diff --git a/tests/rustdoc-json/enums/use_glob.rs b/tests/rustdoc-json/enums/use_glob.rs index 62b8b832a..49990ec53 100644 --- a/tests/rustdoc-json/enums/use_glob.rs +++ b/tests/rustdoc-json/enums/use_glob.rs @@ -10,9 +10,9 @@ pub enum Color { Blue, } -// @set use_Color = "$.index[*][?(@.kind == 'import')].id" -// @is "$.index[*][?(@.kind == 'import')].inner.id" $Color -// @is "$.index[*][?(@.kind == 'import')].inner.glob" true +// @set use_Color = "$.index[*][?(@.inner.import)].id" +// @is "$.index[*][?(@.inner.import)].inner.import.id" $Color +// @is "$.index[*][?(@.inner.import)].inner.import.glob" true pub use Color::*; -// @ismany "$.index[*][?(@.name == 'use_glob')].inner.items[*]" $Color $use_Color +// @ismany "$.index[*][?(@.name == 'use_glob')].inner.module.items[*]" $Color $use_Color diff --git a/tests/rustdoc-json/enums/use_variant.rs b/tests/rustdoc-json/enums/use_variant.rs index 5f0d2b9b1..8190e1cbe 100644 --- a/tests/rustdoc-json/enums/use_variant.rs +++ b/tests/rustdoc-json/enums/use_variant.rs @@ -6,10 +6,10 @@ pub enum AlwaysNone { // @set None = "$.index[*][?(@.name == 'None')].id" None, } -// @is "$.index[*][?(@.name == 'AlwaysNone')].inner.variants[*]" $None +// @is "$.index[*][?(@.name == 'AlwaysNone')].inner.enum.variants[*]" $None -// @set use_None = "$.index[*][?(@.kind == 'import')].id" -// @is "$.index[*][?(@.kind == 'import')].inner.id" $None +// @set use_None = "$.index[*][?(@.inner.import)].id" +// @is "$.index[*][?(@.inner.import)].inner.import.id" $None pub use AlwaysNone::None; -// @ismany "$.index[*][?(@.name == 'use_variant')].inner.items[*]" $AlwaysNone $use_None +// @ismany "$.index[*][?(@.name == 'use_variant')].inner.module.items[*]" $AlwaysNone $use_None diff --git a/tests/rustdoc-json/enums/use_variant_foreign.rs b/tests/rustdoc-json/enums/use_variant_foreign.rs index 11bb6ce1f..a79e899d8 100644 --- a/tests/rustdoc-json/enums/use_variant_foreign.rs +++ b/tests/rustdoc-json/enums/use_variant_foreign.rs @@ -2,7 +2,7 @@ extern crate color; -// @is "$.index[*][?(@.inner.name == 'Red')].kind" '"import"' +// @has "$.index[*].inner.import[?(@.name == 'Red')]" pub use color::Color::Red; // @!has "$.index[*][?(@.name == 'Red')]" diff --git a/tests/rustdoc-json/enums/variant_struct.rs b/tests/rustdoc-json/enums/variant_struct.rs index bc870c502..fe40f1a5d 100644 --- a/tests/rustdoc-json/enums/variant_struct.rs +++ b/tests/rustdoc-json/enums/variant_struct.rs @@ -1,10 +1,10 @@ // @is "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\" -// @is "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\" +// @has "$.index[*][?(@.name=='EnumStruct')].inner.enum" pub enum EnumStruct { - // @is "$.index[*][?(@.name=='x')].kind" \"struct_field\" + // @has "$.index[*][?(@.name=='x')].inner.struct_field" // @set x = "$.index[*][?(@.name=='x')].id" - // @is "$.index[*][?(@.name=='y')].kind" \"struct_field\" + // @has "$.index[*][?(@.name=='y')].inner.struct_field" // @set y = "$.index[*][?(@.name=='y')].id" - // @ismany "$.index[*][?(@.name=='VariantS')].inner.kind.struct.fields[*]" $x $y + // @ismany "$.index[*][?(@.name=='VariantS')].inner.variant.kind.struct.fields[*]" $x $y VariantS { x: u32, y: String }, } diff --git a/tests/rustdoc-json/enums/variant_tuple_struct.rs b/tests/rustdoc-json/enums/variant_tuple_struct.rs index d1207bbfb..358fc1079 100644 --- a/tests/rustdoc-json/enums/variant_tuple_struct.rs +++ b/tests/rustdoc-json/enums/variant_tuple_struct.rs @@ -1,10 +1,10 @@ // @is "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\" -// @is "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\" +// @has "$.index[*][?(@.name=='EnumTupleStruct')].inner.enum" pub enum EnumTupleStruct { - // @is "$.index[*][?(@.name=='0')].kind" \"struct_field\" + // @has "$.index[*][?(@.name=='0')].inner.struct_field" // @set f0 = "$.index[*][?(@.name=='0')].id" - // @is "$.index[*][?(@.name=='1')].kind" \"struct_field\" + // @has "$.index[*][?(@.name=='1')].inner.struct_field" // @set f1 = "$.index[*][?(@.name=='1')].id" - // @ismany "$.index[*][?(@.name=='VariantA')].inner.kind.tuple[*]" $f0 $f1 + // @ismany "$.index[*][?(@.name=='VariantA')].inner.variant.kind.tuple[*]" $f0 $f1 VariantA(u32, String), } diff --git a/tests/rustdoc-json/fn_pointer/abi.rs b/tests/rustdoc-json/fn_pointer/abi.rs index 3c1a453d1..77c0e8233 100644 --- a/tests/rustdoc-json/fn_pointer/abi.rs +++ b/tests/rustdoc-json/fn_pointer/abi.rs @@ -1,25 +1,24 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] -// @is "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='AbiRust')].inner.typedef.type.function_pointer.header.abi" \"Rust\" pub type AbiRust = fn(); -// @is "$.index[*][?(@.name=='AbiC')].inner.type.inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiC')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": false}}' pub type AbiC = extern "C" fn(); -// @is "$.index[*][?(@.name=='AbiSystem')].inner.type.inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiSystem')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": false}}' pub type AbiSystem = extern "system" fn(); -// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.type.inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": true}}' pub type AbiCUnwind = extern "C-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type.inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": true}}' pub type AbiSystemUnwind = extern "system-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.type.inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall\""' pub type AbiVecorcall = extern "vectorcall" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type.inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn(); diff --git a/tests/rustdoc-json/fn_pointer/generics.rs b/tests/rustdoc-json/fn_pointer/generics.rs index a93b01ac2..48672f12d 100644 --- a/tests/rustdoc-json/fn_pointer/generics.rs +++ b/tests/rustdoc-json/fn_pointer/generics.rs @@ -3,12 +3,11 @@ #![feature(no_core)] #![no_core] -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][0]" '"val"' -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.inputs[0][1].inner.lifetime" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.decl.output" '{ "kind": "primitive", "inner": "i32" }' -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].name" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type.inner.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][0]" '"val"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.output.primitive" \"i32\" +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].name" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/tests/rustdoc-json/fn_pointer/qualifiers.rs b/tests/rustdoc-json/fn_pointer/qualifiers.rs index bd65bb3ee..0ab776c21 100644 --- a/tests/rustdoc-json/fn_pointer/qualifiers.rs +++ b/tests/rustdoc-json/fn_pointer/qualifiers.rs @@ -1,9 +1,11 @@ -// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.unsafe" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.const" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.type.inner.header.async" false +// ignore-tidy-linelength + +// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.unsafe" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.async" false pub type FnPointer = fn(); -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.unsafe" true -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.const" false -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type.inner.header.async" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.unsafe" true +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.async" false pub type UnsafePointer = unsafe fn(); diff --git a/tests/rustdoc-json/fns/abi.rs b/tests/rustdoc-json/fns/abi.rs index 0e8b78bc0..d7b98b592 100644 --- a/tests/rustdoc-json/fns/abi.rs +++ b/tests/rustdoc-json/fns/abi.rs @@ -1,25 +1,24 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] -// @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='abi_rust')].inner.function.header.abi" \"Rust\" pub fn abi_rust() {} -// @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_c')].inner.function.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} -// @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='abi_system')].inner.function.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} -// @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_c_unwind')].inner.function.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} -// @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} -// @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} -// @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} diff --git a/tests/rustdoc-json/fns/async_return.rs b/tests/rustdoc-json/fns/async_return.rs index b89781ca9..8192f2e6a 100644 --- a/tests/rustdoc-json/fns/async_return.rs +++ b/tests/rustdoc-json/fns/async_return.rs @@ -5,32 +5,30 @@ use std::future::Future; -// @is "$.index[*][?(@.name=='get_int')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' -// @is "$.index[*][?(@.name=='get_int')].inner.header.async" false +// @is "$.index[*][?(@.name=='get_int')].inner.function.decl.output.primitive" \"i32\" +// @is "$.index[*][?(@.name=='get_int')].inner.function.header.async" false pub fn get_int() -> i32 { 42 } -// @is "$.index[*][?(@.name=='get_int_async')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' -// @is "$.index[*][?(@.name=='get_int_async')].inner.header.async" true +// @is "$.index[*][?(@.name=='get_int_async')].inner.function.decl.output.primitive" \"i32\" +// @is "$.index[*][?(@.name=='get_int_async')].inner.function.header.async" true pub async fn get_int_async() -> i32 { 42 } -// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.kind" '"impl_trait"' -// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' -// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' -// @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' -// @is "$.index[*][?(@.name=='get_int_future')].inner.header.async" false +// @is "$.index[*][?(@.name=='get_int_future')].inner.function.decl.output.impl_trait[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.function.decl.output.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future')].inner.function.decl.output.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type.primitive" \"i32\" +// @is "$.index[*][?(@.name=='get_int_future')].inner.function.header.async" false pub fn get_int_future() -> impl Future<Output = i32> { async { 42 } } -// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.kind" '"impl_trait"' -// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' -// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' -// @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' -// @is "$.index[*][?(@.name=='get_int_future_async')].inner.header.async" true +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.function.decl.output.impl_trait[0].trait_bound.trait.name" '"Future"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.function.decl.output.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.function.decl.output.impl_trait[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type.primitive" \"i32\" +// @is "$.index[*][?(@.name=='get_int_future_async')].inner.function.header.async" true pub async fn get_int_future_async() -> impl Future<Output = i32> { async { 42 } } diff --git a/tests/rustdoc-json/fns/extern_c_variadic.rs b/tests/rustdoc-json/fns/extern_c_variadic.rs index 33bebbab5..d6ea343b9 100644 --- a/tests/rustdoc-json/fns/extern_c_variadic.rs +++ b/tests/rustdoc-json/fns/extern_c_variadic.rs @@ -2,8 +2,8 @@ #![no_core] extern "C" { - // @is "$.index[*][?(@.name == 'not_variadic')].inner.decl.c_variadic" false + // @is "$.index[*][?(@.name == 'not_variadic')].inner.function.decl.c_variadic" false pub fn not_variadic(_: i32); - // @is "$.index[*][?(@.name == 'variadic')].inner.decl.c_variadic" true + // @is "$.index[*][?(@.name == 'variadic')].inner.function.decl.c_variadic" true pub fn variadic(_: i32, ...); } diff --git a/tests/rustdoc-json/fns/generic_args.rs b/tests/rustdoc-json/fns/generic_args.rs index eec295efe..539d17f83 100644 --- a/tests/rustdoc-json/fns/generic_args.rs +++ b/tests/rustdoc-json/fns/generic_args.rs @@ -9,59 +9,55 @@ pub trait Foo {} // @set generic_foo = "$.index[*][?(@.name=='GenericFoo')].id" pub trait GenericFoo<'a> {} -// @is "$.index[*][?(@.name=='generics')].inner.generics.where_predicates" "[]" -// @count "$.index[*][?(@.name=='generics')].inner.generics.params[*]" 1 -// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].name" '"F"' -// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.default" 'null' -// @count "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[*]" 1 -// @is "$.index[*][?(@.name=='generics')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" '$foo' -// @count "$.index[*][?(@.name=='generics')].inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][0]" '"f"' -// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].kind" '"generic"' -// @is "$.index[*][?(@.name=='generics')].inner.decl.inputs[0][1].inner" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.function.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='generics')].inner.function.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.function.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='generics')].inner.function.generics.params[0].kind.type.default" 'null' +// @count "$.index[*][?(@.name=='generics')].inner.function.generics.params[0].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" '$foo' +// @count "$.index[*][?(@.name=='generics')].inner.function.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='generics')].inner.function.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='generics')].inner.function.decl.inputs[0][1].generic" '"F"' pub fn generics<F: Foo>(f: F) {} -// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.where_predicates" "[]" -// @count "$.index[*][?(@.name=='impl_trait')].inner.generics.params[*]" 1 -// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].name" '"impl Foo"' -// @is "$.index[*][?(@.name=='impl_trait')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $foo -// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][0]" '"f"' -// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @count "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[*]" 1 -// @is "$.index[*][?(@.name=='impl_trait')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='impl_trait')].inner.function.generics.where_predicates" "[]" +// @count "$.index[*][?(@.name=='impl_trait')].inner.function.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.function.generics.params[0].name" '"impl Foo"' +// @is "$.index[*][?(@.name=='impl_trait')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $foo +// @count "$.index[*][?(@.name=='impl_trait')].inner.function.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.function.decl.inputs[0][0]" '"f"' +// @count "$.index[*][?(@.name=='impl_trait')].inner.function.decl.inputs[0][1].impl_trait[*]" 1 +// @is "$.index[*][?(@.name=='impl_trait')].inner.function.decl.inputs[0][1].impl_trait[0].trait_bound.trait.id" $foo pub fn impl_trait(f: impl Foo) {} -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.params[*]" 3 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].name" '"F"' -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' -// @count "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[*]" 3 -// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][0]" '"f"' -// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].kind" '"generic"' -// @is "$.index[*][?(@.name=='where_clase')].inner.decl.inputs[0][1].inner" '"F"' -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[*]" 3 +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.params[0].name" '"F"' +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.params[0].kind" '{"type": {"bounds": [], "default": null, "synthetic": false}}' +// @count "$.index[*][?(@.name=='where_clase')].inner.function.decl.inputs[*]" 3 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.decl.inputs[0][0]" '"f"' +// @is "$.index[*][?(@.name=='where_clase')].inner.function.decl.inputs[0][1].generic" '"F"' +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[*]" 3 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F", "kind": "generic"}' -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[*]" 1 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[0].bound_predicate.type.generic" \"F\" +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[0].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[0].bound_predicate.bounds[0].trait_bound.trait.id" $foo -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.type" '{"inner": "G", "kind": "generic"}' -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[*]" 1 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.id" $generic_foo -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[1].bound_predicate.generic_params" "[]" +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.type.generic" \"G\" +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.trait.id" $generic_foo +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.bounds[0].trait_bound.generic_params[0].kind.lifetime.outlives" "[]" +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[1].bound_predicate.generic_params" "[]" -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.lifetime" \"\'b\" -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.type.inner.type" '{"inner": "H", "kind": "generic"}' -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[*]" 1 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.id" $foo -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" -// @count "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" -// @is "$.index[*][?(@.name=='where_clase')].inner.generics.where_predicates[2].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.type.borrowed_ref.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.type.borrowed_ref.type.generic" \"H\" +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.bounds[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.bounds[0].trait_bound.generic_params" "[]" +// @count "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.generic_params[0].name" \"\'b\" +// @is "$.index[*][?(@.name=='where_clase')].inner.function.generics.where_predicates[2].bound_predicate.generic_params[0].kind.lifetime.outlives" "[]" pub fn where_clase<F, G, H>(f: F, g: G, h: H) where F: Foo, diff --git a/tests/rustdoc-json/fns/generic_returns.rs b/tests/rustdoc-json/fns/generic_returns.rs index a9bc2d5d7..27d842066 100644 --- a/tests/rustdoc-json/fns/generic_returns.rs +++ b/tests/rustdoc-json/fns/generic_returns.rs @@ -3,15 +3,14 @@ #![feature(no_core)] #![no_core] -// @count "$.index[*][?(@.name=='generic_returns')].inner.items[*]" 2 +// @count "$.index[*][?(@.name=='generic_returns')].inner.module.items[*]" 2 // @set foo = "$.index[*][?(@.name=='Foo')].id" pub trait Foo {} -// @is "$.index[*][?(@.name=='get_foo')].inner.decl.inputs" [] -// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.kind" '"impl_trait"' -// @count "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[*]" 1 -// @is "$.index[*][?(@.name=='get_foo')].inner.decl.output.inner[0].trait_bound.trait.id" $foo +// @is "$.index[*][?(@.name=='get_foo')].inner.function.decl.inputs" [] +// @count "$.index[*][?(@.name=='get_foo')].inner.function.decl.output.impl_trait[*]" 1 +// @is "$.index[*][?(@.name=='get_foo')].inner.function.decl.output.impl_trait[0].trait_bound.trait.id" $foo pub fn get_foo() -> impl Foo { Fooer {} } diff --git a/tests/rustdoc-json/fns/generics.rs b/tests/rustdoc-json/fns/generics.rs index 7b70ff1df..5239a6f21 100644 --- a/tests/rustdoc-json/fns/generics.rs +++ b/tests/rustdoc-json/fns/generics.rs @@ -6,21 +6,20 @@ // @set wham_id = "$.index[*][?(@.name=='Wham')].id" pub trait Wham {} -// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.where_predicates" [] -// @count "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[*]" 1 -// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].name" '"T"' -// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" false -// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id -// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.decl.inputs" '[["w", {"inner": "T", "kind": "generic"}]]' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.generics.params[0].name" '"T"' +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.generics.params[0].kind.type.synthetic" false +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @is "$.index[*][?(@.name=='one_generic_param_fn')].inner.function.decl.inputs" '[["w", {"generic": "T"}]]' pub fn one_generic_param_fn<T: Wham>(w: T) {} -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.where_predicates" [] -// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[*]" 1 -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].name" '"impl Wham"' -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.synthetic" true -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id -// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][0]" '"w"' -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $wham_id +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.generics.where_predicates" [] +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.generics.params[0].name" '"impl Wham"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.generics.params[0].kind.type.synthetic" true +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $wham_id +// @count "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.decl.inputs[0][0]" '"w"' +// @is "$.index[*][?(@.name=='one_synthetic_generic_param_fn')].inner.function.decl.inputs[0][1].impl_trait[0].trait_bound.trait.id" $wham_id pub fn one_synthetic_generic_param_fn(w: impl Wham) {} diff --git a/tests/rustdoc-json/fns/pattern_arg.rs b/tests/rustdoc-json/fns/pattern_arg.rs index 32b7da0fa..55f24797a 100644 --- a/tests/rustdoc-json/fns/pattern_arg.rs +++ b/tests/rustdoc-json/fns/pattern_arg.rs @@ -1,7 +1,7 @@ -// @is "$.index[*][?(@.name=='fst')].inner.decl.inputs[0][0]" '"(x, _)"' +// @is "$.index[*][?(@.name=='fst')].inner.function.decl.inputs[0][0]" '"(x, _)"' pub fn fst<X, Y>((x, _): (X, Y)) -> X { x } -// @is "$.index[*][?(@.name=='drop_int')].inner.decl.inputs[0][0]" '"_"' +// @is "$.index[*][?(@.name=='drop_int')].inner.function.decl.inputs[0][0]" '"_"' pub fn drop_int(_: i32) {} diff --git a/tests/rustdoc-json/fns/qualifiers.rs b/tests/rustdoc-json/fns/qualifiers.rs index 7ff542900..643865a3f 100644 --- a/tests/rustdoc-json/fns/qualifiers.rs +++ b/tests/rustdoc-json/fns/qualifiers.rs @@ -1,33 +1,33 @@ // edition:2018 -// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.async" false -// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.const" false -// @is "$.index[*][?(@.name=='nothing_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.function.header.async" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.function.header.const" false +// @is "$.index[*][?(@.name=='nothing_fn')].inner.function.header.unsafe" false pub fn nothing_fn() {} -// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.async" false -// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.const" false -// @is "$.index[*][?(@.name=='unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.function.header.async" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.function.header.const" false +// @is "$.index[*][?(@.name=='unsafe_fn')].inner.function.header.unsafe" true pub unsafe fn unsafe_fn() {} -// @is "$.index[*][?(@.name=='const_fn')].inner.header.async" false -// @is "$.index[*][?(@.name=='const_fn')].inner.header.const" true -// @is "$.index[*][?(@.name=='const_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='const_fn')].inner.function.header.async" false +// @is "$.index[*][?(@.name=='const_fn')].inner.function.header.const" true +// @is "$.index[*][?(@.name=='const_fn')].inner.function.header.unsafe" false pub const fn const_fn() {} -// @is "$.index[*][?(@.name=='async_fn')].inner.header.async" true -// @is "$.index[*][?(@.name=='async_fn')].inner.header.const" false -// @is "$.index[*][?(@.name=='async_fn')].inner.header.unsafe" false +// @is "$.index[*][?(@.name=='async_fn')].inner.function.header.async" true +// @is "$.index[*][?(@.name=='async_fn')].inner.function.header.const" false +// @is "$.index[*][?(@.name=='async_fn')].inner.function.header.unsafe" false pub async fn async_fn() {} -// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.async" true -// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.const" false -// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.function.header.async" true +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.function.header.const" false +// @is "$.index[*][?(@.name=='async_unsafe_fn')].inner.function.header.unsafe" true pub async unsafe fn async_unsafe_fn() {} -// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.async" false -// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.const" true -// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.header.unsafe" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.function.header.async" false +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.function.header.const" true +// @is "$.index[*][?(@.name=='const_unsafe_fn')].inner.function.header.unsafe" true pub const unsafe fn const_unsafe_fn() {} // It's impossible for a function to be both const and async, so no test for that diff --git a/tests/rustdoc-json/fns/return_type_alias.rs b/tests/rustdoc-json/fns/return_type_alias.rs index 2578bb49a..e8a7dce8b 100644 --- a/tests/rustdoc-json/fns/return_type_alias.rs +++ b/tests/rustdoc-json/fns/return_type_alias.rs @@ -3,8 +3,7 @@ /// @set foo = "$.index[*][?(@.name=='Foo')].id" pub type Foo = i32; -// @is "$.index[*][?(@.name=='demo')].inner.decl.output.kind" '"resolved_path"' -// @is "$.index[*][?(@.name=='demo')].inner.decl.output.inner.id" $foo +// @is "$.index[*][?(@.name=='demo')].inner.function.decl.output.resolved_path.id" $foo pub fn demo() -> Foo { 42 } diff --git a/tests/rustdoc-json/generic-associated-types/gats.rs b/tests/rustdoc-json/generic-associated-types/gats.rs index e5809783a..99c57ff65 100644 --- a/tests/rustdoc-json/generic-associated-types/gats.rs +++ b/tests/rustdoc-json/generic-associated-types/gats.rs @@ -9,34 +9,32 @@ pub trait Sized {} pub trait Display {} pub trait LendingIterator { - // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*]" 1 - // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.params[*].name" \"\'a\" - // @count "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*]" 1 - // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.type.inner" \"Self\" - // @is "$.index[*][?(@.name=='LendingItem')].inner.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" - // @count "$.index[*][?(@.name=='LendingItem')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.generics.params[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.generics.params[*].name" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.generics.where_predicates[*]" 1 + // @is "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.generics.where_predicates[*].bound_predicate.type.generic" \"Self\" + // @is "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.generics.where_predicates[*].bound_predicate.bounds[*].outlives" \"\'a\" + // @count "$.index[*][?(@.name=='LendingItem')].inner.assoc_type.bounds[*]" 1 type LendingItem<'a>: Display where Self: 'a; - // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.kind" \"qualified_path\" - // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 1 - // @count "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is "$.index[*][?(@.name=='lending_next')].inner.decl.output.inner.name" \"LendingItem\" + // @count "$.index[*][?(@.name=='lending_next')].inner.function.decl.output.qualified_path.args.angle_bracketed.args[*]" 1 + // @count "$.index[*][?(@.name=='lending_next')].inner.function.decl.output.qualified_path.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='lending_next')].inner.function.decl.output.qualified_path.self_type.generic" \"Self\" + // @is "$.index[*][?(@.name=='lending_next')].inner.function.decl.output.qualified_path.name" \"LendingItem\" fn lending_next<'a>(&'a self) -> Self::LendingItem<'a>; } pub trait Iterator { - // @count "$.index[*][?(@.name=='Item')].inner.generics.params[*]" 0 - // @count "$.index[*][?(@.name=='Item')].inner.generics.where_predicates[*]" 0 - // @count "$.index[*][?(@.name=='Item')].inner.bounds[*]" 1 + // @count "$.index[*][?(@.name=='Item')].inner.assoc_type.generics.params[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.assoc_type.generics.where_predicates[*]" 0 + // @count "$.index[*][?(@.name=='Item')].inner.assoc_type.bounds[*]" 1 type Item: Display; - // @is "$.index[*][?(@.name=='next')].inner.decl.output.kind" \"qualified_path\" - // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.args[*]" 0 - // @count "$.index[*][?(@.name=='next')].inner.decl.output.inner.args.angle_bracketed.bindings[*]" 0 - // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.self_type.inner" \"Self\" - // @is "$.index[*][?(@.name=='next')].inner.decl.output.inner.name" \"Item\" + // @count "$.index[*][?(@.name=='next')].inner.function.decl.output.qualified_path.args.angle_bracketed.args[*]" 0 + // @count "$.index[*][?(@.name=='next')].inner.function.decl.output.qualified_path.args.angle_bracketed.bindings[*]" 0 + // @is "$.index[*][?(@.name=='next')].inner.function.decl.output.qualified_path.self_type.generic" \"Self\" + // @is "$.index[*][?(@.name=='next')].inner.function.decl.output.qualified_path.name" \"Item\" fn next<'a>(&'a self) -> Self::Item; } diff --git a/tests/rustdoc-json/glob_import.rs b/tests/rustdoc-json/glob_import.rs index 00051b121..f37ce0abb 100644 --- a/tests/rustdoc-json/glob_import.rs +++ b/tests/rustdoc-json/glob_import.rs @@ -5,7 +5,7 @@ #![no_core] // @has "$.index[*][?(@.name=='glob')]" -// @has "$.index[*][?(@.kind=='import')].inner.name" \"*\" +// @has "$.index[*][?(@.inner.import)].inner.import.name" \"*\" mod m1 { diff --git a/tests/rustdoc-json/impls/auto.rs b/tests/rustdoc-json/impls/auto.rs index 50d852414..ace37e5b3 100644 --- a/tests/rustdoc-json/impls/auto.rs +++ b/tests/rustdoc-json/impls/auto.rs @@ -12,7 +12,8 @@ impl Foo { } // Testing spans, so all tests below code -// @is "$.index[*][?(@.kind=='impl' && @.inner.synthetic==true)].span" null // @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]" // @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]" +// FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91 +// is "$.index[*][?(@.inner.impl.synthetic==true)].span" null pub struct Foo; diff --git a/tests/rustdoc-json/impls/foreign_for_local.rs b/tests/rustdoc-json/impls/foreign_for_local.rs index 290c2d571..20e1cecd7 100644 --- a/tests/rustdoc-json/impls/foreign_for_local.rs +++ b/tests/rustdoc-json/impls/foreign_for_local.rs @@ -3,7 +3,7 @@ extern crate foreign_trait; /// ForeignTrait id hack pub use foreign_trait::ForeignTrait as _; -// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.id" +// @set ForeignTrait = "$.index[*][?(@.docs=='ForeignTrait id hack')].inner.import.id" pub struct LocalStruct; // @set LocalStruct = "$.index[*][?(@.name=='LocalStruct')].id" @@ -12,7 +12,7 @@ pub struct LocalStruct; impl foreign_trait::ForeignTrait for LocalStruct {} // @set impl = "$.index[*][?(@.docs=='foreign for local')].id" -// @is "$.index[*][?(@.docs=='foreign for local')].inner.for.inner.id" $LocalStruct -// @is "$.index[*][?(@.docs=='foreign for local')].inner.trait.id" $ForeignTrait +// @is "$.index[*][?(@.docs=='foreign for local')].inner.impl.for.resolved_path.id" $LocalStruct +// @is "$.index[*][?(@.docs=='foreign for local')].inner.impl.trait.id" $ForeignTrait -// @has "$.index[*][?(@.name=='LocalStruct')].inner.impls[*]" $impl +// @has "$.index[*][?(@.name=='LocalStruct')].inner.struct.impls[*]" $impl diff --git a/tests/rustdoc-json/impls/impl_item_visibility.rs b/tests/rustdoc-json/impls/impl_item_visibility.rs new file mode 100644 index 000000000..efa54d91d --- /dev/null +++ b/tests/rustdoc-json/impls/impl_item_visibility.rs @@ -0,0 +1,26 @@ +#![feature(no_core)] +#![no_core] + +pub struct Foo; + +/// impl Foo priv +impl Foo { + fn baz() {} +} +// @!has '$.index[*][?(@.docs=="impl Foo priv")]' + + +/// impl Foo pub +impl Foo { + pub fn qux() {} +} +// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"' + + +/// impl Foo hidden +impl Foo { + #[doc(hidden)] + pub fn __quazl(){} +} +// FIXME(#111564): Is this the right behaviour? +// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"' diff --git a/tests/rustdoc-json/impls/impl_item_visibility_show_hidden.rs b/tests/rustdoc-json/impls/impl_item_visibility_show_hidden.rs new file mode 100644 index 000000000..3c6fefc4c --- /dev/null +++ b/tests/rustdoc-json/impls/impl_item_visibility_show_hidden.rs @@ -0,0 +1,28 @@ +// compile-flags: --document-hidden-items +#![feature(no_core)] +#![no_core] + +pub struct Foo; + +/// impl Foo priv +impl Foo { + fn baz() {} +} +// FIXME(#111564): Is this the right behaviour? +// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"' + + +/// impl Foo pub +impl Foo { + pub fn qux() {} +} +// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"' + + +/// impl Foo hidden +impl Foo { + #[doc(hidden)] + pub fn __quazl(){} +} +// FIXME(#111564): Is this the right behaviour? +// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"' diff --git a/tests/rustdoc-json/impls/impl_item_visibility_show_private.rs b/tests/rustdoc-json/impls/impl_item_visibility_show_private.rs new file mode 100644 index 000000000..b98d1e416 --- /dev/null +++ b/tests/rustdoc-json/impls/impl_item_visibility_show_private.rs @@ -0,0 +1,27 @@ +// compile-flags: --document-private-items +#![feature(no_core)] +#![no_core] + +pub struct Foo; + +/// impl Foo priv +impl Foo { + fn baz() {} +} +// @is '$.index[*][?(@.docs=="impl Foo priv")].visibility' '"default"' + + +/// impl Foo pub +impl Foo { + pub fn qux() {} +} +// @is '$.index[*][?(@.docs=="impl Foo pub")].visibility' '"default"' + + +/// impl Foo hidden +impl Foo { + #[doc(hidden)] + pub fn __quazl(){} +} +// FIXME(#111564): Is this the right behaviour? +// @is '$.index[*][?(@.docs=="impl Foo hidden")].visibility' '"default"' diff --git a/tests/rustdoc-json/impls/import_from_private.rs b/tests/rustdoc-json/impls/import_from_private.rs index fa88b6113..d2b0665dc 100644 --- a/tests/rustdoc-json/impls/import_from_private.rs +++ b/tests/rustdoc-json/impls/import_from_private.rs @@ -4,19 +4,19 @@ #![no_core] mod bar { - // @set baz = "$.index[*][?(@.kind=='struct')].id" + // @set baz = "$.index[*][?(@.inner.struct)].id" pub struct Baz; - // @set impl = "$.index[*][?(@.kind=='impl')].id" + // @set impl = "$.index[*][?(@.inner.impl)].id" impl Baz { - // @set doit = "$.index[*][?(@.kind=='function')].id" + // @set doit = "$.index[*][?(@.inner.function)].id" pub fn doit() {} } } -// @set import = "$.index[*][?(@.kind=='import')].id" +// @set import = "$.index[*][?(@.inner.import)].id" pub use bar::Baz; -// @is "$.index[*][?(@.kind=='module')].inner.items[*]" $import -// @is "$.index[*][?(@.kind=='import')].inner.id" $baz -// @is "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl -// @is "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit +// @is "$.index[*].inner.module.items[*]" $import +// @is "$.index[*].inner.import.id" $baz +// @is "$.index[*].inner.struct.impls[*]" $impl +// @is "$.index[*].inner.impl.items[*]" $doit diff --git a/tests/rustdoc-json/impls/local_for_foreign.rs b/tests/rustdoc-json/impls/local_for_foreign.rs index 74f2f08b5..72352ce88 100644 --- a/tests/rustdoc-json/impls/local_for_foreign.rs +++ b/tests/rustdoc-json/impls/local_for_foreign.rs @@ -3,7 +3,7 @@ extern crate foreign_struct; /// ForeignStruct id hack pub use foreign_struct::ForeignStruct as _; -// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.id" +// @set ForeignStruct = "$.index[*][?(@.docs=='ForeignStruct id hack')].inner.import.id" pub trait LocalTrait {} // @set LocalTrait = "$.index[*][?(@.name=='LocalTrait')].id" @@ -12,7 +12,7 @@ pub trait LocalTrait {} impl LocalTrait for foreign_struct::ForeignStruct {} // @set impl = "$.index[*][?(@.docs=='local for foreign')].id" -// @is "$.index[*][?(@.docs=='local for foreign')].inner.trait.id" $LocalTrait -// @is "$.index[*][?(@.docs=='local for foreign')].inner.for.inner.id" $ForeignStruct +// @is "$.index[*][?(@.docs=='local for foreign')].inner.impl.trait.id" $LocalTrait +// @is "$.index[*][?(@.docs=='local for foreign')].inner.impl.for.resolved_path.id" $ForeignStruct -// @is "$.index[*][?(@.name=='LocalTrait')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.name=='LocalTrait')].inner.trait.implementations[*]" $impl diff --git a/tests/rustdoc-json/impls/local_for_local.rs b/tests/rustdoc-json/impls/local_for_local.rs index 93dedb7ec..37a720003 100644 --- a/tests/rustdoc-json/impls/local_for_local.rs +++ b/tests/rustdoc-json/impls/local_for_local.rs @@ -9,7 +9,7 @@ pub trait Trait {} /// impl impl Trait for Struct {} -// @is "$.index[*][?(@.name=='Struct')].inner.impls[*]" $impl -// @is "$.index[*][?(@.name=='Trait')].inner.implementations[*]" $impl -// @is "$.index[*][?(@.docs=='impl')].inner.trait.id" $trait -// @is "$.index[*][?(@.docs=='impl')].inner.for.inner.id" $struct +// @is "$.index[*][?(@.name=='Struct')].inner.struct.impls[*]" $impl +// @is "$.index[*][?(@.name=='Trait')].inner.trait.implementations[*]" $impl +// @is "$.index[*][?(@.docs=='impl')].inner.impl.trait.id" $trait +// @is "$.index[*][?(@.docs=='impl')].inner.impl.for.resolved_path.id" $struct diff --git a/tests/rustdoc-json/impls/local_for_local_primitive.rs b/tests/rustdoc-json/impls/local_for_local_primitive.rs index 8383dcc04..769dd3f0a 100644 --- a/tests/rustdoc-json/impls/local_for_local_primitive.rs +++ b/tests/rustdoc-json/impls/local_for_local_primitive.rs @@ -5,14 +5,13 @@ // @set Local = "$.index[*][?(@.name=='Local')].id" pub trait Local {} -// @is "$.index[*][?(@.docs=='Local for bool')].inner.trait.id" $Local -// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.kind" '"primitive"' -// @is "$.index[*][?(@.docs=='Local for bool')].inner.for.inner" '"bool"' +// @is "$.index[*][?(@.docs=='Local for bool')].inner.impl.trait.id" $Local +// @is "$.index[*][?(@.docs=='Local for bool')].inner.impl.for.primitive" '"bool"' /// Local for bool impl Local for bool {} // @set impl = "$.index[*][?(@.docs=='Local for bool')].id" -// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.name=='Local')].inner.trait.implementations[*]" $impl // FIXME(#101695): Test bool's `impls` include "Local for bool" // @has "$.index[*][?(@.name=='bool')]" diff --git a/tests/rustdoc-json/impls/local_for_primitive.rs b/tests/rustdoc-json/impls/local_for_primitive.rs index 7702a526f..85278c0e0 100644 --- a/tests/rustdoc-json/impls/local_for_primitive.rs +++ b/tests/rustdoc-json/impls/local_for_primitive.rs @@ -2,6 +2,6 @@ pub trait Local {} // @set impl = "$.index[*][?(@.docs=='local for bool')].id" -// @is "$.index[*][?(@.name=='Local')].inner.implementations[*]" $impl +// @is "$.index[*][?(@.name=='Local')].inner.trait.implementations[*]" $impl /// local for bool impl Local for bool {} diff --git a/tests/rustdoc-json/lifetime/longest.rs b/tests/rustdoc-json/lifetime/longest.rs index 326dab8e5..dc28258a8 100644 --- a/tests/rustdoc-json/lifetime/longest.rs +++ b/tests/rustdoc-json/lifetime/longest.rs @@ -3,30 +3,27 @@ #![feature(no_core)] #![no_core] -// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].name" \"\'a\" -// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @is "$.index[*][?(@.name=='longest')].inner.generics.params[0].kind" '{"lifetime": {"outlives": []}}' -// @count "$.index[*][?(@.name=='longest')].inner.generics.params[*]" 1 -// @is "$.index[*][?(@.name=='longest')].inner.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @is "$.index[*][?(@.name=='longest')].inner.function.generics.params[0].kind" '{"lifetime": {"outlives": []}}' +// @count "$.index[*][?(@.name=='longest')].inner.function.generics.params[*]" 1 +// @is "$.index[*][?(@.name=='longest')].inner.function.generics.where_predicates" [] -// @count "$.index[*][?(@.name=='longest')].inner.decl.inputs[*]" 2 -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][0]" '"l"' -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][0]" '"r"' +// @count "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[*]" 2 +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[0][0]" '"l"' +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[1][0]" '"r"' -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.mutable" false -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[0][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[0][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[0][1].borrowed_ref.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[0][1].borrowed_ref.type.primitive" \"str\" -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.mutable" false -// @is "$.index[*][?(@.name=='longest')].inner.decl.inputs[1][1].inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[1][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[1][1].borrowed_ref.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.inputs[1][1].borrowed_ref.type.primitive" \"str\" -// @is "$.index[*][?(@.name=='longest')].inner.decl.output.kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.mutable" false -// @is "$.index[*][?(@.name=='longest')].inner.decl.output.inner.type" '{"inner": "str", "kind": "primitive"}' +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.output.borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.output.borrowed_ref.mutable" false +// @is "$.index[*][?(@.name=='longest')].inner.function.decl.output.borrowed_ref.type.primitive" \"str\" pub fn longest<'a>(l: &'a str, r: &'a str) -> &'a str { if l.len() > r.len() { l } else { r } diff --git a/tests/rustdoc-json/lifetime/outlives.rs b/tests/rustdoc-json/lifetime/outlives.rs index e15a533ef..6e105b382 100644 --- a/tests/rustdoc-json/lifetime/outlives.rs +++ b/tests/rustdoc-json/lifetime/outlives.rs @@ -3,21 +3,19 @@ #![feature(no_core)] #![no_core] -// @count "$.index[*][?(@.name=='foo')].inner.generics.params[*]" 3 -// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates" [] -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].name" \"\'a\" -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].name" \"\'b\" -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].name" '"T"' -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[0].kind.lifetime.outlives" [] -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[1].kind.lifetime.outlives" [\"\'a\"] -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.default" null -// @count "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[*]" 1 -// @is "$.index[*][?(@.name=='foo')].inner.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.mutable" false -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.lifetime" \"\'b\" -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.mutable" false -// @is "$.index[*][?(@.name=='foo')].inner.decl.inputs[0][1].inner.type.inner.type" '{"inner": "T", "kind": "generic"}' +// @count "$.index[*][?(@.name=='foo')].inner.function.generics.params[*]" 3 +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates" [] +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[1].name" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[2].name" '"T"' +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[1].kind.lifetime.outlives" [\"\'a\"] +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[2].kind.type.default" null +// @count "$.index[*][?(@.name=='foo')].inner.function.generics.params[2].kind.type.bounds[*]" 1 +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.params[2].kind.type.bounds[0].outlives" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.function.decl.inputs[0][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.function.decl.inputs[0][1].borrowed_ref.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.function.decl.inputs[0][1].borrowed_ref.type.borrowed_ref.lifetime" \"\'b\" +// @is "$.index[*][?(@.name=='foo')].inner.function.decl.inputs[0][1].borrowed_ref.type.borrowed_ref.mutable" false +// @is "$.index[*][?(@.name=='foo')].inner.function.decl.inputs[0][1].borrowed_ref.type.borrowed_ref.type.generic" \"T\" pub fn foo<'a, 'b: 'a, T: 'b>(_: &'a &'b T) {} diff --git a/tests/rustdoc-json/methods/abi.rs b/tests/rustdoc-json/methods/abi.rs index 4c97d97ce..b8279298c 100644 --- a/tests/rustdoc-json/methods/abi.rs +++ b/tests/rustdoc-json/methods/abi.rs @@ -1,7 +1,6 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] #![feature(no_core)] #![no_core] @@ -9,47 +8,47 @@ pub struct Foo; impl Foo { - // @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='abi_rust')].inner.function.header.abi" \"Rust\" pub fn abi_rust() {} - // @is "$.index[*][?(@.name=='abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_c')].inner.function.header.abi" '{"C": {"unwind": false}}' pub extern "C" fn abi_c() {} - // @is "$.index[*][?(@.name=='abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='abi_system')].inner.function.header.abi" '{"System": {"unwind": false}}' pub extern "system" fn abi_system() {} - // @is "$.index[*][?(@.name=='abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_c_unwind')].inner.function.header.abi" '{"C": {"unwind": true}}' pub extern "C-unwind" fn abi_c_unwind() {} - // @is "$.index[*][?(@.name=='abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}' pub extern "system-unwind" fn abi_system_unwind() {} - // @is "$.index[*][?(@.name=='abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""' pub extern "vectorcall" fn abi_vectorcall() {} - // @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""' pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {} } pub trait Bar { - // @is "$.index[*][?(@.name=='trait_abi_rust')].inner.header.abi" \"Rust\" + // @is "$.index[*][?(@.name=='trait_abi_rust')].inner.function.header.abi" \"Rust\" fn trait_abi_rust() {} - // @is "$.index[*][?(@.name=='trait_abi_c')].inner.header.abi" '{"C": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_c')].inner.function.header.abi" '{"C": {"unwind": false}}' extern "C" fn trait_abi_c() {} - // @is "$.index[*][?(@.name=='trait_abi_system')].inner.header.abi" '{"System": {"unwind": false}}' + // @is "$.index[*][?(@.name=='trait_abi_system')].inner.function.header.abi" '{"System": {"unwind": false}}' extern "system" fn trait_abi_system() {} - // @is "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.header.abi" '{"C": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_c_unwind')].inner.function.header.abi" '{"C": {"unwind": true}}' extern "C-unwind" fn trait_abi_c_unwind() {} - // @is "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.header.abi" '{"System": {"unwind": true}}' + // @is "$.index[*][?(@.name=='trait_abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}' extern "system-unwind" fn trait_abi_system_unwind() {} - // @is "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.header.abi.Other" '"\"vectorcall\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""' extern "vectorcall" fn trait_abi_vectorcall() {} - // @is "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.header.abi.Other" '"\"vectorcall-unwind\""' + // @is "$.index[*][?(@.name=='trait_abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""' extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {} } diff --git a/tests/rustdoc-json/methods/qualifiers.rs b/tests/rustdoc-json/methods/qualifiers.rs index b9a5e5601..65977bc82 100644 --- a/tests/rustdoc-json/methods/qualifiers.rs +++ b/tests/rustdoc-json/methods/qualifiers.rs @@ -3,34 +3,34 @@ pub struct Foo; impl Foo { - // @is "$.index[*][?(@.name=='const_meth')].inner.header.async" false - // @is "$.index[*][?(@.name=='const_meth')].inner.header.const" true - // @is "$.index[*][?(@.name=='const_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='const_meth')].inner.function.header.async" false + // @is "$.index[*][?(@.name=='const_meth')].inner.function.header.const" true + // @is "$.index[*][?(@.name=='const_meth')].inner.function.header.unsafe" false pub const fn const_meth() {} - // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.async" false - // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.const" false - // @is "$.index[*][?(@.name=='nothing_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.function.header.async" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.function.header.const" false + // @is "$.index[*][?(@.name=='nothing_meth')].inner.function.header.unsafe" false pub fn nothing_meth() {} - // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.async" false - // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.const" false - // @is "$.index[*][?(@.name=='unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.function.header.async" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.function.header.const" false + // @is "$.index[*][?(@.name=='unsafe_meth')].inner.function.header.unsafe" true pub unsafe fn unsafe_meth() {} - // @is "$.index[*][?(@.name=='async_meth')].inner.header.async" true - // @is "$.index[*][?(@.name=='async_meth')].inner.header.const" false - // @is "$.index[*][?(@.name=='async_meth')].inner.header.unsafe" false + // @is "$.index[*][?(@.name=='async_meth')].inner.function.header.async" true + // @is "$.index[*][?(@.name=='async_meth')].inner.function.header.const" false + // @is "$.index[*][?(@.name=='async_meth')].inner.function.header.unsafe" false pub async fn async_meth() {} - // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.async" true - // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.const" false - // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.function.header.async" true + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.function.header.const" false + // @is "$.index[*][?(@.name=='async_unsafe_meth')].inner.function.header.unsafe" true pub async unsafe fn async_unsafe_meth() {} - // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.async" false - // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.const" true - // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.header.unsafe" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.function.header.async" false + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.function.header.const" true + // @is "$.index[*][?(@.name=='const_unsafe_meth')].inner.function.header.unsafe" true pub const unsafe fn const_unsafe_meth() {} // It's impossible for a method to be both const and async, so no test for that diff --git a/tests/rustdoc-json/nested.rs b/tests/rustdoc-json/nested.rs index ee2d2efa9..e012cfc50 100644 --- a/tests/rustdoc-json/nested.rs +++ b/tests/rustdoc-json/nested.rs @@ -2,30 +2,31 @@ // compile-flags: --crate-version 1.0.0 // @is "$.crate_version" \"1.0.0\" -// @is "$.index[*][?(@.name=='nested')].kind" \"module\" -// @is "$.index[*][?(@.name=='nested')].inner.is_crate" true +// @has "$.index[*][?(@.name=='nested')].inner.module" +// @is "$.index[*][?(@.name=='nested')].inner.module.is_crate" true // @set l1_id = "$.index[*][?(@.name=='l1')].id" -// @ismany "$.index[*][?(@.name=='nested')].inner.items[*]" $l1_id +// @ismany "$.index[*][?(@.name=='nested')].inner.module.items[*]" $l1_id -// @is "$.index[*][?(@.name=='l1')].kind" \"module\" -// @is "$.index[*][?(@.name=='l1')].inner.is_crate" false +// @has "$.index[*][?(@.name=='l1')].inner.module" +// @is "$.index[*][?(@.name=='l1')].inner.module.is_crate" false pub mod l1 { - // @is "$.index[*][?(@.name=='l3')].kind" \"module\" - // @is "$.index[*][?(@.name=='l3')].inner.is_crate" false + // @has "$.index[*][?(@.name=='l3')].inner.module" + // @is "$.index[*][?(@.name=='l3')].inner.module.is_crate" false // @set l3_id = "$.index[*][?(@.name=='l3')].id" pub mod l3 { - // @is "$.index[*][?(@.name=='L4')].kind" \"struct\" - // @is "$.index[*][?(@.name=='L4')].inner.kind" \"unit\" + // @has "$.index[*][?(@.name=='L4')].inner.struct" + // @is "$.index[*][?(@.name=='L4')].inner.struct.kind" '"unit"' // @set l4_id = "$.index[*][?(@.name=='L4')].id" - // @ismany "$.index[*][?(@.name=='l3')].inner.items[*]" $l4_id + // @ismany "$.index[*][?(@.name=='l3')].inner.module.items[*]" $l4_id pub struct L4; } - // @is "$.index[*][?(@.inner.source=='l3::L4')].kind" \"import\" - // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.glob" false - // @is "$.index[*][?(@.inner.source=='l3::L4')].inner.id" $l4_id - // @set l4_use_id = "$.index[*][?(@.inner.source=='l3::L4')].id" + // @is "$.index[*][?(@.inner.import)].inner.import.glob" false + // @is "$.index[*][?(@.inner.import)].inner.import.source" '"l3::L4"' + // @is "$.index[*][?(@.inner.import)].inner.import.glob" false + // @is "$.index[*][?(@.inner.import)].inner.import.id" $l4_id + // @set l4_use_id = "$.index[*][?(@.inner.import)].id" pub use l3::L4; } -// @ismany "$.index[*][?(@.name=='l1')].inner.items[*]" $l3_id $l4_use_id +// @ismany "$.index[*][?(@.name=='l1')].inner.module.items[*]" $l3_id $l4_use_id diff --git a/tests/rustdoc-json/non_lifetime_binders.rs b/tests/rustdoc-json/non_lifetime_binders.rs index ca5a00834..cabee0b1c 100644 --- a/tests/rustdoc-json/non_lifetime_binders.rs +++ b/tests/rustdoc-json/non_lifetime_binders.rs @@ -16,9 +16,9 @@ struct PhantomData<T_>; pub struct Wrapper<T_>(PhantomData<T_>); -// @count "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[*]" 2 -// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\" -// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' -// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].name" \"T\" -// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].kind" '{ "type": { "bounds": [], "default": null, "synthetic": false } }' +// @count "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[*]" 2 +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[1].name" \"T\" +// @is "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[0].bound_predicate.generic_params[1].kind" '{ "type": { "bounds": [], "default": null, "synthetic": false } }' pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/rustdoc-json/primitives/local_primitive.rs b/tests/rustdoc-json/primitives/local_primitive.rs index 0cf479faf..562c7e4d7 100644 --- a/tests/rustdoc-json/primitives/local_primitive.rs +++ b/tests/rustdoc-json/primitives/local_primitive.rs @@ -14,7 +14,7 @@ mod prim_i32 {} // @set local_i32 = "$.index[*][?(@.name=='i32')].id" // @has "$.index[*][?(@.name=='local_primitive')]" -// @ismany "$.index[*][?(@.name=='local_primitive')].inner.items[*]" $local_i32 +// @ismany "$.index[*][?(@.name=='local_primitive')].inner.module.items[*]" $local_i32 // @is "$.index[*][?(@.name=='local_primitive')].links['prim@i32']" $local_i32 // Let's ensure the `prim_i32` module isn't present in the output JSON: diff --git a/tests/rustdoc-json/primitives/primitive_impls.rs b/tests/rustdoc-json/primitives/primitive_impls.rs index 85d179ee4..4b7b7646b 100644 --- a/tests/rustdoc-json/primitives/primitive_impls.rs +++ b/tests/rustdoc-json/primitives/primitive_impls.rs @@ -15,7 +15,7 @@ impl i32 { self } - // @is "$.index[*][?(@.docs=='Only core can do this')].inner.items[*]" $identity + // @is "$.index[*][?(@.docs=='Only core can do this')].inner.impl.items[*]" $identity } // @set Trait = "$.index[*][?(@.name=='Trait')].id" @@ -30,5 +30,5 @@ mod prim_i32 {} // @set i32 = "$.index[*][?(@.docs=='i32')].id" // @is "$.index[*][?(@.docs=='i32')].name" '"i32"' -// @is "$.index[*][?(@.docs=='i32')].inner.name" '"i32"' -// @ismany "$.index[*][?(@.docs=='i32')].inner.impls[*]" $impl_i32 $impl_trait_for_i32 +// @is "$.index[*][?(@.docs=='i32')].inner.primitive.name" '"i32"' +// @ismany "$.index[*][?(@.docs=='i32')].inner.primitive.impls[*]" $impl_i32 $impl_trait_for_i32 diff --git a/tests/rustdoc-json/primitives/primitive_type.rs b/tests/rustdoc-json/primitives/primitive_type.rs index 8024044bc..5f251b3b8 100644 --- a/tests/rustdoc-json/primitives/primitive_type.rs +++ b/tests/rustdoc-json/primitives/primitive_type.rs @@ -1,22 +1,17 @@ #![feature(never_type)] // @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" -// @is "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" -// @is "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.typedef.type.primitive" \"never\" pub type PrimNever = !; -// @is "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" -// @is "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.typedef.type.primitive" \"str\" pub type PrimStr = str; -// @is "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" -// @is "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.typedef.type.primitive" \"bool\" pub type PrimBool = bool; -// @is "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" -// @is "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.typedef.type.primitive" \"char\" pub type PrimChar = char; -// @is "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" -// @is "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.typedef.type.primitive" \"u8\" pub type PrimU8 = u8; diff --git a/tests/rustdoc-json/primitives/use_primitive.rs b/tests/rustdoc-json/primitives/use_primitive.rs index 5180a804f..f8118b820 100644 --- a/tests/rustdoc-json/primitives/use_primitive.rs +++ b/tests/rustdoc-json/primitives/use_primitive.rs @@ -13,8 +13,8 @@ mod usize {} // @!is "$.index[*][?(@.name=='checked_add')]" $local_crate_id // @!has "$.index[*][?(@.name=='is_ascii_uppercase')]" -// @is "$.index[*][?(@.kind=='import' && @.inner.name=='my_i32')].inner.id" null +// @is "$.index[*].inner.import[?(@.name=='my_i32')].id" null pub use i32 as my_i32; -// @is "$.index[*][?(@.kind=='import' && @.inner.name=='u32')].inner.id" null +// @is "$.index[*].inner.import[?(@.name=='u32')].id" null pub use u32; diff --git a/tests/rustdoc-json/reexport/auxiliary/enum_with_discriminant.rs b/tests/rustdoc-json/reexport/auxiliary/enum_with_discriminant.rs new file mode 100644 index 000000000..4fa26204b --- /dev/null +++ b/tests/rustdoc-json/reexport/auxiliary/enum_with_discriminant.rs @@ -0,0 +1,6 @@ +//! Should not be inlined + +/// Should not be inlined +pub enum O { + L = -1, +} diff --git a/tests/rustdoc-json/reexport/doc_inline_external_crate.rs b/tests/rustdoc-json/reexport/doc_inline_external_crate.rs new file mode 100644 index 000000000..1c5fed8c6 --- /dev/null +++ b/tests/rustdoc-json/reexport/doc_inline_external_crate.rs @@ -0,0 +1,11 @@ +// Regression Test for https://github.com/rust-lang/rust/issues/110138 +// aux-build: enum_with_discriminant.rs +// ignore-tidy-linelength + +#[doc(inline)] +pub extern crate enum_with_discriminant; + +// @!has '$.index[*][?(@.docs == "Should not be inlined")]' +// @has '$.index[*][?(@.name == "enum_with_discriminant")].inner.extern_crate' +// @set enum_with_discriminant = '$.index[*][?(@.name == "enum_with_discriminant")].id' +// @is '$.index[*][?(@.name == "doc_inline_external_crate")].inner.module.items[*]' $enum_with_discriminant diff --git a/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs b/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs index f076feb71..37ca279b3 100644 --- a/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs +++ b/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs @@ -7,5 +7,5 @@ // ignore-tidy-linelength -// @is "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\" +// @is "$.index[*][?(@.inner.module)].name" \"export_extern_crate_as_self\" pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has diff --git a/tests/rustdoc-json/reexport/extern_crate_glob.rs b/tests/rustdoc-json/reexport/extern_crate_glob.rs new file mode 100644 index 000000000..553ee79b4 --- /dev/null +++ b/tests/rustdoc-json/reexport/extern_crate_glob.rs @@ -0,0 +1,11 @@ +// aux-build: enum_with_discriminant.rs + +extern crate enum_with_discriminant; + +#[doc(inline)] +pub use enum_with_discriminant::*; + +// @!has '$.index[*][?(@.docs == "Should not be inlined")]' +// @is '$.index[*][?(@.inner.import)].inner.import.name' \"enum_with_discriminant\" +// @set use = '$.index[*][?(@.inner.import)].id' +// @is '$.index[*][?(@.name == "extern_crate_glob")].inner.module.items[*]' $use diff --git a/tests/rustdoc-json/reexport/glob_collision.rs b/tests/rustdoc-json/reexport/glob_collision.rs index f91144dbf..dee35ba78 100644 --- a/tests/rustdoc-json/reexport/glob_collision.rs +++ b/tests/rustdoc-json/reexport/glob_collision.rs @@ -3,26 +3,28 @@ #![feature(no_core)] #![no_core] -// @set m1 = "$.index[*][?(@.name == 'm1' && @.kind == 'module')].id" -// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.items" [] -// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.is_stripped" true +// @set m1 = "$.index[*][?(@.name == 'm1' && @.inner.module)].id" +// @is "$.index[*][?(@.name == 'm1')].inner.module.items" [] +// @is "$.index[*][?(@.name == 'm1')].inner.module.is_stripped" true mod m1 { pub fn f() {} } -// @set m2 = "$.index[*][?(@.name == 'm2' && @.kind == 'module')].id" -// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.items" [] -// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.is_stripped" true +// @set m2 = "$.index[*][?(@.name == 'm2' && @.inner.module)].id" +// @is "$.index[*][?(@.name == 'm2')].inner.module.items" [] +// @is "$.index[*][?(@.name == 'm2')].inner.module.is_stripped" true mod m2 { pub fn f(_: u8) {} } -// @set m1_use = "$.index[*][?(@.inner.name=='m1')].id" -// @is "$.index[*][?(@.inner.name=='m1')].inner.id" $m1 -// @is "$.index[*][?(@.inner.name=='m1')].inner.glob" true +// @set m1_use = "$.index[*][?(@.docs=='m1 re-export')].id" +// @is "$.index[*].inner.import[?(@.name=='m1')].id" $m1 +// @is "$.index[*].inner.import[?(@.name=='m1')].glob" true +/// m1 re-export pub use m1::*; -// @set m2_use = "$.index[*][?(@.inner.name=='m2')].id" -// @is "$.index[*][?(@.inner.name=='m2')].inner.id" $m2 -// @is "$.index[*][?(@.inner.name=='m2')].inner.glob" true +// @set m2_use = "$.index[*][?(@.docs=='m2 re-export')].id" +// @is "$.index[*].inner.import[?(@.name=='m2')].id" $m2 +// @is "$.index[*].inner.import[?(@.name=='m2')].glob" true +/// m2 re-export pub use m2::*; -// @ismany "$.index[*][?(@.inner.is_crate==true)].inner.items[*]" $m1_use $m2_use +// @ismany "$.index[*].inner.module[?(@.is_crate==true)].items[*]" $m1_use $m2_use diff --git a/tests/rustdoc-json/reexport/glob_empty_mod.rs b/tests/rustdoc-json/reexport/glob_empty_mod.rs index da6822835..8b7150c8f 100644 --- a/tests/rustdoc-json/reexport/glob_empty_mod.rs +++ b/tests/rustdoc-json/reexport/glob_empty_mod.rs @@ -1,8 +1,8 @@ // Regression test for https://github.com/rust-lang/rust/issues/100973 -// @is "$.index[*][?(@.name=='m1' && @.kind == 'module')].inner.is_stripped" true +// @is "$.index[*][?(@.name=='m1' && @.inner.module)].inner.module.is_stripped" true // @set m1 = "$.index[*][?(@.name=='m1')].id" mod m1 {} -// @is "$.index[*][?(@.inner.name=='m1' && @.kind=='import')].inner.id" $m1 +// @is "$.index[*][?(@.inner.import)].inner.import.id" $m1 pub use m1::*; diff --git a/tests/rustdoc-json/reexport/glob_extern.rs b/tests/rustdoc-json/reexport/glob_extern.rs index 7a1e8c11f..78edfaf0a 100644 --- a/tests/rustdoc-json/reexport/glob_extern.rs +++ b/tests/rustdoc-json/reexport/glob_extern.rs @@ -3,8 +3,7 @@ #![no_core] #![feature(no_core)] -// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].inner.module.is_stripped" "true" mod mod1 { extern "C" { // @set public_fn_id = "$.index[*][?(@.name=='public_fn')].id" @@ -12,12 +11,12 @@ mod mod1 { // @!has "$.index[*][?(@.name=='private_fn')]" fn private_fn(); } - // @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $public_fn_id + // @ismany "$.index[*][?(@.name=='mod1')].inner.module.items[*]" $public_fn_id // @set mod1_id = "$.index[*][?(@.name=='mod1')].id" } -// @is "$.index[*][?(@.kind=='import')].inner.glob" true -// @is "$.index[*][?(@.kind=='import')].inner.id" $mod1_id -// @set use_id = "$.index[*][?(@.kind=='import')].id" -// @ismany "$.index[*][?(@.name=='glob_extern')].inner.items[*]" $use_id +// @is "$.index[*][?(@.inner.import)].inner.import.glob" true +// @is "$.index[*][?(@.inner.import)].inner.import.id" $mod1_id +// @set use_id = "$.index[*][?(@.inner.import)].id" +// @ismany "$.index[*][?(@.name=='glob_extern')].inner.module.items[*]" $use_id pub use mod1::*; diff --git a/tests/rustdoc-json/reexport/glob_private.rs b/tests/rustdoc-json/reexport/glob_private.rs index 3a83a2081..ae4e87d23 100644 --- a/tests/rustdoc-json/reexport/glob_private.rs +++ b/tests/rustdoc-json/reexport/glob_private.rs @@ -3,11 +3,9 @@ #![no_core] #![feature(no_core)] -// @is "$.index[*][?(@.name=='mod1')].kind" \"module\" -// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +// @is "$.index[*][?(@.name=='mod1')].inner.module.is_stripped" "true" mod mod1 { - // @is "$.index[*][?(@.name=='mod2')].kind" \"module\" - // @is "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true" + // @is "$.index[*][?(@.name=='mod2')].inner.module.is_stripped" "true" mod mod2 { // @set m2pub_id = "$.index[*][?(@.name=='Mod2Public')].id" pub struct Mod2Public; @@ -16,7 +14,9 @@ mod mod1 { struct Mod2Private; } - // @set mod2_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')].id" + // @set mod2_use_id = "$.index[*][?(@.docs=='Mod2 re-export')].id" + // @is "$.index[*][?(@.docs=='Mod2 re-export')].inner.import.name" \"mod2\" + /// Mod2 re-export pub use self::mod2::*; // @set m1pub_id = "$.index[*][?(@.name=='Mod1Public')].id" @@ -25,9 +25,11 @@ mod mod1 { struct Mod1Private; } -// @set mod1_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id" +// @set mod1_use_id = "$.index[*][?(@.docs=='Mod1 re-export')].id" +// @is "$.index[*][?(@.docs=='Mod1 re-export')].inner.import.name" \"mod1\" +/// Mod1 re-export pub use mod1::*; -// @ismany "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id -// @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id $mod2_use_id -// @ismany "$.index[*][?(@.name=='glob_private')].inner.items[*]" $mod1_use_id +// @ismany "$.index[*][?(@.name=='mod2')].inner.module.items[*]" $m2pub_id +// @ismany "$.index[*][?(@.name=='mod1')].inner.module.items[*]" $m1pub_id $mod2_use_id +// @ismany "$.index[*][?(@.name=='glob_private')].inner.module.items[*]" $mod1_use_id diff --git a/tests/rustdoc-json/reexport/in_root_and_mod.rs b/tests/rustdoc-json/reexport/in_root_and_mod.rs index 7b97ebf21..f81445bd4 100644 --- a/tests/rustdoc-json/reexport/in_root_and_mod.rs +++ b/tests/rustdoc-json/reexport/in_root_and_mod.rs @@ -7,10 +7,10 @@ mod foo { pub struct Foo; } -// @has "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]" +// @has "$.index[*].inner[?(@.import.source=='foo::Foo')]" pub use foo::Foo; pub mod bar { - // @has "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]" + // @has "$.index[*].inner[?(@.import.source=='crate::foo::Foo')]" pub use crate::foo::Foo; } diff --git a/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs b/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs index f6d932d92..c5c41b25f 100644 --- a/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs +++ b/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs @@ -3,18 +3,20 @@ pub mod foo { // @set bar_id = "$.index[*][?(@.name=='Bar')].id" - // @ismany "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id + // @ismany "$.index[*][?(@.name=='foo')].inner.module.items[*]" $bar_id pub struct Bar; } -// @set root_import_id = "$.index[*][?(@.inner.source=='foo::Bar')].id" -// @is "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id -// @has "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id +// @set root_import_id = "$.index[*][?(@.docs=='Outer re-export')].id" +// @is "$.index[*].inner[?(@.import.source=='foo::Bar')].import.id" $bar_id +// @has "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.module.items[*]" $root_import_id +/// Outer re-export pub use foo::Bar; pub mod baz { - // @set baz_import_id = "$.index[*][?(@.inner.source=='crate::foo::Bar')].id" - // @is "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id - // @ismany "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id + // @set baz_import_id = "$.index[*][?(@.docs=='Inner re-export')].id" + // @is "$.index[*].inner[?(@.import.source=='crate::foo::Bar')].import.id" $bar_id + // @ismany "$.index[*][?(@.name=='baz')].inner.module.items[*]" $baz_import_id + /// Inner re-export pub use crate::foo::Bar; } diff --git a/tests/rustdoc-json/reexport/macro.rs b/tests/rustdoc-json/reexport/macro.rs index b4882100f..ac0632b98 100644 --- a/tests/rustdoc-json/reexport/macro.rs +++ b/tests/rustdoc-json/reexport/macro.rs @@ -9,7 +9,8 @@ macro_rules! repro { () => {}; } -// @set repro2_id = "$.index[*][?(@.inner.name=='repro2')].id" +// @set repro2_id = "$.index[*][?(@.docs=='Re-export')].id" +/// Re-export pub use crate::repro as repro2; -// @ismany "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id +// @ismany "$.index[*][?(@.name=='macro')].inner.module.items[*]" $repro_id $repro2_id diff --git a/tests/rustdoc-json/reexport/mod_not_included.rs b/tests/rustdoc-json/reexport/mod_not_included.rs index 7b7600ef2..1c49f213d 100644 --- a/tests/rustdoc-json/reexport/mod_not_included.rs +++ b/tests/rustdoc-json/reexport/mod_not_included.rs @@ -9,6 +9,6 @@ mod m1 { pub use m1::x; -// @has "$.index[*][?(@.name=='x' && @.kind=='function')]" -// @has "$.index[*][?(@.kind=='import' && @.inner.name=='x')].inner.source" '"m1::x"' +// @has "$.index[*][?(@.name=='x' && @.inner.function)]" +// @has "$.index[*].inner[?(@.import.name=='x')].import.source" '"m1::x"' // @!has "$.index[*][?(@.name=='m1')]" diff --git a/tests/rustdoc-json/reexport/private_twice_one_inline.rs b/tests/rustdoc-json/reexport/private_twice_one_inline.rs index 687a3b2ac..8c8152bd1 100644 --- a/tests/rustdoc-json/reexport/private_twice_one_inline.rs +++ b/tests/rustdoc-json/reexport/private_twice_one_inline.rs @@ -11,18 +11,18 @@ extern crate pub_struct as foo; #[doc(inline)] // @set crate_use_id = "$.index[*][?(@.docs=='Hack A')].id" -// @set foo_id = "$.index[*][?(@.docs=='Hack A')].inner.id" +// @set foo_id = "$.index[*][?(@.docs=='Hack A')].inner.import.id" /// Hack A pub use foo::Foo; // @set bar_id = "$.index[*][?(@.name=='bar')].id" pub mod bar { - // @is "$.index[*][?(@.docs=='Hack B')].inner.id" $foo_id + // @is "$.index[*][?(@.docs=='Hack B')].inner.import.id" $foo_id // @set bar_use_id = "$.index[*][?(@.docs=='Hack B')].id" - // @ismany "$.index[*][?(@.name=='bar')].inner.items[*]" $bar_use_id + // @ismany "$.index[*][?(@.name=='bar')].inner.module.items[*]" $bar_use_id /// Hack B pub use foo::Foo; } -// @ismany "$.index[*][?(@.kind=='import')].id" $crate_use_id $bar_use_id -// @ismany "$.index[*][?(@.name=='private_twice_one_inline')].inner.items[*]" $bar_id $crate_use_id +// @ismany "$.index[*][?(@.inner.import)].id" $crate_use_id $bar_use_id +// @ismany "$.index[*][?(@.name=='private_twice_one_inline')].inner.module.items[*]" $bar_id $crate_use_id diff --git a/tests/rustdoc-json/reexport/private_two_names.rs b/tests/rustdoc-json/reexport/private_two_names.rs index 9858538a9..cdcbf2a2b 100644 --- a/tests/rustdoc-json/reexport/private_two_names.rs +++ b/tests/rustdoc-json/reexport/private_two_names.rs @@ -8,15 +8,19 @@ // @!has "$.index[*][?(@.name=='style')]" mod style { - // @set color_struct_id = "$.index[*][?(@.kind=='struct' && @.name=='Color')].id" + // @set color_struct_id = "$.index[*][?(@.inner.struct && @.name=='Color')].id" pub struct Color; } -// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].inner.id" $color_struct_id -// @set color_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].id" +// @is "$.index[*][?(@.docs=='First re-export')].inner.import.id" $color_struct_id +// @is "$.index[*][?(@.docs=='First re-export')].inner.import.name" \"Color\" +// @set color_export_id = "$.index[*][?(@.docs=='First re-export')].id" +/// First re-export pub use style::Color; -// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].inner.id" $color_struct_id -// @set colour_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].id" +// @is "$.index[*][?(@.docs=='Second re-export')].inner.import.id" $color_struct_id +// @is "$.index[*][?(@.docs=='Second re-export')].inner.import.name" \"Colour\" +// @set colour_export_id = "$.index[*][?(@.docs=='Second re-export')].id" +/// Second re-export pub use style::Color as Colour; -// @ismany "$.index[*][?(@.name=='private_two_names')].inner.items[*]" $color_export_id $colour_export_id +// @ismany "$.index[*][?(@.name=='private_two_names')].inner.module.items[*]" $color_export_id $colour_export_id diff --git a/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs b/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs index 239b1a23b..61075088a 100644 --- a/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs +++ b/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs @@ -1,9 +1,9 @@ // Regression test for <https://github.com/rust-lang/rust/issues/102583>. // @set impl_S = "$.index[*][?(@.docs=='impl S')].id" -// @has "$.index[*][?(@.name=='S')].inner.impls[*]" $impl_S +// @has "$.index[*][?(@.name=='S')].inner.struct.impls[*]" $impl_S // @set is_present = "$.index[*][?(@.name=='is_present')].id" -// @is "$.index[*][?(@.docs=='impl S')].inner.items[*]" $is_present +// @is "$.index[*][?(@.docs=='impl S')].inner.impl.items[*]" $is_present // @!has "$.index[*][?(@.name=='hidden_impl')]" // @!has "$.index[*][?(@.name=='hidden_fn')]" diff --git a/tests/rustdoc-json/reexport/rename_private.rs b/tests/rustdoc-json/reexport/rename_private.rs index 8fd850f9b..911446023 100644 --- a/tests/rustdoc-json/reexport/rename_private.rs +++ b/tests/rustdoc-json/reexport/rename_private.rs @@ -3,11 +3,11 @@ #![no_core] #![feature(no_core)] -// @!has "$.index[*][?(@.kind=='inner')]" +// @!has "$.index[*][?(@.name=='inner')]" mod inner { // @has "$.index[*][?(@.name=='Public')]" pub struct Public; } -// @is "$.index[*][?(@.kind=='import')].inner.name" \"NewName\" +// @is "$.index[*][?(@.inner.import)].inner.import.name" \"NewName\" pub use inner::Public as NewName; diff --git a/tests/rustdoc-json/reexport/rename_public.rs b/tests/rustdoc-json/reexport/rename_public.rs index e30907fe2..d0fd314bd 100644 --- a/tests/rustdoc-json/reexport/rename_public.rs +++ b/tests/rustdoc-json/reexport/rename_public.rs @@ -6,12 +6,13 @@ // @set inner_id = "$.index[*][?(@.name=='inner')].id" pub mod inner { // @set public_id = "$.index[*][?(@.name=='Public')].id" - // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @ismany "$.index[*][?(@.name=='inner')].inner.module.items[*]" $public_id pub struct Public; } -// @set import_id = "$.index[*][?(@.inner.name=='NewName')].id" -// @!has "$.index[*][?(@.inner.name=='Public')]" -// @is "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.docs=='Re-export')].id" +// @!has "$.index[*].inner[?(@.import.name=='Public')]" +// @is "$.index[*].inner[?(@.import.name=='NewName')].import.source" \"inner::Public\" +/// Re-export pub use inner::Public as NewName; -// @ismany "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id $import_id +// @ismany "$.index[*][?(@.name=='rename_public')].inner.module.items[*]" $inner_id $import_id diff --git a/tests/rustdoc-json/reexport/same_name_different_types.rs b/tests/rustdoc-json/reexport/same_name_different_types.rs index 2314a4eb9..6a765b733 100644 --- a/tests/rustdoc-json/reexport/same_name_different_types.rs +++ b/tests/rustdoc-json/reexport/same_name_different_types.rs @@ -16,10 +16,10 @@ pub mod nested { pub fn Foo() {} } -// @ismany "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')].inner.id" $foo_fn $foo_struct -// @ismany "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')].inner.id" $foo_fn $foo_struct +// @ismany "$.index[*].inner[?(@.import.name == 'Foo')].import.id" $foo_fn $foo_struct +// @ismany "$.index[*].inner[?(@.import.name == 'Bar')].import.id" $foo_fn $foo_struct -// @count "$.index[*][?(@.inner.name == 'Foo' && @.kind == 'import')]" 2 +// @count "$.index[*].inner[?(@.import.name == 'Foo')]" 2 pub use nested::Foo; -// @count "$.index[*][?(@.inner.name == 'Bar' && @.kind == 'import')]" 2 +// @count "$.index[*].inner[?(@.import.name == 'Bar')]" 2 pub use Foo as Bar; diff --git a/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs b/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs index 880dbdc44..a00547dc3 100644 --- a/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs +++ b/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs @@ -11,11 +11,13 @@ mod inner { pub trait Trait {} } -// @set export_id = "$.index[*][?(@.inner.name=='Trait')].id" -// @is "$.index[*][?(@.inner.name=='Trait')].inner.id" $trait_id +// @set export_id = "$.index[*][?(@.docs=='First re-export')].id" +// @is "$.index[*].inner[?(@.import.name=='Trait')].import.id" $trait_id +/// First re-export pub use inner::Trait; -// @set reexport_id = "$.index[*][?(@.inner.name=='Reexport')].id" -// @is "$.index[*][?(@.inner.name=='Reexport')].inner.id" $trait_id +// @set reexport_id = "$.index[*][?(@.docs=='Second re-export')].id" +// @is "$.index[*].inner[?(@.import.name=='Reexport')].import.id" $trait_id +/// Second re-export pub use inner::Trait as Reexport; -// @ismany "$.index[*][?(@.name=='same_type_reexported_more_than_once')].inner.items[*]" $reexport_id $export_id +// @ismany "$.index[*][?(@.name=='same_type_reexported_more_than_once')].inner.module.items[*]" $reexport_id $export_id diff --git a/tests/rustdoc-json/reexport/simple_private.rs b/tests/rustdoc-json/reexport/simple_private.rs index d058ce059..462efee51 100644 --- a/tests/rustdoc-json/reexport/simple_private.rs +++ b/tests/rustdoc-json/reexport/simple_private.rs @@ -8,9 +8,9 @@ mod inner { pub struct Public; } -// @is "$.index[*][?(@.kind=='import')].inner.name" \"Public\" -// @is "$.index[*][?(@.kind=='import')].inner.id" $pub_id -// @set use_id = "$.index[*][?(@.kind=='import')].id" +// @is "$.index[*][?(@.inner.import)].inner.import.name" \"Public\" +// @is "$.index[*][?(@.inner.import)].inner.import.id" $pub_id +// @set use_id = "$.index[*][?(@.inner.import)].id" pub use inner::Public; -// @ismany "$.index[*][?(@.name=='simple_private')].inner.items[*]" $use_id +// @ismany "$.index[*][?(@.name=='simple_private')].inner.module.items[*]" $use_id diff --git a/tests/rustdoc-json/reexport/simple_public.rs b/tests/rustdoc-json/reexport/simple_public.rs index e64a0dcb7..1373f96f8 100644 --- a/tests/rustdoc-json/reexport/simple_public.rs +++ b/tests/rustdoc-json/reexport/simple_public.rs @@ -7,12 +7,13 @@ pub mod inner { // @set public_id = "$.index[*][?(@.name=='Public')].id" - // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + // @ismany "$.index[*][?(@.name=='inner')].inner.module.items[*]" $public_id pub struct Public; } -// @set import_id = "$.index[*][?(@.inner.name=='Public')].id" -// @is "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" +// @set import_id = "$.index[*][?(@.docs=='Outer')].id" +// @is "$.index[*][?(@.docs=='Outer')].inner.import.source" \"inner::Public\" +/// Outer pub use inner::Public; -// @ismany "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id $inner_id +// @ismany "$.index[*][?(@.name=='simple_public')].inner.module.items[*]" $import_id $inner_id diff --git a/tests/rustdoc-json/return_private.rs b/tests/rustdoc-json/return_private.rs index a8d1fae30..0ce81b5e5 100644 --- a/tests/rustdoc-json/return_private.rs +++ b/tests/rustdoc-json/return_private.rs @@ -8,8 +8,8 @@ mod secret { pub struct Secret; } -// @is "$.index[*][?(@.name=='get_secret')].kind" \"function\" -// @is "$.index[*][?(@.name=='get_secret')].inner.decl.output.inner.name" \"secret::Secret\" +// @has "$.index[*][?(@.name=='get_secret')].inner.function" +// @is "$.index[*][?(@.name=='get_secret')].inner.function.decl.output.resolved_path.name" \"secret::Secret\" pub fn get_secret() -> secret::Secret { secret::Secret } diff --git a/tests/rustdoc-json/structs/plain_all_pub.rs b/tests/rustdoc-json/structs/plain_all_pub.rs index b86ab93c2..777260100 100644 --- a/tests/rustdoc-json/structs/plain_all_pub.rs +++ b/tests/rustdoc-json/structs/plain_all_pub.rs @@ -5,7 +5,7 @@ pub struct Demo { // @set x = "$.index[*][?(@.name=='x')].id" // @set y = "$.index[*][?(@.name=='y')].id" -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[1]" $y -// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 2 -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" false +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[0]" $x +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[1]" $y +// @count "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[*]" 2 +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields_stripped" false diff --git a/tests/rustdoc-json/structs/plain_doc_hidden.rs b/tests/rustdoc-json/structs/plain_doc_hidden.rs index 7800b55a4..1ff4489ef 100644 --- a/tests/rustdoc-json/structs/plain_doc_hidden.rs +++ b/tests/rustdoc-json/structs/plain_doc_hidden.rs @@ -6,6 +6,6 @@ pub struct Demo { // @set x = "$.index[*][?(@.name=='x')].id" // @!has "$.index[*][?(@.name=='y')].id" -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x -// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields_stripped" true diff --git a/tests/rustdoc-json/structs/plain_empty.rs b/tests/rustdoc-json/structs/plain_empty.rs index 1d01b8bc1..c037c0251 100644 --- a/tests/rustdoc-json/structs/plain_empty.rs +++ b/tests/rustdoc-json/structs/plain_empty.rs @@ -1,5 +1,5 @@ // @is "$.index[*][?(@.name=='PlainEmpty')].visibility" \"public\" -// @is "$.index[*][?(@.name=='PlainEmpty')].kind" \"struct\" -// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields_stripped" false -// @is "$.index[*][?(@.name=='PlainEmpty')].inner.kind.plain.fields" [] +// @has "$.index[*][?(@.name=='PlainEmpty')].inner.struct" +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.struct.kind.plain.fields_stripped" false +// @is "$.index[*][?(@.name=='PlainEmpty')].inner.struct.kind.plain.fields" [] pub struct PlainEmpty {} diff --git a/tests/rustdoc-json/structs/plain_pub_priv.rs b/tests/rustdoc-json/structs/plain_pub_priv.rs index 9b771224d..ff061be62 100644 --- a/tests/rustdoc-json/structs/plain_pub_priv.rs +++ b/tests/rustdoc-json/structs/plain_pub_priv.rs @@ -4,6 +4,6 @@ pub struct Demo { } // @set x = "$.index[*][?(@.name=='x')].id" -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[0]" $x -// @count "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields[*]" 1 -// @is "$.index[*][?(@.name=='Demo')].inner.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[0]" $x +// @count "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields[*]" 1 +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.plain.fields_stripped" true diff --git a/tests/rustdoc-json/structs/tuple.rs b/tests/rustdoc-json/structs/tuple.rs index 6bdb753ee..16ab95ed2 100644 --- a/tests/rustdoc-json/structs/tuple.rs +++ b/tests/rustdoc-json/structs/tuple.rs @@ -1,4 +1,4 @@ // @is "$.index[*][?(@.name=='Tuple')].visibility" \"public\" -// @is "$.index[*][?(@.name=='Tuple')].kind" \"struct\" -// @is "$.index[*][?(@.name=='Tuple')].inner.kind.tuple" '[null, null]' +// @has "$.index[*][?(@.name=='Tuple')].inner.struct" +// @is "$.index[*][?(@.name=='Tuple')].inner.struct.kind.tuple" '[null, null]' pub struct Tuple(u32, String); diff --git a/tests/rustdoc-json/structs/tuple_empty.rs b/tests/rustdoc-json/structs/tuple_empty.rs index 0ad6a8954..4d4af8558 100644 --- a/tests/rustdoc-json/structs/tuple_empty.rs +++ b/tests/rustdoc-json/structs/tuple_empty.rs @@ -1,2 +1,2 @@ -// @is "$.index[*][?(@.name=='TupleUnit')].inner.kind.tuple" [] +// @is "$.index[*][?(@.name=='TupleUnit')].inner.struct.kind.tuple" [] pub struct TupleUnit(); diff --git a/tests/rustdoc-json/structs/tuple_pub_priv.rs b/tests/rustdoc-json/structs/tuple_pub_priv.rs index 9d5a1d1c8..a669ba1df 100644 --- a/tests/rustdoc-json/structs/tuple_pub_priv.rs +++ b/tests/rustdoc-json/structs/tuple_pub_priv.rs @@ -7,7 +7,7 @@ pub struct Demo( // @set field = "$.index[*][?(@.docs=='field')].id" -// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[0]" null -// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[1]" $field -// @is "$.index[*][?(@.name=='Demo')].inner.kind.tuple[2]" null -// @count "$.index[*][?(@.name=='Demo')].inner.kind.tuple[*]" 3 +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.tuple[0]" null +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.tuple[1]" $field +// @is "$.index[*][?(@.name=='Demo')].inner.struct.kind.tuple[2]" null +// @count "$.index[*][?(@.name=='Demo')].inner.struct.kind.tuple[*]" 3 diff --git a/tests/rustdoc-json/structs/unit.rs b/tests/rustdoc-json/structs/unit.rs index 265709717..640d3fb78 100644 --- a/tests/rustdoc-json/structs/unit.rs +++ b/tests/rustdoc-json/structs/unit.rs @@ -1,4 +1,4 @@ // @is "$.index[*][?(@.name=='Unit')].visibility" \"public\" -// @is "$.index[*][?(@.name=='Unit')].kind" \"struct\" -// @is "$.index[*][?(@.name=='Unit')].inner.kind" \"unit\" +// @has "$.index[*][?(@.name=='Unit')].inner.struct" +// @is "$.index[*][?(@.name=='Unit')].inner.struct.kind" \"unit\" pub struct Unit; diff --git a/tests/rustdoc-json/structs/with_generics.rs b/tests/rustdoc-json/structs/with_generics.rs index 00474800a..d721cbdbe 100644 --- a/tests/rustdoc-json/structs/with_generics.rs +++ b/tests/rustdoc-json/structs/with_generics.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; // @is "$.index[*][?(@.name=='WithGenerics')].visibility" \"public\" -// @is "$.index[*][?(@.name=='WithGenerics')].kind" \"struct\" -// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].name" \"T\" -// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[0].kind.type.bounds" [] -// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].name" \"U\" -// @is "$.index[*][?(@.name=='WithGenerics')].inner.generics.params[1].kind.type.bounds" [] -// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields_stripped" true -// @is "$.index[*][?(@.name=='WithGenerics')].inner.kind.plain.fields" [] +// @has "$.index[*][?(@.name=='WithGenerics')].inner.struct" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.generics.params[0].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.generics.params[1].name" \"U\" +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.generics.params[1].kind.type.bounds" [] +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithGenerics')].inner.struct.kind.plain.fields" [] pub struct WithGenerics<T, U> { stuff: Vec<T>, things: HashMap<U, U>, diff --git a/tests/rustdoc-json/structs/with_primitives.rs b/tests/rustdoc-json/structs/with_primitives.rs index 9c5a37f39..e0285a9e6 100644 --- a/tests/rustdoc-json/structs/with_primitives.rs +++ b/tests/rustdoc-json/structs/with_primitives.rs @@ -1,9 +1,11 @@ +// ignore-tidy-linelength + // @is "$.index[*][?(@.name=='WithPrimitives')].visibility" \"public\" -// @is "$.index[*][?(@.name=='WithPrimitives')].kind" \"struct\" -// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].name" \"\'a\" -// @is "$.index[*][?(@.name=='WithPrimitives')].inner.generics.params[0].kind.lifetime.outlives" [] -// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields_stripped" true -// @is "$.index[*][?(@.name=='WithPrimitives')].inner.kind.plain.fields" [] +// @has "$.index[*][?(@.name=='WithPrimitives')].inner.struct" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.struct.generics.params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.struct.generics.params[0].kind.lifetime.outlives" [] +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.struct.kind.plain.fields_stripped" true +// @is "$.index[*][?(@.name=='WithPrimitives')].inner.struct.kind.plain.fields" [] pub struct WithPrimitives<'a> { num: u32, s: &'a str, diff --git a/tests/rustdoc-json/traits/has_body.rs b/tests/rustdoc-json/traits/has_body.rs index a57cb97d4..219e2d9bc 100644 --- a/tests/rustdoc-json/traits/has_body.rs +++ b/tests/rustdoc-json/traits/has_body.rs @@ -1,21 +1,21 @@ // @has "$.index[*][?(@.name=='Foo')]" pub trait Foo { - // @is "$.index[*][?(@.name=='no_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='no_self')].inner.function.has_body" false fn no_self(); - // @is "$.index[*][?(@.name=='move_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='move_self')].inner.function.has_body" false fn move_self(self); - // @is "$.index[*][?(@.name=='ref_self')].inner.has_body" false + // @is "$.index[*][?(@.name=='ref_self')].inner.function.has_body" false fn ref_self(&self); - // @is "$.index[*][?(@.name=='no_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='no_self_def')].inner.function.has_body" true fn no_self_def() {} - // @is "$.index[*][?(@.name=='move_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='move_self_def')].inner.function.has_body" true fn move_self_def(self) {} - // @is "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true + // @is "$.index[*][?(@.name=='ref_self_def')].inner.function.has_body" true fn ref_self_def(&self) {} } pub trait Bar: Clone { - // @is "$.index[*][?(@.name=='method')].inner.has_body" false + // @is "$.index[*][?(@.name=='method')].inner.function.has_body" false fn method(&self, param: usize); } diff --git a/tests/rustdoc-json/traits/implementors.rs b/tests/rustdoc-json/traits/implementors.rs index db3fe5df7..7d351ad61 100644 --- a/tests/rustdoc-json/traits/implementors.rs +++ b/tests/rustdoc-json/traits/implementors.rs @@ -2,18 +2,18 @@ #![no_core] // @set wham = "$.index[*][?(@.name=='Wham')].id" -// @count "$.index[*][?(@.name=='Wham')].inner.implementations[*]" 1 -// @set gmWham = "$.index[*][?(@.name=='Wham')].inner.implementations[0]" +// @count "$.index[*][?(@.name=='Wham')].inner.trait.implementations[*]" 1 +// @set gmWham = "$.index[*][?(@.name=='Wham')].inner.trait.implementations[0]" pub trait Wham {} -// @count "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[*]" 1 -// @is "$.index[*][?(@.name=='GeorgeMichael')].inner.impls[0]" $gmWham +// @count "$.index[*][?(@.name=='GeorgeMichael')].inner.struct.impls[*]" 1 +// @is "$.index[*][?(@.name=='GeorgeMichael')].inner.struct.impls[0]" $gmWham // @set gm = "$.index[*][?(@.name=='Wham')].id" // jsonpath_lib isnt expressive enough (for now) to get the "impl" item, so we // just check it isn't pointing to the type, but when you port to jsondocck-ng // check what the impl item is -// @!is "$.index[*][?(@.name=='Wham')].inner.implementations[0]" $gm +// @!is "$.index[*][?(@.name=='Wham')].inner.trait.implementations[0]" $gm pub struct GeorgeMichael {} impl Wham for GeorgeMichael {} diff --git a/tests/rustdoc-json/traits/supertrait.rs b/tests/rustdoc-json/traits/supertrait.rs index 4048fdd74..2123ac404 100644 --- a/tests/rustdoc-json/traits/supertrait.rs +++ b/tests/rustdoc-json/traits/supertrait.rs @@ -8,19 +8,19 @@ pub trait Loud {} // @set very_loud_id = "$.index[*][?(@.name=='VeryLoud')].id" -// @count "$.index[*][?(@.name=='VeryLoud')].inner.bounds[*]" 1 -// @is "$.index[*][?(@.name=='VeryLoud')].inner.bounds[0].trait_bound.trait.id" $loud_id +// @count "$.index[*][?(@.name=='VeryLoud')].inner.trait.bounds[*]" 1 +// @is "$.index[*][?(@.name=='VeryLoud')].inner.trait.bounds[0].trait_bound.trait.id" $loud_id pub trait VeryLoud: Loud {} // @set sounds_good_id = "$.index[*][?(@.name=='SoundsGood')].id" pub trait SoundsGood {} -// @count "$.index[*][?(@.name=='MetalBand')].inner.bounds[*]" 2 -// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[0].trait_bound.trait.id" $very_loud_id -// @is "$.index[*][?(@.name=='MetalBand')].inner.bounds[1].trait_bound.trait.id" $sounds_good_id +// @count "$.index[*][?(@.name=='MetalBand')].inner.trait.bounds[*]" 2 +// @is "$.index[*][?(@.name=='MetalBand')].inner.trait.bounds[0].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='MetalBand')].inner.trait.bounds[1].trait_bound.trait.id" $sounds_good_id pub trait MetalBand: VeryLoud + SoundsGood {} -// @count "$.index[*][?(@.name=='DnabLatem')].inner.bounds[*]" 2 -// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[1].trait_bound.trait.id" $very_loud_id -// @is "$.index[*][?(@.name=='DnabLatem')].inner.bounds[0].trait_bound.trait.id" $sounds_good_id +// @count "$.index[*][?(@.name=='DnabLatem')].inner.trait.bounds[*]" 2 +// @is "$.index[*][?(@.name=='DnabLatem')].inner.trait.bounds[1].trait_bound.trait.id" $very_loud_id +// @is "$.index[*][?(@.name=='DnabLatem')].inner.trait.bounds[0].trait_bound.trait.id" $sounds_good_id pub trait DnabLatem: SoundsGood + VeryLoud {} diff --git a/tests/rustdoc-json/traits/trait_alias.rs b/tests/rustdoc-json/traits/trait_alias.rs index 35db9296c..4fcc26f7d 100644 --- a/tests/rustdoc-json/traits/trait_alias.rs +++ b/tests/rustdoc-json/traits/trait_alias.rs @@ -4,24 +4,24 @@ #![feature(trait_alias)] // @set Orig = "$.index[*][?(@.name == 'Orig')].id" -// @is "$.index[*][?(@.name == 'Orig')].kind" '"trait"' +// @has "$.index[*][?(@.name == 'Orig')].inner.trait" pub trait Orig<T> {} // @set Alias = "$.index[*][?(@.name == 'Alias')].id" -// @is "$.index[*][?(@.name == 'Alias')].kind" '"trait_alias"' -// @is "$.index[*][?(@.name == 'Alias')].inner.generics" '{"params": [], "where_predicates": []}' -// @count "$.index[*][?(@.name == 'Alias')].inner.params[*]" 1 -// @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.id" $Orig -// @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.args.angle_bracketed.args[0].type.inner" '"i32"' +// @has "$.index[*][?(@.name == 'Alias')].inner.trait_alias" +// @is "$.index[*][?(@.name == 'Alias')].inner.trait_alias.generics" '{"params": [], "where_predicates": []}' +// @count "$.index[*][?(@.name == 'Alias')].inner.trait_alias.params[*]" 1 +// @is "$.index[*][?(@.name == 'Alias')].inner.trait_alias.params[0].trait_bound.trait.id" $Orig +// @is "$.index[*][?(@.name == 'Alias')].inner.trait_alias.params[0].trait_bound.trait.args.angle_bracketed.args[0].type.primitive" '"i32"' pub trait Alias = Orig<i32>; pub struct Struct; impl Orig<i32> for Struct {} -// @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].kind" '"impl_trait"' -// @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $Alias -// @is "$.index[*][?(@.name=='takes_alias')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $Alias +// @has "$.index[*][?(@.name=='takes_alias')].inner.function.decl.inputs[0][1].impl_trait" +// @is "$.index[*][?(@.name=='takes_alias')].inner.function.decl.inputs[0][1].impl_trait[0].trait_bound.trait.id" $Alias +// @is "$.index[*][?(@.name=='takes_alias')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $Alias pub fn takes_alias(_: impl Alias) {} // FIXME: Should the trait be mentioned in both the decl and generics? diff --git a/tests/rustdoc-json/type/dyn.rs b/tests/rustdoc-json/type/dyn.rs index eaf249252..e5ee60fad 100644 --- a/tests/rustdoc-json/type/dyn.rs +++ b/tests/rustdoc-json/type/dyn.rs @@ -1,46 +1,46 @@ // ignore-tidy-linelength use std::fmt::Debug; -// @count "$.index[*][?(@.name=='dyn')].inner.items[*]" 3 +// @count "$.index[*][?(@.name=='dyn')].inner.module.items[*]" 3 // @set sync_int_gen = "$.index[*][?(@.name=='SyncIntGen')].id" // @set ref_fn = "$.index[*][?(@.name=='RefFn')].id" // @set weird_order = "$.index[*][?(@.name=='WeirdOrder')].id" -// @ismany "$.index[*][?(@.name=='dyn')].inner.items[*]" $sync_int_gen $ref_fn $weird_order +// @ismany "$.index[*][?(@.name=='dyn')].inner.module.items[*]" $sync_int_gen $ref_fn $weird_order -// @is "$.index[*][?(@.name=='SyncIntGen')].kind" \"typedef\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.generics" '{"params": [], "where_predicates": []}' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.kind" \"resolved_path\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.name" \"Box\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.bindings" [] -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args" 1 -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"dyn_trait\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.lifetime" \"\'static\" -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[*]" 3 -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Fn"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[2].trait.name" '"Sync"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"inner": "i32","kind": "primitive"}}}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.generics" '{"params": [], "where_predicates": []}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.name" \"Box\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args" 1 +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.lifetime" \"\'static\" +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[*]" 3 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].trait.name" '"Sync"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"primitive": "i32"}}}' pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>; -// @is "$.index[*][?(@.name=='RefFn')].kind" \"typedef\" -// @is "$.index[*][?(@.name=='RefFn')].inner.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.mutable" 'false' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.lifetime" "\"'a\"" -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.kind" '"dyn_trait"' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.lifetime" null -// @count "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[*]" 1 -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.name" '"Fn"' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.inputs[0].inner.lifetime" "\"'b\"" -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='RefFn')].inner.type.inner.type.inner.traits[0].trait.args.parenthesized.output.inner.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.typedef" +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' +// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.mutable" 'false' +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.lifetime" "\"'a\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait" +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.lifetime" null +// @count "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[*]" 1 +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' +// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref.lifetime" "\"'b\"" pub type RefFn<'a> = &'a dyn for<'b> Fn(&'b i32) -> &'b i32; -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[0].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type.inner.args.angle_bracketed.args[0].type.inner.traits[1].trait.name" '"Debug"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Debug"' pub type WeirdOrder = Box<dyn Send + Debug>; diff --git a/tests/rustdoc-json/type/extern.rs b/tests/rustdoc-json/type/extern.rs index d287d5ebe..c30146ce9 100644 --- a/tests/rustdoc-json/type/extern.rs +++ b/tests/rustdoc-json/type/extern.rs @@ -6,5 +6,4 @@ extern { } // @is "$.index[*][?(@.docs=='No inner information')].name" '"Foo"' -// @is "$.index[*][?(@.docs=='No inner information')].kind" '"foreign_type"' -// @!has "$.index[*][?(@.docs=='No inner information')].inner" +// @is "$.index[*][?(@.docs=='No inner information')].inner" \"foreign_type\" diff --git a/tests/rustdoc-json/type/fn_lifetime.rs b/tests/rustdoc-json/type/fn_lifetime.rs index d7216ec76..424c5dce2 100644 --- a/tests/rustdoc-json/type/fn_lifetime.rs +++ b/tests/rustdoc-json/type/fn_lifetime.rs @@ -1,27 +1,26 @@ // ignore-tidy-linelength -// @is "$.index[*][?(@.name=='GenericFn')].kind" \"typedef\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef" -// @ismany "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.generics.where_predicates[*]" 0 -// @is "$.index[*][?(@.name=='GenericFn')].inner.type.kind" \"function_pointer\" -// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.generic_params[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='GenericFn')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @ismany "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.generic_params[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type GenericFn<'a> = fn(&'a i32) -> &'a i32; -// @is "$.index[*][?(@.name=='ForAll')].kind" \"typedef\" -// @count "$.index[*][?(@.name=='ForAll')].inner.generics.params[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.generic_params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.inputs[*][1].inner.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='ForAll')].inner.type.inner.decl.output.inner.lifetime" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.typedef" +// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.params[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type ForAll = for<'a> fn(&'a i32) -> &'a i32; diff --git a/tests/rustdoc-json/type/generic_default.rs b/tests/rustdoc-json/type/generic_default.rs index 9c6d4540b..b46428745 100644 --- a/tests/rustdoc-json/type/generic_default.rs +++ b/tests/rustdoc-json/type/generic_default.rs @@ -9,25 +9,25 @@ pub enum Result<T, E> { // @set my_error = "$.index[*][?(@.name=='MyError')].id" pub struct MyError {} -// @is "$.index[*][?(@.name=='MyResult')].kind" \"typedef\" -// @count "$.index[*][?(@.name=='MyResult')].inner.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[*]" 2 -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].name" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].name" \"E\" -// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type" -// @has "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type" -// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.bounds[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.bounds[*]" 0 -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[0].kind.type.default" null -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.kind" \"resolved_path\" -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.id" $my_error -// @is "$.index[*][?(@.name=='MyResult')].inner.generics.params[1].kind.type.default.inner.name" \"MyError\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.kind" \"resolved_path\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.id" $result -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.name" \"Result\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.bindings" [] -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.kind" \"generic\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.kind" \"generic\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[0].type.inner" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.type.inner.args.angle_bracketed.args[1].type.inner" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef" +// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[*]" 2 +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].name" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type" +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type" +// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.bounds[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.bounds[*]" 0 +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.default" null +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.id" $my_error +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.name" \"MyError\" +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.id" $result +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.name" \"Result\" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" +// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" \"E\" pub type MyResult<T, E = MyError> = Result<T, E>; diff --git a/tests/rustdoc-json/type/hrtb.rs b/tests/rustdoc-json/type/hrtb.rs index 2c4ee00d4..f7ac878ce 100644 --- a/tests/rustdoc-json/type/hrtb.rs +++ b/tests/rustdoc-json/type/hrtb.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength -// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.type" '{"inner": "F","kind": "generic"}' -// @is "$.index[*][?(@.name=='genfn')].inner.generics.where_predicates[0].bound_predicate.generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='genfn')].inner.function.generics.where_predicates[0].bound_predicate.type" '{"generic": "F"}' +// @is "$.index[*][?(@.name=='genfn')].inner.function.generics.where_predicates[0].bound_predicate.generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' pub fn genfn<F>(f: F) where for<'a, 'b> F: Fn(&'a i32, &'b i32), @@ -10,14 +10,12 @@ where f(&zero, &zero); } -// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' -// @is "$.index[*][?(@.name=='dynfn')].inner.generics" '{"params": [], "where_predicates": []}' -// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].kind" '"borrowed_ref"' -// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.kind" '"dyn_trait"' -// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.lifetime" null -// @count "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[*]" 1 -// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' -// @is "$.index[*][?(@.name=='dynfn')].inner.decl.inputs[0][1].inner.type.inner.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='dynfn')].inner.function.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.function.generics" '{"params": [], "where_predicates": []}' +// @is "$.index[*][?(@.name=='dynfn')].inner.function.decl.inputs[0][1].borrowed_ref.type.dyn_trait.lifetime" null +// @count "$.index[*][?(@.name=='dynfn')].inner.function.decl.inputs[0][1].borrowed_ref.type.dyn_trait.traits[*]" 1 +// @is "$.index[*][?(@.name=='dynfn')].inner.function.decl.inputs[0][1].borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"},{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='dynfn')].inner.function.decl.inputs[0][1].borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' pub fn dynfn(f: &dyn for<'a, 'b> Fn(&'a i32, &'b i32)) { let zero = 0; f(&zero, &zero); diff --git a/tests/rustdoc-json/type/inherent_associated_type.rs b/tests/rustdoc-json/type/inherent_associated_type.rs new file mode 100644 index 000000000..64c6c53ce --- /dev/null +++ b/tests/rustdoc-json/type/inherent_associated_type.rs @@ -0,0 +1,26 @@ +// ignore-tidy-linelength +#![feature(inherent_associated_types)] +#![feature(no_core)] +#![allow(incomplete_features)] +#![no_core] + +// @set OwnerMetadata = '$.index[*][?(@.name=="OwnerMetadata")].id' +pub struct OwnerMetadata; +// @set Owner = '$.index[*][?(@.name=="Owner")].id' +pub struct Owner; + +pub fn create() -> Owner::Metadata { + OwnerMetadata +} +// @is '$.index[*][?(@.name=="create")].inner.function.decl.output.qualified_path.name' '"Metadata"' +// @is '$.index[*][?(@.name=="create")].inner.function.decl.output.qualified_path.trait' null +// @is '$.index[*][?(@.name=="create")].inner.function.decl.output.qualified_path.self_type.resolved_path.id' $Owner + +/// impl +impl Owner { + /// iat + pub type Metadata = OwnerMetadata; +} +// @set iat = '$.index[*][?(@.docs=="iat")].id' +// @is '$.index[*][?(@.docs=="impl")].inner.impl.items[*]' $iat +// @is '$.index[*][?(@.docs=="iat")].inner.assoc_type.default.resolved_path.id' $OwnerMetadata diff --git a/tests/rustdoc-json/type/inherent_associated_type_bound.rs b/tests/rustdoc-json/type/inherent_associated_type_bound.rs new file mode 100644 index 000000000..2e9b13d0c --- /dev/null +++ b/tests/rustdoc-json/type/inherent_associated_type_bound.rs @@ -0,0 +1,19 @@ +// ignore-tidy-linelength +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// @set Carrier = '$.index[*][?(@.name=="Carrier")].id' +pub struct Carrier<'a>(&'a ()); + +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.generic_params[*].name' \""'b"\" +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\" +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"' +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.trait' null +// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"' + +pub type User = for<'b> fn(Carrier<'b>::Focus<i32>); + +impl<'a> Carrier<'a> { + pub type Focus<T> = &'a mut T; +} diff --git a/tests/rustdoc-json/type/inherent_associated_type_projections.rs b/tests/rustdoc-json/type/inherent_associated_type_projections.rs new file mode 100644 index 000000000..942e323ef --- /dev/null +++ b/tests/rustdoc-json/type/inherent_associated_type_projections.rs @@ -0,0 +1,32 @@ +// ignore-tidy-linelength +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// @set Parametrized = '$.index[*][?(@.name=="Parametrized")].id' +pub struct Parametrized<T>(T); + +// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.id' $Parametrized +// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\" +// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.name' '"Proj"' +// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.trait' null +pub type Test = Parametrized<i32>::Proj; + +/// param_bool +impl Parametrized<bool> { + /// param_bool_proj + pub type Proj = (); +} + +/// param_i32 +impl Parametrized<i32> { + /// param_i32_proj + pub type Proj = String; +} + +// @set param_bool = '$.index[*][?(@.docs=="param_bool")].id' +// @set param_i32 = '$.index[*][?(@.docs=="param_i32")].id' +// @set param_bool_proj = '$.index[*][?(@.docs=="param_bool_proj")].id' +// @set param_i32_proj = '$.index[*][?(@.docs=="param_i32_proj")].id' + +// @is '$.index[*][?(@.docs=="param_bool")].inner.impl.items[*]' $param_bool_proj +// @is '$.index[*][?(@.docs=="param_i32")].inner.impl.items[*]' $param_i32_proj diff --git a/tests/rustdoc-json/unions/impl.rs b/tests/rustdoc-json/unions/impl.rs index 4454a69ec..7456892df 100644 --- a/tests/rustdoc-json/unions/impl.rs +++ b/tests/rustdoc-json/unions/impl.rs @@ -1,15 +1,15 @@ #![no_std] // @is "$.index[*][?(@.name=='Ux')].visibility" \"public\" -// @is "$.index[*][?(@.name=='Ux')].kind" \"union\" +// @has "$.index[*][?(@.name=='Ux')].inner.union" pub union Ux { a: u32, b: u64 } // @is "$.index[*][?(@.name=='Num')].visibility" \"public\" -// @is "$.index[*][?(@.name=='Num')].kind" \"trait\" +// @has "$.index[*][?(@.name=='Num')].inner.trait" pub trait Num {} -// @count "$.index[*][?(@.name=='Ux')].inner.impls" 1 +// @count "$.index[*][?(@.name=='Ux')].inner.union.impls" 1 impl Num for Ux {} diff --git a/tests/rustdoc-json/unions/union.rs b/tests/rustdoc-json/unions/union.rs index c9df2b81c..22b70e1ce 100644 --- a/tests/rustdoc-json/unions/union.rs +++ b/tests/rustdoc-json/unions/union.rs @@ -1,6 +1,6 @@ // @has "$.index[*][?(@.name=='Union')].visibility" \"public\" -// @has "$.index[*][?(@.name=='Union')].kind" \"union\" -// @!has "$.index[*][?(@.name=='Union')].inner.struct_type" +// @has "$.index[*][?(@.name=='Union')].inner.union" +// @!has "$.index[*][?(@.name=='Union')].inner.union.struct_type" // @set Union = "$.index[*][?(@.name=='Union')].id" pub union Union { int: i32, @@ -8,8 +8,8 @@ pub union Union { } -// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.kind" '"resolved_path"' -// @is "$.index[*][?(@.name=='make_int_union')].inner.decl.output.inner.id" $Union +// @has "$.index[*][?(@.name=='make_int_union')].inner.function.decl.output.resolved_path" +// @is "$.index[*][?(@.name=='make_int_union')].inner.function.decl.output.resolved_path.id" $Union pub fn make_int_union(int: i32) -> Union { Union { int } } diff --git a/tests/rustdoc-ui/check-cfg-test.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr index 9770be2f1..9770be2f1 100644 --- a/tests/rustdoc-ui/check-cfg-test.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr diff --git a/tests/rustdoc-ui/check-cfg-unstable.rs b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs index 5c500ce6c..5c500ce6c 100644 --- a/tests/rustdoc-ui/check-cfg-unstable.rs +++ b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs diff --git a/tests/rustdoc-ui/check-cfg-unstable.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr index 9b27c2bc0..9b27c2bc0 100644 --- a/tests/rustdoc-ui/check-cfg-unstable.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr diff --git a/tests/rustdoc-ui/check-cfg.rs b/tests/rustdoc-ui/check-cfg/check-cfg.rs index fa8789ad3..fa8789ad3 100644 --- a/tests/rustdoc-ui/check-cfg.rs +++ b/tests/rustdoc-ui/check-cfg/check-cfg.rs diff --git a/tests/rustdoc-ui/check-cfg.stderr b/tests/rustdoc-ui/check-cfg/check-cfg.stderr index 1db8e1d91..03fb6f96f 100644 --- a/tests/rustdoc-ui/check-cfg.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg.stderr @@ -2,7 +2,7 @@ warning: unexpected `cfg` condition name --> $DIR/check-cfg.rs:5:7 | LL | #[cfg(uniz)] - | ^^^^ help: did you mean: `unix` + | ^^^^ help: there is a config with a similar name: `unix` | = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/rustdoc-ui/auxiliary/extern_macros.rs b/tests/rustdoc-ui/doctest/auxiliary/extern_macros.rs index ee1fec4c5..ee1fec4c5 100644 --- a/tests/rustdoc-ui/auxiliary/extern_macros.rs +++ b/tests/rustdoc-ui/doctest/auxiliary/extern_macros.rs diff --git a/tests/rustdoc-ui/block-doc-comment.rs b/tests/rustdoc-ui/doctest/block-doc-comment.rs index ce529916e..ce529916e 100644 --- a/tests/rustdoc-ui/block-doc-comment.rs +++ b/tests/rustdoc-ui/doctest/block-doc-comment.rs diff --git a/tests/rustdoc-ui/block-doc-comment.stdout b/tests/rustdoc-ui/doctest/block-doc-comment.stdout index 7326c0a25..7326c0a25 100644 --- a/tests/rustdoc-ui/block-doc-comment.stdout +++ b/tests/rustdoc-ui/doctest/block-doc-comment.stdout diff --git a/tests/rustdoc-ui/cfg-test.rs b/tests/rustdoc-ui/doctest/cfg-test.rs index d40b92837..a263baa97 100644 --- a/tests/rustdoc-ui/cfg-test.rs +++ b/tests/rustdoc-ui/doctest/cfg-test.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test --test-args --test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // Crates like core have doctests gated on `cfg(not(test))` so we need to make diff --git a/tests/rustdoc-ui/cfg-test.stdout b/tests/rustdoc-ui/doctest/cfg-test.stdout index 2960ff8d3..2960ff8d3 100644 --- a/tests/rustdoc-ui/cfg-test.stdout +++ b/tests/rustdoc-ui/doctest/cfg-test.stdout diff --git a/tests/rustdoc-ui/check-attr-test.rs b/tests/rustdoc-ui/doctest/check-attr-test.rs index e95547014..e95547014 100644 --- a/tests/rustdoc-ui/check-attr-test.rs +++ b/tests/rustdoc-ui/doctest/check-attr-test.rs diff --git a/tests/rustdoc-ui/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr index 01beba1ff..01beba1ff 100644 --- a/tests/rustdoc-ui/check-attr-test.stderr +++ b/tests/rustdoc-ui/doctest/check-attr-test.stderr diff --git a/tests/rustdoc-ui/check-cfg-test.rs b/tests/rustdoc-ui/doctest/check-cfg-test.rs index 920432276..49a801c3f 100644 --- a/tests/rustdoc-ui/check-cfg-test.rs +++ b/tests/rustdoc-ui/doctest/check-cfg-test.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options -// normalize-stderr-test: "tests/rustdoc-ui" -> "$$DIR" -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// The doctest will produce a warning because feature invalid is unexpected diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr new file mode 100644 index 000000000..f84543c20 --- /dev/null +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -0,0 +1,11 @@ +warning: unexpected `cfg` condition value + --> $DIR/check-cfg-test.rs:9:7 + | +LL | #[cfg(feature = "invalid")] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `test` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/check-cfg-test.stdout b/tests/rustdoc-ui/doctest/check-cfg-test.stdout index b7db49bcf..b7db49bcf 100644 --- a/tests/rustdoc-ui/check-cfg-test.stdout +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stdout diff --git a/tests/rustdoc-ui/display-output.rs b/tests/rustdoc-ui/doctest/display-output.rs index 23bc54e3c..7a26dbff9 100644 --- a/tests/rustdoc-ui/display-output.rs +++ b/tests/rustdoc-ui/doctest/display-output.rs @@ -3,7 +3,7 @@ // check-pass // edition:2018 // compile-flags:--test --test-args=--show-output -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/display-output.stdout b/tests/rustdoc-ui/doctest/display-output.stdout index ad25d1ce5..ad25d1ce5 100644 --- a/tests/rustdoc-ui/display-output.stdout +++ b/tests/rustdoc-ui/doctest/display-output.stdout diff --git a/tests/rustdoc-ui/doc-comment-multi-line-attr.rs b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.rs index db674e229..75508f435 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-attr.rs +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.rs @@ -1,6 +1,6 @@ // Regression test for #97440: Multiline inner attribute triggers ICE during doctest // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doc-comment-multi-line-attr.stdout b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.stdout index e47edbd2a..e47edbd2a 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-attr.stdout +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.stdout diff --git a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.rs b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.rs index 6ce3cb9fc..3b0b27edb 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.rs +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.rs @@ -1,5 +1,5 @@ // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.stdout b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.stdout index bf3521e4f..bf3521e4f 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.stdout +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.stdout diff --git a/tests/rustdoc-ui/doc-test-attr-pass.rs b/tests/rustdoc-ui/doctest/doc-test-attr-pass.rs index 12608f244..12608f244 100644 --- a/tests/rustdoc-ui/doc-test-attr-pass.rs +++ b/tests/rustdoc-ui/doctest/doc-test-attr-pass.rs diff --git a/tests/rustdoc-ui/doc-test-attr.rs b/tests/rustdoc-ui/doctest/doc-test-attr.rs index 46178ad86..46178ad86 100644 --- a/tests/rustdoc-ui/doc-test-attr.rs +++ b/tests/rustdoc-ui/doctest/doc-test-attr.rs diff --git a/tests/rustdoc-ui/doc-test-attr.stderr b/tests/rustdoc-ui/doctest/doc-test-attr.stderr index 5e6014954..5e6014954 100644 --- a/tests/rustdoc-ui/doc-test-attr.stderr +++ b/tests/rustdoc-ui/doctest/doc-test-attr.stderr diff --git a/tests/rustdoc-ui/doc-test-doctest-feature.rs b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.rs index 88cf44e64..9c1f4936e 100644 --- a/tests/rustdoc-ui/doc-test-doctest-feature.rs +++ b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // Make sure `cfg(doctest)` is set when finding doctests but not inside diff --git a/tests/rustdoc-ui/doc-test-doctest-feature.stdout b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.stdout index d7de1f105..d7de1f105 100644 --- a/tests/rustdoc-ui/doc-test-doctest-feature.stdout +++ b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.stdout diff --git a/tests/rustdoc-ui/doc-test-rustdoc-feature.rs b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs index dc72a4857..1f90d13af 100644 --- a/tests/rustdoc-ui/doc-test-rustdoc-feature.rs +++ b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" #![feature(doc_cfg)] diff --git a/tests/rustdoc-ui/doc-test-rustdoc-feature.stdout b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout index 5b07fc4c8..5b07fc4c8 100644 --- a/tests/rustdoc-ui/doc-test-rustdoc-feature.stdout +++ b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout diff --git a/tests/rustdoc-ui/doctest-edition.rs b/tests/rustdoc-ui/doctest/doctest-edition.rs index b0787be97..b0787be97 100644 --- a/tests/rustdoc-ui/doctest-edition.rs +++ b/tests/rustdoc-ui/doctest/doctest-edition.rs diff --git a/tests/rustdoc-ui/doctest-edition.stderr b/tests/rustdoc-ui/doctest/doctest-edition.stderr index 8a3329aa3..8a3329aa3 100644 --- a/tests/rustdoc-ui/doctest-edition.stderr +++ b/tests/rustdoc-ui/doctest/doctest-edition.stderr diff --git a/tests/rustdoc-ui/doctest-multiline-crate-attribute.rs b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.rs index 260f5a7a6..a3bde6cb9 100644 --- a/tests/rustdoc-ui/doctest-multiline-crate-attribute.rs +++ b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.rs @@ -1,5 +1,5 @@ // compile-flags:--test --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doctest-multiline-crate-attribute.stdout b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.stdout index 07a4f657d..07a4f657d 100644 --- a/tests/rustdoc-ui/doctest-multiline-crate-attribute.stdout +++ b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.stdout diff --git a/tests/rustdoc-ui/doctest-output.rs b/tests/rustdoc-ui/doctest/doctest-output.rs index 303f76896..26754b73f 100644 --- a/tests/rustdoc-ui/doctest-output.rs +++ b/tests/rustdoc-ui/doctest/doctest-output.rs @@ -1,7 +1,7 @@ // edition:2018 // aux-build:extern_macros.rs // compile-flags:--test --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doctest-output.stdout b/tests/rustdoc-ui/doctest/doctest-output.stdout index 35b0e366f..35b0e366f 100644 --- a/tests/rustdoc-ui/doctest-output.stdout +++ b/tests/rustdoc-ui/doctest/doctest-output.stdout diff --git a/tests/rustdoc-ui/failed-doctest-compile-fail.rs b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.rs index 4dfca600f..53b3857df 100644 --- a/tests/rustdoc-ui/failed-doctest-compile-fail.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-compile-fail.stdout b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.stdout index af3a90a74..af3a90a74 100644 --- a/tests/rustdoc-ui/failed-doctest-compile-fail.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.stdout diff --git a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs index 03a5b9d5d..84e4d6160 100644 --- a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.stdout b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout index 61468b6c7..61468b6c7 100644 --- a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout diff --git a/tests/rustdoc-ui/failed-doctest-missing-codes.rs b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.rs index 66a229a0c..4e3b848fc 100644 --- a/tests/rustdoc-ui/failed-doctest-missing-codes.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-missing-codes.stdout b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.stdout index bacbb47b5..bacbb47b5 100644 --- a/tests/rustdoc-ui/failed-doctest-missing-codes.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.stdout diff --git a/tests/rustdoc-ui/failed-doctest-output-windows.rs b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.rs index 456a9e68f..6bc6c33c7 100644 --- a/tests/rustdoc-ui/failed-doctest-output-windows.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.rs @@ -7,7 +7,7 @@ // compile-flags:--test --test-args --test-threads=1 // rustc-env:RUST_BACKTRACE=0 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-output-windows.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout index 6c147054d..6c147054d 100644 --- a/tests/rustdoc-ui/failed-doctest-output-windows.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout diff --git a/tests/rustdoc-ui/failed-doctest-output.rs b/tests/rustdoc-ui/doctest/failed-doctest-output.rs index 77647f8ec..3e1312382 100644 --- a/tests/rustdoc-ui/failed-doctest-output.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.rs @@ -7,7 +7,7 @@ // compile-flags:--test --test-args --test-threads=1 // rustc-env:RUST_BACKTRACE=0 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-output.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout index 630198a56..630198a56 100644 --- a/tests/rustdoc-ui/failed-doctest-output.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout diff --git a/tests/rustdoc-ui/failed-doctest-should-panic.rs b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs index c134f8006..36284e814 100644 --- a/tests/rustdoc-ui/failed-doctest-should-panic.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-should-panic.stdout b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout index 57a20092a..57a20092a 100644 --- a/tests/rustdoc-ui/failed-doctest-should-panic.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout diff --git a/tests/rustdoc-ui/no-run-flag-error.rs b/tests/rustdoc-ui/doctest/no-run-flag-error.rs index 4ead62148..4ead62148 100644 --- a/tests/rustdoc-ui/no-run-flag-error.rs +++ b/tests/rustdoc-ui/doctest/no-run-flag-error.rs diff --git a/tests/rustdoc-ui/no-run-flag-error.stderr b/tests/rustdoc-ui/doctest/no-run-flag-error.stderr index d032646c3..d032646c3 100644 --- a/tests/rustdoc-ui/no-run-flag-error.stderr +++ b/tests/rustdoc-ui/doctest/no-run-flag-error.stderr diff --git a/tests/rustdoc-ui/no-run-flag.rs b/tests/rustdoc-ui/doctest/no-run-flag.rs index 181730eb4..1cf3b7c4b 100644 --- a/tests/rustdoc-ui/no-run-flag.rs +++ b/tests/rustdoc-ui/doctest/no-run-flag.rs @@ -2,7 +2,7 @@ // check-pass // compile-flags:-Z unstable-options --test --no-run --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/no-run-flag.stdout b/tests/rustdoc-ui/doctest/no-run-flag.stdout index 02f28aaf6..02f28aaf6 100644 --- a/tests/rustdoc-ui/no-run-flag.stdout +++ b/tests/rustdoc-ui/doctest/no-run-flag.stdout diff --git a/tests/rustdoc-ui/nocapture-fail.rs b/tests/rustdoc-ui/doctest/nocapture-fail.rs index 9a3fb592c..ce487a43d 100644 --- a/tests/rustdoc-ui/nocapture-fail.rs +++ b/tests/rustdoc-ui/doctest/nocapture-fail.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags:--test -Zunstable-options --nocapture -// normalize-stderr-test: "tests/rustdoc-ui" -> "$$DIR" -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ```compile_fail diff --git a/tests/rustdoc-ui/nocapture-fail.stderr b/tests/rustdoc-ui/doctest/nocapture-fail.stderr index b65b622c1..b65b622c1 100644 --- a/tests/rustdoc-ui/nocapture-fail.stderr +++ b/tests/rustdoc-ui/doctest/nocapture-fail.stderr diff --git a/tests/rustdoc-ui/nocapture-fail.stdout b/tests/rustdoc-ui/doctest/nocapture-fail.stdout index 754f77db5..754f77db5 100644 --- a/tests/rustdoc-ui/nocapture-fail.stdout +++ b/tests/rustdoc-ui/doctest/nocapture-fail.stdout diff --git a/tests/rustdoc-ui/nocapture.rs b/tests/rustdoc-ui/doctest/nocapture.rs index 3eb38f2fb..25fbcf857 100644 --- a/tests/rustdoc-ui/nocapture.rs +++ b/tests/rustdoc-ui/doctest/nocapture.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -Zunstable-options --nocapture -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/nocapture.stderr b/tests/rustdoc-ui/doctest/nocapture.stderr index af6415db3..af6415db3 100644 --- a/tests/rustdoc-ui/nocapture.stderr +++ b/tests/rustdoc-ui/doctest/nocapture.stderr diff --git a/tests/rustdoc-ui/nocapture.stdout b/tests/rustdoc-ui/doctest/nocapture.stdout index 4880e75da..4880e75da 100644 --- a/tests/rustdoc-ui/nocapture.stdout +++ b/tests/rustdoc-ui/doctest/nocapture.stdout diff --git a/tests/rustdoc-ui/private-doc-test.rs b/tests/rustdoc-ui/doctest/private-doc-test.rs index a1f9f8dca..a1f9f8dca 100644 --- a/tests/rustdoc-ui/private-doc-test.rs +++ b/tests/rustdoc-ui/doctest/private-doc-test.rs diff --git a/tests/rustdoc-ui/private-item-doc-test.rs b/tests/rustdoc-ui/doctest/private-item-doc-test.rs index 1a3d6cc63..1a3d6cc63 100644 --- a/tests/rustdoc-ui/private-item-doc-test.rs +++ b/tests/rustdoc-ui/doctest/private-item-doc-test.rs diff --git a/tests/rustdoc-ui/private-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr index 5df613298..5df613298 100644 --- a/tests/rustdoc-ui/private-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr diff --git a/tests/rustdoc-ui/private-public-item-doc-test.rs b/tests/rustdoc-ui/doctest/private-public-item-doc-test.rs index 7cc62b38c..7cc62b38c 100644 --- a/tests/rustdoc-ui/private-public-item-doc-test.rs +++ b/tests/rustdoc-ui/doctest/private-public-item-doc-test.rs diff --git a/tests/rustdoc-ui/private-public-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr index f50dbd184..f50dbd184 100644 --- a/tests/rustdoc-ui/private-public-item-doc-test.stderr +++ b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr diff --git a/tests/rustdoc-ui/public-reexported-item-doc-test.rs b/tests/rustdoc-ui/doctest/public-reexported-item-doc-test.rs index b86a53305..b86a53305 100644 --- a/tests/rustdoc-ui/public-reexported-item-doc-test.rs +++ b/tests/rustdoc-ui/doctest/public-reexported-item-doc-test.rs diff --git a/tests/rustdoc-ui/run-directory.correct.stdout b/tests/rustdoc-ui/doctest/run-directory.correct.stdout index e9b275479..e9b275479 100644 --- a/tests/rustdoc-ui/run-directory.correct.stdout +++ b/tests/rustdoc-ui/doctest/run-directory.correct.stdout diff --git a/tests/rustdoc-ui/run-directory.incorrect.stdout b/tests/rustdoc-ui/doctest/run-directory.incorrect.stdout index 97a5dbc5c..97a5dbc5c 100644 --- a/tests/rustdoc-ui/run-directory.incorrect.stdout +++ b/tests/rustdoc-ui/doctest/run-directory.incorrect.stdout diff --git a/tests/rustdoc-ui/run-directory.rs b/tests/rustdoc-ui/doctest/run-directory.rs index b8d0647f0..1ff0af2d1 100644 --- a/tests/rustdoc-ui/run-directory.rs +++ b/tests/rustdoc-ui/doctest/run-directory.rs @@ -4,12 +4,12 @@ // check-pass // [correct]compile-flags:--test --test-run-directory={{src-base}} // [incorrect]compile-flags:--test --test-run-directory={{src-base}}/coverage -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` /// assert_eq!( -/// std::fs::read_to_string("run-directory.rs").unwrap(), +/// std::fs::read_to_string("doctest/run-directory.rs").unwrap(), /// include_str!("run-directory.rs"), /// ); /// ``` @@ -17,7 +17,7 @@ pub fn foo() {} /// ``` -/// assert!(std::fs::read_to_string("run-directory.rs").is_err()); +/// assert!(std::fs::read_to_string("doctest/run-directory.rs").is_err()); /// ``` #[cfg(incorrect)] pub fn foo() {} diff --git a/tests/rustdoc-ui/test-compile-fail1.rs b/tests/rustdoc-ui/doctest/test-compile-fail1.rs index a05390238..a05390238 100644 --- a/tests/rustdoc-ui/test-compile-fail1.rs +++ b/tests/rustdoc-ui/doctest/test-compile-fail1.rs diff --git a/tests/rustdoc-ui/test-compile-fail1.stderr b/tests/rustdoc-ui/doctest/test-compile-fail1.stderr index 72915e46b..72915e46b 100644 --- a/tests/rustdoc-ui/test-compile-fail1.stderr +++ b/tests/rustdoc-ui/doctest/test-compile-fail1.stderr diff --git a/tests/rustdoc-ui/test-compile-fail2.rs b/tests/rustdoc-ui/doctest/test-compile-fail2.rs index 651ded0a0..651ded0a0 100644 --- a/tests/rustdoc-ui/test-compile-fail2.rs +++ b/tests/rustdoc-ui/doctest/test-compile-fail2.rs diff --git a/tests/rustdoc-ui/test-compile-fail2.stderr b/tests/rustdoc-ui/doctest/test-compile-fail2.stderr index cee5b63cf..cee5b63cf 100644 --- a/tests/rustdoc-ui/test-compile-fail2.stderr +++ b/tests/rustdoc-ui/doctest/test-compile-fail2.stderr diff --git a/tests/rustdoc-ui/test-compile-fail3.rs b/tests/rustdoc-ui/doctest/test-compile-fail3.rs index faa30ad83..faa30ad83 100644 --- a/tests/rustdoc-ui/test-compile-fail3.rs +++ b/tests/rustdoc-ui/doctest/test-compile-fail3.rs diff --git a/tests/rustdoc-ui/test-compile-fail3.stderr b/tests/rustdoc-ui/doctest/test-compile-fail3.stderr index fab801b3b..fab801b3b 100644 --- a/tests/rustdoc-ui/test-compile-fail3.stderr +++ b/tests/rustdoc-ui/doctest/test-compile-fail3.stderr diff --git a/tests/rustdoc-ui/test-no_std.rs b/tests/rustdoc-ui/doctest/test-no_std.rs index 51abf1c72..fd651d1a3 100644 --- a/tests/rustdoc-ui/test-no_std.rs +++ b/tests/rustdoc-ui/doctest/test-no_std.rs @@ -1,5 +1,5 @@ // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/test-no_std.stdout b/tests/rustdoc-ui/doctest/test-no_std.stdout index 8d5a30804..8d5a30804 100644 --- a/tests/rustdoc-ui/test-no_std.stdout +++ b/tests/rustdoc-ui/doctest/test-no_std.stdout diff --git a/tests/rustdoc-ui/test-type.rs b/tests/rustdoc-ui/doctest/test-type.rs index 7f5a8f3fc..036d37f9d 100644 --- a/tests/rustdoc-ui/test-type.rs +++ b/tests/rustdoc-ui/doctest/test-type.rs @@ -1,6 +1,6 @@ // compile-flags: --test --test-args=--test-threads=1 // check-pass -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/test-type.stdout b/tests/rustdoc-ui/doctest/test-type.stdout index a66fd240d..a66fd240d 100644 --- a/tests/rustdoc-ui/test-type.stdout +++ b/tests/rustdoc-ui/doctest/test-type.stdout diff --git a/tests/rustdoc-ui/unparseable-doc-test.rs b/tests/rustdoc-ui/doctest/unparseable-doc-test.rs index f0a56a91b..fd8b2094d 100644 --- a/tests/rustdoc-ui/unparseable-doc-test.rs +++ b/tests/rustdoc-ui/doctest/unparseable-doc-test.rs @@ -1,5 +1,5 @@ // compile-flags: --test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 // rustc-env: RUST_BACKTRACE=0 diff --git a/tests/rustdoc-ui/unparseable-doc-test.stdout b/tests/rustdoc-ui/doctest/unparseable-doc-test.stdout index 2641c66f2..2641c66f2 100644 --- a/tests/rustdoc-ui/unparseable-doc-test.stdout +++ b/tests/rustdoc-ui/doctest/unparseable-doc-test.stdout diff --git a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs new file mode 100644 index 000000000..e49fe0798 --- /dev/null +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs @@ -0,0 +1,9 @@ +// check-pass + +pub fn f() -> impl Sized { + pub enum E { + V(E), + } + + unimplemented!() +} diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-impl-trait-return.rs index 939da186f..939da186f 100644 --- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-impl-trait-return.rs diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-impl-trait-return.stderr index aff7402bc..aff7402bc 100644 --- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-impl-trait-return.stderr diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs index ac5172574..096130d77 100644 --- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs @@ -1,6 +1,9 @@ +// check-pass + fn f() -> impl Sized { - enum E { //~ ERROR + enum E { V(E), } + unimplemented!() } diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.rs index 87620d74e..87620d74e 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.rs +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.stderr index a8ddf91bc..a8ddf91bc 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.stderr +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.stderr diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.rs index 8f4f561b4..8f4f561b4 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt.rs +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.stderr index 4c8c607e7..4c8c607e7 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt.stderr +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.stderr diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt2.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.rs index da5142087..da5142087 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt2.rs +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt2.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.stderr index 4c8c607e7..4c8c607e7 100644 --- a/tests/rustdoc-ui/generate-link-to-definition-opt2.stderr +++ b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.stderr diff --git a/tests/rustdoc-ui/ice-bug-report-url.rs b/tests/rustdoc-ui/ice-bug-report-url.rs new file mode 100644 index 000000000..8ede91cf8 --- /dev/null +++ b/tests/rustdoc-ui/ice-bug-report-url.rs @@ -0,0 +1,14 @@ +// compile-flags: -Ztreat-err-as-bug +// failure-status: 101 +// error-pattern: aborting due to +// error-pattern: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md + +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*" -> "note: rustc {version} running on {platform}" +// normalize-stderr-test "thread.*panicked at .*, compiler.*" -> "thread panicked at 'aborting due to `-Z treat-err-as-bug`'" +// normalize-stderr-test " +\d{1,}: .*\n" -> "" +// normalize-stderr-test " + at .*\n" -> "" +// normalize-stderr-test ".*note: Some details are omitted.*\n" -> "" + +fn wrong() +//~^ ERROR expected one of diff --git a/tests/rustdoc-ui/ice-bug-report-url.stderr b/tests/rustdoc-ui/ice-bug-report-url.stderr new file mode 100644 index 000000000..98c08b9a8 --- /dev/null +++ b/tests/rustdoc-ui/ice-bug-report-url.stderr @@ -0,0 +1,17 @@ +error: expected one of `->`, `where`, or `{`, found `<eof>` + --> $DIR/ice-bug-report-url.rs:13:10 + | +LL | fn wrong() + | ^ expected one of `->`, `where`, or `{` + +thread panicked at 'aborting due to `-Z treat-err-as-bug`' +stack backtrace: + +error: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md + +note: rustc {version} running on {platform} + +query stack during panic: +end of query stack diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr b/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr deleted file mode 100644 index a61577bd1..000000000 --- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0072]: recursive type `f::E` has infinite size - --> $DIR/infinite-recursive-type-impl-trait.rs:2:5 - | -LL | enum E { - | ^^^^^^ -LL | V(E), - | - recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | V(Box<E>), - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/rustdoc-ui/assoc-item-not-in-scope.rs b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.rs index 0976515f4..0976515f4 100644 --- a/tests/rustdoc-ui/assoc-item-not-in-scope.rs +++ b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.rs diff --git a/tests/rustdoc-ui/assoc-item-not-in-scope.stderr b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.stderr index 04594ad41..04594ad41 100644 --- a/tests/rustdoc-ui/assoc-item-not-in-scope.stderr +++ b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.stderr diff --git a/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs b/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs deleted file mode 100644 index 6c48f5aa0..000000000 --- a/tests/rustdoc-ui/intra-doc/auxiliary/inner-crate-enum.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub enum O { - L = -1, -} diff --git a/tests/rustdoc-ui/deny-intra-link-resolution-failure.rs b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.rs index 09da124b1..09da124b1 100644 --- a/tests/rustdoc-ui/deny-intra-link-resolution-failure.rs +++ b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.rs diff --git a/tests/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.stderr index 3e08354a6..3e08354a6 100644 --- a/tests/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.stderr diff --git a/tests/rustdoc-ui/intra-doc/inline-external-enum.rs b/tests/rustdoc-ui/intra-doc/inline-external-enum.rs deleted file mode 100644 index 363dd7f64..000000000 --- a/tests/rustdoc-ui/intra-doc/inline-external-enum.rs +++ /dev/null @@ -1,8 +0,0 @@ -// check-pass -// aux-build: inner-crate-enum.rs -// compile-flags:-Z unstable-options --output-format json - -#[doc(inline)] -pub extern crate inner_crate_enum; - -fn main() {} diff --git a/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.rs b/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.rs new file mode 100644 index 000000000..ef9c56f75 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.rs @@ -0,0 +1,6 @@ +// this test used to ICE +#![deny(rustdoc::broken_intra_doc_links)] +//! [Clone ()]. //~ ERROR unresolved +//! [Clone !]. //~ ERROR incompatible +//! [`Clone ()`]. //~ ERROR unresolved +//! [`Clone !`]. //~ ERROR incompatible diff --git a/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.stderr b/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.stderr new file mode 100644 index 000000000..6c834fd0a --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-110495-suffix-with-space.stderr @@ -0,0 +1,55 @@ +error: unresolved link to `Clone` + --> $DIR/issue-110495-suffix-with-space.rs:3:6 + | +LL | //! [Clone ()]. + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +note: the lint level is defined here + --> $DIR/issue-110495-suffix-with-space.rs:2:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the trait, prefix with `trait@` + | +LL - //! [Clone ()]. +LL + //! [trait@Clone ]. + | + +error: incompatible link kind for `Clone` + --> $DIR/issue-110495-suffix-with-space.rs:4:6 + | +LL | //! [Clone !]. + | ^^^^^^^ this link resolved to a derive macro, which is not a macro + | +help: to link to the derive macro, prefix with `derive@` + | +LL - //! [Clone !]. +LL + //! [derive@Clone ]. + | + +error: unresolved link to `Clone` + --> $DIR/issue-110495-suffix-with-space.rs:5:7 + | +LL | //! [`Clone ()`]. + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - //! [`Clone ()`]. +LL + //! [`trait@Clone `]. + | + +error: incompatible link kind for `Clone` + --> $DIR/issue-110495-suffix-with-space.rs:6:7 + | +LL | //! [`Clone !`]. + | ^^^^^^^ this link resolved to a derive macro, which is not a macro + | +help: to link to the derive macro, prefix with `derive@` + | +LL - //! [`Clone !`]. +LL + //! [`derive@Clone `]. + | + +error: aborting due to 4 previous errors + diff --git a/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.rs b/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.rs new file mode 100644 index 000000000..4e74278dc --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.rs @@ -0,0 +1,10 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/111189>. +// This test ensures that it doesn't crash. + +#![deny(warnings)] + +/// #[rustfmt::skip] +//~^ ERROR unresolved link to `rustfmt::skip` +/// #[clippy::whatever] +//~^ ERROR unresolved link to `clippy::whatever` +pub fn foo() {} diff --git a/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.stderr b/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.stderr new file mode 100644 index 000000000..edd3dfa7d --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/issue-111189-resolution-ice.stderr @@ -0,0 +1,21 @@ +error: unresolved link to `rustfmt::skip` + --> $DIR/issue-111189-resolution-ice.rs:6:7 + | +LL | /// #[rustfmt::skip] + | ^^^^^^^^^^^^^ no item named `rustfmt` in scope + | +note: the lint level is defined here + --> $DIR/issue-111189-resolution-ice.rs:4:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]` + +error: unresolved link to `clippy::whatever` + --> $DIR/issue-111189-resolution-ice.rs:8:7 + | +LL | /// #[clippy::whatever] + | ^^^^^^^^^^^^^^^^ no item named `clippy` in scope + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/pub-export-lint.rs b/tests/rustdoc-ui/intra-doc/pub-export-lint.rs index f2e66b77b..f2e66b77b 100644 --- a/tests/rustdoc-ui/pub-export-lint.rs +++ b/tests/rustdoc-ui/intra-doc/pub-export-lint.rs diff --git a/tests/rustdoc-ui/pub-export-lint.stderr b/tests/rustdoc-ui/intra-doc/pub-export-lint.stderr index 81ef79961..81ef79961 100644 --- a/tests/rustdoc-ui/pub-export-lint.stderr +++ b/tests/rustdoc-ui/intra-doc/pub-export-lint.stderr diff --git a/tests/rustdoc-ui/reference-link-reports-error-once.rs b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.rs index 71bd2c522..71bd2c522 100644 --- a/tests/rustdoc-ui/reference-link-reports-error-once.rs +++ b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.rs diff --git a/tests/rustdoc-ui/reference-link-reports-error-once.stderr b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.stderr index 2ab67090f..2ab67090f 100644 --- a/tests/rustdoc-ui/reference-link-reports-error-once.stderr +++ b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.stderr diff --git a/tests/rustdoc-ui/reference-links.rs b/tests/rustdoc-ui/intra-doc/reference-links.rs index e81e03446..e81e03446 100644 --- a/tests/rustdoc-ui/reference-links.rs +++ b/tests/rustdoc-ui/intra-doc/reference-links.rs diff --git a/tests/rustdoc-ui/reference-links.stderr b/tests/rustdoc-ui/intra-doc/reference-links.stderr index c98a2fd7c..c98a2fd7c 100644 --- a/tests/rustdoc-ui/reference-links.stderr +++ b/tests/rustdoc-ui/intra-doc/reference-links.stderr diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.rs b/tests/rustdoc-ui/intra-doc/weird-syntax.rs new file mode 100644 index 000000000..ca18842fb --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.rs @@ -0,0 +1,140 @@ +// Many examples are from +// https://github.com/rust-lang/rust/issues/110111#issuecomment-1517800781 +#![deny(rustdoc::broken_intra_doc_links)] + +//! This test case is closely linked to [raphlinus/pulldown-cmark#441], getting offsets of +//! link components. In particular, pulldown-cmark doesn't provide the offsets of the contents +//! of a link. +//! +//! To work around this, rustdoc parses parts of a link definition itself. This is basically a +//! test suite for that link syntax parser. +//! +//! [raphlinus/pulldown-cmark#441]: https://github.com/raphlinus/pulldown-cmark/issues/441 + +use std::clone::Clone; + +// Basic version // + +/// [`struct@Clone`] //~ERROR link +pub struct LinkToCloneWithBackquotes; + +/// [```struct@Clone```] //~ERROR link +pub struct LinkToCloneWithMultipleBackquotes; + +/// [ ` struct@Clone ` ] //~ERROR link +pub struct LinkToCloneWithSpacesAndBackquotes; + +/// [ `Clone ()` ] //~ERROR link +pub struct LinkToCloneWithSpacesBackquotesAndParens; + +/// [`Clone ()` ] //~ERROR link +pub struct LinkToCloneWithSpacesEndBackquotesAndParens; + +/// [ `Clone ()`] //~ERROR link +pub struct LinkToCloneWithSpacesStartBackquotesAndParens; + +/// [```Clone ()```] //~ERROR link +pub struct LinkToCloneWithMultipleBackquotesAndParens; + +/// [```Clone \(\)```] // not URL-shaped enough +pub struct LinkToCloneWithMultipleBackquotesAndEscapedParens; + +/// [ ``` Clone () ``` ] //~ERROR link +pub struct LinkToCloneWithSpacesMultipleBackquotesAndParens; + +/// [ x \] ] // not URL-shaped enough +pub struct LinkWithEscapedCloseBrace; + +/// [ x \[ ] // not URL-shaped enough +pub struct LinkWithEscapedOpenBrace; + +/// [ x \( ] // not URL-shaped enough +pub struct LinkWithEscapedCloseParen; + +/// [ x \) ] // not URL-shaped enough +pub struct LinkWithEscapedOpenParen; + +/// [ Clone \(\) ] // not URL-shaped enough +pub struct LinkWithEscapedParens; + +// [][] version // + +/// [x][ struct@Clone] //~ERROR link +pub struct XLinkToCloneWithStartSpace; + +/// [x][struct@Clone ] //~ERROR link +pub struct XLinkToCloneWithEndSpace; + +/// [x][Clone\(\)] not URL-shaped enough +pub struct XLinkToCloneWithEscapedParens; + +/// [x][`Clone`] not URL-shaped enough +pub struct XLinkToCloneWithBackquotes; + +/// [x][Clone()] //~ERROR link +pub struct XLinkToCloneWithUnescapedParens; + +/// [x][Clone ()] //~ERROR link +pub struct XLinkToCloneWithUnescapedParensAndDoubleSpace; + +/// [x][Clone [] //~ERROR unresolved link to `x` +pub struct XLinkToCloneWithUnmatchedOpenParenAndDoubleSpace; + +/// [x][Clone \[] // not URL-shaped enough +pub struct XLinkToCloneWithUnmatchedEscapedOpenParenAndDoubleSpace; + +/// [x][Clone \]] // not URL-shaped enough +pub struct XLinkToCloneWithUnmatchedEscapedCloseParenAndDoubleSpace; + +// []() version // + +/// [w]( struct@Clone) //~ERROR link +pub struct WLinkToCloneWithStartSpace; + +/// [w](struct@Clone ) //~ERROR link +pub struct WLinkToCloneWithEndSpace; + +/// [w](Clone\(\)) //~ERROR link +pub struct WLinkToCloneWithEscapedParens; + +/// [w](`Clone`) not URL-shaped enough +pub struct WLinkToCloneWithBackquotes; + +/// [w](Clone()) //~ERROR link +pub struct WLinkToCloneWithUnescapedParens; + +/// [w](Clone ()) not URL-shaped enough +pub struct WLinkToCloneWithUnescapedParensAndDoubleSpace; + +/// [w](Clone () //~ERROR unresolved link to `w` +pub struct WLinkToCloneWithUnmatchedOpenParenAndDoubleSpace; + +/// [w](Clone \() //~ERROR unresolved link to `w` +pub struct WLinkToCloneWithUnmatchedEscapedOpenParenAndDoubleSpace; + +/// [w](Clone \)) //~ERROR unresolved link to `w` +pub struct WLinkToCloneWithUnmatchedEscapedCloseParenAndDoubleSpace; + +// References + +/// The [cln][] link here is going to be unresolved, because `Clone()` gets rejected //~ERROR link +/// in Markdown for not being URL-shaped enough. +/// +/// [cln]: Clone() //~ERROR link +pub struct LinkToCloneWithParensInReference; + +/// The [cln][] link here is going to be unresolved, because `struct@Clone` gets //~ERROR link +/// rejected in Markdown for not being URL-shaped enough. +/// +/// [cln]: struct@Clone //~ERROR link +pub struct LinkToCloneWithWrongPrefix; + +/// The [cln][] link here will produce a plain text suggestion //~ERROR link +/// +/// [cln]: Clone\(\) +pub struct LinkToCloneWithEscapedParensInReference; + +/// The [cln][] link here will produce a plain text suggestion //~ERROR link +/// +/// [cln]: struct\@Clone +pub struct LinkToCloneWithEscapedAtsInReference; diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr new file mode 100644 index 000000000..f50feb57f --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr @@ -0,0 +1,272 @@ +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:18:7 + | +LL | /// [`struct@Clone`] + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +note: the lint level is defined here + --> $DIR/weird-syntax.rs:3:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the trait, prefix with `trait@` + | +LL | /// [`trait@Clone`] + | ~~~~~~ + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:21:9 + | +LL | /// [```struct@Clone```] + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [```trait@Clone```] + | ~~~~~~ + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:24:11 + | +LL | /// [ ` struct@Clone ` ] + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [ ` trait@Clone ` ] + | ~~~~~~ + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:27:9 + | +LL | /// [ `Clone ()` ] + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [ `Clone ()` ] +LL + /// [ `trait@Clone ` ] + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:30:7 + | +LL | /// [`Clone ()` ] + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [`Clone ()` ] +LL + /// [`trait@Clone ` ] + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:33:9 + | +LL | /// [ `Clone ()`] + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [ `Clone ()`] +LL + /// [ `trait@Clone `] + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:36:9 + | +LL | /// [```Clone ()```] + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [```Clone ()```] +LL + /// [```trait@Clone ```] + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:42:13 + | +LL | /// [ ``` Clone () ``` ] + | ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [ ``` Clone () ``` ] +LL + /// [ ``` trait@Clone ``` ] + | + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:62:10 + | +LL | /// [x][ struct@Clone] + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [x][ trait@Clone] + | ~~~~~~ + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:65:9 + | +LL | /// [x][struct@Clone ] + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [x][trait@Clone ] + | ~~~~~~ + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:74:9 + | +LL | /// [x][Clone()] + | ^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [x][Clone()] +LL + /// [x][trait@Clone] + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:77:9 + | +LL | /// [x][Clone ()] + | ^^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [x][Clone ()] +LL + /// [x][trait@Clone ] + | + +error: unresolved link to `x` + --> $DIR/weird-syntax.rs:80:6 + | +LL | /// [x][Clone [] + | ^ no item named `x` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:91:10 + | +LL | /// [w]( struct@Clone) + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [w]( trait@Clone) + | ~~~~~~ + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:94:9 + | +LL | /// [w](struct@Clone ) + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL | /// [w](trait@Clone ) + | ~~~~~~ + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:97:9 + | +LL | /// [w](Clone\(\)) + | ^^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [w](Clone\(\)) +LL + /// [w](trait@Clone) + | + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:103:9 + | +LL | /// [w](Clone()) + | ^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [w](Clone()) +LL + /// [w](trait@Clone) + | + +error: unresolved link to `w` + --> $DIR/weird-syntax.rs:109:6 + | +LL | /// [w](Clone () + | ^ no item named `w` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `w` + --> $DIR/weird-syntax.rs:112:6 + | +LL | /// [w](Clone \() + | ^ no item named `w` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `w` + --> $DIR/weird-syntax.rs:115:6 + | +LL | /// [w](Clone \)) + | ^ no item named `w` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `cln` + --> $DIR/weird-syntax.rs:120:10 + | +LL | /// The [cln][] link here is going to be unresolved, because `Clone()` gets rejected + | ^^^ no item named `cln` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `cln` + --> $DIR/weird-syntax.rs:123:6 + | +LL | /// [cln]: Clone() + | ^^^ no item named `cln` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `cln` + --> $DIR/weird-syntax.rs:126:10 + | +LL | /// The [cln][] link here is going to be unresolved, because `struct@Clone` gets + | ^^^ no item named `cln` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `cln` + --> $DIR/weird-syntax.rs:129:6 + | +LL | /// [cln]: struct@Clone + | ^^^ no item named `cln` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: unresolved link to `Clone` + --> $DIR/weird-syntax.rs:132:9 + | +LL | /// The [cln][] link here will produce a plain text suggestion + | ^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace + | + = help: to link to the trait, prefix with `trait@`: trait@Clone + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:137:9 + | +LL | /// The [cln][] link here will produce a plain text suggestion + | ^^^^^ this link resolved to a trait, which is not a struct + | + = help: to link to the trait, prefix with `trait@`: trait@Clone + +error: aborting due to 26 previous errors + diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs new file mode 100644 index 000000000..c920a815f --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs @@ -0,0 +1,12 @@ +type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; +//~^ ERROR cycle detected when expanding type alias + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + Box::new(i) +} + +fn main() { + let meh = 42; + let muh = 42; + assert!(bar(&meh) == bar(&muh)); +} diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr new file mode 100644 index 000000000..79e1b7531 --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr @@ -0,0 +1,25 @@ +error[E0391]: cycle detected when expanding type alias `Bar` + --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:38 + | +LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; + | ^^^^^^^^^^^ + | + = note: ...which immediately requires expanding type alias `Bar` again + = note: type aliases cannot be recursive + = help: consider using a struct, enum, or union instead to break the cycle + = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information +note: cycle used when collecting item types in top-level module + --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:1 + | +LL | / type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; +LL | | +LL | | +LL | | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { +... | +LL | | assert!(bar(&meh) == bar(&muh)); +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs new file mode 100644 index 000000000..2d46ddbfa --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} diff --git a/tests/rustdoc-ui/auxiliary/empty-fn.rs b/tests/rustdoc-ui/issues/auxiliary/empty-fn.rs index 877810f15..877810f15 100644 --- a/tests/rustdoc-ui/auxiliary/empty-fn.rs +++ b/tests/rustdoc-ui/issues/auxiliary/empty-fn.rs diff --git a/tests/rustdoc-ui/auxiliary/issue-61592.rs b/tests/rustdoc-ui/issues/auxiliary/issue-61592.rs index 57a365b3f..57a365b3f 100644 --- a/tests/rustdoc-ui/auxiliary/issue-61592.rs +++ b/tests/rustdoc-ui/issues/auxiliary/issue-61592.rs diff --git a/tests/rustdoc-ui/auxiliary/panic-handler.rs b/tests/rustdoc-ui/issues/auxiliary/panic-handler.rs index 0aaaeee10..0aaaeee10 100644 --- a/tests/rustdoc-ui/auxiliary/panic-handler.rs +++ b/tests/rustdoc-ui/issues/auxiliary/panic-handler.rs diff --git a/tests/rustdoc-ui/issue-101076.rs b/tests/rustdoc-ui/issues/issue-101076.rs index 648f99029..648f99029 100644 --- a/tests/rustdoc-ui/issue-101076.rs +++ b/tests/rustdoc-ui/issues/issue-101076.rs diff --git a/tests/rustdoc-ui/issue-102986.rs b/tests/rustdoc-ui/issues/issue-102986.rs index 001784ac2..001784ac2 100644 --- a/tests/rustdoc-ui/issue-102986.rs +++ b/tests/rustdoc-ui/issues/issue-102986.rs diff --git a/tests/rustdoc-ui/issue-102986.stderr b/tests/rustdoc-ui/issues/issue-102986.stderr index 3a573726c..3a573726c 100644 --- a/tests/rustdoc-ui/issue-102986.stderr +++ b/tests/rustdoc-ui/issues/issue-102986.stderr diff --git a/tests/rustdoc-ui/issue-103997.rs b/tests/rustdoc-ui/issues/issue-103997.rs index 36f42fb15..36f42fb15 100644 --- a/tests/rustdoc-ui/issue-103997.rs +++ b/tests/rustdoc-ui/issues/issue-103997.rs diff --git a/tests/rustdoc-ui/issue-103997.stderr b/tests/rustdoc-ui/issues/issue-103997.stderr index c06db9149..c06db9149 100644 --- a/tests/rustdoc-ui/issue-103997.stderr +++ b/tests/rustdoc-ui/issues/issue-103997.stderr diff --git a/tests/rustdoc-ui/issue-105334.rs b/tests/rustdoc-ui/issues/issue-105334.rs index ee1adc6a0..ee1adc6a0 100644 --- a/tests/rustdoc-ui/issue-105334.rs +++ b/tests/rustdoc-ui/issues/issue-105334.rs diff --git a/tests/rustdoc-ui/issue-105334.stderr b/tests/rustdoc-ui/issues/issue-105334.stderr index e163bb4db..e163bb4db 100644 --- a/tests/rustdoc-ui/issue-105334.stderr +++ b/tests/rustdoc-ui/issues/issue-105334.stderr diff --git a/tests/rustdoc-ui/issue-105737.rs b/tests/rustdoc-ui/issues/issue-105737.rs index 154f069d8..154f069d8 100644 --- a/tests/rustdoc-ui/issue-105737.rs +++ b/tests/rustdoc-ui/issues/issue-105737.rs diff --git a/tests/rustdoc-ui/issue-105737.stderr b/tests/rustdoc-ui/issues/issue-105737.stderr index 2dd9beb17..2dd9beb17 100644 --- a/tests/rustdoc-ui/issue-105737.stderr +++ b/tests/rustdoc-ui/issues/issue-105737.stderr diff --git a/tests/rustdoc-ui/issue-105742.rs b/tests/rustdoc-ui/issues/issue-105742.rs index 8f4172c0c..1fbb70c78 100644 --- a/tests/rustdoc-ui/issue-105742.rs +++ b/tests/rustdoc-ui/issues/issue-105742.rs @@ -19,6 +19,8 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Index<<Self as SVec>::Item, //~^ expected 1 lifetime argument //~| expected 1 generic argument @@ -26,6 +28,8 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Self as SVec>::Item> as SVec>::Item, //~^ expected 1 lifetime argument //~| expected 1 generic argument @@ -34,11 +38,15 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` //~| expected 1 generic argument //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` > { type Item<'a, T>; diff --git a/tests/rustdoc-ui/issue-105742.stderr b/tests/rustdoc-ui/issues/issue-105742.stderr index cd53762ef..b63176c91 100644 --- a/tests/rustdoc-ui/issue-105742.stderr +++ b/tests/rustdoc-ui/issues/issue-105742.stderr @@ -5,7 +5,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -21,7 +21,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:22:37 + --> $DIR/issue-105742.rs:24:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:22:37 + --> $DIR/issue-105742.rs:24:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:30 + --> $DIR/issue-105742.rs:33:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:30 + --> $DIR/issue-105742.rs:33:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:46 + --> $DIR/issue-105742.rs:33:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:46 + --> $DIR/issue-105742.rs:33:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -133,7 +133,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -149,7 +149,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -165,7 +165,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -181,7 +181,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -191,13 +191,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:22:37 + --> $DIR/issue-105742.rs:24:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -207,13 +207,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:22:37 + --> $DIR/issue-105742.rs:24:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -223,13 +223,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:30 + --> $DIR/issue-105742.rs:33:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -239,13 +239,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:30 + --> $DIR/issue-105742.rs:33:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -255,13 +255,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:46 + --> $DIR/issue-105742.rs:33:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -271,13 +271,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:29:46 + --> $DIR/issue-105742.rs:33:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -317,13 +317,141 @@ LL | | > { | |__^ ...because it uses `Self` as a type parameter error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:45:38 + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | <Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | <Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:24:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Index<<Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:24:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Index<<Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:33:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:33:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:33:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:33:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:51:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:53:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -333,13 +461,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>; | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:45:38 + --> $DIR/issue-105742.rs:53:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:43:10 + --> $DIR/issue-105742.rs:51:10 | LL | type Item<'a, T>; | ^^^^ - @@ -348,7 +476,7 @@ help: add missing generic argument LL | fn len(&self) -> <Self as SVec>::Item<T>; | +++ -error: aborting due to 21 previous errors +error: aborting due to 29 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/rustdoc-ui/issue-106213.rs b/tests/rustdoc-ui/issues/issue-106213.rs index 6d51846b7..6d51846b7 100644 --- a/tests/rustdoc-ui/issue-106213.rs +++ b/tests/rustdoc-ui/issues/issue-106213.rs diff --git a/tests/rustdoc-ui/issue-106213.stderr b/tests/rustdoc-ui/issues/issue-106213.stderr index 0a4ff69ba..0a4ff69ba 100644 --- a/tests/rustdoc-ui/issue-106213.stderr +++ b/tests/rustdoc-ui/issues/issue-106213.stderr diff --git a/tests/rustdoc-ui/issue-106226.rs b/tests/rustdoc-ui/issues/issue-106226.rs index 71b497a9a..71b497a9a 100644 --- a/tests/rustdoc-ui/issue-106226.rs +++ b/tests/rustdoc-ui/issues/issue-106226.rs diff --git a/tests/rustdoc-ui/issue-106226.stderr b/tests/rustdoc-ui/issues/issue-106226.stderr index 1c973dab6..1c973dab6 100644 --- a/tests/rustdoc-ui/issue-106226.stderr +++ b/tests/rustdoc-ui/issues/issue-106226.stderr diff --git a/tests/rustdoc-ui/issue-107918.rs b/tests/rustdoc-ui/issues/issue-107918.rs index 13788df0f..13788df0f 100644 --- a/tests/rustdoc-ui/issue-107918.rs +++ b/tests/rustdoc-ui/issues/issue-107918.rs diff --git a/tests/rustdoc-ui/issue-109282-import-inline-merge.rs b/tests/rustdoc-ui/issues/issue-109282-import-inline-merge.rs index 0ec852322..0ec852322 100644 --- a/tests/rustdoc-ui/issue-109282-import-inline-merge.rs +++ b/tests/rustdoc-ui/issues/issue-109282-import-inline-merge.rs diff --git a/tests/rustdoc-ui/issues/issue-110900.rs b/tests/rustdoc-ui/issues/issue-110900.rs new file mode 100644 index 000000000..e3154baf8 --- /dev/null +++ b/tests/rustdoc-ui/issues/issue-110900.rs @@ -0,0 +1,28 @@ +// check-pass + +#![crate_type="lib"] +#![feature(associated_type_bounds)] + +trait A<'a> {} +trait B<'b> {} + +trait C<'c>: for<'a> A<'a> + for<'b> B<'b> { + type As; +} + +trait E<'e> { + type As; +} +trait F<'f>: for<'a> A<'a> + for<'e> E<'e> {} +struct G<T> +where + T: for<'l, 'i> H<'l, 'i, As: for<'a> A<'a> + 'i> +{ + t: std::marker::PhantomData<T>, +} + +trait I<'a, 'b, 'c> { + type As; +} + +trait H<'d, 'e>: for<'f> I<'d, 'f, 'e> + 'd {} diff --git a/tests/rustdoc-ui/issue-58473-2.rs b/tests/rustdoc-ui/issues/issue-58473-2.rs index 000b6a329..000b6a329 100644 --- a/tests/rustdoc-ui/issue-58473-2.rs +++ b/tests/rustdoc-ui/issues/issue-58473-2.rs diff --git a/tests/rustdoc-ui/issue-58473.rs b/tests/rustdoc-ui/issues/issue-58473.rs index 44e1f58d0..44e1f58d0 100644 --- a/tests/rustdoc-ui/issue-58473.rs +++ b/tests/rustdoc-ui/issues/issue-58473.rs diff --git a/tests/rustdoc-ui/issue-61592-2.rs b/tests/rustdoc-ui/issues/issue-61592-2.rs index 5b4fc5ee7..5b4fc5ee7 100644 --- a/tests/rustdoc-ui/issue-61592-2.rs +++ b/tests/rustdoc-ui/issues/issue-61592-2.rs diff --git a/tests/rustdoc-ui/issue-61592-2.stderr b/tests/rustdoc-ui/issues/issue-61592-2.stderr index 1b7f8bb55..1b7f8bb55 100644 --- a/tests/rustdoc-ui/issue-61592-2.stderr +++ b/tests/rustdoc-ui/issues/issue-61592-2.stderr diff --git a/tests/rustdoc-ui/issue-61592.rs b/tests/rustdoc-ui/issues/issue-61592.rs index 66772557f..66772557f 100644 --- a/tests/rustdoc-ui/issue-61592.rs +++ b/tests/rustdoc-ui/issues/issue-61592.rs diff --git a/tests/rustdoc-ui/issue-61592.stderr b/tests/rustdoc-ui/issues/issue-61592.stderr index 9c9c9106f..9c9c9106f 100644 --- a/tests/rustdoc-ui/issue-61592.stderr +++ b/tests/rustdoc-ui/issues/issue-61592.stderr diff --git a/tests/rustdoc-ui/issue-61732.rs b/tests/rustdoc-ui/issues/issue-61732.rs index 4bd8efeaa..4bd8efeaa 100644 --- a/tests/rustdoc-ui/issue-61732.rs +++ b/tests/rustdoc-ui/issues/issue-61732.rs diff --git a/tests/rustdoc-ui/issue-61732.stderr b/tests/rustdoc-ui/issues/issue-61732.stderr index d16ec6a85..d16ec6a85 100644 --- a/tests/rustdoc-ui/issue-61732.stderr +++ b/tests/rustdoc-ui/issues/issue-61732.stderr diff --git a/tests/rustdoc-ui/issue-74134.private.stderr b/tests/rustdoc-ui/issues/issue-74134.private.stderr index 44c88b618..44c88b618 100644 --- a/tests/rustdoc-ui/issue-74134.private.stderr +++ b/tests/rustdoc-ui/issues/issue-74134.private.stderr diff --git a/tests/rustdoc-ui/issue-74134.public.stderr b/tests/rustdoc-ui/issues/issue-74134.public.stderr index 5b1887b83..5b1887b83 100644 --- a/tests/rustdoc-ui/issue-74134.public.stderr +++ b/tests/rustdoc-ui/issues/issue-74134.public.stderr diff --git a/tests/rustdoc-ui/issue-74134.rs b/tests/rustdoc-ui/issues/issue-74134.rs index b1be9123a..b1be9123a 100644 --- a/tests/rustdoc-ui/issue-74134.rs +++ b/tests/rustdoc-ui/issues/issue-74134.rs diff --git a/tests/rustdoc-ui/issue-79465.rs b/tests/rustdoc-ui/issues/issue-79465.rs index e50f3995b..e50f3995b 100644 --- a/tests/rustdoc-ui/issue-79465.rs +++ b/tests/rustdoc-ui/issues/issue-79465.rs diff --git a/tests/rustdoc-ui/issue-79465.stderr b/tests/rustdoc-ui/issues/issue-79465.stderr index d187a2e66..d187a2e66 100644 --- a/tests/rustdoc-ui/issue-79465.stderr +++ b/tests/rustdoc-ui/issues/issue-79465.stderr diff --git a/tests/rustdoc-ui/issue-79467.rs b/tests/rustdoc-ui/issues/issue-79467.rs index eb0b9b380..eb0b9b380 100644 --- a/tests/rustdoc-ui/issue-79467.rs +++ b/tests/rustdoc-ui/issues/issue-79467.rs diff --git a/tests/rustdoc-ui/issue-79467.stderr b/tests/rustdoc-ui/issues/issue-79467.stderr index 561513a43..561513a43 100644 --- a/tests/rustdoc-ui/issue-79467.stderr +++ b/tests/rustdoc-ui/issues/issue-79467.stderr diff --git a/tests/rustdoc-ui/issue-79494.rs b/tests/rustdoc-ui/issues/issue-79494.rs index fc39424b7..fc39424b7 100644 --- a/tests/rustdoc-ui/issue-79494.rs +++ b/tests/rustdoc-ui/issues/issue-79494.rs diff --git a/tests/rustdoc-ui/issue-79494.stderr b/tests/rustdoc-ui/issues/issue-79494.stderr index 7ed5ed382..7ed5ed382 100644 --- a/tests/rustdoc-ui/issue-79494.stderr +++ b/tests/rustdoc-ui/issues/issue-79494.stderr diff --git a/tests/rustdoc-ui/issue-80992.rs b/tests/rustdoc-ui/issues/issue-80992.rs index 80ff225b8..f5ae16981 100644 --- a/tests/rustdoc-ui/issue-80992.rs +++ b/tests/rustdoc-ui/issues/issue-80992.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" pub fn test() -> Result<(), ()> { diff --git a/tests/rustdoc-ui/issue-80992.stdout b/tests/rustdoc-ui/issues/issue-80992.stdout index d2b1cd1d5..d2b1cd1d5 100644 --- a/tests/rustdoc-ui/issue-80992.stdout +++ b/tests/rustdoc-ui/issues/issue-80992.stdout diff --git a/tests/rustdoc-ui/issue-81662-shortness.rs b/tests/rustdoc-ui/issues/issue-81662-shortness.rs index 8a90813b3..0240d217b 100644 --- a/tests/rustdoc-ui/issue-81662-shortness.rs +++ b/tests/rustdoc-ui/issues/issue-81662-shortness.rs @@ -1,5 +1,5 @@ // compile-flags:--test --error-format=short -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/issue-81662-shortness.stdout b/tests/rustdoc-ui/issues/issue-81662-shortness.stdout index 748113be3..748113be3 100644 --- a/tests/rustdoc-ui/issue-81662-shortness.stdout +++ b/tests/rustdoc-ui/issues/issue-81662-shortness.stdout diff --git a/tests/rustdoc-ui/issue-83883-describe-lints.rs b/tests/rustdoc-ui/issues/issue-83883-describe-lints.rs index 0474d6c14..0474d6c14 100644 --- a/tests/rustdoc-ui/issue-83883-describe-lints.rs +++ b/tests/rustdoc-ui/issues/issue-83883-describe-lints.rs diff --git a/tests/rustdoc-ui/issue-83883-describe-lints.stdout b/tests/rustdoc-ui/issues/issue-83883-describe-lints.stdout index bbf66a315..bbf66a315 100644 --- a/tests/rustdoc-ui/issue-83883-describe-lints.stdout +++ b/tests/rustdoc-ui/issues/issue-83883-describe-lints.stdout diff --git a/tests/rustdoc-ui/issue-91134.rs b/tests/rustdoc-ui/issues/issue-91134.rs index 42703ee4d..85362f186 100644 --- a/tests/rustdoc-ui/issue-91134.rs +++ b/tests/rustdoc-ui/issues/issue-91134.rs @@ -1,7 +1,7 @@ // compile-flags: --test --crate-name=empty_fn --extern=empty_fn --test-args=--test-threads=1 // aux-build:empty-fn.rs // check-pass -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // edition:2021 diff --git a/tests/rustdoc-ui/issue-91134.stdout b/tests/rustdoc-ui/issues/issue-91134.stdout index 084062743..084062743 100644 --- a/tests/rustdoc-ui/issue-91134.stdout +++ b/tests/rustdoc-ui/issues/issue-91134.stdout diff --git a/tests/rustdoc-ui/issue-91713.rs b/tests/rustdoc-ui/issues/issue-91713.rs index 610bbf11d..610bbf11d 100644 --- a/tests/rustdoc-ui/issue-91713.rs +++ b/tests/rustdoc-ui/issues/issue-91713.rs diff --git a/tests/rustdoc-ui/issue-91713.stderr b/tests/rustdoc-ui/issues/issue-91713.stderr index 44ead7a1d..44ead7a1d 100644 --- a/tests/rustdoc-ui/issue-91713.stderr +++ b/tests/rustdoc-ui/issues/issue-91713.stderr diff --git a/tests/rustdoc-ui/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout index 167835243..167835243 100644 --- a/tests/rustdoc-ui/issue-91713.stdout +++ b/tests/rustdoc-ui/issues/issue-91713.stdout diff --git a/tests/rustdoc-ui/issue-96287.rs b/tests/rustdoc-ui/issues/issue-96287.rs index 08cc7ef4c..08cc7ef4c 100644 --- a/tests/rustdoc-ui/issue-96287.rs +++ b/tests/rustdoc-ui/issues/issue-96287.rs diff --git a/tests/rustdoc-ui/issue-96287.stderr b/tests/rustdoc-ui/issues/issue-96287.stderr index 7722eb960..7722eb960 100644 --- a/tests/rustdoc-ui/issue-96287.stderr +++ b/tests/rustdoc-ui/issues/issue-96287.stderr diff --git a/tests/rustdoc-ui/issue-98690.rs b/tests/rustdoc-ui/issues/issue-98690.rs index fe9bd87ab..fe9bd87ab 100644 --- a/tests/rustdoc-ui/issue-98690.rs +++ b/tests/rustdoc-ui/issues/issue-98690.rs diff --git a/tests/rustdoc-ui/issue-98690.stderr b/tests/rustdoc-ui/issues/issue-98690.stderr index 47d94f99a..47d94f99a 100644 --- a/tests/rustdoc-ui/issue-98690.stderr +++ b/tests/rustdoc-ui/issues/issue-98690.stderr diff --git a/tests/rustdoc-ui/bare-urls.fixed b/tests/rustdoc-ui/lints/bare-urls.fixed index 23aa5c44c..23aa5c44c 100644 --- a/tests/rustdoc-ui/bare-urls.fixed +++ b/tests/rustdoc-ui/lints/bare-urls.fixed diff --git a/tests/rustdoc-ui/bare-urls.rs b/tests/rustdoc-ui/lints/bare-urls.rs index 592f57343..592f57343 100644 --- a/tests/rustdoc-ui/bare-urls.rs +++ b/tests/rustdoc-ui/lints/bare-urls.rs diff --git a/tests/rustdoc-ui/bare-urls.stderr b/tests/rustdoc-ui/lints/bare-urls.stderr index ccf52cd0b..ccf52cd0b 100644 --- a/tests/rustdoc-ui/bare-urls.stderr +++ b/tests/rustdoc-ui/lints/bare-urls.stderr diff --git a/tests/rustdoc-ui/check-attr.rs b/tests/rustdoc-ui/lints/check-attr.rs index 0b3f7bedd..0b3f7bedd 100644 --- a/tests/rustdoc-ui/check-attr.rs +++ b/tests/rustdoc-ui/lints/check-attr.rs diff --git a/tests/rustdoc-ui/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr index f66e63ab7..f66e63ab7 100644 --- a/tests/rustdoc-ui/check-attr.stderr +++ b/tests/rustdoc-ui/lints/check-attr.stderr diff --git a/tests/rustdoc-ui/check-fail.rs b/tests/rustdoc-ui/lints/check-fail.rs index 02632b4ce..02632b4ce 100644 --- a/tests/rustdoc-ui/check-fail.rs +++ b/tests/rustdoc-ui/lints/check-fail.rs diff --git a/tests/rustdoc-ui/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr index f05e457af..f05e457af 100644 --- a/tests/rustdoc-ui/check-fail.stderr +++ b/tests/rustdoc-ui/lints/check-fail.stderr diff --git a/tests/rustdoc-ui/check.rs b/tests/rustdoc-ui/lints/check.rs index e389a81bb..e389a81bb 100644 --- a/tests/rustdoc-ui/check.rs +++ b/tests/rustdoc-ui/lints/check.rs diff --git a/tests/rustdoc-ui/check.stderr b/tests/rustdoc-ui/lints/check.stderr index c5ed5d0c3..c5ed5d0c3 100644 --- a/tests/rustdoc-ui/check.stderr +++ b/tests/rustdoc-ui/lints/check.stderr diff --git a/tests/rustdoc-ui/deny-missing-docs-crate.rs b/tests/rustdoc-ui/lints/deny-missing-docs-crate.rs index b74eba3f6..b74eba3f6 100644 --- a/tests/rustdoc-ui/deny-missing-docs-crate.rs +++ b/tests/rustdoc-ui/lints/deny-missing-docs-crate.rs diff --git a/tests/rustdoc-ui/deny-missing-docs-crate.stderr b/tests/rustdoc-ui/lints/deny-missing-docs-crate.stderr index 5025b0b0c..5025b0b0c 100644 --- a/tests/rustdoc-ui/deny-missing-docs-crate.stderr +++ b/tests/rustdoc-ui/lints/deny-missing-docs-crate.stderr diff --git a/tests/rustdoc-ui/deny-missing-docs-macro.rs b/tests/rustdoc-ui/lints/deny-missing-docs-macro.rs index b1c125317..b1c125317 100644 --- a/tests/rustdoc-ui/deny-missing-docs-macro.rs +++ b/tests/rustdoc-ui/lints/deny-missing-docs-macro.rs diff --git a/tests/rustdoc-ui/deny-missing-docs-macro.stderr b/tests/rustdoc-ui/lints/deny-missing-docs-macro.stderr index 0867b0818..0867b0818 100644 --- a/tests/rustdoc-ui/deny-missing-docs-macro.stderr +++ b/tests/rustdoc-ui/lints/deny-missing-docs-macro.stderr diff --git a/tests/rustdoc-ui/doc-attr.rs b/tests/rustdoc-ui/lints/doc-attr.rs index 980d1c0e2..980d1c0e2 100644 --- a/tests/rustdoc-ui/doc-attr.rs +++ b/tests/rustdoc-ui/lints/doc-attr.rs diff --git a/tests/rustdoc-ui/doc-attr.stderr b/tests/rustdoc-ui/lints/doc-attr.stderr index 68df2771f..68df2771f 100644 --- a/tests/rustdoc-ui/doc-attr.stderr +++ b/tests/rustdoc-ui/lints/doc-attr.stderr diff --git a/tests/rustdoc-ui/doc-spotlight.fixed b/tests/rustdoc-ui/lints/doc-spotlight.fixed index 4b58778ea..4b58778ea 100644 --- a/tests/rustdoc-ui/doc-spotlight.fixed +++ b/tests/rustdoc-ui/lints/doc-spotlight.fixed diff --git a/tests/rustdoc-ui/doc-spotlight.rs b/tests/rustdoc-ui/lints/doc-spotlight.rs index 16e387245..16e387245 100644 --- a/tests/rustdoc-ui/doc-spotlight.rs +++ b/tests/rustdoc-ui/lints/doc-spotlight.rs diff --git a/tests/rustdoc-ui/doc-spotlight.stderr b/tests/rustdoc-ui/lints/doc-spotlight.stderr index 58612327f..58612327f 100644 --- a/tests/rustdoc-ui/doc-spotlight.stderr +++ b/tests/rustdoc-ui/lints/doc-spotlight.stderr diff --git a/tests/rustdoc-ui/doc-without-codeblock.rs b/tests/rustdoc-ui/lints/doc-without-codeblock.rs index 86d7c83d3..86d7c83d3 100644 --- a/tests/rustdoc-ui/doc-without-codeblock.rs +++ b/tests/rustdoc-ui/lints/doc-without-codeblock.rs diff --git a/tests/rustdoc-ui/doc-without-codeblock.stderr b/tests/rustdoc-ui/lints/doc-without-codeblock.stderr index ebf2a2d54..ebf2a2d54 100644 --- a/tests/rustdoc-ui/doc-without-codeblock.stderr +++ b/tests/rustdoc-ui/lints/doc-without-codeblock.stderr diff --git a/tests/rustdoc-ui/doc_cfg_hide.rs b/tests/rustdoc-ui/lints/doc_cfg_hide.rs index 5d8791748..5d8791748 100644 --- a/tests/rustdoc-ui/doc_cfg_hide.rs +++ b/tests/rustdoc-ui/lints/doc_cfg_hide.rs diff --git a/tests/rustdoc-ui/doc_cfg_hide.stderr b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr index 03623368c..b7e8870fd 100644 --- a/tests/rustdoc-ui/doc_cfg_hide.stderr +++ b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr @@ -16,7 +16,7 @@ LL | #![deny(warnings)] help: to apply to the crate, use an inner attribute | LL | #![doc(cfg_hide(doc))] - | ~~~~~~~~~~~~~~~~~~~~~~ + | + error: `#[doc(cfg_hide(...)]` takes a list of attributes --> $DIR/doc_cfg_hide.rs:4:8 diff --git a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.rs b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.rs index 0901ac364..0901ac364 100644 --- a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.rs +++ b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.rs diff --git a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.stderr b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.stderr index efc5f349f..efc5f349f 100644 --- a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.stderr +++ b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.stderr diff --git a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.rs index c34ea0567..c34ea0567 100644 --- a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs +++ b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.rs diff --git a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.stderr index 326dcfe3b..326dcfe3b 100644 --- a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr +++ b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.stderr diff --git a/tests/rustdoc-ui/invalid-doc-attr.rs b/tests/rustdoc-ui/lints/invalid-doc-attr.rs index de004b41e..c231e43b3 100644 --- a/tests/rustdoc-ui/invalid-doc-attr.rs +++ b/tests/rustdoc-ui/lints/invalid-doc-attr.rs @@ -5,7 +5,7 @@ //~^ ERROR can only be applied at the crate level //~| WARN is being phased out //~| HELP to apply to the crate, use an inner attribute -//~| SUGGESTION #![doc(test(no_crate_inject))] +//~| SUGGESTION ! #[doc(inline)] //~^ ERROR can only be applied to a `use` item //~| WARN is being phased out diff --git a/tests/rustdoc-ui/invalid-doc-attr.stderr b/tests/rustdoc-ui/lints/invalid-doc-attr.stderr index 3c66e587b..b23b8ded8 100644 --- a/tests/rustdoc-ui/invalid-doc-attr.stderr +++ b/tests/rustdoc-ui/lints/invalid-doc-attr.stderr @@ -16,7 +16,7 @@ LL | #![deny(warnings)] help: to apply to the crate, use an inner attribute | LL | #![doc(test(no_crate_inject))] - | + | + error: this attribute can only be applied to a `use` item --> $DIR/invalid-doc-attr.rs:9:7 diff --git a/tests/rustdoc-ui/invalid-html-self-closing-tag.rs b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.rs index d973a53cb..d973a53cb 100644 --- a/tests/rustdoc-ui/invalid-html-self-closing-tag.rs +++ b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.rs diff --git a/tests/rustdoc-ui/invalid-html-self-closing-tag.stderr b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.stderr index e45edfb43..e45edfb43 100644 --- a/tests/rustdoc-ui/invalid-html-self-closing-tag.stderr +++ b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.stderr diff --git a/tests/rustdoc-ui/invalid-html-tags.rs b/tests/rustdoc-ui/lints/invalid-html-tags.rs index 317f1fd1d..317f1fd1d 100644 --- a/tests/rustdoc-ui/invalid-html-tags.rs +++ b/tests/rustdoc-ui/lints/invalid-html-tags.rs diff --git a/tests/rustdoc-ui/invalid-html-tags.stderr b/tests/rustdoc-ui/lints/invalid-html-tags.stderr index 9c2bfcf2c..9c2bfcf2c 100644 --- a/tests/rustdoc-ui/invalid-html-tags.stderr +++ b/tests/rustdoc-ui/lints/invalid-html-tags.stderr diff --git a/tests/rustdoc-ui/lint-group.rs b/tests/rustdoc-ui/lints/lint-group.rs index ad88157f6..ad88157f6 100644 --- a/tests/rustdoc-ui/lint-group.rs +++ b/tests/rustdoc-ui/lints/lint-group.rs diff --git a/tests/rustdoc-ui/lint-group.stderr b/tests/rustdoc-ui/lints/lint-group.stderr index 7ff09fcc4..7ff09fcc4 100644 --- a/tests/rustdoc-ui/lint-group.stderr +++ b/tests/rustdoc-ui/lints/lint-group.stderr diff --git a/tests/rustdoc-ui/lint-missing-doc-code-example.rs b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.rs index 40f35728d..40f35728d 100644 --- a/tests/rustdoc-ui/lint-missing-doc-code-example.rs +++ b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.rs diff --git a/tests/rustdoc-ui/lint-missing-doc-code-example.stderr b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.stderr index f93312501..f93312501 100644 --- a/tests/rustdoc-ui/lint-missing-doc-code-example.stderr +++ b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.stderr diff --git a/tests/rustdoc-ui/no-crate-level-doc-lint.rs b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs index a186410ac..a186410ac 100644 --- a/tests/rustdoc-ui/no-crate-level-doc-lint.rs +++ b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs diff --git a/tests/rustdoc-ui/no-crate-level-doc-lint.stderr b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr index fb3a5e415..fb3a5e415 100644 --- a/tests/rustdoc-ui/no-crate-level-doc-lint.stderr +++ b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr diff --git a/tests/rustdoc-ui/renamed-lint-still-applies.rs b/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs index a4d3a4b49..a4d3a4b49 100644 --- a/tests/rustdoc-ui/renamed-lint-still-applies.rs +++ b/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs diff --git a/tests/rustdoc-ui/renamed-lint-still-applies.stderr b/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr index ee9b67cb9..ee9b67cb9 100644 --- a/tests/rustdoc-ui/renamed-lint-still-applies.stderr +++ b/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr diff --git a/tests/rustdoc-ui/rustdoc-all-only-stable-lints.rs b/tests/rustdoc-ui/lints/rustdoc-all-only-stable-lints.rs index e106d06af..e106d06af 100644 --- a/tests/rustdoc-ui/rustdoc-all-only-stable-lints.rs +++ b/tests/rustdoc-ui/lints/rustdoc-all-only-stable-lints.rs diff --git a/tests/rustdoc-ui/unknown-renamed-lints.rs b/tests/rustdoc-ui/lints/unknown-renamed-lints.rs index ddf03dd07..ddf03dd07 100644 --- a/tests/rustdoc-ui/unknown-renamed-lints.rs +++ b/tests/rustdoc-ui/lints/unknown-renamed-lints.rs diff --git a/tests/rustdoc-ui/unknown-renamed-lints.stderr b/tests/rustdoc-ui/lints/unknown-renamed-lints.stderr index bf529b9f8..bf529b9f8 100644 --- a/tests/rustdoc-ui/unknown-renamed-lints.stderr +++ b/tests/rustdoc-ui/lints/unknown-renamed-lints.stderr diff --git a/tests/rustdoc-ui/unused-braces-lint.rs b/tests/rustdoc-ui/lints/unused-braces-lint.rs index be0e31e4b..be0e31e4b 100644 --- a/tests/rustdoc-ui/unused-braces-lint.rs +++ b/tests/rustdoc-ui/lints/unused-braces-lint.rs diff --git a/tests/rustdoc-ui/unused.rs b/tests/rustdoc-ui/lints/unused.rs index 702b24c36..702b24c36 100644 --- a/tests/rustdoc-ui/unused.rs +++ b/tests/rustdoc-ui/lints/unused.rs diff --git a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.rs index 8f4fde96d..8f4fde96d 100644 --- a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.rs +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.rs diff --git a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.stderr index 750aa3207..750aa3207 100644 --- a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.stderr +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.stderr diff --git a/tests/rustdoc-ui/scrape-examples-ice.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-ice.rs index d629b62a7..d629b62a7 100644 --- a/tests/rustdoc-ui/scrape-examples-ice.rs +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-ice.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-1.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.rs index a1f005c32..a1f005c32 100644 --- a/tests/rustdoc-ui/scrape-examples-wrong-options-1.rs +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-1.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.stderr index eb8e9f799..eb8e9f799 100644 --- a/tests/rustdoc-ui/scrape-examples-wrong-options-1.stderr +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.stderr diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-2.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.rs index 4aacec7f0..4aacec7f0 100644 --- a/tests/rustdoc-ui/scrape-examples-wrong-options-2.rs +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-2.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.stderr index eb8e9f799..eb8e9f799 100644 --- a/tests/rustdoc-ui/scrape-examples-wrong-options-2.stderr +++ b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.stderr diff --git a/tests/rustdoc-ui/unescaped_backticks.rs b/tests/rustdoc-ui/unescaped_backticks.rs new file mode 100644 index 000000000..e99cd1f3d --- /dev/null +++ b/tests/rustdoc-ui/unescaped_backticks.rs @@ -0,0 +1,354 @@ +#![deny(rustdoc::unescaped_backticks)] +#![allow(rustdoc::broken_intra_doc_links)] +#![allow(rustdoc::invalid_html_tags)] + +/// +pub fn empty() {} + +#[doc = ""] +pub fn empty2() {} + +/// ` +//~^ ERROR unescaped backtick +pub fn single() {} + +/// \` +pub fn escaped() {} + +/// \\` +//~^ ERROR unescaped backtick +pub fn not_escaped() {} + +/// \\\` +pub fn not_not_escaped() {} + +/// [`link1] +//~^ ERROR unescaped backtick +pub fn link1() {} + +/// [link2`] +//~^ ERROR unescaped backtick +pub fn link2() {} + +/// [`link_long](link_long) +//~^ ERROR unescaped backtick +pub fn link_long() {} + +/// [`broken-link] +//~^ ERROR unescaped backtick +pub fn broken_link() {} + +/// <xx:`> +pub fn url() {} + +/// <x:`> +//~^ ERROR unescaped backtick +pub fn not_url() {} + +/// <h1>`</h1> +pub fn html_tag() {} + +/// ` +pub fn html_escape() {} + +/// 🦀`🦀 +//~^ ERROR unescaped backtick +pub fn unicode() {} + +/// `foo( +//~^ ERROR unescaped backtick +/// +/// paragraph +pub fn paragraph() {} + +/// `foo `bar` +//~^ ERROR unescaped backtick +/// +/// paragraph +pub fn paragraph2() {} + +/// `foo( +//~^ ERROR unescaped backtick +/// not paragraph +pub fn not_paragraph() {} + +/// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. +//~^ ERROR unescaped backtick +/// +/// You could use this function to add 42 to a number `n` (add(n, 42)`), +/// or even to add a number `n` to 42 (`add(42, b)`)! +//~^ ERROR unescaped backtick +pub fn add1(a: i32, b: i32) -> i32 { a + b } + +/// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. +//~^ ERROR unescaped backtick +/// +/// You could use this function to add 42 to a number `n` (`add(n, 42)), +/// or even to add a number `n` to 42 (`add(42, n)`)! +//~^ ERROR unescaped backtick +pub fn add2(a: i32, b: i32) -> i32 { a + b } + +/// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. +//~^ ERROR unescaped backtick +/// +/// You could use this function to add 42 to a number `n` (`add(n, 42)`), +/// or even to add a number `n` to 42 (add(42, n)`)! +//~^ ERROR unescaped backtick +pub fn add3(a: i32, b: i32) -> i32 { a + b } + +/// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). +//~^ ERROR unescaped backtick +/// +/// You could use this function to add 42 to a number `n` (`add(n, 42)), +/// or even to add a number `n` to 42 (`add(42, n)`)! +//~^ ERROR unescaped backtick +pub fn add4(a: i32, b: i32) -> i32 { a + b } + +#[doc = "`"] +//~^ ERROR unescaped backtick +pub fn attr() {} + +#[doc = concat!("\\", "`")] +pub fn attr_escaped() {} + +#[doc = concat!("\\\\", "`")] +//~^ ERROR unescaped backtick +pub fn attr_not_escaped() {} + +#[doc = "Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`."] +//~^ ERROR unescaped backtick +pub fn attr_add1(a: i32, b: i32) -> i32 { a + b } + +#[doc = "Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`."] +//~^ ERROR unescaped backtick +pub fn attr_add2(a: i32, b: i32) -> i32 { a + b } + +#[doc = "Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`."] +//~^ ERROR unescaped backtick +pub fn attr_add3(a: i32, b: i32) -> i32 { a + b } + +#[doc = "Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)."] +//~^ ERROR unescaped backtick +pub fn attr_add4(a: i32, b: i32) -> i32 { a + b } + +/// ``double backticks`` +/// `foo +//~^ ERROR unescaped backtick +pub fn double_backticks() {} + +/// # `(heading +//~^ ERROR unescaped backtick +/// ## heading2)` +//~^ ERROR unescaped backtick +/// +/// multi `( +//~^ ERROR unescaped backtick +/// line +/// ) heading +/// = +/// +/// para)`(graph +//~^ ERROR unescaped backtick +/// +/// para)`(graph2 +//~^ ERROR unescaped backtick +/// +/// 1. foo)` +//~^ ERROR unescaped backtick +/// 2. `(bar +//~^ ERROR unescaped backtick +/// * baz)` +//~^ ERROR unescaped backtick +/// * `(quux +//~^ ERROR unescaped backtick +/// +/// `#![this_is_actually_an_image(and(not), an = "attribute")] +//~^ ERROR unescaped backtick +/// +/// #![this_is_actually_an_image(and(not), an = "attribute")]` +//~^ ERROR unescaped backtick +/// +/// [this_is_actually_an_image(and(not), an = "attribute")]: `.png +/// +/// | `table( | )head` | +//~^ ERROR unescaped backtick +//~| ERROR unescaped backtick +/// |---------|--------| +/// | table`( | )`body | +//~^ ERROR unescaped backtick +//~| ERROR unescaped backtick +pub fn complicated_markdown() {} + +/// The `custom_mir` attribute tells the compiler to treat the function as being custom MIR. This +/// attribute only works on functions - there is no way to insert custom MIR into the middle of +/// another function. The `dialect` and `phase` parameters indicate which [version of MIR][dialect +/// docs] you are inserting here. Generally you'll want to use `#![custom_mir(dialect = "built")]` +/// if you want your MIR to be modified by the full MIR pipeline, or `#![custom_mir(dialect = +//~^ ERROR unescaped backtick +/// "runtime", phase = "optimized")] if you don't. +pub mod mir {} + +pub mod rustc { + /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to + //~^ ERROR unescaped backtick + /// ensure it gets used. + pub fn ty_error_with_message() {} + + pub struct WhereClause { + /// `true` if we ate a `where` token: this can happen + /// if we parsed no predicates (e.g. `struct Foo where {} + /// This allows us to accurately pretty-print + /// in `nt_to_tokenstream` + //~^ ERROR unescaped backtick + pub has_where_token: bool, + } + + /// A symbol is an interned or gensymed string. The use of `newtype_index!` means + /// that `Option<Symbol>` only takes up 4 bytes, because `newtype_index! reserves + //~^ ERROR unescaped backtick + /// the last 256 values for tagging purposes. + pub struct Symbol(); + + /// It is equivalent to `OpenOptions::new()` but allows you to write more + /// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")` + /// you can write `File::with_options().read(true).open("foo.txt"). This + /// also avoids the need to import `OpenOptions`. + //~^ ERROR unescaped backtick + pub fn with_options() {} + + /// Subtracts `set from `row`. `set` can be either `BitSet` or + /// `HybridBitSet`. Has no effect if `row` does not exist. + //~^ ERROR unescaped backtick + /// + /// Returns true if the row was changed. + pub fn subtract_row() {} + + pub mod assert_module_sources { + //! The reason that we use `cfg=...` and not `#[cfg_attr]` is so that + //! the HIR doesn't change as a result of the annotations, which might + //! perturb the reuse results. + //! + //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] + //~^ ERROR unescaped backtick + //! allows for doing a more fine-grained check to see if pre- or post-lto data + //! was re-used. + + /// `cfg=... + //~^ ERROR unescaped backtick + pub fn foo() {} + + /// `cfg=... and not `#[cfg_attr]` + //~^ ERROR unescaped backtick + pub fn bar() {} + } + + /// Conceptually, this is like a `Vec<Vec<RWU>>`. But the number of + /// RWU`s can get very large, so it uses a more compact representation. + //~^ ERROR unescaped backtick + pub struct RWUTable {} + + /// Like [Self::canonicalize_query], but preserves distinct universes. For + /// example, canonicalizing `&'?0: Trait<'?1>`, where `'?0` is in `U1` and + /// `'?1` is in `U3` would be canonicalized to have ?0` in `U1` and `'?1` + /// in `U2`. + //~^ ERROR unescaped backtick + /// + /// This is used for Chalk integration. + pub fn canonicalize_query_preserving_universes() {} + + /// Note that we used to return `Error` here, but that was quite + /// dubious -- the premise was that an error would *eventually* be + /// reported, when the obligation was processed. But in general once + /// you see an `Error` you are supposed to be able to assume that an + /// error *has been* reported, so that you can take whatever heuristic + /// paths you want to take. To make things worse, it was possible for + /// cycles to arise, where you basically had a setup like `<MyType<$0> + /// as Trait>::Foo == $0`. Here, normalizing `<MyType<$0> as + /// Trait>::Foo> to `[type error]` would lead to an obligation of + /// `<MyType<[type error]> as Trait>::Foo`. We are supposed to report + /// an error for this obligation, but we legitimately should not, + /// because it contains `[type error]`. Yuck! (See issue #29857 for + //~^ ERROR unescaped backtick + /// one case where this arose.) + pub fn normalize_to_error() {} + + /// you don't want to cache that `B: AutoTrait` or `A: AutoTrait` + /// is `EvaluatedToOk`; this is because they were only considered + /// ok on the premise that if `A: AutoTrait` held, but we indeed + /// encountered a problem (later on) with `A: AutoTrait. So we + /// currently set a flag on the stack node for `B: AutoTrait` (as + /// well as the second instance of `A: AutoTrait`) to suppress + //~^ ERROR unescaped backtick + /// caching. + pub struct TraitObligationStack; + + /// Extend `scc` so that it can outlive some placeholder region + /// from a universe it can't name; at present, the only way for + /// this to be true is if `scc` outlives `'static`. This is + /// actually stricter than necessary: ideally, we'd support bounds + /// like `for<'a: 'b`>` that might then allow us to approximate + /// `'a` with `'b` and not `'static`. But it will have to do for + //~^ ERROR unescaped backtick + /// now. + pub fn add_incompatible_universe(){} +} + +/// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], +/// which returns an `Option<Dispatch>`. If all [`Dispatch`] clones that point +/// at the `Subscriber` have been dropped, [`WeakDispatch::upgrade`] will return +/// `None`. Otherwise, it will return `Some(Dispatch)`. +//~^ ERROR unescaped backtick +/// +/// Returns some reference to this `[`Subscriber`] value if it is of type `T`, +/// or `None` if it isn't. +//~^ ERROR unescaped backtick +/// +/// Called before the filtered [`Layer]'s [`on_event`], to determine if +/// `on_event` should be called. +//~^ ERROR unescaped backtick +/// +/// Therefore, if the `Filter will change the value returned by this +/// method, it is responsible for ensuring that +/// [`rebuild_interest_cache`][rebuild] is called after the value of the max +//~^ ERROR unescaped backtick +/// level changes. +pub mod tracing {} + +macro_rules! id { + ($($tt:tt)*) => { $($tt)* } +} + +id! { + /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], + //~^ ERROR unescaped backtick + //~| ERROR unescaped backtick + //~| ERROR unescaped backtick + //~| ERROR unescaped backtick + /// which returns an `Option<Dispatch>`. If all [`Dispatch`] clones that point + /// at the `Subscriber` have been dropped, [`WeakDispatch::upgrade`] will return + /// `None`. Otherwise, it will return `Some(Dispatch)`. + /// + /// Returns some reference to this `[`Subscriber`] value if it is of type `T`, + /// or `None` if it isn't. + /// + /// Called before the filtered [`Layer]'s [`on_event`], to determine if + /// `on_event` should be called. + /// + /// Therefore, if the `Filter will change the value returned by this + /// method, it is responsible for ensuring that + /// [`rebuild_interest_cache`][rebuild] is called after the value of the max + /// level changes. + pub mod tracing_macro {} +} + +/// Regression test for <https://github.com/rust-lang/rust/issues/111117> +pub mod trillium_server_common { + /// One-indexed, because the first CloneCounter is included. If you don't + /// want the original to count, construct a [``CloneCounterObserver`] + /// instead and use [`CloneCounterObserver::counter`] to increment. + //~^ ERROR unescaped backtick + pub struct CloneCounter; + + /// This is used by the above. + pub struct CloneCounterObserver; +} diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr new file mode 100644 index 000000000..bf1f18889 --- /dev/null +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -0,0 +1,971 @@ +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:186:70 + | +LL | /// if you want your MIR to be modified by the full MIR pipeline, or `#![custom_mir(dialect = + | ^ + | +note: the lint level is defined here + --> $DIR/unescaped_backticks.rs:1:9 + | +LL | #![deny(rustdoc::unescaped_backticks)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: the closing backtick of an inline code may be missing + | +LL | /// "runtime", phase = "optimized")]` if you don't. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// if you want your MIR to be modified by the full MIR pipeline, or \`#![custom_mir(dialect = + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:231:13 + | +LL | //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")]` + | + +help: if you meant to use a literal backtick, escape it + | +LL | //! \`#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:236:13 + | +LL | /// `cfg=... + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// `cfg=...` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \`cfg=... + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:240:42 + | +LL | /// `cfg=... and not `#[cfg_attr]` + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// `cfg=...` and not `#[cfg_attr]` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// `cfg=... and not `#[cfg_attr]\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:192:91 + | +LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg` to + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given \`msg to + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:201:34 + | +LL | /// in `nt_to_tokenstream` + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// if we parsed no predicates (e.g. `struct` Foo where {} + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// in `nt_to_tokenstream\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:207:62 + | +LL | /// that `Option<Symbol>` only takes up 4 bytes, because `newtype_index! reserves + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// that `Option<Symbol>` only takes up 4 bytes, because `newtype_index!` reserves + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// that `Option<Symbol>` only takes up 4 bytes, because \`newtype_index! reserves + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:215:52 + | +LL | /// also avoids the need to import `OpenOptions`. + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// you can write `File::with_options().read(true).open("foo.txt")`. This + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// also avoids the need to import `OpenOptions\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:220:46 + | +LL | /// `HybridBitSet`. Has no effect if `row` does not exist. + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// Subtracts `set` from `row`. `set` can be either `BitSet` or + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// `HybridBitSet`. Has no effect if `row\` does not exist. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:246:12 + | +LL | /// RWU`s can get very large, so it uses a more compact representation. + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `RWU`s can get very large, so it uses a more compact representation. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// RWU\`s can get very large, so it uses a more compact representation. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:253:15 + | +LL | /// in `U2`. + | ^ + | +help: the opening backtick of a previous inline code may be missing + | +LL | /// `'?1` is in `U3` would be canonicalized to have `?0` in `U1` and `'?1` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// in `U2\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:270:42 + | +LL | /// because it contains `[type error]`. Yuck! (See issue #29857 for + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// as Trait>::Foo == $0`. Here, normalizing `<MyType<$0>` as + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// because it contains `[type error]\`. Yuck! (See issue #29857 for + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:280:53 + | +LL | /// well as the second instance of `A: AutoTrait`) to suppress + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// encountered a problem (later on) with `A:` AutoTrait. So we + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// well as the second instance of `A: AutoTrait\`) to suppress + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:290:40 + | +LL | /// `'a` with `'b` and not `'static`. But it will have to do for + | ^ + | + = help: the opening or closing backtick of an inline code may be missing +help: if you meant to use a literal backtick, escape it + | +LL | /// `'a` with `'b` and not `'static\`. But it will have to do for + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:299:54 + | +LL | /// `None`. Otherwise, it will return `Some(Dispatch)`. + | ^ + | +help: the opening backtick of a previous inline code may be missing + | +LL | /// The `Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// `None`. Otherwise, it will return `Some(Dispatch)\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:303:13 + | +LL | /// or `None` if it isn't. + | ^ + | + = help: the opening or closing backtick of an inline code may be missing +help: if you meant to use a literal backtick, escape it + | +LL | /// or `None\` if it isn't. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:307:14 + | +LL | /// `on_event` should be called. + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// Called before the filtered [`Layer`]'s [`on_event`], to determine if + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// `on_event\` should be called. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:312:29 + | +LL | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// Therefore, if the `Filter` will change the value returned by this + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// [`rebuild_interest_cache\`][rebuild] is called after the value of the max + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:322:5 + | +LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], +LL | | +LL | | +LL | | +... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max +LL | | /// level changes. + | |______________________^ + | + = help: the opening backtick of a previous inline code may be missing + change: The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], + to this: The `Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], + = help: if you meant to use a literal backtick, escape it + change: `None`. Otherwise, it will return `Some(Dispatch)`. + to this: `None`. Otherwise, it will return `Some(Dispatch)\`. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:322:5 + | +LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], +LL | | +LL | | +LL | | +... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max +LL | | /// level changes. + | |______________________^ + | + = help: the opening or closing backtick of an inline code may be missing + = help: if you meant to use a literal backtick, escape it + change: or `None` if it isn't. + to this: or `None\` if it isn't. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:322:5 + | +LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], +LL | | +LL | | +LL | | +... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max +LL | | /// level changes. + | |______________________^ + | + = help: a previous inline code might be longer than expected + change: Called before the filtered [`Layer]'s [`on_event`], to determine if + to this: Called before the filtered [`Layer`]'s [`on_event`], to determine if + = help: if you meant to use a literal backtick, escape it + change: `on_event` should be called. + to this: `on_event\` should be called. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:322:5 + | +LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], +LL | | +LL | | +LL | | +... | +LL | | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max +LL | | /// level changes. + | |______________________^ + | + = help: a previous inline code might be longer than expected + change: Therefore, if the `Filter will change the value returned by this + to this: Therefore, if the `Filter` will change the value returned by this + = help: if you meant to use a literal backtick, escape it + change: [`rebuild_interest_cache`][rebuild] is called after the value of the max + to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:348:56 + | +LL | /// instead and use [`CloneCounterObserver::counter`] to increment. + | ^ + | + = help: the opening or closing backtick of an inline code may be missing +help: if you meant to use a literal backtick, escape it + | +LL | /// instead and use [`CloneCounterObserver::counter\`] to increment. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:11:5 + | +LL | /// ` + | ^ + | + = help: the opening or closing backtick of an inline code may be missing +help: if you meant to use a literal backtick, escape it + | +LL | /// \` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:18:7 + | +LL | /// \` + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `\` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:25:6 + | +LL | /// [`link1] + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// [`link1`] + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// [\`link1] + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:29:11 + | +LL | /// [link2`] + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// [`link2`] + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// [link2\`] + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:33:6 + | +LL | /// [`link_long](link_long) + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// [`link_long`](link_long) + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// [\`link_long](link_long) + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:37:6 + | +LL | /// [`broken-link] + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// [`broken-link`] + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// [\`broken-link] + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:44:8 + | +LL | /// <x:`> + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `<x:`> + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// <x:\`> + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:54:6 + | +LL | /// 🦀`🦀 + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `🦀`🦀 + | + +help: the closing backtick of an inline code may be missing + | +LL | /// 🦀`🦀` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// 🦀\`🦀 + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:58:5 + | +LL | /// `foo( + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// `foo(` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \`foo( + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:64:14 + | +LL | /// `foo `bar` + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// `foo` `bar` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// `foo `bar\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:70:5 + | +LL | /// `foo( + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// not paragraph` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \`foo( + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:75:83 + | +LL | /// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. + | ^ + | +help: the opening backtick of a previous inline code may be missing + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:79:51 + | +LL | /// or even to add a number `n` to 42 (`add(42, b)`)! + | ^ + | +help: the opening backtick of a previous inline code may be missing + | +LL | /// You could use this function to add 42 to a number `n` (`add(n, 42)`), + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// or even to add a number `n` to 42 (`add(42, b)\`)! + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:83:83 + | +LL | /// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:87:51 + | +LL | /// or even to add a number `n` to 42 (`add(42, n)`)! + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// You could use this function to add 42 to a number `n` (`add(n, 42)`), + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:91:83 + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)\`. + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:95:50 + | +LL | /// or even to add a number `n` to 42 (add(42, n)`)! + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// or even to add a number `n` to 42 (`add(42, n)`)! + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// or even to add a number `n` to 42 (add(42, n)\`)! + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:99:74 + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// Addition is commutative, which means that `add(a, b)` is the same as \`add(b, a). + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:103:51 + | +LL | /// or even to add a number `n` to 42 (`add(42, n)`)! + | ^ + | +help: a previous inline code might be longer than expected + | +LL | /// You could use this function to add 42 to a number `n` (`add(n, 42)`), + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:107:1 + | +LL | #[doc = "`"] + | ^^^^^^^^^^^^ + | + = help: the opening or closing backtick of an inline code may be missing + = help: if you meant to use a literal backtick, escape it + change: ` + to this: \` + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:114:1 + | +LL | #[doc = concat!("\\", "`")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the opening backtick of an inline code may be missing + change: \` + to this: `\` + = help: if you meant to use a literal backtick, escape it + change: \` + to this: \\` + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:118:1 + | +LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`."] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the opening backtick of a previous inline code may be missing + change: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. + to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + = help: if you meant to use a literal backtick, escape it + change: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. + to this: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)\`. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:122:1 + | +LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`."] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: a previous inline code might be longer than expected + change: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. + to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + = help: if you meant to use a literal backtick, escape it + change: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. + to this: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)\`. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:126:1 + | +LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`."] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the opening backtick of an inline code may be missing + change: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. + to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + = help: if you meant to use a literal backtick, escape it + change: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. + to this: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)\`. + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:130:1 + | +LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)."] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the closing backtick of an inline code may be missing + change: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). + to this: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)`. + = help: if you meant to use a literal backtick, escape it + change: Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). + to this: Addition is commutative, which means that `add(a, b)` is the same as \`add(b, a). + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:135:5 + | +LL | /// `foo + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// `foo` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \`foo + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:139:7 + | +LL | /// # `(heading + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// # `(heading` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// # \`(heading + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:141:17 + | +LL | /// ## heading2)` + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// ## `heading2)` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// ## heading2)\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:144:11 + | +LL | /// multi `( + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// )` heading + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// multi \`( + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:150:10 + | +LL | /// para)`(graph + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `para)`(graph + | + +help: the closing backtick of an inline code may be missing + | +LL | /// para)`(graph` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// para)\`(graph + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:153:10 + | +LL | /// para)`(graph2 + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `para)`(graph2 + | + +help: the closing backtick of an inline code may be missing + | +LL | /// para)`(graph2` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// para)\`(graph2 + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:156:12 + | +LL | /// 1. foo)` + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// 1. `foo)` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// 1. foo)\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:158:8 + | +LL | /// 2. `(bar + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// 2. `(bar` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// 2. \`(bar + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:160:11 + | +LL | /// * baz)` + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// * `baz)` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// * baz)\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:162:7 + | +LL | /// * `(quux + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// * `(quux` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// * \`(quux + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:165:5 + | +LL | /// `#![this_is_actually_an_image(and(not), an = "attribute")] + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// `#`![this_is_actually_an_image(and(not), an = "attribute")] + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// \`#![this_is_actually_an_image(and(not), an = "attribute")] + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:168:62 + | +LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]` + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// `#![this_is_actually_an_image(and(not), an = "attribute")]` + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]\` + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:173:7 + | +LL | /// | `table( | )head` | + | ^ + | +help: the closing backtick of an inline code may be missing + | +LL | /// | `table(` | )head` | + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// | \`table( | )head` | + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:173:22 + | +LL | /// | `table( | )head` | + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// | `table( | `)head` | + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// | `table( | )head\` | + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:177:12 + | +LL | /// | table`( | )`body | + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// | `table`( | )`body | + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// | table\`( | )`body | + | + + +error: unescaped backtick + --> $DIR/unescaped_backticks.rs:177:18 + | +LL | /// | table`( | )`body | + | ^ + | +help: the opening backtick of an inline code may be missing + | +LL | /// | table`( | `)`body | + | + +help: the closing backtick of an inline code may be missing + | +LL | /// | table`( | )`body` | + | + +help: if you meant to use a literal backtick, escape it + | +LL | /// | table`( | )\`body | + | + + +error: aborting due to 64 previous errors + diff --git a/tests/rustdoc/deref-const-fn.rs b/tests/rustdoc/deref/deref-const-fn.rs index 8ecca6d12..8ecca6d12 100644 --- a/tests/rustdoc/deref-const-fn.rs +++ b/tests/rustdoc/deref/deref-const-fn.rs diff --git a/tests/rustdoc/deref/deref-multiple-impl-blocks.rs b/tests/rustdoc/deref/deref-multiple-impl-blocks.rs new file mode 100644 index 000000000..fa3607c5f --- /dev/null +++ b/tests/rustdoc/deref/deref-multiple-impl-blocks.rs @@ -0,0 +1,43 @@ +#![crate_name="foo"] + +use std::ops::{Deref, DerefMut}; + +// @has foo/struct.Vec.html +// @count - '//h2[@id="deref-methods-Slice"]' 1 +// @count - '//div[@id="deref-methods-Slice-1"]' 1 +// @count - '//div[@id="deref-methods-Slice-1"][@class="impl-items"]' 1 +// @count - '//div[@id="deref-methods-Slice-1"]/div[@class="impl-items"]' 0 +pub struct Vec; + +pub struct Slice; + +impl Deref for Vec { + type Target = Slice; + fn deref(&self) -> &Slice { + &Slice + } +} + +impl DerefMut for Vec { + fn deref_mut(&mut self) -> &mut Slice { + &mut Slice + } +} + +impl Slice { + pub fn sort_floats(&mut self) { + todo!(); + } +} + +impl Slice { + pub fn sort(&mut self) { + todo!(); + } +} + +impl Slice { + pub fn len(&self) { + todo!(); + } +} diff --git a/tests/rustdoc/deref-mut-methods.rs b/tests/rustdoc/deref/deref-mut-methods.rs index fdf843422..fdf843422 100644 --- a/tests/rustdoc/deref-mut-methods.rs +++ b/tests/rustdoc/deref/deref-mut-methods.rs diff --git a/tests/rustdoc/deref-recursive-pathbuf.rs b/tests/rustdoc/deref/deref-recursive-pathbuf.rs index be2b42b5a..be2b42b5a 100644 --- a/tests/rustdoc/deref-recursive-pathbuf.rs +++ b/tests/rustdoc/deref/deref-recursive-pathbuf.rs diff --git a/tests/rustdoc/deref-recursive.rs b/tests/rustdoc/deref/deref-recursive.rs index 0436f2f86..0436f2f86 100644 --- a/tests/rustdoc/deref-recursive.rs +++ b/tests/rustdoc/deref/deref-recursive.rs diff --git a/tests/rustdoc/deref-slice-core.rs b/tests/rustdoc/deref/deref-slice-core.rs index cccf273a8..cccf273a8 100644 --- a/tests/rustdoc/deref-slice-core.rs +++ b/tests/rustdoc/deref/deref-slice-core.rs diff --git a/tests/rustdoc/deref-to-primitive.rs b/tests/rustdoc/deref/deref-to-primitive.rs index 527de780d..527de780d 100644 --- a/tests/rustdoc/deref-to-primitive.rs +++ b/tests/rustdoc/deref/deref-to-primitive.rs diff --git a/tests/rustdoc/deref-typedef.rs b/tests/rustdoc/deref/deref-typedef.rs index 32424d13e..32424d13e 100644 --- a/tests/rustdoc/deref-typedef.rs +++ b/tests/rustdoc/deref/deref-typedef.rs diff --git a/tests/rustdoc/escape-deref-methods.rs b/tests/rustdoc/deref/escape-deref-methods.rs index 66919d73e..66919d73e 100644 --- a/tests/rustdoc/escape-deref-methods.rs +++ b/tests/rustdoc/deref/escape-deref-methods.rs diff --git a/tests/rustdoc/issue-100679-sidebar-links-deref.rs b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs index f09d23206..f09d23206 100644 --- a/tests/rustdoc/issue-100679-sidebar-links-deref.rs +++ b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs diff --git a/tests/rustdoc/recursive-deref-sidebar.rs b/tests/rustdoc/deref/recursive-deref-sidebar.rs index 619f40eff..619f40eff 100644 --- a/tests/rustdoc/recursive-deref-sidebar.rs +++ b/tests/rustdoc/deref/recursive-deref-sidebar.rs diff --git a/tests/rustdoc/recursive-deref.rs b/tests/rustdoc/deref/recursive-deref.rs index aa38485c4..aa38485c4 100644 --- a/tests/rustdoc/recursive-deref.rs +++ b/tests/rustdoc/deref/recursive-deref.rs diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs index d368db909..6006354eb 100644 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs @@ -29,7 +29,7 @@ pub trait Stage { // // @has - '//*[@id="associatedconstant.ARRAY1"]' \ // 'const ARRAY1: [u8; { _ }]' - const ARRAY1: [u8; Struct::new(/* ... */) + Self::ABSTRACT * 1_000]; + const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]; // @has - '//*[@id="associatedconstant.VERBOSE"]' \ // 'const VERBOSE: [u16; { _ }]' @@ -73,10 +73,14 @@ pub struct Struct { private: () } impl Struct { const fn new() -> Self { Self { private: () } } + const fn do_something(self, x: usize) -> usize { + x + } } - +/* FIXME(const-trait): readd this impl const std::ops::Add<usize> for Struct { type Output = usize; fn add(self, _: usize) -> usize { 0 } } +*/ diff --git a/tests/rustdoc/impl-alias-substituted.rs b/tests/rustdoc/impl-alias-substituted.rs new file mode 100644 index 000000000..82dfffe5f --- /dev/null +++ b/tests/rustdoc/impl-alias-substituted.rs @@ -0,0 +1,9 @@ +pub struct Matrix<T, const N: usize, const M: usize>([[T; N]; M]); + +pub type Vector<T, const N: usize> = Matrix<T, N, 1>; + +// @has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<T: Copy> Matrix<T, 3, 1>" +impl<T: Copy> Vector<T, 3> { + pub fn test() {} +} diff --git a/tests/rustdoc/inherent-projections.rs b/tests/rustdoc/inherent-projections.rs new file mode 100644 index 000000000..9bda0acaf --- /dev/null +++ b/tests/rustdoc/inherent-projections.rs @@ -0,0 +1,44 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// @has 'inherent_projections/fn.create.html' +// @has - '//pre[@class="rust item-decl"]' "create() -> Owner::Metadata" +// @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Owner.html#associatedtype.Metadata' +pub fn create() -> Owner::Metadata {} + +pub struct Owner; + +impl Owner { + pub type Metadata = (); +} + +// Make sure we handle bound vars correctly. +// @has 'inherent_projections/type.User.html' '//pre[@class="rust item-decl"]' "for<'a> fn(_: Carrier<'a>::Focus)" +pub type User = for<'a> fn(Carrier<'a>::Focus); + +pub struct Carrier<'a>(&'a ()); + +impl<'a> Carrier<'a> { + pub type Focus = &'a mut i32; +} + +//////////////////////////////////////// + +// FIXME(inherent_associated_types): Below we link to `Proj` but we should link to `Proj-1`. +// The current test checks for the buggy behavior for demonstration purposes. + +// @has 'inherent_projections/type.Test.html' +// @has - '//pre[@class="rust item-decl"]' "Parametrized<i32>" +// @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj' +// @!has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj-1' +pub type Test = Parametrized<i32>::Proj; + +pub struct Parametrized<T>(T); + +impl Parametrized<bool> { + pub type Proj = (); +} + +impl Parametrized<i32> { + pub type Proj = String; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/repr.rs b/tests/rustdoc/inline_cross/auxiliary/repr.rs new file mode 100644 index 000000000..4a6648a64 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/repr.rs @@ -0,0 +1,22 @@ +#![feature(repr_simd)] + +#[repr(C, align(8))] +pub struct ReprC { + field: u8, +} +#[repr(simd, packed(2))] +pub struct ReprSimd { + field: u8, +} +#[repr(transparent)] +pub struct ReprTransparent { + field: u8, +} +#[repr(isize)] +pub enum ReprIsize { + Bla, +} +#[repr(u8)] +pub enum ReprU8 { + Bla, +} diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs new file mode 100644 index 000000000..9e107cee9 --- /dev/null +++ b/tests/rustdoc/inline_cross/repr.rs @@ -0,0 +1,29 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/110698>. +// This test ensures that the re-exported items still have the `#[repr(...)]` attribute. + +// aux-build:repr.rs + +#![crate_name = "foo"] + +extern crate repr; + +// @has 'foo/struct.ReprC.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' +#[doc(inline)] +pub use repr::ReprC; +// @has 'foo/struct.ReprSimd.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' +#[doc(inline)] +pub use repr::ReprSimd; +// @has 'foo/struct.ReprTransparent.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[doc(inline)] +pub use repr::ReprTransparent; +// @has 'foo/enum.ReprIsize.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' +#[doc(inline)] +pub use repr::ReprIsize; +// @has 'foo/enum.ReprU8.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' +#[doc(inline)] +pub use repr::ReprU8; diff --git a/tests/rustdoc/intra-doc/inherent-associated-types.rs b/tests/rustdoc/intra-doc/inherent-associated-types.rs new file mode 100644 index 000000000..2b28d2ae6 --- /dev/null +++ b/tests/rustdoc/intra-doc/inherent-associated-types.rs @@ -0,0 +1,45 @@ +#![feature(inherent_associated_types)] + +#![allow(incomplete_features)] +#![deny(rustdoc::broken_intra_doc_links)] + +// @has inherent_associated_types/index.html + +// @has - '//a/@href' 'enum.Simple.html#associatedtype.Type' +//! [`Simple::Type`] + +pub enum Simple {} + +impl Simple { + pub type Type = (); +} + +//////////////////////////////////////// + +// @has 'inherent_associated_types/type.Test0.html' '//a/@href' \ +// 'struct.Parametrized.html#associatedtype.Proj' +/// [`Parametrized<bool>::Proj`] +pub type Test0 = (); + +// FIXME(inherent_associated_types): The intra-doc link below should point to `Proj-1` not `Proj`. +// The current test checks for the buggy behavior for demonstration purposes. +// The same bug happens for inherent associated functions and constants (see #85960, #93398). +// +// Further, at some point we should reject the intra-doc link `Parametrized::Proj`. +// It currently links to `Parametrized<bool>::Proj`. + +// @has 'inherent_associated_types/type.Test1.html' +// @has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj' +// @!has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj-1' +/// [`Parametrized<i32>::Proj`] +pub type Test1 = (); + +pub struct Parametrized<T>(T); + +impl Parametrized<bool> { + pub type Proj = (); +} + +impl Parametrized<i32> { + pub type Proj = String; +} diff --git a/tests/rustdoc/issue-106142.rs b/tests/rustdoc/issue-106142.rs new file mode 100644 index 000000000..41505e724 --- /dev/null +++ b/tests/rustdoc/issue-106142.rs @@ -0,0 +1,14 @@ +// @has 'issue_106142/a/index.html' +// @count 'issue_106142/a/index.html' '//ul[@class="item-table"]//li//a' 1 + +#![allow(rustdoc::broken_intra_doc_links)] + +pub mod a { + /// [`m`] + pub fn f() {} + + #[macro_export] + macro_rules! m { + () => {}; + } +} diff --git a/tests/rustdoc/issue-110422-inner-private.rs b/tests/rustdoc/issue-110422-inner-private.rs new file mode 100644 index 000000000..ee8ed5cc6 --- /dev/null +++ b/tests/rustdoc/issue-110422-inner-private.rs @@ -0,0 +1,64 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/110422>. +// This test ensures that inner items (except for implementations and macros) +// don't appear in documentation. + +// compile-flags: --document-private-items + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// Checking there is no "trait" entry. +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 4 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Functions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Macros' + +// @has - '//a[@href="fn.foo.html"]' 'foo' +fn foo() { + fn bar() {} + + // @has - '//a[@class="macro"]' 'visible_macro' + // @!has - '//a[@class="macro"]' 'non_visible_macro' + // @has 'foo/macro.visible_macro.html' + // @!has 'foo/macro.non_visible_macro.html' + #[macro_export] + macro_rules! visible_macro { + () => {} + } + + macro_rules! non_visible_macro { + () => {} + } +} + +// @has 'foo/index.html' +// @has - '//a[@href="struct.Bar.html"]' 'Bar' +struct Bar; + +const BAR: i32 = { + // @!has - '//a[@href="fn.yo.html"]' 'yo' + // @!has 'foo/fn.yo.html' + fn yo() {} + + // @!has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' + // @!has 'foo/trait.Foo.html' + trait Foo { + fn babar() {} + } + impl Foo for Bar {} + + // @has 'foo/struct.Bar.html' + // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' + // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 + // We now check that the `Foo` trait is not documented nor visible on `Bar` page. + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Implementations' + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Auto Trait Implementations' + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Blanket Implementations' + // @!has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' + impl Bar { + fn foo() {} + } + + 1 +}; diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/issue-110629-private-type-cycle.rs new file mode 100644 index 000000000..a4efbb098 --- /dev/null +++ b/tests/rustdoc/issue-110629-private-type-cycle.rs @@ -0,0 +1,19 @@ +// compile-flags: --document-private-items + +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; + +// @has issue_110629_private_type_cycle/type.Bar.html +// @has - '//pre[@class="rust item-decl"]' \ +// "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;" + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs new file mode 100644 index 000000000..8e1029a1c --- /dev/null +++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs @@ -0,0 +1,31 @@ +#![feature(no_core)] +#![no_core] +#![crate_name = "foo"] + +// @!has 'foo/hidden/index.html' +// FIXME: add missing `@` for the two next tests once issue is fixed! +// To be done in <https://github.com/rust-lang/rust/issues/111249>. +// !has 'foo/hidden/inner/index.html' +// !has 'foo/hidden/inner/trait.Foo.html' +#[doc(hidden)] +pub mod hidden { + pub mod inner { + pub trait Foo { + /// Hello, world! + fn test(); + } + } +} + +// @has 'foo/visible/index.html' +// @has 'foo/visible/trait.Foo.html' +#[doc(inline)] +pub use hidden::inner as visible; + +// @has 'foo/struct.Bar.html' +// @count - '//*[@id="impl-Foo-for-Bar"]' 1 +pub struct Bar; + +impl visible::Foo for Bar { + fn test() {} +} diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs new file mode 100644 index 000000000..a9ce4a345 --- /dev/null +++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs @@ -0,0 +1,21 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/111064>. +// Methods from a re-exported trait inside a `#[doc(hidden)]` item should +// be visible. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// @has - '//*[@id="main-content"]//*[@class="item-name"]/a[@href="trait.Foo.html"]' 'Foo' + +// @has 'foo/trait.Foo.html' +// @has - '//*[@id="main-content"]//*[@class="code-header"]' 'fn test()' + +#[doc(hidden)] +mod hidden { + pub trait Foo { + /// Hello, world! + fn test(); + } +} + +pub use hidden::Foo; diff --git a/tests/rustdoc/issue-46506-pub-reexport-of-pub-reexport.rs b/tests/rustdoc/issue-46506-pub-reexport-of-pub-reexport.rs new file mode 100644 index 000000000..d8953eaf5 --- /dev/null +++ b/tests/rustdoc/issue-46506-pub-reexport-of-pub-reexport.rs @@ -0,0 +1,24 @@ +// This is a regression test for <https://github.com/rust-lang/rust/issues/46506>. +// This test ensures that if public re-exported is re-exported, it won't be inlined. + +#![crate_name = "foo"] + +// @has 'foo/associations/index.html' +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Traits' +// @has - '//*[@id="main-content"]//a[@href="trait.GroupedBy.html"]' 'GroupedBy' +// @has 'foo/associations/trait.GroupedBy.html' +pub mod associations { + mod belongs_to { + pub trait GroupedBy {} + } + pub use self::belongs_to::GroupedBy; +} + +// @has 'foo/prelude/index.html' +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' +// @has - '//*[@id="main-content"]//*[@id="reexport.GroupedBy"]' 'pub use associations::GroupedBy;' +pub mod prelude { + pub use associations::GroupedBy; +} diff --git a/tests/rustdoc/issue-60522-duplicated-glob-reexport.rs b/tests/rustdoc/issue-60522-duplicated-glob-reexport.rs new file mode 100644 index 000000000..1429b5e47 --- /dev/null +++ b/tests/rustdoc/issue-60522-duplicated-glob-reexport.rs @@ -0,0 +1,39 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/60522>. +// This test ensures that the `banana` and `peach` modules don't appear twice +// and that the visible modules are not the re-exported ones. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 1 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Modules' +// @count - '//*[@id="main-content"]/*[@class="item-table"]//*[@class="mod"]' 2 +// @has - '//*[@id="main-content"]//*[@class="mod"]' 'banana' +// @has - '//*[@id="main-content"]//*[@href="banana/index.html"]' 'banana' +// @has - '//*[@id="main-content"]//*[@class="mod"]' 'peach' +// @has - '//*[@id="main-content"]//*[@href="peach/index.html"]' 'peach' + +pub use crate::my_crate::*; + +mod my_crate { + pub mod banana { + pub struct Yellow; + } + pub mod peach { + pub struct Pink; + } +} + +// @has 'foo/banana/index.html' +// @count - '//*[@id="main-content"]//*[@class="struct"]' 1 +// @has - '//*[@id="main-content"]//*[@class="struct"]' 'Brown' +pub mod banana { + pub struct Brown; +} + +// @has 'foo/peach/index.html' +// @count - '//*[@id="main-content"]//*[@class="struct"]' 1 +// @has - '//*[@id="main-content"]//*[@class="struct"]' 'Pungent' +pub mod peach { + pub struct Pungent; +} diff --git a/tests/rustdoc/issue-94183-blanket-impl-reexported-trait.rs b/tests/rustdoc/issue-94183-blanket-impl-reexported-trait.rs new file mode 100644 index 000000000..95ddd4c74 --- /dev/null +++ b/tests/rustdoc/issue-94183-blanket-impl-reexported-trait.rs @@ -0,0 +1,31 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/94183>. +// This test ensures that a publicly re-exported private trait will +// appear in the blanket impl list. + +#![crate_name = "foo"] + +// @has 'foo/struct.S.html' + +mod actual_sub { + pub trait Actual {} + pub trait Another {} + + // `Another` is publicly re-exported so it should appear in the blanket impl list. + // @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Another for T' + impl<T> Another for T {} + + trait Foo {} + + // `Foo` is not publicly re-exported nor reachable so it shouldn't appear in the + // blanket impl list. + // @!has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Foo for T' + impl<T> Foo for T {} +} + +pub use actual_sub::{Actual, Another}; + +// `Actual` is publicly re-exported so it should appear in the blanket impl list. +// @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Actual for T' +impl<T> Actual for T {} + +pub struct S; diff --git a/tests/rustdoc/nested-items-issue-111415.rs b/tests/rustdoc/nested-items-issue-111415.rs new file mode 100644 index 000000000..9b7688c33 --- /dev/null +++ b/tests/rustdoc/nested-items-issue-111415.rs @@ -0,0 +1,36 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/111415>. +// This test ensures that only impl blocks are documented in bodies. + +#![crate_name = "foo"] + +// @has 'foo/index.html' +// Checking there are only three sections. +// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Functions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Traits' +// Checking that there are only three items. +// @count - '//*[@id="main-content"]//*[@class="item-name"]' 3 +// @has - '//*[@id="main-content"]//a[@href="struct.Bar.html"]' 'Bar' +// @has - '//*[@id="main-content"]//a[@href="fn.foo.html"]' 'foo' +// @has - '//*[@id="main-content"]//a[@href="trait.Foo.html"]' 'Foo' + +// Now checking that the `foo` method is visible in `Bar` page. +// @has 'foo/struct.Bar.html' +// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub fn foo()' +// @has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar()' +pub struct Bar; + +pub trait Foo { + fn bar() {} +} + +pub fn foo() { + pub mod inaccessible {} + pub fn inner() {} + pub const BAR: u32 = 0; + impl Bar { + pub fn foo() {} + } + impl Foo for Bar {} +} diff --git a/tests/rustdoc/playground-arg.rs b/tests/rustdoc/playground-arg.rs index f3811fe0b..2542ed657 100644 --- a/tests/rustdoc/playground-arg.rs +++ b/tests/rustdoc/playground-arg.rs @@ -10,4 +10,4 @@ pub fn dummy() {} // ensure that `extern crate foo;` was inserted into code snips automatically: -// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0Ause+foo::dummy;%0Adummy();%0A%7D&edition=2015"]' "Run" +// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0A%23%5Ballow(unused_extern_crates)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0Ause+foo::dummy;%0Adummy();%0A%7D&edition=2015"]' "Run" diff --git a/tests/rustdoc/reexport-doc-hidden.rs b/tests/rustdoc/reexport-doc-hidden.rs index 3ea5fde72..d9ed95486 100644 --- a/tests/rustdoc/reexport-doc-hidden.rs +++ b/tests/rustdoc/reexport-doc-hidden.rs @@ -21,6 +21,5 @@ macro_rules! foo { () => {}; } -// This is a bug: https://github.com/rust-lang/rust/issues/59368 -// @!has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' pub use crate::foo as Macro; diff --git a/tests/rustdoc/reexport-hidden-macro.rs b/tests/rustdoc/reexport-hidden-macro.rs index afcfa9796..47a21e394 100644 --- a/tests/rustdoc/reexport-hidden-macro.rs +++ b/tests/rustdoc/reexport-hidden-macro.rs @@ -5,6 +5,7 @@ // @has 'foo/index.html' // @has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2' +// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' // @has 'foo/macro.Macro2.html' // @has - '//*[@class="docblock"]' 'Displayed' @@ -15,7 +16,6 @@ macro_rules! foo { () => {}; } -/// not displayed pub use crate::foo as Macro; /// Displayed #[doc(inline)] diff --git a/tests/rustdoc/reexport-of-doc-hidden.rs b/tests/rustdoc/reexport-of-doc-hidden.rs new file mode 100644 index 000000000..b733716c2 --- /dev/null +++ b/tests/rustdoc/reexport-of-doc-hidden.rs @@ -0,0 +1,42 @@ +// This test ensures that all re-exports of doc hidden elements are displayed. + +#![crate_name = "foo"] + +#[doc(hidden)] +pub struct Bar; + +#[macro_export] +#[doc(hidden)] +macro_rules! foo { + () => {}; +} + +// @has 'foo/index.html' +// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +pub use crate::foo as Macro; +// @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' +pub use crate::foo as Macro2; +// @has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;' +pub use crate::Bar as Boo; +// @has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;' +pub use crate::Bar as Boo2; + +pub fn fofo() {} + +// @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' +pub use crate::fofo as f1; +// @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' +pub use crate::fofo as f2; + +pub mod sub { + // @has 'foo/sub/index.html' + // @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' + pub use crate::foo as Macro; + // @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' + pub use crate::foo as Macro2; + + // @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' + pub use crate::fofo as f1; + // @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' + pub use crate::fofo as f2; +} diff --git a/tests/rustdoc/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs index 1120302ac..5d742dc39 100644 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/rfc-2632-const-trait-impl.rs @@ -13,57 +13,57 @@ use std::marker::Destruct; pub struct S<T>(T); // @!has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Clone' +// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Clone' +// @has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' #[const_trait] pub trait Tr<T> { // @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' - // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' + // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' - // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' - fn a<A: ~const Clone + ~const Destruct>() + // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' + fn a<A: ~const Fn() + ~const Destruct>() where - Option<A>: ~const Clone + ~const Destruct, + Option<A>: ~const Fn() + ~const Destruct, { } } // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Clone' +// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' -impl<T: ~const Clone + ~const Destruct> const Tr<T> for T +// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' +impl<T: ~const Fn() + ~const Destruct> const Tr<T> for T where - Option<T>: ~const Clone + ~const Destruct, + Option<T>: ~const Fn() + ~const Destruct, { - fn a<A: ~const Clone + ~const Destruct>() + fn a<A: ~const Fn() + ~const Destruct>() where - Option<A>: ~const Clone + ~const Destruct, + Option<A>: ~const Fn() + ~const Destruct, { } } // @!has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Clone' +// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' // @!has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Clone' -pub const fn foo<F: ~const Clone + ~const Destruct>() +// @has - '//pre[@class="rust item-decl"]/code/span[@class="where fmt-newline"]' ': Fn' +pub const fn foo<F: ~const Fn() + ~const Destruct>() where - Option<F>: ~const Clone + ~const Destruct, + Option<F>: ~const Fn() + ~const Destruct, { F::a() } impl<T> S<T> { // @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' - // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone' + // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' // @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' - // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone' - pub const fn foo<B, C: ~const Clone + ~const Destruct>() + // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Fn' + pub const fn foo<B, C: ~const Fn() + ~const Destruct>() where - B: ~const Clone + ~const Destruct, + B: ~const Fn() + ~const Destruct, { B::a() } diff --git a/tests/rustdoc/test-strikethrough.rs b/tests/rustdoc/test-strikethrough.rs index c7855729a..58162153b 100644 --- a/tests/rustdoc/test-strikethrough.rs +++ b/tests/rustdoc/test-strikethrough.rs @@ -1,6 +1,13 @@ #![crate_name = "foo"] -// @has foo/fn.f.html -// @has - //del "Y" -/// ~~Y~~ +// Test that strikethrough works with single and double tildes and that it shows up on +// the item's dedicated page as well as the parent module's summary of items. + +// @has foo/index.html //del 'strike' +// @has foo/index.html //del 'through' + +// @has foo/fn.f.html //del 'strike' +// @has foo/fn.f.html //del 'through' + +/// ~~strike~~ ~through~ pub fn f() {} diff --git a/tests/ui-fulldeps/compiler-calls.rs b/tests/ui-fulldeps/compiler-calls.rs index a9520b592..b6d3b7b04 100644 --- a/tests/ui-fulldeps/compiler-calls.rs +++ b/tests/ui-fulldeps/compiler-calls.rs @@ -2,7 +2,6 @@ // Test that the Callbacks interface to the compiler works. // ignore-cross-compile -// ignore-stage1 // ignore-remote #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/deriving-encodable-decodable-box.rs b/tests/ui-fulldeps/deriving-encodable-decodable-box.rs deleted file mode 100644 index 1c376f59e..000000000 --- a/tests/ui-fulldeps/deriving-encodable-decodable-box.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass - -#![allow(unused_imports)] -#![feature(rustc_private)] - -extern crate rustc_macros; -extern crate rustc_serialize; - -// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta -// files. -#[allow(unused_extern_crates)] -extern crate rustc_driver; - -use rustc_macros::{Decodable, Encodable}; -use rustc_serialize::opaque::{MemDecoder, MemEncoder}; -use rustc_serialize::{Decodable, Encodable, Encoder}; - -#[derive(Encodable, Decodable)] -struct A { - foo: Box<[bool]>, -} - -fn main() { - let obj = A { foo: Box::new([true, false]) }; - - let mut encoder = MemEncoder::new(); - obj.encode(&mut encoder); - let data = encoder.finish(); - - let mut decoder = MemDecoder::new(&data, 0); - let obj2 = A::decode(&mut decoder); - - assert_eq!(obj.foo, obj2.foo); -} diff --git a/tests/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs b/tests/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs deleted file mode 100644 index 844d40f2e..000000000 --- a/tests/ui-fulldeps/deriving-encodable-decodable-cell-refcell.rs +++ /dev/null @@ -1,44 +0,0 @@ -// run-pass - -#![allow(unused_imports)] -// This briefly tests the capability of `Cell` and `RefCell` to implement the -// `Encodable` and `Decodable` traits via `#[derive(Encodable, Decodable)]` -#![feature(rustc_private)] - -extern crate rustc_macros; -extern crate rustc_serialize; - -// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta -// files. -#[allow(unused_extern_crates)] -extern crate rustc_driver; - -use rustc_macros::{Decodable, Encodable}; -use rustc_serialize::opaque::{MemDecoder, MemEncoder}; -use rustc_serialize::{Decodable, Encodable, Encoder}; -use std::cell::{Cell, RefCell}; - -#[derive(Encodable, Decodable)] -struct A { - baz: isize, -} - -#[derive(Encodable, Decodable)] -struct B { - foo: Cell<bool>, - bar: RefCell<A>, -} - -fn main() { - let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) }; - - let mut encoder = MemEncoder::new(); - obj.encode(&mut encoder); - let data = encoder.finish(); - - let mut decoder = MemDecoder::new(&data, 0); - let obj2 = B::decode(&mut decoder); - - assert_eq!(obj.foo.get(), obj2.foo.get()); - assert_eq!(obj.bar.borrow().baz, obj2.bar.borrow().baz); -} diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs index 6ba13387b..1dd6d211b 100644 --- a/tests/ui-fulldeps/fluent-messages/test.rs +++ b/tests/ui-fulldeps/fluent-messages/test.rs @@ -3,8 +3,8 @@ #![feature(rustc_private)] #![crate_type = "lib"] -extern crate rustc_macros; -use rustc_macros::fluent_messages; +extern crate rustc_fluent_macro; +use rustc_fluent_macro::fluent_messages; /// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it /// expects `crate::DiagnosticMessage` to exist. diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.rs b/tests/ui-fulldeps/hash-stable-is-unstable.rs index 11fe688f3..37d7472ec 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.rs +++ b/tests/ui-fulldeps/hash-stable-is-unstable.rs @@ -1,4 +1,3 @@ -// ignore-stage1 // compile-flags: -Zdeduplicate-diagnostics=yes extern crate rustc_data_structures; //~^ use of unstable library feature 'rustc_private' diff --git a/tests/ui-fulldeps/hash-stable-is-unstable.stderr b/tests/ui-fulldeps/hash-stable-is-unstable.stderr index d25657691..1a8994d72 100644 --- a/tests/ui-fulldeps/hash-stable-is-unstable.stderr +++ b/tests/ui-fulldeps/hash-stable-is-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/hash-stable-is-unstable.rs:3:1 + --> $DIR/hash-stable-is-unstable.rs:2:1 | LL | extern crate rustc_data_structures; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | extern crate rustc_data_structures; = help: add `#![feature(rustc_private)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/hash-stable-is-unstable.rs:5:1 + --> $DIR/hash-stable-is-unstable.rs:4:1 | LL | extern crate rustc_macros; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | extern crate rustc_macros; = help: add `#![feature(rustc_private)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/hash-stable-is-unstable.rs:7:1 + --> $DIR/hash-stable-is-unstable.rs:6:1 | LL | extern crate rustc_query_system; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | extern crate rustc_query_system; = help: add `#![feature(rustc_private)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/hash-stable-is-unstable.rs:10:5 + --> $DIR/hash-stable-is-unstable.rs:9:5 | LL | use rustc_macros::HashStable; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | use rustc_macros::HashStable; = help: add `#![feature(rustc_private)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/hash-stable-is-unstable.rs:13:10 + --> $DIR/hash-stable-is-unstable.rs:12:10 | LL | #[derive(HashStable)] | ^^^^^^^^^^ diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index 3aa65d53d..994fc26ba 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -7,15 +7,17 @@ #![deny(rustc::diagnostic_outside_of_impl)] extern crate rustc_errors; +extern crate rustc_fluent_macro; extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddToDiagnostic, IntoDiagnostic, Diagnostic, DiagnosticBuilder, - ErrorGuaranteed, Handler, DiagnosticMessage, SubdiagnosticMessage, + AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, Handler, + IntoDiagnostic, SubdiagnosticMessage, }; -use rustc_macros::{fluent_messages, Diagnostic, Subdiagnostic}; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; fluent_messages! { "./diagnostics.ftl" } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index 6f797ebc2..6e670c018 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -1,5 +1,5 @@ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:41:17 + --> $DIR/diagnostics.rs:43:17 | LL | handler.struct_err("untranslatable diagnostic") | ^^^^^^^^^^ @@ -11,13 +11,13 @@ LL | #![deny(rustc::untranslatable_diagnostic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:61:14 + --> $DIR/diagnostics.rs:63:14 | LL | diag.note("untranslatable diagnostic"); | ^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:78:25 + --> $DIR/diagnostics.rs:80:25 | LL | let _diag = handler.struct_err(crate::fluent_generated::no_crate_example); | ^^^^^^^^^^ @@ -29,13 +29,13 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:81:25 + --> $DIR/diagnostics.rs:83:25 | LL | let _diag = handler.struct_err("untranslatable diagnostic"); | ^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:81:25 + --> $DIR/diagnostics.rs:83:25 | LL | let _diag = handler.struct_err("untranslatable diagnostic"); | ^^^^^^^^^^ diff --git a/tests/ui-fulldeps/issue-14021.rs b/tests/ui-fulldeps/issue-14021.rs deleted file mode 100644 index 309b5c4a0..000000000 --- a/tests/ui-fulldeps/issue-14021.rs +++ /dev/null @@ -1,33 +0,0 @@ -// run-pass - -#![allow(unused_mut)] -#![allow(unused_imports)] -#![feature(rustc_private)] - -extern crate rustc_macros; -extern crate rustc_serialize; - -// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta -// files. -#[allow(unused_extern_crates)] -extern crate rustc_driver; - -use rustc_macros::{Decodable, Encodable}; -use rustc_serialize::opaque::{MemDecoder, MemEncoder}; -use rustc_serialize::{Decodable, Encodable, Encoder}; - -#[derive(Encodable, Decodable, PartialEq, Debug)] -struct UnitLikeStruct; - -pub fn main() { - let obj = UnitLikeStruct; - - let mut encoder = MemEncoder::new(); - obj.encode(&mut encoder); - let data = encoder.finish(); - - let mut decoder = MemDecoder::new(&data, 0); - let obj2 = UnitLikeStruct::decode(&mut decoder); - - assert_eq!(obj, obj2); -} diff --git a/tests/ui-fulldeps/pathless-extern-unstable.rs b/tests/ui-fulldeps/pathless-extern-unstable.rs index 524b0c2f7..7fba8343b 100644 --- a/tests/ui-fulldeps/pathless-extern-unstable.rs +++ b/tests/ui-fulldeps/pathless-extern-unstable.rs @@ -1,4 +1,3 @@ -// ignore-stage1 // edition:2018 // compile-flags:--extern rustc_middle diff --git a/tests/ui-fulldeps/pathless-extern-unstable.stderr b/tests/ui-fulldeps/pathless-extern-unstable.stderr index dcc3cddd3..174cd3c28 100644 --- a/tests/ui-fulldeps/pathless-extern-unstable.stderr +++ b/tests/ui-fulldeps/pathless-extern-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/pathless-extern-unstable.rs:7:9 + --> $DIR/pathless-extern-unstable.rs:6:9 | LL | pub use rustc_middle; | ^^^^^^^^^^^^ diff --git a/tests/ui-fulldeps/auxiliary/empty-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs index c24cdc97a..c24cdc97a 100644 --- a/tests/ui-fulldeps/auxiliary/empty-plugin.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs diff --git a/tests/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs index 3f6caecaa..3f6caecaa 100644 --- a/tests/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs diff --git a/tests/ui-fulldeps/auxiliary/lint-for-crate.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs index 6304c07d2..6304c07d2 100644 --- a/tests/ui-fulldeps/auxiliary/lint-for-crate.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs diff --git a/tests/ui-fulldeps/auxiliary/lint-group-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs index 4a41e7fbb..4a41e7fbb 100644 --- a/tests/ui-fulldeps/auxiliary/lint-group-plugin-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs diff --git a/tests/ui-fulldeps/auxiliary/lint-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs index 30956deb7..30956deb7 100644 --- a/tests/ui-fulldeps/auxiliary/lint-plugin-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs diff --git a/tests/ui-fulldeps/auxiliary/lint-tool-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs index c2c024865..c2c024865 100644 --- a/tests/ui-fulldeps/auxiliary/lint-tool-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs diff --git a/tests/ui-fulldeps/auxiliary/lto-syntax-extension-lib.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs index 954a1e554..954a1e554 100644 --- a/tests/ui-fulldeps/auxiliary/lto-syntax-extension-lib.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs diff --git a/tests/ui-fulldeps/auxiliary/lto-syntax-extension-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs index 9b075c1a5..9b075c1a5 100644 --- a/tests/ui-fulldeps/auxiliary/lto-syntax-extension-plugin.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs diff --git a/tests/ui-fulldeps/auxiliary/multiple-plugins-1.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs index fd6e9e20f..fd6e9e20f 100644 --- a/tests/ui-fulldeps/auxiliary/multiple-plugins-1.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs diff --git a/tests/ui-fulldeps/auxiliary/multiple-plugins-2.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs index fd6e9e20f..fd6e9e20f 100644 --- a/tests/ui-fulldeps/auxiliary/multiple-plugins-2.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs diff --git a/tests/ui-fulldeps/auxiliary/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs index e83dfe804..e83dfe804 100644 --- a/tests/ui-fulldeps/auxiliary/outlive-expansion-phase.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs diff --git a/tests/ui-fulldeps/auxiliary/rlib-crate-test.rs b/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs index 3ba73538e..3ba73538e 100644 --- a/tests/ui-fulldeps/auxiliary/rlib-crate-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs diff --git a/tests/ui-fulldeps/feature-gate-plugin.rs b/tests/ui-fulldeps/plugin/feature-gate-plugin.rs index 85eaf5336..85eaf5336 100644 --- a/tests/ui-fulldeps/feature-gate-plugin.rs +++ b/tests/ui-fulldeps/plugin/feature-gate-plugin.rs diff --git a/tests/ui-fulldeps/feature-gate-plugin.stderr b/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr index 5e40561c7..5e40561c7 100644 --- a/tests/ui-fulldeps/feature-gate-plugin.stderr +++ b/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr diff --git a/tests/ui-fulldeps/gated-plugin.rs b/tests/ui-fulldeps/plugin/gated-plugin.rs index 85eaf5336..85eaf5336 100644 --- a/tests/ui-fulldeps/gated-plugin.rs +++ b/tests/ui-fulldeps/plugin/gated-plugin.rs diff --git a/tests/ui-fulldeps/gated-plugin.stderr b/tests/ui-fulldeps/plugin/gated-plugin.stderr index f48f1eab6..f48f1eab6 100644 --- a/tests/ui-fulldeps/gated-plugin.stderr +++ b/tests/ui-fulldeps/plugin/gated-plugin.stderr diff --git a/tests/ui-fulldeps/issue-15778-fail.rs b/tests/ui-fulldeps/plugin/issue-15778-fail.rs index beecaadf9..beecaadf9 100644 --- a/tests/ui-fulldeps/issue-15778-fail.rs +++ b/tests/ui-fulldeps/plugin/issue-15778-fail.rs diff --git a/tests/ui-fulldeps/issue-15778-fail.stderr b/tests/ui-fulldeps/plugin/issue-15778-fail.stderr index a37893e12..a37893e12 100644 --- a/tests/ui-fulldeps/issue-15778-fail.stderr +++ b/tests/ui-fulldeps/plugin/issue-15778-fail.stderr diff --git a/tests/ui-fulldeps/issue-40001.rs b/tests/ui-fulldeps/plugin/issue-40001.rs index e14338fdb..e14338fdb 100644 --- a/tests/ui-fulldeps/issue-40001.rs +++ b/tests/ui-fulldeps/plugin/issue-40001.rs diff --git a/tests/ui-fulldeps/issue-40001.stderr b/tests/ui-fulldeps/plugin/issue-40001.stderr index 73ec06924..73ec06924 100644 --- a/tests/ui-fulldeps/issue-40001.stderr +++ b/tests/ui-fulldeps/plugin/issue-40001.stderr diff --git a/tests/ui-fulldeps/lint-group-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs index 9f8a87960..9f8a87960 100644 --- a/tests/ui-fulldeps/lint-group-plugin-deny-cmdline.rs +++ b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs diff --git a/tests/ui-fulldeps/lint-group-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr index 20486d596..20486d596 100644 --- a/tests/ui-fulldeps/lint-group-plugin-deny-cmdline.stderr +++ b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr diff --git a/tests/ui-fulldeps/lint-group-plugin.rs b/tests/ui-fulldeps/plugin/lint-group-plugin.rs index 7b74be7a9..7b74be7a9 100644 --- a/tests/ui-fulldeps/lint-group-plugin.rs +++ b/tests/ui-fulldeps/plugin/lint-group-plugin.rs diff --git a/tests/ui-fulldeps/lint-group-plugin.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin.stderr index 6f429dad0..6f429dad0 100644 --- a/tests/ui-fulldeps/lint-group-plugin.stderr +++ b/tests/ui-fulldeps/plugin/lint-group-plugin.stderr diff --git a/tests/ui-fulldeps/lint-plugin-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs index 1cc16e2fd..1cc16e2fd 100644 --- a/tests/ui-fulldeps/lint-plugin-cmdline-allow.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs diff --git a/tests/ui-fulldeps/lint-plugin-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr index f06703a27..f06703a27 100644 --- a/tests/ui-fulldeps/lint-plugin-cmdline-allow.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr diff --git a/tests/ui-fulldeps/lint-plugin-cmdline-load.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs index 0bd95dfbd..0bd95dfbd 100644 --- a/tests/ui-fulldeps/lint-plugin-cmdline-load.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs diff --git a/tests/ui-fulldeps/lint-plugin-cmdline-load.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr index 82679c9e1..82679c9e1 100644 --- a/tests/ui-fulldeps/lint-plugin-cmdline-load.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr diff --git a/tests/ui-fulldeps/lint-plugin-deny-attr.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs index 04230a8e8..04230a8e8 100644 --- a/tests/ui-fulldeps/lint-plugin-deny-attr.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs diff --git a/tests/ui-fulldeps/lint-plugin-deny-attr.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr index 5e8891bf1..5e8891bf1 100644 --- a/tests/ui-fulldeps/lint-plugin-deny-attr.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr diff --git a/tests/ui-fulldeps/lint-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs index c460cfd5f..c460cfd5f 100644 --- a/tests/ui-fulldeps/lint-plugin-deny-cmdline.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs diff --git a/tests/ui-fulldeps/lint-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr index d5d6b5352..d5d6b5352 100644 --- a/tests/ui-fulldeps/lint-plugin-deny-cmdline.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr diff --git a/tests/ui-fulldeps/lint-plugin-forbid-attrs.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs index cf31b3ec1..cf31b3ec1 100644 --- a/tests/ui-fulldeps/lint-plugin-forbid-attrs.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs diff --git a/tests/ui-fulldeps/lint-plugin-forbid-attrs.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr index ae34b25cc..ae34b25cc 100644 --- a/tests/ui-fulldeps/lint-plugin-forbid-attrs.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr diff --git a/tests/ui-fulldeps/lint-plugin-forbid-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs index b9d1aa85a..b9d1aa85a 100644 --- a/tests/ui-fulldeps/lint-plugin-forbid-cmdline.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs diff --git a/tests/ui-fulldeps/lint-plugin-forbid-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr index 491c4d206..491c4d206 100644 --- a/tests/ui-fulldeps/lint-plugin-forbid-cmdline.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr diff --git a/tests/ui-fulldeps/lint-plugin.rs b/tests/ui-fulldeps/plugin/lint-plugin.rs index 66057eea6..66057eea6 100644 --- a/tests/ui-fulldeps/lint-plugin.rs +++ b/tests/ui-fulldeps/plugin/lint-plugin.rs diff --git a/tests/ui-fulldeps/lint-plugin.stderr b/tests/ui-fulldeps/plugin/lint-plugin.stderr index dd5d3d72e..dd5d3d72e 100644 --- a/tests/ui-fulldeps/lint-plugin.stderr +++ b/tests/ui-fulldeps/plugin/lint-plugin.stderr diff --git a/tests/ui-fulldeps/lint-tool-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs index 83a8b3e1a..83a8b3e1a 100644 --- a/tests/ui-fulldeps/lint-tool-cmdline-allow.rs +++ b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs diff --git a/tests/ui-fulldeps/lint-tool-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr index b060e3a3e..b060e3a3e 100644 --- a/tests/ui-fulldeps/lint-tool-cmdline-allow.stderr +++ b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr diff --git a/tests/ui-fulldeps/lint-tool-test.rs b/tests/ui-fulldeps/plugin/lint-tool-test.rs index f92bcd213..f92bcd213 100644 --- a/tests/ui-fulldeps/lint-tool-test.rs +++ b/tests/ui-fulldeps/plugin/lint-tool-test.rs diff --git a/tests/ui-fulldeps/lint-tool-test.stderr b/tests/ui-fulldeps/plugin/lint-tool-test.stderr index 027cf8f80..027cf8f80 100644 --- a/tests/ui-fulldeps/lint-tool-test.stderr +++ b/tests/ui-fulldeps/plugin/lint-tool-test.stderr diff --git a/tests/ui-fulldeps/lto-syntax-extension.rs b/tests/ui-fulldeps/plugin/lto-syntax-extension.rs index 5964e70f1..5964e70f1 100644 --- a/tests/ui-fulldeps/lto-syntax-extension.rs +++ b/tests/ui-fulldeps/plugin/lto-syntax-extension.rs diff --git a/tests/ui-fulldeps/lto-syntax-extension.stderr b/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr index 555493f32..555493f32 100644 --- a/tests/ui-fulldeps/lto-syntax-extension.stderr +++ b/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr diff --git a/tests/ui-fulldeps/macro-crate-rlib.rs b/tests/ui-fulldeps/plugin/macro-crate-rlib.rs index 1fd514c61..38bd34053 100644 --- a/tests/ui-fulldeps/macro-crate-rlib.rs +++ b/tests/ui-fulldeps/plugin/macro-crate-rlib.rs @@ -1,4 +1,5 @@ // aux-build:rlib-crate-test.rs +// ignore-stage1 // ignore-cross-compile gives a different error message #![feature(plugin)] diff --git a/tests/ui-fulldeps/macro-crate-rlib.stderr b/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr index 9c2b992b7..0651cee56 100644 --- a/tests/ui-fulldeps/macro-crate-rlib.stderr +++ b/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr @@ -1,5 +1,5 @@ error[E0457]: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib format - --> $DIR/macro-crate-rlib.rs:5:11 + --> $DIR/macro-crate-rlib.rs:6:11 | LL | #![plugin(rlib_crate_test)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui-fulldeps/multiple-plugins.rs b/tests/ui-fulldeps/plugin/multiple-plugins.rs index 9af3ebd57..9af3ebd57 100644 --- a/tests/ui-fulldeps/multiple-plugins.rs +++ b/tests/ui-fulldeps/plugin/multiple-plugins.rs diff --git a/tests/ui-fulldeps/multiple-plugins.stderr b/tests/ui-fulldeps/plugin/multiple-plugins.stderr index 878ffabfc..878ffabfc 100644 --- a/tests/ui-fulldeps/multiple-plugins.stderr +++ b/tests/ui-fulldeps/plugin/multiple-plugins.stderr diff --git a/tests/ui-fulldeps/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs index fb22888d9..fb22888d9 100644 --- a/tests/ui-fulldeps/outlive-expansion-phase.rs +++ b/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs diff --git a/tests/ui-fulldeps/outlive-expansion-phase.stderr b/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr index e40a08ae7..e40a08ae7 100644 --- a/tests/ui-fulldeps/outlive-expansion-phase.stderr +++ b/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr diff --git a/tests/ui-fulldeps/plugin-args.rs b/tests/ui-fulldeps/plugin/plugin-args.rs index 488f2b775..488f2b775 100644 --- a/tests/ui-fulldeps/plugin-args.rs +++ b/tests/ui-fulldeps/plugin/plugin-args.rs diff --git a/tests/ui-fulldeps/plugin-args.stderr b/tests/ui-fulldeps/plugin/plugin-args.stderr index 177f33005..177f33005 100644 --- a/tests/ui-fulldeps/plugin-args.stderr +++ b/tests/ui-fulldeps/plugin/plugin-args.stderr diff --git a/tests/ui-fulldeps/plugin-as-extern-crate.rs b/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs index 4d26e08d8..4d26e08d8 100644 --- a/tests/ui-fulldeps/plugin-as-extern-crate.rs +++ b/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs new file mode 100644 index 000000000..642b58b07 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -0,0 +1,49 @@ +// check-fail +// Tests that a doc comment will not preclude a field from being considered a diagnostic argument +// normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" +// normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC" + +// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, +// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler +// the test is just ignored on stable and beta: +// ignore-stage1 +// ignore-beta +// ignore-stable + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_errors; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_session; +extern crate rustc_span; + +use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage}; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::{Diagnostic, Subdiagnostic}; +use rustc_span::Span; + +fluent_messages! { "./example.ftl" } + +struct NotIntoDiagnosticArg; + +#[derive(Diagnostic)] +#[diag(no_crate_example)] +struct Test { + #[primary_span] + span: Span, + /// A doc comment + arg: NotIntoDiagnosticArg, + //~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +} + +#[derive(Subdiagnostic)] +#[label(no_crate_example)] +struct SubTest { + #[primary_span] + span: Span, + /// A doc comment + arg: NotIntoDiagnosticArg, + //~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +} diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr new file mode 100644 index 000000000..e4b8958b4 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -0,0 +1,30 @@ +error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + --> $DIR/diagnostic-derive-doc-comment-field.rs:37:10 + | +LL | #[derive(Diagnostic)] + | ---------- required by a bound introduced by this call +... +LL | arg: NotIntoDiagnosticArg, + | ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` + | + = help: normalized in stderr +note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC + = note: this error originates in the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + --> $DIR/diagnostic-derive-doc-comment-field.rs:47:10 + | +LL | #[derive(Subdiagnostic)] + | ------------- required by a bound introduced by this call +... +LL | arg: NotIntoDiagnosticArg, + | ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` + | + = help: normalized in stderr +note: required by a bound in `Diagnostic::set_arg` + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:964:5 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 6cc7bab37..39e34d73f 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -6,6 +6,7 @@ // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // changing the output of this test. Since Diagnostic is strictly internal to the compiler // the test is just ignored on stable and beta: +// ignore-stage1 // ignore-beta // ignore-stable @@ -16,8 +17,10 @@ extern crate rustc_span; use rustc_span::symbol::Ident; use rustc_span::Span; +extern crate rustc_fluent_macro; extern crate rustc_macros; -use rustc_macros::{fluent_messages, Diagnostic, LintDiagnostic, Subdiagnostic}; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; extern crate rustc_middle; use rustc_middle::ty::Ty; @@ -336,12 +339,12 @@ struct ErrorWithDefaultLabelAttr<'a> { } #[derive(Diagnostic)] -//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied #[diag(no_crate_example, code = "E0123")] struct ArgFieldWithoutSkip { #[primary_span] span: Span, other: Hello, + //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied } #[derive(Diagnostic)] diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index a2f3bb527..801e4b579 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,11 +1,11 @@ error: unsupported type attribute for diagnostic derive enum - --> $DIR/diagnostic-derive.rs:41:1 + --> $DIR/diagnostic-derive.rs:44:1 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:44:5 + --> $DIR/diagnostic-derive.rs:47:5 | LL | Foo, | ^^^ @@ -13,7 +13,7 @@ LL | Foo, = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:46:5 + --> $DIR/diagnostic-derive.rs:49:5 | LL | Bar, | ^^^ @@ -21,19 +21,19 @@ LL | Bar, = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: expected parentheses: #[diag(...)] - --> $DIR/diagnostic-derive.rs:52:8 + --> $DIR/diagnostic-derive.rs:55:8 | LL | #[diag = "E0123"] | ^ error: `#[nonsense(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:57:1 + --> $DIR/diagnostic-derive.rs:60:1 | LL | #[nonsense(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:57:1 + --> $DIR/diagnostic-derive.rs:60:1 | LL | / #[nonsense(no_crate_example, code = "E0123")] LL | | @@ -45,7 +45,7 @@ LL | | struct InvalidStructAttr {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:64:1 + --> $DIR/diagnostic-derive.rs:67:1 | LL | / #[diag("E0123")] LL | | @@ -55,13 +55,13 @@ LL | | struct InvalidLitNestedAttr {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug must be the first argument - --> $DIR/diagnostic-derive.rs:74:16 + --> $DIR/diagnostic-derive.rs:77:16 | LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")] | ^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:74:1 + --> $DIR/diagnostic-derive.rs:77:1 | LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")] LL | | @@ -72,7 +72,7 @@ LL | | struct InvalidNestedStructAttr1 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:80:8 + --> $DIR/diagnostic-derive.rs:83:8 | LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] | ^^^^^^^^ @@ -80,7 +80,7 @@ LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:80:1 + --> $DIR/diagnostic-derive.rs:83:1 | LL | / #[diag(nonsense = "...", code = "E0123", slug = "foo")] LL | | @@ -91,7 +91,7 @@ LL | | struct InvalidNestedStructAttr2 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:86:8 + --> $DIR/diagnostic-derive.rs:89:8 | LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] | ^^^^^^^^ @@ -99,7 +99,7 @@ LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:86:1 + --> $DIR/diagnostic-derive.rs:89:1 | LL | / #[diag(nonsense = 4, code = "E0123", slug = "foo")] LL | | @@ -110,7 +110,7 @@ LL | | struct InvalidNestedStructAttr3 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:92:42 + --> $DIR/diagnostic-derive.rs:95:42 | LL | #[diag(no_crate_example, code = "E0123", slug = "foo")] | ^^^^ @@ -118,55 +118,55 @@ LL | #[diag(no_crate_example, code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: `#[suggestion = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:99:5 + --> $DIR/diagnostic-derive.rs:102:5 | LL | #[suggestion = "bar"] | ^^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:106:8 + --> $DIR/diagnostic-derive.rs:109:8 | LL | #[diag(no_crate_example, code = "E0456")] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:105:8 + --> $DIR/diagnostic-derive.rs:108:8 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:106:26 + --> $DIR/diagnostic-derive.rs:109:26 | LL | #[diag(no_crate_example, code = "E0456")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:105:26 + --> $DIR/diagnostic-derive.rs:108:26 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:112:42 + --> $DIR/diagnostic-derive.rs:115:42 | LL | #[diag(no_crate_example, code = "E0456", code = "E0457")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:112:26 + --> $DIR/diagnostic-derive.rs:115:26 | LL | #[diag(no_crate_example, code = "E0456", code = "E0457")] | ^^^^ error: diagnostic slug must be the first argument - --> $DIR/diagnostic-derive.rs:117:43 + --> $DIR/diagnostic-derive.rs:120:43 | LL | #[diag(no_crate_example, no_crate::example, code = "E0456")] | ^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:122:1 + --> $DIR/diagnostic-derive.rs:125:1 | LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | struct KindNotProvided {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:125:1 + --> $DIR/diagnostic-derive.rs:128:1 | LL | / #[diag(code = "E0456")] LL | | @@ -184,31 +184,31 @@ LL | | struct SlugNotProvided {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:136:5 + --> $DIR/diagnostic-derive.rs:139:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: `#[nonsense]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:144:5 + --> $DIR/diagnostic-derive.rs:147:5 | LL | #[nonsense] | ^^^^^^^^^^^ error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:161:5 + --> $DIR/diagnostic-derive.rs:164:5 | LL | #[label(no_crate_label)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `name` doesn't refer to a field on this type - --> $DIR/diagnostic-derive.rs:169:46 + --> $DIR/diagnostic-derive.rs:172:46 | LL | #[suggestion(no_crate_suggestion, code = "{name}")] | ^^^^^^^^ error: invalid format string: expected `'}'` but string was terminated - --> $DIR/diagnostic-derive.rs:174:10 + --> $DIR/diagnostic-derive.rs:177:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ expected `'}'` in format string @@ -217,7 +217,7 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid format string: unmatched `}` found - --> $DIR/diagnostic-derive.rs:184:10 + --> $DIR/diagnostic-derive.rs:187:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ unmatched `}` in format string @@ -226,19 +226,19 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:204:5 + --> $DIR/diagnostic-derive.rs:207:5 | LL | #[label(no_crate_label)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:223:5 + --> $DIR/diagnostic-derive.rs:226:5 | LL | #[suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:231:18 + --> $DIR/diagnostic-derive.rs:234:18 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^ @@ -246,13 +246,13 @@ LL | #[suggestion(nonsense = "bar")] = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:231:5 + --> $DIR/diagnostic-derive.rs:234:5 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:240:18 + --> $DIR/diagnostic-derive.rs:243:18 | LL | #[suggestion(msg = "bar")] | ^^^ @@ -260,13 +260,13 @@ LL | #[suggestion(msg = "bar")] = help: only `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:240:5 + --> $DIR/diagnostic-derive.rs:243:5 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wrong field type for suggestion - --> $DIR/diagnostic-derive.rs:263:5 + --> $DIR/diagnostic-derive.rs:266:5 | LL | / #[suggestion(no_crate_suggestion, code = "This is suggested code")] LL | | @@ -276,79 +276,79 @@ LL | | suggestion: Applicability, = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` error: specified multiple times - --> $DIR/diagnostic-derive.rs:279:24 + --> $DIR/diagnostic-derive.rs:282:24 | LL | suggestion: (Span, Span, Applicability), | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:279:18 + --> $DIR/diagnostic-derive.rs:282:18 | LL | suggestion: (Span, Span, Applicability), | ^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:287:33 + --> $DIR/diagnostic-derive.rs:290:33 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:287:18 + --> $DIR/diagnostic-derive.rs:290:18 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:294:5 + --> $DIR/diagnostic-derive.rs:297:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:445:5 + --> $DIR/diagnostic-derive.rs:448:5 | LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:447:24 + --> $DIR/diagnostic-derive.rs:450:24 | LL | suggestion: (Span, Applicability), | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:453:69 + --> $DIR/diagnostic-derive.rs:456:69 | LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")] | ^^^^^^^^ error: the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()` - --> $DIR/diagnostic-derive.rs:520:5 + --> $DIR/diagnostic-derive.rs:523:5 | LL | #[help(no_crate_help)] | ^^^^^^^^^^^^^^^^^^^^^^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/diagnostic-derive.rs:529:32 + --> $DIR/diagnostic-derive.rs:532:32 | LL | #[label(no_crate_label, foo)] | ^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:537:29 + --> $DIR/diagnostic-derive.rs:540:29 | LL | #[label(no_crate_label, foo = "...")] | ^^^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:545:29 + --> $DIR/diagnostic-derive.rs:548:29 | LL | #[label(no_crate_label, foo("..."))] | ^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:557:5 + --> $DIR/diagnostic-derive.rs:560:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -356,13 +356,13 @@ LL | #[primary_span] = help: the `primary_span` field attribute is not valid for lint diagnostics error: `#[error(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:577:1 + --> $DIR/diagnostic-derive.rs:580:1 | LL | #[error(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:577:1 + --> $DIR/diagnostic-derive.rs:580:1 | LL | / #[error(no_crate_example, code = "E0123")] LL | | @@ -374,13 +374,13 @@ LL | | struct ErrorAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[warn_(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:584:1 + --> $DIR/diagnostic-derive.rs:587:1 | LL | #[warn_(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:584:1 + --> $DIR/diagnostic-derive.rs:587:1 | LL | / #[warn_(no_crate_example, code = "E0123")] LL | | @@ -392,13 +392,13 @@ LL | | struct WarnAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:591:1 + --> $DIR/diagnostic-derive.rs:594:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:591:1 + --> $DIR/diagnostic-derive.rs:594:1 | LL | / #[lint(no_crate_example, code = "E0123")] LL | | @@ -410,19 +410,19 @@ LL | | struct LintAttributeOnSessionDiag {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:598:1 + --> $DIR/diagnostic-derive.rs:601:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:598:1 + --> $DIR/diagnostic-derive.rs:601:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:598:1 + --> $DIR/diagnostic-derive.rs:601:1 | LL | / #[lint(no_crate_example, code = "E0123")] LL | | @@ -435,19 +435,19 @@ LL | | struct LintAttributeOnLintDiag {} = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` error: specified multiple times - --> $DIR/diagnostic-derive.rs:608:53 + --> $DIR/diagnostic-derive.rs:611:53 | LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:608:39 + --> $DIR/diagnostic-derive.rs:611:39 | LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] | ^^^^ error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:617:24 + --> $DIR/diagnostic-derive.rs:620:24 | LL | suggestion: (Span, usize), | ^^^^^ @@ -455,7 +455,7 @@ LL | suggestion: (Span, usize), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:625:17 + --> $DIR/diagnostic-derive.rs:628:17 | LL | suggestion: (Span,), | ^^^^^^^ @@ -463,13 +463,13 @@ LL | suggestion: (Span,), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:632:5 + --> $DIR/diagnostic-derive.rs:635:5 | LL | #[suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:639:1 + --> $DIR/diagnostic-derive.rs:642:1 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -477,7 +477,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:646:5 + --> $DIR/diagnostic-derive.rs:649:5 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -485,13 +485,13 @@ LL | #[multipart_suggestion(no_crate_suggestion)] = help: consider creating a `Subdiagnostic` instead error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/diagnostic-derive.rs:642:24 + --> $DIR/diagnostic-derive.rs:645:24 | LL | #[multipart_suggestion()] | ^ error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:654:1 + --> $DIR/diagnostic-derive.rs:657:1 | LL | #[suggestion(no_crate_suggestion, code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -499,7 +499,7 @@ LL | #[suggestion(no_crate_suggestion, code = "...")] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[label]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:663:1 + --> $DIR/diagnostic-derive.rs:666:1 | LL | #[label] | ^^^^^^^^ @@ -507,31 +507,31 @@ LL | #[label] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:697:7 + --> $DIR/diagnostic-derive.rs:700:7 | LL | #[subdiagnostic(bad)] | ^^^^^^^^^^^^^^^^^^ error: `#[subdiagnostic = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:705:5 + --> $DIR/diagnostic-derive.rs:708:5 | LL | #[subdiagnostic = "bad"] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:713:7 + --> $DIR/diagnostic-derive.rs:716:7 | LL | #[subdiagnostic(bad, bad)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:721:7 + --> $DIR/diagnostic-derive.rs:724:7 | LL | #[subdiagnostic("bad")] | ^^^^^^^^^^^^^^^^^^^^ error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:729:5 + --> $DIR/diagnostic-derive.rs:732:5 | LL | #[subdiagnostic(eager)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -539,31 +539,31 @@ LL | #[subdiagnostic(eager)] = help: eager subdiagnostics are not supported on lints error: expected at least one string literal for `code(...)` - --> $DIR/diagnostic-derive.rs:787:23 + --> $DIR/diagnostic-derive.rs:790:23 | LL | #[suggestion(code())] | ^ error: `code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:795:23 + --> $DIR/diagnostic-derive.rs:798:23 | LL | #[suggestion(code(foo))] | ^^^ error: unexpected token - --> $DIR/diagnostic-derive.rs:795:23 + --> $DIR/diagnostic-derive.rs:798:23 | LL | #[suggestion(code(foo))] | ^^^ error: expected string literal - --> $DIR/diagnostic-derive.rs:804:25 + --> $DIR/diagnostic-derive.rs:807:25 | LL | #[suggestion(code = 3)] | ^ error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:819:5 + --> $DIR/diagnostic-derive.rs:822:5 | LL | #[suggestion(no_crate_suggestion, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -573,67 +573,67 @@ LL | #[suggestion(no_crate_suggestion, code = "")] = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:57:3 + --> $DIR/diagnostic-derive.rs:60:3 | LL | #[nonsense(no_crate_example, code = "E0123")] | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:144:7 + --> $DIR/diagnostic-derive.rs:147:7 | LL | #[nonsense] | ^^^^^^^^ error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive.rs:577:3 + --> $DIR/diagnostic-derive.rs:580:3 | LL | #[error(no_crate_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive.rs:584:3 + --> $DIR/diagnostic-derive.rs:587:3 | LL | #[warn_(no_crate_example, code = "E0123")] | ^^^^^ help: a built-in attribute with a similar name exists: `warn` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:591:3 + --> $DIR/diagnostic-derive.rs:594:3 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:598:3 + --> $DIR/diagnostic-derive.rs:601:3 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:639:3 + --> $DIR/diagnostic-derive.rs:642:3 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:642:3 + --> $DIR/diagnostic-derive.rs:645:3 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:646:7 + --> $DIR/diagnostic-derive.rs:649:7 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated` - --> $DIR/diagnostic-derive.rs:69:8 + --> $DIR/diagnostic-derive.rs:72:8 | LL | #[diag(nonsense, code = "E0123")] | ^^^^^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_34` in this scope - --> $DIR/diagnostic-derive.rs:801:10 + --> $DIR/diagnostic-derive.rs:804:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ not found in this scope @@ -641,15 +641,18 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied - --> $DIR/diagnostic-derive.rs:338:10 + --> $DIR/diagnostic-derive.rs:346:12 | LL | #[derive(Diagnostic)] - | ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` + | ---------- required by a bound introduced by this call +... +LL | other: Hello, + | ^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` | = help: normalized in stderr note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC - = note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 84 previous errors diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 1d928ca93..1bfbb6001 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -4,6 +4,7 @@ // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // changing the output of this test. Since Subdiagnostic is strictly internal to the compiler // the test is just ignored on stable and beta: +// ignore-stage1 // ignore-beta // ignore-stable @@ -11,12 +12,14 @@ #![crate_type = "lib"] extern crate rustc_errors; +extern crate rustc_fluent_macro; extern crate rustc_macros; extern crate rustc_session; extern crate rustc_span; use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage}; -use rustc_macros::{fluent_messages, Subdiagnostic}; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::Subdiagnostic; use rustc_span::Span; fluent_messages! { "./example.ftl" } diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 4211b91f0..fca4f5068 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -1,5 +1,5 @@ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:49:1 + --> $DIR/subdiagnostic-derive.rs:52:1 | LL | / #[label(no_crate_example)] LL | | @@ -9,133 +9,133 @@ LL | | } | |_^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:56:1 + --> $DIR/subdiagnostic-derive.rs:59:1 | LL | #[label] | ^^^^^^^^ error: `#[foo]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:65:1 + --> $DIR/subdiagnostic-derive.rs:68:1 | LL | #[foo] | ^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:75:1 + --> $DIR/subdiagnostic-derive.rs:78:1 | LL | #[label = "..."] | ^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:84:9 + --> $DIR/subdiagnostic-derive.rs:87:9 | LL | #[label(bug = "...")] | ^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:84:1 + --> $DIR/subdiagnostic-derive.rs:87:1 | LL | #[label(bug = "...")] | ^^^^^^^^^^^^^^^^^^^^^ error: unexpected literal in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:94:9 + --> $DIR/subdiagnostic-derive.rs:97:9 | LL | #[label("...")] | ^^^^^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:103:9 + --> $DIR/subdiagnostic-derive.rs:106:9 | LL | #[label(slug = 4)] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:103:1 + --> $DIR/subdiagnostic-derive.rs:106:1 | LL | #[label(slug = 4)] | ^^^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:113:9 + --> $DIR/subdiagnostic-derive.rs:116:9 | LL | #[label(slug("..."))] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:113:1 + --> $DIR/subdiagnostic-derive.rs:116:1 | LL | #[label(slug("..."))] | ^^^^^^^^^^^^^^^^^^^^^ error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:133:9 + --> $DIR/subdiagnostic-derive.rs:136:9 | LL | #[label()] | ^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:142:27 + --> $DIR/subdiagnostic-derive.rs:145:27 | LL | #[label(no_crate_example, code = "...")] | ^^^^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:151:27 + --> $DIR/subdiagnostic-derive.rs:154:27 | LL | #[label(no_crate_example, applicability = "machine-applicable")] | ^^^^^^^^^^^^^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:160:1 + --> $DIR/subdiagnostic-derive.rs:163:1 | LL | #[foo] | ^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:174:5 + --> $DIR/subdiagnostic-derive.rs:177:5 | LL | #[bar] | ^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:186:5 + --> $DIR/subdiagnostic-derive.rs:189:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:198:5 + --> $DIR/subdiagnostic-derive.rs:201:5 | LL | #[bar = 4] | ^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:210:5 + --> $DIR/subdiagnostic-derive.rs:213:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:222:13 + --> $DIR/subdiagnostic-derive.rs:225:13 | LL | #[label(code = "...")] | ^^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:222:5 + --> $DIR/subdiagnostic-derive.rs:225:5 | LL | #[label(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^ error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:251:5 + --> $DIR/subdiagnostic-derive.rs:254:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:248:1 + --> $DIR/subdiagnostic-derive.rs:251:1 | LL | / #[label(no_crate_example)] LL | | @@ -147,13 +147,13 @@ LL | | } | |_^ error: `#[applicability]` is only valid on suggestions - --> $DIR/subdiagnostic-derive.rs:261:5 + --> $DIR/subdiagnostic-derive.rs:264:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: `#[bar]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:271:5 + --> $DIR/subdiagnostic-derive.rs:274:5 | LL | #[bar] | ^^^^^^ @@ -161,13 +161,13 @@ LL | #[bar] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: `#[bar = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:282:5 + --> $DIR/subdiagnostic-derive.rs:285:5 | LL | #[bar = "..."] | ^^^^^^^^^^^^^^ error: `#[bar(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:293:5 + --> $DIR/subdiagnostic-derive.rs:296:5 | LL | #[bar("...")] | ^^^^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | #[bar("...")] = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:309:1 + --> $DIR/subdiagnostic-derive.rs:312:1 | LL | / union AC { LL | | @@ -185,73 +185,73 @@ LL | | } | |_^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:324:44 + --> $DIR/subdiagnostic-derive.rs:327:44 | LL | #[label(no_crate_example, no_crate::example)] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:337:5 + --> $DIR/subdiagnostic-derive.rs:340:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:334:5 + --> $DIR/subdiagnostic-derive.rs:337:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:343:8 + --> $DIR/subdiagnostic-derive.rs:346:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:380:46 + --> $DIR/subdiagnostic-derive.rs:383:46 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:380:32 + --> $DIR/subdiagnostic-derive.rs:383:32 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:398:5 + --> $DIR/subdiagnostic-derive.rs:401:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:395:5 + --> $DIR/subdiagnostic-derive.rs:398:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:408:5 + --> $DIR/subdiagnostic-derive.rs:411:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:421:1 + --> $DIR/subdiagnostic-derive.rs:424:1 | LL | #[suggestion(no_crate_example)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:431:62 + --> $DIR/subdiagnostic-derive.rs:434:62 | LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] | ^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:449:1 + --> $DIR/subdiagnostic-derive.rs:452:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -261,25 +261,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:463:1 + --> $DIR/subdiagnostic-derive.rs:466:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:483:39 + --> $DIR/subdiagnostic-derive.rs:486:39 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:502:43 + --> $DIR/subdiagnostic-derive.rs:505:43 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:525:5 + --> $DIR/subdiagnostic-derive.rs:528:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | #[suggestion_part] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead error: `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:528:5 + --> $DIR/subdiagnostic-derive.rs:531:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:522:1 + --> $DIR/subdiagnostic-derive.rs:525:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -307,7 +307,7 @@ LL | | } | |_^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:537:42 + --> $DIR/subdiagnostic-derive.rs:540:42 | LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] | ^^^^ @@ -315,7 +315,7 @@ LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "mac = help: only `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:537:1 + --> $DIR/subdiagnostic-derive.rs:540:1 | LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] LL | | @@ -326,19 +326,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:547:5 + --> $DIR/subdiagnostic-derive.rs:550:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:555:23 + --> $DIR/subdiagnostic-derive.rs:558:23 | LL | #[suggestion_part()] | ^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:564:5 + --> $DIR/subdiagnostic-derive.rs:567:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -346,7 +346,7 @@ LL | #[primary_span] = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:561:1 + --> $DIR/subdiagnostic-derive.rs:564:1 | LL | / #[multipart_suggestion(no_crate_example)] LL | | @@ -358,121 +358,121 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:572:5 + --> $DIR/subdiagnostic-derive.rs:575:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ error: `code` is the only valid nested attribute - --> $DIR/subdiagnostic-derive.rs:578:23 + --> $DIR/subdiagnostic-derive.rs:581:23 | LL | #[suggestion_part(foo = "bar")] | ^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:582:5 + --> $DIR/subdiagnostic-derive.rs:585:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:585:5 + --> $DIR/subdiagnostic-derive.rs:588:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:575:23 + --> $DIR/subdiagnostic-derive.rs:578:23 | LL | #[suggestion_part()] | ^ error: expected `,` - --> $DIR/subdiagnostic-derive.rs:578:27 + --> $DIR/subdiagnostic-derive.rs:581:27 | LL | #[suggestion_part(foo = "bar")] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:593:37 + --> $DIR/subdiagnostic-derive.rs:596:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:593:23 + --> $DIR/subdiagnostic-derive.rs:596:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive.rs:622:5 + --> $DIR/subdiagnostic-derive.rs:625:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:670:34 + --> $DIR/subdiagnostic-derive.rs:673:34 | LL | #[suggestion_part(code("foo"))] | ^ error: unexpected token - --> $DIR/subdiagnostic-derive.rs:670:28 + --> $DIR/subdiagnostic-derive.rs:673:28 | LL | #[suggestion_part(code("foo"))] | ^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:680:41 + --> $DIR/subdiagnostic-derive.rs:683:41 | LL | #[suggestion_part(code("foo", "bar"))] | ^ error: unexpected token - --> $DIR/subdiagnostic-derive.rs:680:28 + --> $DIR/subdiagnostic-derive.rs:683:28 | LL | #[suggestion_part(code("foo", "bar"))] | ^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:690:30 + --> $DIR/subdiagnostic-derive.rs:693:30 | LL | #[suggestion_part(code(3))] | ^ error: unexpected token - --> $DIR/subdiagnostic-derive.rs:690:28 + --> $DIR/subdiagnostic-derive.rs:693:28 | LL | #[suggestion_part(code(3))] | ^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:700:29 + --> $DIR/subdiagnostic-derive.rs:703:29 | LL | #[suggestion_part(code())] | ^ error: expected string literal - --> $DIR/subdiagnostic-derive.rs:712:30 + --> $DIR/subdiagnostic-derive.rs:715:30 | LL | #[suggestion_part(code = 3)] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:754:1 + --> $DIR/subdiagnostic-derive.rs:757:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:754:1 + --> $DIR/subdiagnostic-derive.rs:757:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:763:1 + --> $DIR/subdiagnostic-derive.rs:766:1 | LL | #[suggestion_hidden(no_crate_example, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -480,7 +480,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:771:1 + --> $DIR/subdiagnostic-derive.rs:774:1 | LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -488,7 +488,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:779:51 + --> $DIR/subdiagnostic-derive.rs:782:51 | LL | #[suggestion(no_crate_example, code = "", style = "foo")] | ^^^^^ @@ -496,31 +496,31 @@ LL | #[suggestion(no_crate_example, code = "", style = "foo")] = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:787:49 + --> $DIR/subdiagnostic-derive.rs:790:49 | LL | #[suggestion(no_crate_example, code = "", style = 42)] | ^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:795:48 + --> $DIR/subdiagnostic-derive.rs:798:48 | LL | #[suggestion(no_crate_example, code = "", style)] | ^ error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:803:48 + --> $DIR/subdiagnostic-derive.rs:806:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ error: expected `,` - --> $DIR/subdiagnostic-derive.rs:803:48 + --> $DIR/subdiagnostic-derive.rs:806:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:815:5 + --> $DIR/subdiagnostic-derive.rs:818:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -529,7 +529,7 @@ LL | #[primary_span] = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:812:1 + --> $DIR/subdiagnostic-derive.rs:815:1 | LL | / #[suggestion(no_crate_example, code = "")] LL | | @@ -541,67 +541,67 @@ LL | | } | |_^ error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:65:3 + --> $DIR/subdiagnostic-derive.rs:68:3 | LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:160:3 + --> $DIR/subdiagnostic-derive.rs:163:3 | LL | #[foo] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:174:7 + --> $DIR/subdiagnostic-derive.rs:177:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:186:7 + --> $DIR/subdiagnostic-derive.rs:189:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:198:7 + --> $DIR/subdiagnostic-derive.rs:201:7 | LL | #[bar = 4] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:210:7 + --> $DIR/subdiagnostic-derive.rs:213:7 | LL | #[bar("...")] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:271:7 + --> $DIR/subdiagnostic-derive.rs:274:7 | LL | #[bar] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:282:7 + --> $DIR/subdiagnostic-derive.rs:285:7 | LL | #[bar = "..."] | ^^^ error: cannot find attribute `bar` in this scope - --> $DIR/subdiagnostic-derive.rs:293:7 + --> $DIR/subdiagnostic-derive.rs:296:7 | LL | #[bar("...")] | ^^^ error[E0425]: cannot find value `slug` in module `crate::fluent_generated` - --> $DIR/subdiagnostic-derive.rs:123:9 + --> $DIR/subdiagnostic-derive.rs:126:9 | LL | #[label(slug)] | ^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_29` in this scope - --> $DIR/subdiagnostic-derive.rs:706:10 + --> $DIR/subdiagnostic-derive.rs:709:10 | LL | #[derive(Subdiagnostic)] | ^^^^^^^^^^^^^ not found in this scope diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index dfde8c97e..a3db2e9ef 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -33,7 +33,6 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { // Find items in the local crate. let items = stable_mir::all_local_items(); - assert!(get_item(tcx, &items, (DefKind::Fn, "foo_bar")).is_some()); assert!(get_item(tcx, &items, (DefKind::Fn, "foo::bar")).is_some()); // Find the `std` crate. @@ -41,6 +40,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { let bar = get_item(tcx, &items, (DefKind::Fn, "bar")).unwrap(); let body = bar.body(); + assert_eq!(body.locals.len(), 2); assert_eq!(body.blocks.len(), 1); let block = &body.blocks[0]; assert_eq!(block.statements.len(), 1); @@ -52,6 +52,34 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { stable_mir::mir::Terminator::Return => {} other => panic!("{other:?}"), } + + let foo_bar = get_item(tcx, &items, (DefKind::Fn, "foo_bar")).unwrap(); + let body = foo_bar.body(); + assert_eq!(body.locals.len(), 7); + assert_eq!(body.blocks.len(), 4); + let block = &body.blocks[0]; + match &block.terminator { + stable_mir::mir::Terminator::Call { .. } => {} + other => panic!("{other:?}"), + } + + let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); + let body = drop.body(); + assert_eq!(body.blocks.len(), 2); + let block = &body.blocks[0]; + match &block.terminator { + stable_mir::mir::Terminator::Drop { .. } => {} + other => panic!("{other:?}"), + } + + let assert = get_item(tcx, &items, (DefKind::Fn, "assert")).unwrap(); + let body = assert.body(); + assert_eq!(body.blocks.len(), 2); + let block = &body.blocks[0]; + match &block.terminator { + stable_mir::mir::Terminator::Assert { .. } => {} + other => panic!("{other:?}"), + } } // Use internal API to find a function in a crate. @@ -97,7 +125,7 @@ impl Callbacks for SMirCalls { queries: &'tcx Queries<'tcx>, ) -> Compilation { queries.global_ctxt().unwrap().enter(|tcx| { - test_stable_mir(tcx); + rustc_smir::rustc_internal::run(tcx, || test_stable_mir(tcx)); }); // No need to keep going. Compilation::Stop @@ -123,6 +151,12 @@ fn generate_input(path: &str) -> std::io::Result<()> { let x_64 = foo::bar(x); let y_64 = foo::bar(y); x_64.wrapping_add(y_64) + }} + + pub fn drop(_: String) {{}} + + pub fn assert(x: i32) -> i32 {{ + x + 1 }}"# )?; Ok(()) diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs index 039507d51..0dccb633d 100644 --- a/tests/ui/abi/stack-probes-lto.rs +++ b/tests/ui/abi/stack-probes-lto.rs @@ -5,6 +5,7 @@ // ignore-mips64 // ignore-sparc // ignore-sparc64 +// ignore-loongarch64 // ignore-wasm // ignore-emscripten no processes // ignore-sgx no processes diff --git a/tests/ui/abi/stack-probes.rs b/tests/ui/abi/stack-probes.rs index 8dba54c3f..8137c9230 100644 --- a/tests/ui/abi/stack-probes.rs +++ b/tests/ui/abi/stack-probes.rs @@ -5,6 +5,7 @@ // ignore-mips64 // ignore-sparc // ignore-sparc64 +// ignore-loongarch64 // ignore-wasm // ignore-emscripten no processes // ignore-sgx no processes diff --git a/tests/ui/argument-suggestions/issue-97484.stderr b/tests/ui/argument-suggestions/issue-97484.stderr index a86cbbf18..082564fbc 100644 --- a/tests/ui/argument-suggestions/issue-97484.stderr +++ b/tests/ui/argument-suggestions/issue-97484.stderr @@ -16,7 +16,7 @@ LL | fn foo(a: &A, d: D, e: &E, g: G) {} help: consider borrowing here | LL | foo(&&A, B, C, D, &E, F, G); - | ~~ + | + help: remove the extra arguments | LL - foo(&&A, B, C, D, E, F, G); diff --git a/tests/ui/array-slice-vec/slice-mut-2.stderr b/tests/ui/array-slice-vec/slice-mut-2.stderr index 5b040d3e4..c33919c41 100644 --- a/tests/ui/array-slice-vec/slice-mut-2.stderr +++ b/tests/ui/array-slice-vec/slice-mut-2.stderr @@ -7,7 +7,7 @@ LL | let _ = &mut x[2..4]; help: consider changing this to be a mutable reference | LL | let x: &[isize] = &mut [1, 2, 3, 4, 5]; - | ~~~~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/associated-consts/projection-unspecified-but-bounded.rs b/tests/ui/associated-consts/projection-unspecified-but-bounded.rs new file mode 100644 index 000000000..b1a0f3996 --- /dev/null +++ b/tests/ui/associated-consts/projection-unspecified-but-bounded.rs @@ -0,0 +1,16 @@ +#![feature(associated_const_equality)] + +// Issue 110549 + +pub trait TraitWAssocConst { + const A: usize; +} + +fn foo<T: TraitWAssocConst<A = 32>>() {} + +fn bar<T: TraitWAssocConst>() { + foo::<T>(); + //~^ ERROR type mismatch resolving `<T as TraitWAssocConst>::A == 32` +} + +fn main() {} diff --git a/tests/ui/associated-consts/projection-unspecified-but-bounded.stderr b/tests/ui/associated-consts/projection-unspecified-but-bounded.stderr new file mode 100644 index 000000000..8175e510a --- /dev/null +++ b/tests/ui/associated-consts/projection-unspecified-but-bounded.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving `<T as TraitWAssocConst>::A == 32` + --> $DIR/projection-unspecified-but-bounded.rs:12:11 + | +LL | foo::<T>(); + | ^ expected `32`, found `<T as TraitWAssocConst>::A` + | + = note: expected constant `32` + found constant `<T as TraitWAssocConst>::A` +note: required by a bound in `foo` + --> $DIR/projection-unspecified-but-bounded.rs:9:28 + | +LL | fn foo<T: TraitWAssocConst<A = 32>>() {} + | ^^^^^^ required by this bound in `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs new file mode 100644 index 000000000..f41574403 --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs @@ -0,0 +1,10 @@ +// known-bug: #108491 + +// FIXME(inherent_associated_types): This should pass. + +struct Foo { + bar: Self::Bar, +} +impl Foo { + pub type Bar = usize; +} diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr new file mode 100644 index 000000000..f313c4946 --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr @@ -0,0 +1,49 @@ +error[E0601]: `main` function not found in crate `cycle_iat_inside_of_adt` + --> $DIR/cycle-iat-inside-of-adt.rs:10:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/cycle-iat-inside-of-adt.rs` + +error[E0391]: cycle detected when computing predicates of `Foo` + --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + | +note: ...which requires computing predicates of `Foo`... + --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ +note: ...which requires computing inferred outlives predicates of `Foo`... + --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + = note: ...which requires computing the inferred outlives predicates for items in this crate... +note: ...which requires computing type of `Foo::bar`... + --> $DIR/cycle-iat-inside-of-adt.rs:6:5 + | +LL | bar: Self::Bar, + | ^^^^^^^^^^^^^^ +note: ...which requires computing normalized predicates of `Foo`... + --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + = note: ...which again requires computing predicates of `Foo`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + | +LL | / struct Foo { +LL | | bar: Self::Bar, +LL | | } +LL | | impl Foo { +LL | | pub type Bar = usize; +LL | | } + | |_^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0391, E0601. +For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.rs b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.rs new file mode 100644 index 000000000..0c2a38b11 --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.rs @@ -0,0 +1,16 @@ +// known-bug: unknown + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// FIXME(inherent_associated_types): This shouldn't lead to a cycle error. + +fn user<T>() where S<T>::P: std::fmt::Debug {} + +struct S<T>; + +impl<T: Copy> S<T> { + type P = (); +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr new file mode 100644 index 000000000..aaa9a39ea --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-where-predicate.stderr @@ -0,0 +1,37 @@ +error[E0391]: cycle detected when computing predicates of `user` + --> $DIR/cycle-iat-inside-of-where-predicate.rs:8:1 + | +LL | fn user<T>() where S<T>::P: std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires computing predicates of `user`... + --> $DIR/cycle-iat-inside-of-where-predicate.rs:8:1 + | +LL | fn user<T>() where S<T>::P: std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires computing explicit predicates of `user`... + --> $DIR/cycle-iat-inside-of-where-predicate.rs:8:1 + | +LL | fn user<T>() where S<T>::P: std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires computing normalized predicates of `user`... + --> $DIR/cycle-iat-inside-of-where-predicate.rs:8:1 + | +LL | fn user<T>() where S<T>::P: std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing predicates of `user`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/cycle-iat-inside-of-where-predicate.rs:3:1 + | +LL | / #![feature(inherent_associated_types)] +LL | | #![allow(incomplete_features)] +LL | | +LL | | // FIXME(inherent_associated_types): This shouldn't lead to a cycle error. +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/associated-inherent-types/bugs/ice-substitution.rs b/tests/ui/associated-inherent-types/bugs/ice-substitution.rs deleted file mode 100644 index 53ac79e05..000000000 --- a/tests/ui/associated-inherent-types/bugs/ice-substitution.rs +++ /dev/null @@ -1,23 +0,0 @@ -// known-bug: unknown -// failure-status: 101 -// normalize-stderr-test "note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" -// rustc-env:RUST_BACKTRACE=0 - -// FIXME: I presume a type variable that couldn't be solved by `resolve_vars_if_possible` -// escapes the InferCtxt snapshot. - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] - -struct Cont<T>(T); - -impl<T: Copy> Cont<T> { - type Out = Vec<T>; -} - -pub fn weird<T: Copy>(x: T) { - let _: Cont<_>::Out = vec![true]; -} - -fn main() {} diff --git a/tests/ui/associated-inherent-types/bugs/ice-substitution.stderr b/tests/ui/associated-inherent-types/bugs/ice-substitution.stderr deleted file mode 100644 index 7b0d1c505..000000000 --- a/tests/ui/associated-inherent-types/bugs/ice-substitution.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: the compiler unexpectedly panicked. this is a bug. - -query stack during panic: -#0 [typeck] type-checking `weird` -#1 [typeck_item_bodies] type-checking all item bodies -end of query stack diff --git a/tests/ui/associated-inherent-types/bugs/inference-fail.rs b/tests/ui/associated-inherent-types/bugs/inference-fail.rs deleted file mode 100644 index a920b412b..000000000 --- a/tests/ui/associated-inherent-types/bugs/inference-fail.rs +++ /dev/null @@ -1,15 +0,0 @@ -// known-bug: unknown - -#![feature(inherent_associated_types)] -#![allow(incomplete_features)] - -struct S<T>(T); - -impl S<()> { - type P = i128; -} - -fn main() { - // We fail to infer `_ == ()` here. - let _: S<_>::P; -} diff --git a/tests/ui/associated-inherent-types/bugs/lack-of-regionck.rs b/tests/ui/associated-inherent-types/bugs/lack-of-regionck.rs deleted file mode 100644 index 632dbf385..000000000 --- a/tests/ui/associated-inherent-types/bugs/lack-of-regionck.rs +++ /dev/null @@ -1,19 +0,0 @@ -// known-bug: unknown -// check-pass - -// We currently don't region-check inherent associated type projections at all. - -#![feature(inherent_associated_types)] -#![allow(incomplete_features, dead_code)] - -struct S<T>(T); - -impl S<&'static ()> { - type T = (); -} - -fn usr<'a>() { - let _: S::<&'a ()>::T; // this should *fail* but it doesn't! -} - -fn main() {} diff --git a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs new file mode 100644 index 000000000..c7f66e645 --- /dev/null +++ b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs @@ -0,0 +1,15 @@ +// known-bug: #100041 +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// FIXME(inherent_associated_types): This should fail. + +struct Foo; + +impl Foo { + type Bar<T> = (); +} + +fn main() -> Foo::Bar::<Vec<[u32]>> {} diff --git a/tests/ui/associated-inherent-types/const-generics.rs b/tests/ui/associated-inherent-types/const-generics.rs new file mode 100644 index 000000000..5b7c00bcc --- /dev/null +++ b/tests/ui/associated-inherent-types/const-generics.rs @@ -0,0 +1,23 @@ +// Regression test for issue #109759. +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +struct Bar<const X: usize>([(); X]); + +impl<const X: usize> Bar<X> { + pub fn new() -> Self { + Self([(); X]) + } +} + +impl Foo { + type Bar<const X: usize> = Bar<X>; +} + +fn main() { + let _ = Foo::Bar::<10>::new(); +} diff --git a/tests/ui/associated-inherent-types/dispatch-on-self-type-0.rs b/tests/ui/associated-inherent-types/dispatch-on-self-type-0.rs index f846bfa41..83be4f43b 100644 --- a/tests/ui/associated-inherent-types/dispatch-on-self-type-0.rs +++ b/tests/ui/associated-inherent-types/dispatch-on-self-type-0.rs @@ -31,7 +31,7 @@ fn main() { let _: Select<u8>::Projection = (); let _: Choose<NonCopy>::Result = (); - let _: Choose<bool>::Result = vec![true]; + let _: Choose<&str>::Result = vec!["…"]; // regression test for issue #108957 } // Test if we use the correct `ParamEnv` when proving obligations. diff --git a/tests/ui/associated-inherent-types/former-subst-ice.rs b/tests/ui/associated-inherent-types/former-subst-ice.rs new file mode 100644 index 000000000..48390b943 --- /dev/null +++ b/tests/ui/associated-inherent-types/former-subst-ice.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Cont<T>(T); + +impl<T: Copy> Cont<T> { + type Out = Vec<T>; +} + +pub fn weird<T: Copy>(x: T) { + let _: Cont<_>::Out = vec![true]; +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr new file mode 100644 index 000000000..464b59c24 --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/generic-associated-types-bad.rs:16:10 + | +LL | const _: Ty::Pr<String> = String::new(); + | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `Ty::Pr` + --> $DIR/generic-associated-types-bad.rs:10:16 + | +LL | type Pr<T: Copy> = T; + | ^^^^ required by this bound in `Ty::Pr` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr new file mode 100644 index 000000000..4f371b24e --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Vec<()>: Copy` is not satisfied + --> $DIR/generic-associated-types-bad.rs:20:12 + | +LL | let _: Ty::Pr<Vec<()>>; + | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<()>` + | +note: required by a bound in `Ty::Pr` + --> $DIR/generic-associated-types-bad.rs:10:16 + | +LL | type Pr<T: Copy> = T; + | ^^^^ required by this bound in `Ty::Pr` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr new file mode 100644 index 000000000..74ec39424 --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.region.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> $DIR/generic-associated-types-bad.rs:25:12 + | +LL | fn user<'a>() { + | -- lifetime `'a` defined here +LL | #[cfg(region)] +LL | let _: Ty::Static<&'a str> = ""; + | ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.rs b/tests/ui/associated-inherent-types/generic-associated-types-bad.rs new file mode 100644 index 000000000..e66392a0a --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.rs @@ -0,0 +1,26 @@ +// revisions: item local region + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +#[derive(Clone, Copy)] +pub enum Ty {} + +impl Ty { + type Pr<T: Copy> = T; + + type Static<Q: 'static> = Q; +} + +#[cfg(item)] +const _: Ty::Pr<String> = String::new(); //[item]~ the trait bound `String: Copy` is not satisfied + +fn main() { + #[cfg(local)] + let _: Ty::Pr<Vec<()>>; //[local]~ ERROR the trait bound `Vec<()>: Copy` is not satisfied +} + +fn user<'a>() { + #[cfg(region)] + let _: Ty::Static<&'a str> = ""; //[region]~ ERROR lifetime may not live long enough +} diff --git a/tests/ui/associated-inherent-types/generic-const-exprs.rs b/tests/ui/associated-inherent-types/generic-const-exprs.rs new file mode 100644 index 000000000..a4ac0ecfa --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-const-exprs.rs @@ -0,0 +1,28 @@ +// check-pass + +#![feature(inherent_associated_types, generic_const_exprs)] +#![allow(incomplete_features)] + +struct Parent<const O: usize>; + +impl<const O: usize> Parent<O> { + type Mapping<const I: usize> = Store<{ O + I }> + where + [(); O + I]: + ; +} + +struct Store<const N: usize>; + +impl<const N: usize> Store<N> { + const REIFIED: usize = N; + + fn reify() -> usize { + N + } +} + +fn main() { + let _ = Parent::<2>::Mapping::<{ 12 * 2 }>::REIFIED; + let _ = Parent::<1>::Mapping::<{ 2 * 5 }>::reify(); +} diff --git a/tests/ui/associated-inherent-types/inference-fail.rs b/tests/ui/associated-inherent-types/inference-fail.rs new file mode 100644 index 000000000..939a4ff60 --- /dev/null +++ b/tests/ui/associated-inherent-types/inference-fail.rs @@ -0,0 +1,11 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T> S<T> { type P = (); } + +fn main() { + // There is no way to infer this type. + let _: S<_>::P = (); //~ ERROR type annotations needed +} diff --git a/tests/ui/associated-inherent-types/bugs/inference-fail.stderr b/tests/ui/associated-inherent-types/inference-fail.stderr index 425691bd6..f29144e4a 100644 --- a/tests/ui/associated-inherent-types/bugs/inference-fail.stderr +++ b/tests/ui/associated-inherent-types/inference-fail.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/inference-fail.rs:14:14 + --> $DIR/inference-fail.rs:10:12 | -LL | let _: S<_>::P; - | ^ cannot infer type +LL | let _: S<_>::P = (); + | ^^^^^^^ cannot infer type for type parameter `T` error: aborting due to previous error diff --git a/tests/ui/associated-inherent-types/inference.rs b/tests/ui/associated-inherent-types/inference.rs new file mode 100644 index 000000000..ebd8e1d55 --- /dev/null +++ b/tests/ui/associated-inherent-types/inference.rs @@ -0,0 +1,40 @@ +// Testing inference capabilities. +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![allow(dropping_copy_types)] + +use std::convert::identity; + +struct Container<T>(T); + +impl Container<u32> { + type Sink = (); +} + +impl<Any> Container<Any> { + type Thing = Any; +} + +impl<T> Container<(T, ())> { + type Output = ((), Wrapped<T>); +} + +fn main() { + // Inferred via the Self type of the impl. + let _: Container<_>::Sink; + + // Inferred via the RHS: + + let _: Container<_>::Thing = 0; + + let _: Container<Wrapped<_>>::Thing = Wrapped(false); + + let _: Container<_>::Output = (drop(1), Wrapped("...")); + + let binding: Container<_>::Thing = Default::default(); // unsolved at this point + identity::<String>(binding); // constrained and solved here +} + +struct Wrapped<T>(T); diff --git a/tests/ui/associated-inherent-types/issue-109768.rs b/tests/ui/associated-inherent-types/issue-109768.rs new file mode 100644 index 000000000..a3ae2e2ab --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109768.rs @@ -0,0 +1,12 @@ +// incremental + +struct Wrapper<T>(T); + +struct Local<T, U>(T, U); + +impl<T> Local { //~ ERROR missing generics for struct `Local` + type AssocType3 = T; //~ ERROR inherent associated types are unstable + + const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(); +} +//~^ ERROR `main` function not found diff --git a/tests/ui/associated-inherent-types/issue-109768.stderr b/tests/ui/associated-inherent-types/issue-109768.stderr new file mode 100644 index 000000000..97706d406 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109768.stderr @@ -0,0 +1,35 @@ +error[E0601]: `main` function not found in crate `issue_109768` + --> $DIR/issue-109768.rs:11:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/issue-109768.rs` + +error[E0107]: missing generics for struct `Local` + --> $DIR/issue-109768.rs:7:9 + | +LL | impl<T> Local { + | ^^^^^ expected 2 generic arguments + | +note: struct defined here, with 2 generic parameters: `T`, `U` + --> $DIR/issue-109768.rs:5:8 + | +LL | struct Local<T, U>(T, U); + | ^^^^^ - - +help: add missing generic arguments + | +LL | impl<T> Local<T, U> { + | ++++++ + +error[E0658]: inherent associated types are unstable + --> $DIR/issue-109768.rs:8:5 + | +LL | type AssocType3 = T; + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0107, E0601, E0658. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/associated-inherent-types/issue-109789.rs b/tests/ui/associated-inherent-types/issue-109789.rs new file mode 100644 index 000000000..0b5ba7d1f --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109789.rs @@ -0,0 +1,22 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo<T>(T); + +impl Foo<fn(&'static ())> { + type Assoc = u32; +} + +trait Other {} +impl Other for u32 {} + +// FIXME(inherent_associated_types): Avoid emitting two diagnostics (they only differ in span). +// FIXME(inherent_associated_types): Enhancement: Spruce up the diagnostic by saying something like +// "implementation is not general enough" as is done for traits via +// `try_report_trait_placeholder_mismatch`. + +fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} +//~^ ERROR mismatched types +//~| ERROR mismatched types + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-109789.stderr b/tests/ui/associated-inherent-types/issue-109789.stderr new file mode 100644 index 000000000..7af338274 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109789.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-109789.rs:18:1 + | +LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected struct `Foo<fn(&'static ())>` + found struct `Foo<for<'a> fn(&'a ())>` + +error[E0308]: mismatched types + --> $DIR/issue-109789.rs:18:11 + | +LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected struct `Foo<fn(&'static ())>` + found struct `Foo<for<'a> fn(&'a ())>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-inherent-types/issue-109790.rs b/tests/ui/associated-inherent-types/issue-109790.rs new file mode 100644 index 000000000..88327f864 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109790.rs @@ -0,0 +1,18 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![deny(single_use_lifetimes)] + +struct Foo<T>(T); + +impl<'a> Foo<fn(&'a ())> { + type Assoc = &'a (); +} + +trait Other {} +impl Other for u32 {} + +fn bar(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111879-0.rs b/tests/ui/associated-inherent-types/issue-111879-0.rs new file mode 100644 index 000000000..e37f7d34a --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-0.rs @@ -0,0 +1,14 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// Check that we don't crash when printing inherent projections in diagnostics. + +pub struct Carrier<'a>(&'a ()); + +pub type User = for<'b> fn(Carrier<'b>::Focus<i32>); + +impl<'a> Carrier<'a> { + pub type Focus<T> = &'a mut User; //~ ERROR overflow evaluating associated type +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111879-0.stderr b/tests/ui/associated-inherent-types/issue-111879-0.stderr new file mode 100644 index 000000000..7bdbad440 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-0.stderr @@ -0,0 +1,8 @@ +error: overflow evaluating associated type `Carrier<'b>::Focus<i32>` + --> $DIR/issue-111879-0.rs:11:25 + | +LL | pub type Focus<T> = &'a mut User; + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/issue-111879-1.rs b/tests/ui/associated-inherent-types/issue-111879-1.rs new file mode 100644 index 000000000..7acc4f945 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-1.rs @@ -0,0 +1,12 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// Check that we don't crash when printing inherent projections in diagnostics. + +struct Foo<T>(T); + +impl<'a> Foo<fn(&'a ())> { + type Assoc = &'a (); +} + +fn main(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {} //~ ERROR `main` function has wrong type diff --git a/tests/ui/associated-inherent-types/issue-111879-1.stderr b/tests/ui/associated-inherent-types/issue-111879-1.stderr new file mode 100644 index 000000000..689b45e09 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-1.stderr @@ -0,0 +1,12 @@ +error[E0580]: `main` function has wrong type + --> $DIR/issue-111879-1.rs:12:1 + | +LL | fn main(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected fn pointer `fn()` + found fn pointer `fn(for<'a> fn(Foo<fn(&'a ())>::Assoc))` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0580`. diff --git a/tests/ui/associated-inherent-types/late-bound-regions.rs b/tests/ui/associated-inherent-types/late-bound-regions.rs new file mode 100644 index 000000000..488a2cda6 --- /dev/null +++ b/tests/ui/associated-inherent-types/late-bound-regions.rs @@ -0,0 +1,25 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// Test if we correctly normalize `S<'a>::P` with respect to late-bound regions. + +type Function = for<'a> fn(&'a i32) -> S<'a>::P; + +struct S<'a>(&'a ()); + +trait Inter { + type P; +} + +impl<'a> S<'a> { + type P = &'a i32; +} + +fn ret_ref_local<'e>() -> &'e i32 { + let f: Function = |x| x; + + let local = 0; + f(&local) //~ ERROR cannot return value referencing local variable `local` +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/late-bound-regions.stderr b/tests/ui/associated-inherent-types/late-bound-regions.stderr new file mode 100644 index 000000000..4706fcca9 --- /dev/null +++ b/tests/ui/associated-inherent-types/late-bound-regions.stderr @@ -0,0 +1,12 @@ +error[E0515]: cannot return value referencing local variable `local` + --> $DIR/late-bound-regions.rs:22:5 + | +LL | f(&local) + | ^^------^ + | | | + | | `local` is borrowed here + | returns a value referencing data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff --git a/tests/ui/associated-inherent-types/normalization-overflow.rs b/tests/ui/associated-inherent-types/normalization-overflow.rs new file mode 100644 index 000000000..4228238aa --- /dev/null +++ b/tests/ui/associated-inherent-types/normalization-overflow.rs @@ -0,0 +1,12 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// FIXME(fmease): I'd prefer to report a cycle error here instead of an overflow one. + +struct T; + +impl T { + type This = Self::This; //~ ERROR overflow evaluating associated type `T::This` +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/normalization-overflow.stderr b/tests/ui/associated-inherent-types/normalization-overflow.stderr new file mode 100644 index 000000000..16bb64281 --- /dev/null +++ b/tests/ui/associated-inherent-types/normalization-overflow.stderr @@ -0,0 +1,8 @@ +error: overflow evaluating associated type `T::This` + --> $DIR/normalization-overflow.rs:9:17 + | +LL | type This = Self::This; + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/private-in-public.rs b/tests/ui/associated-inherent-types/private-in-public.rs new file mode 100644 index 000000000..a4b372537 --- /dev/null +++ b/tests/ui/associated-inherent-types/private-in-public.rs @@ -0,0 +1,26 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![crate_type = "lib"] + +#![deny(private_in_public)] + +pub type PubAlias0 = PubTy::PrivAssocTy; +//~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446) +//~| WARNING this was previously accepted +pub type PubAlias1 = PrivTy::PubAssocTy; +//~^ ERROR private type `PrivTy` in public interface (error E0446) +//~| WARNING this was previously accepted +pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>; +//~^ ERROR private type `PrivTy` in public interface (error E0446) +//~| WARNING this was previously accepted + +pub struct PubTy; +impl PubTy { + type PrivAssocTy = (); + pub type PubAssocTy<T> = T; +} + +struct PrivTy; +impl PrivTy { + pub type PubAssocTy = (); +} diff --git a/tests/ui/associated-inherent-types/private-in-public.stderr b/tests/ui/associated-inherent-types/private-in-public.stderr new file mode 100644 index 000000000..f0a64e961 --- /dev/null +++ b/tests/ui/associated-inherent-types/private-in-public.stderr @@ -0,0 +1,34 @@ +error: private associated type `PubTy::PrivAssocTy` in public interface (error E0446) + --> $DIR/private-in-public.rs:7:1 + | +LL | pub type PubAlias0 = PubTy::PrivAssocTy; + | ^^^^^^^^^^^^^^^^^^ + | + = 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 #34537 <https://github.com/rust-lang/rust/issues/34537> +note: the lint level is defined here + --> $DIR/private-in-public.rs:5:9 + | +LL | #![deny(private_in_public)] + | ^^^^^^^^^^^^^^^^^ + +error: private type `PrivTy` in public interface (error E0446) + --> $DIR/private-in-public.rs:10:1 + | +LL | pub type PubAlias1 = PrivTy::PubAssocTy; + | ^^^^^^^^^^^^^^^^^^ + | + = 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 #34537 <https://github.com/rust-lang/rust/issues/34537> + +error: private type `PrivTy` in public interface (error E0446) + --> $DIR/private-in-public.rs:13:1 + | +LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>; + | ^^^^^^^^^^^^^^^^^^ + | + = 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 #34537 <https://github.com/rust-lang/rust/issues/34537> + +error: aborting due to 3 previous errors + diff --git a/tests/ui/associated-inherent-types/regionck-0.rs b/tests/ui/associated-inherent-types/regionck-0.rs new file mode 100644 index 000000000..7c94539ac --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-0.rs @@ -0,0 +1,14 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl S<&'static ()> { + type T = (); +} + +fn user<'a>() { + let _: S::<&'a ()>::T; //~ ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/regionck-0.stderr b/tests/ui/associated-inherent-types/regionck-0.stderr new file mode 100644 index 000000000..3a438ee63 --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-0.stderr @@ -0,0 +1,10 @@ +error: lifetime may not live long enough + --> $DIR/regionck-0.rs:11:12 + | +LL | fn user<'a>() { + | -- lifetime `'a` defined here +LL | let _: S::<&'a ()>::T; + | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/regionck-1.rs b/tests/ui/associated-inherent-types/regionck-1.rs new file mode 100644 index 000000000..ec663cd0f --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-1.rs @@ -0,0 +1,13 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct U; + +impl U { + // Don't imply any bounds here. + + type NoTyOutliv<'a, T> = &'a T; //~ ERROR the parameter type `T` may not live long enough + type NoReOutliv<'a, 'b> = &'a &'b (); //~ ERROR reference has a longer lifetime than the data it references +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/regionck-1.stderr b/tests/ui/associated-inherent-types/regionck-1.stderr new file mode 100644 index 000000000..b17d89ca3 --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-1.stderr @@ -0,0 +1,29 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regionck-1.rs:9:30 + | +LL | type NoTyOutliv<'a, T> = &'a T; + | ^^^^^- help: consider adding a where clause: `where T: 'a` + | | + | ...so that the reference type `&'a T` does not outlive the data it points at + +error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references + --> $DIR/regionck-1.rs:10:31 + | +LL | type NoReOutliv<'a, 'b> = &'a &'b (); + | ^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regionck-1.rs:10:21 + | +LL | type NoReOutliv<'a, 'b> = &'a &'b (); + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regionck-1.rs:10:25 + | +LL | type NoReOutliv<'a, 'b> = &'a &'b (); + | ^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/associated-inherent-types/regionck-2.rs b/tests/ui/associated-inherent-types/regionck-2.rs new file mode 100644 index 000000000..7a0b8b083 --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-2.rs @@ -0,0 +1,14 @@ +// Regression test for issue #109299. + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Lexer<'d>(&'d ()); + +impl Lexer<'static> { + type Cursor = (); +} + +fn test(_: Lexer::Cursor) {} //~ ERROR mismatched types + +fn main() {} diff --git a/tests/ui/associated-inherent-types/regionck-2.stderr b/tests/ui/associated-inherent-types/regionck-2.stderr new file mode 100644 index 000000000..b0a4ed35d --- /dev/null +++ b/tests/ui/associated-inherent-types/regionck-2.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regionck-2.rs:12:12 + | +LL | fn test(_: Lexer::Cursor) {} + | ^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected struct `Lexer<'static>` + found struct `Lexer<'_>` +note: the anonymous lifetime defined here... + --> $DIR/regionck-2.rs:12:12 + | +LL | fn test(_: Lexer::Cursor) {} + | ^^^^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs new file mode 100644 index 000000000..b32b4288a --- /dev/null +++ b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs @@ -0,0 +1,26 @@ +// check-pass +// compile-flags: --crate-type=lib + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +// Bounds on the self type play a major role in the resolution of inherent associated types (*). +// As a result of that, if a type alias contains any then its bounds have to be respected and the +// lint `type_alias_bounds` should not fire. +// +// FIXME(inherent_associated_types): In the current implementation that is. We might move the +// selection phase of IATs from hir_typeck to trait_selection resulting in us not requiring the +// ParamEnv that early allowing us to ignore bounds on type aliases again. +// Triage this before stabilization. + +#![deny(type_alias_bounds)] + +pub type Alias<T: Bound> = (Source<T>::Assoc,); + + +pub struct Source<T>(T); +pub trait Bound {} + +impl<T: Bound> Source<T> { + pub type Assoc = (); +} diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.rs b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.rs new file mode 100644 index 000000000..d081c4d5b --- /dev/null +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.rs @@ -0,0 +1,12 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T: Copy> S<T> { + type T = T; +} + +fn main() { + let _: S<_>::T = String::new(); //~ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr new file mode 100644 index 000000000..ecf30f4cd --- /dev/null +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/unsatisfied-bounds-inferred-type.rs:11:12 + | +LL | let _: S<_>::T = String::new(); + | ^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `S<T>::T` + --> $DIR/unsatisfied-bounds-inferred-type.rs:6:9 + | +LL | impl<T: Copy> S<T> { + | ^^^^ required by this bound in `S<T>::T` +LL | type T = T; + | - required by a bound in this associated type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.rs b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.rs new file mode 100644 index 000000000..97bd2c421 --- /dev/null +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.rs @@ -0,0 +1,14 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct S<T>(T); + +impl<T> S<T> { + type X = () + where + T: Copy; +} + +fn main() { + let _: S::<String>::X; //~ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr new file mode 100644 index 000000000..d4968cd05 --- /dev/null +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/unsatisfied-bounds-where-clause-on-assoc-ty.rs:13:12 + | +LL | let _: S::<String>::X; + | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `S<T>::X` + --> $DIR/unsatisfied-bounds-where-clause-on-assoc-ty.rs:9:12 + | +LL | type X = () + | - required by a bound in this associated type +LL | where +LL | T: Copy; + | ^^^^ required by this bound in `S<T>::X` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-type-bounds/duplicate.rs b/tests/ui/associated-type-bounds/duplicate.rs index f67410986..4b8bf52c3 100644 --- a/tests/ui/associated-type-bounds/duplicate.rs +++ b/tests/ui/associated-type-bounds/duplicate.rs @@ -193,10 +193,13 @@ trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] trait TRS1: Iterator<Item: Copy, Item: Send> {} //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] trait TRS2: Iterator<Item: Copy, Item: Copy> {} //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] trait TRS3: Iterator<Item: 'static, Item: 'static> {} //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] trait TRW1<T> where T: Iterator<Item: Copy, Item: Send>, diff --git a/tests/ui/associated-type-bounds/duplicate.stderr b/tests/ui/associated-type-bounds/duplicate.stderr index c3061327f..08721eff7 100644 --- a/tests/ui/associated-type-bounds/duplicate.stderr +++ b/tests/ui/associated-type-bounds/duplicate.stderr @@ -367,7 +367,23 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:196:34 + --> $DIR/duplicate.rs:194:34 + | +LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:197:34 + | +LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:197:34 | LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | ---------- ^^^^^^^^^^ re-bound here @@ -375,7 +391,15 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:198:37 + --> $DIR/duplicate.rs:200:37 + | +LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/duplicate.rs:200:37 | LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | ------------- ^^^^^^^^^^^^^ re-bound here @@ -383,7 +407,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:202:29 + --> $DIR/duplicate.rs:205:29 | LL | T: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -391,7 +415,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:208:29 + --> $DIR/duplicate.rs:211:29 | LL | T: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -399,7 +423,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:214:32 + --> $DIR/duplicate.rs:217:32 | LL | T: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -407,7 +431,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:220:32 + --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -415,7 +439,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:220:32 + --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator<Item: Copy, Item: Send>, | ---------- ^^^^^^^^^^ re-bound here @@ -423,7 +447,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:227:32 + --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -431,7 +455,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:227:32 + --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, | ---------- ^^^^^^^^^^ re-bound here @@ -439,7 +463,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:234:35 + --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -447,7 +471,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:234:35 + --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, | ------------- ^^^^^^^^^^^^^ re-bound here @@ -455,7 +479,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:252:40 + --> $DIR/duplicate.rs:255:40 | LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here @@ -463,7 +487,7 @@ LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:254:44 + --> $DIR/duplicate.rs:257:44 | LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; | ---------- ^^^^^^^^^^ re-bound here @@ -471,7 +495,7 @@ LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:256:43 + --> $DIR/duplicate.rs:259:43 | LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; | ------------- ^^^^^^^^^^^^^ re-bound here @@ -479,7 +503,7 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:240:34 + --> $DIR/duplicate.rs:243:34 | LL | type A: Iterator<Item: Copy, Item: Send>; | ---------- ^^^^^^^^^^ re-bound here @@ -487,7 +511,7 @@ LL | type A: Iterator<Item: Copy, Item: Send>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:244:34 + --> $DIR/duplicate.rs:247:34 | LL | type A: Iterator<Item: Copy, Item: Copy>; | ---------- ^^^^^^^^^^ re-bound here @@ -495,13 +519,13 @@ LL | type A: Iterator<Item: Copy, Item: Copy>; | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/duplicate.rs:248:37 + --> $DIR/duplicate.rs:251:37 | LL | type A: Iterator<Item: 'static, Item: 'static>; | ------------- ^^^^^^^^^^^^^ re-bound here | | | `Item` bound here first -error: aborting due to 63 previous errors +error: aborting due to 66 previous errors For more information about this error, try `rustc --explain E0719`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 79cee5517..58ce41d1a 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -2,7 +2,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn method() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index b23e0f791..95ef7d82f 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -1,11 +1,11 @@ error: return type notation uses `()` instead of `(..)` for elided arguments - --> $DIR/bad-inputs-and-output.rs:19:24 + --> $DIR/bad-inputs-and-output.rs:18:24 | LL | fn baz<T: Trait<method(..): Send>>() {} | ^^ help: remove the `..` error[E0658]: associated type bounds are unstable - --> $DIR/bad-inputs-and-output.rs:11:17 + --> $DIR/bad-inputs-and-output.rs:10:17 | LL | fn foo<T: Trait<method(i32): Send>>() {} | ^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | fn foo<T: Trait<method(i32): Send>>() {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/bad-inputs-and-output.rs:15:17 + --> $DIR/bad-inputs-and-output.rs:14:17 | LL | fn bar<T: Trait<method() -> (): Send>>() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -31,26 +31,18 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-inputs-and-output.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: argument types not allowed with return type notation - --> $DIR/bad-inputs-and-output.rs:11:23 + --> $DIR/bad-inputs-and-output.rs:10:23 | LL | fn foo<T: Trait<method(i32): Send>>() {} | ^^^^^ help: remove the input types: `()` error: return type not allowed with return type notation - --> $DIR/bad-inputs-and-output.rs:15:25 + --> $DIR/bad-inputs-and-output.rs:14:25 | LL | fn bar<T: Trait<method() -> (): Send>>() {} | ^^^^^^ help: remove the return type -error: aborting due to 5 previous errors; 2 warnings emitted +error: aborting due to 5 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index 0b7530b65..edc6a8e4c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -4,7 +4,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Foo { async fn method() -> Result<(), ()>; diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr index 722c774cb..9962f4706 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr @@ -7,13 +7,5 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/basic.rs:5:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr index 1645d8c26..c2da4f576 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -7,31 +7,23 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/basic.rs:5:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: future cannot be sent between threads safely - --> $DIR/basic.rs:24:13 + --> $DIR/basic.rs:23:13 | LL | is_send(foo::<T>()); | ^^^^^^^^^^ future returned by `foo` is not `Send` | = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/basic.rs:14:5 + --> $DIR/basic.rs:13:5 | LL | T::method().await?; | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send` note: required by a bound in `is_send` - --> $DIR/basic.rs:18:20 + --> $DIR/basic.rs:17:20 | LL | fn is_send(_: impl Send) {} | ^^^^ required by this bound in `is_send` -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index 75f757e90..6884305d7 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -2,7 +2,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete use std::future::Future; diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr index c5b2e5710..490bfdc4c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -7,19 +7,11 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/equality.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: return type notation is not allowed to use type equality - --> $DIR/equality.rs:13:18 + --> $DIR/equality.rs:12:18 | LL | fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs index 7b98a5cda..a52562d78 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -2,13 +2,12 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn method() {} } fn bar<T: Trait<methid(): Send>>() {} -//~^ ERROR cannot find associated function `methid` in trait `Trait` +//~^ ERROR cannot find associated function `methid` for `Trait` fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr index 34f5bda88..5b1c4cb0b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -7,19 +7,11 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - -error: cannot find associated function `methid` in trait `Trait` - --> $DIR/missing.rs:11:17 +error: cannot find associated function `methid` for `Trait` + --> $DIR/missing.rs:10:17 | LL | fn bar<T: Trait<methid(): Send>>() {} | ^^^^^^^^^^^^^^ -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/associated-type-bounds/supertrait-defines-ty.rs b/tests/ui/associated-type-bounds/supertrait-defines-ty.rs new file mode 100644 index 000000000..b6f37cb90 --- /dev/null +++ b/tests/ui/associated-type-bounds/supertrait-defines-ty.rs @@ -0,0 +1,26 @@ +// check-pass + +// Make sure that we don't look into associated type bounds when looking for +// supertraits that define an associated type. Fixes #76593. + +#![feature(associated_type_bounds)] + +trait Load: Sized { + type Blob; +} + +trait Primitive: Load<Blob = Self> {} + +trait BlobPtr: Primitive {} + +trait CleanPtr: Load<Blob: BlobPtr> { + fn to_blob(&self) -> Self::Blob; +} + +impl Load for () { + type Blob = Self; +} +impl Primitive for () {} +impl BlobPtr for () {} + +fn main() {} diff --git a/tests/ui/associated-types/associated-types-eq-3.stderr b/tests/ui/associated-types/associated-types-eq-3.stderr index 15ce4fc91..c3377eed2 100644 --- a/tests/ui/associated-types/associated-types-eq-3.stderr +++ b/tests/ui/associated-types/associated-types-eq-3.stderr @@ -43,7 +43,7 @@ note: expected this to be `Bar` | LL | type A = usize; | ^^^^^ - = note: required for the cast from `isize` to the object type `dyn Foo<A = Bar>` + = note: required for the cast from `&isize` to `&dyn Foo<A = Bar>` error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr index a28a0b74e..fdec01b95 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -4,7 +4,7 @@ error[E0271]: expected `IntoIter<u32>` to be an iterator that yields `i32`, but LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter(); | ^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` | - = note: required for the cast from `std::vec::IntoIter<u32>` to the object type `dyn Iterator<Item = u32, Item = i32>` + = note: required for the cast from `&std::vec::IntoIter<u32>` to `&dyn Iterator<Item = u32, Item = i32>` error: aborting due to previous error diff --git a/tests/ui/issues/issue-27901.rs b/tests/ui/associated-types/issue-27901.rs index ffd90b689..ffd90b689 100644 --- a/tests/ui/issues/issue-27901.rs +++ b/tests/ui/associated-types/issue-27901.rs diff --git a/tests/ui/associated-types/issue-65774-1.stderr b/tests/ui/associated-types/issue-65774-1.stderr index 91b557555..9c77a25c4 100644 --- a/tests/ui/associated-types/issue-65774-1.stderr +++ b/tests/ui/associated-types/issue-65774-1.stderr @@ -25,7 +25,7 @@ LL | impl<'a, T: MyDisplay> MyDisplay for &'a mut T { } | --------- ^^^^^^^^^ ^^^^^^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `&mut T` to the object type `dyn MyDisplay` + = note: required for the cast from `&&mut T` to `&dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/issue-65774-2.stderr b/tests/ui/associated-types/issue-65774-2.stderr index c22302cdc..ca8a727f0 100644 --- a/tests/ui/associated-types/issue-65774-2.stderr +++ b/tests/ui/associated-types/issue-65774-2.stderr @@ -18,7 +18,7 @@ LL | writer.my_write(valref) | ^^^^^^ the trait `MyDisplay` is not implemented for `T` | = help: the trait `MyDisplay` is implemented for `&'a mut T` - = note: required for the cast from `T` to the object type `dyn MyDisplay` + = note: required for the cast from `&mut T` to `&dyn MyDisplay` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/substs-ppaux.verbose.stderr b/tests/ui/associated-types/substs-ppaux.verbose.stderr index e4f6ba573..ad67899e6 100644 --- a/tests/ui/associated-types/substs-ppaux.verbose.stderr +++ b/tests/ui/associated-types/substs-ppaux.verbose.stderr @@ -77,7 +77,7 @@ LL | <str as Foo<u8>>::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` -note: required for `str` to implement `Foo<'_#0r, '_#1r, u8>` +note: required for `str` to implement `Foo<'?0, '?1, u8>` --> $DIR/substs-ppaux.rs:11:17 | LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking.stderr index fb83ca90a..dee90262f 100644 --- a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr +++ b/tests/ui/async-await/async-await-let-else.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later LL | }; | - `r` is later dropped here note: required by a bound in `is_send` @@ -65,12 +65,12 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ - `Rc::new(())` is later dropped here + | | | + | | await occurs here, with `Rc::new(())` maybe used later | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 @@ -86,12 +86,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later ... LL | }; | - `r` is later dropped here diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr index c284bbfb1..e3fcceaa3 100644 --- a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | @@ -63,10 +63,10 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later | | | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` @@ -83,12 +83,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | diff --git a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr index d3c5e80a3..ece4e51ec 100644 --- a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later LL | }; | - `r` is later dropped here note: required by a bound in `is_send` @@ -28,10 +28,10 @@ LL | is_send(foo2(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:23:26 + --> $DIR/async-await-let-else.rs:23:27 | LL | bar2(Rc::new(())).await - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later | | | has type `Rc<()>` which is not `Send` LL | }; @@ -50,12 +50,12 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ - `Rc::new(())` is later dropped here + | | | + | | await occurs here, with `Rc::new(())` maybe used later | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 @@ -71,12 +71,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later ... LL | }; | - `r` is later dropped here diff --git a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr index a6dbb0716..bbd5a822d 100644 --- a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -35,7 +35,7 @@ error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semant LL | let _: &dyn Future<Output = ()> = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to the object type `dyn Future<Output = ()>` + = note: required for the cast from `&[async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 25:6]` to `&dyn Future<Output = ()>` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:12:43 @@ -51,7 +51,7 @@ error[E0271]: expected `[async block@$DIR/async-block-control-flow-static-semant LL | let _: &dyn Future<Output = ()> = █ | ^^^^^^ expected `()`, found `u8` | - = note: required for the cast from `[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to the object type `dyn Future<Output = ()>` + = note: required for the cast from `&[async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 16:6]` to `&dyn Future<Output = ()>` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:49:44 diff --git a/tests/ui/async-await/async-error-span.drop_tracking.stderr b/tests/ui/async-await/async-error-span.drop_tracking.stderr index c6257cb32..99a674a26 100644 --- a/tests/ui/async-await/async-error-span.drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.drop_tracking.stderr @@ -14,10 +14,10 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:17 + --> $DIR/async-error-span.rs:19:18 | LL | get_future().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr index c6257cb32..99a674a26 100644 --- a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr @@ -14,10 +14,10 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:17 + --> $DIR/async-error-span.rs:19:18 | LL | get_future().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr index 0f0dc335e..0515edaed 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------------- has type `Option<impl Debug>` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later + | ^^^^^ await occurs here, with `Some(non_send())` maybe used later ... LL | } | - `Some(non_send())` is later dropped here @@ -29,13 +29,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later LL | } LL | } | - `get_formatter()` is later dropped here diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr index 57a012801..219945e09 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------------- has type `Option<impl Debug>` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later + | ^^^^^ await occurs here, with `Some(non_send())` maybe used later note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | @@ -26,13 +26,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | diff --git a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr index 5cec21d89..b29d2e192 100644 --- a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(local_dropped_before_await()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:27:10 + --> $DIR/async-fn-nonsend.rs:27:11 | LL | let x = non_send(); | - has type `impl Debug` which is not `Send` LL | drop(x); LL | fut().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `assert_send` @@ -29,12 +29,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------- has type `impl Debug` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `non_send()` maybe used later + | ^^^^^ await occurs here, with `non_send()` maybe used later ... LL | } | - `non_send()` is later dropped here @@ -52,13 +52,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later LL | } LL | } | - `get_formatter()` is later dropped here @@ -76,13 +76,13 @@ LL | assert_send(non_sync_with_method_call_panic()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:56:14 + --> $DIR/async-fn-nonsend.rs:56:15 | LL | let f: &mut std::fmt::Formatter = panic!(); | - has type `&mut Formatter<'_>` which is not `Send` LL | if non_sync().fmt(f).unwrap() == () { LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later + | ^^^^^ await occurs here, with `f` maybe used later LL | } LL | } | - `f` is later dropped here @@ -100,13 +100,13 @@ LL | assert_send(non_sync_with_method_call_infinite_loop()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:63:14 + --> $DIR/async-fn-nonsend.rs:63:15 | LL | let f: &mut std::fmt::Formatter = loop {}; | - has type `&mut Formatter<'_>` which is not `Send` LL | if non_sync().fmt(f).unwrap() == () { LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later + | ^^^^^ await occurs here, with `f` maybe used later LL | } LL | } | - `f` is later dropped here diff --git a/tests/ui/async-await/async-fn-nonsend.stderr b/tests/ui/async-await/async-fn-nonsend.stderr deleted file mode 100644 index 0f0dc335e..000000000 --- a/tests/ui/async-await/async-fn-nonsend.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:72:17 - | -LL | assert_send(non_send_temporary_in_match()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 - | -LL | match Some(non_send()) { - | ---------------- has type `Option<impl Debug>` which is not `Send` -LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later -... -LL | } - | - `Some(non_send())` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:74:17 - | -LL | assert_send(non_sync_with_method_call()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 - | -LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); - | --------------- has type `Formatter<'_>` which is not `Send` -... -LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later -LL | } -LL | } - | - `get_formatter()` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index d6404b30e..5d29325c8 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -17,13 +17,13 @@ LL | | }); = help: within `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>` = note: `UnwindSafe` is implemented for `&std::task::Context<'_>`, but not for `&mut std::task::Context<'_>` note: future does not implement `UnwindSafe` as this value is used across an await - --> $DIR/async-is-unwindsafe.rs:25:17 + --> $DIR/async-is-unwindsafe.rs:25:18 | LL | let cx_ref = &mut cx; | ------ has type `&mut Context<'_>` which does not implement `UnwindSafe` LL | LL | async {}.await; // this needs an inner await point - | ^^^^^^ await occurs here, with `cx_ref` maybe used later + | ^^^^^ await occurs here, with `cx_ref` maybe used later ... LL | }); | - `cx_ref` is later dropped here diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr index b30f28837..7b03e5666 100644 --- a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -143,7 +143,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo9() -> Result<(), ()> { | ---- this is not `async` LL | let _ = await bar(); - | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks --> $DIR/incorrect-syntax-suggestions.rs:57:13 @@ -151,7 +151,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo10() -> Result<(), ()> { | ----- this is not `async` LL | let _ = await? bar(); - | ^^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks --> $DIR/incorrect-syntax-suggestions.rs:66:14 @@ -159,71 +159,71 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo12() -> Result<(), ()> { | ----- this is not `async` LL | let _ = (await bar())?; - | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:71:18 + --> $DIR/incorrect-syntax-suggestions.rs:71:19 | LL | fn foo13() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await(); - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:76:18 + --> $DIR/incorrect-syntax-suggestions.rs:76:19 | LL | fn foo14() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await()?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:81:18 + --> $DIR/incorrect-syntax-suggestions.rs:81:19 | LL | fn foo15() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:85:18 + --> $DIR/incorrect-syntax-suggestions.rs:85:19 | LL | fn foo16() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:90:22 + --> $DIR/incorrect-syntax-suggestions.rs:90:23 | LL | fn foo() -> Result<(), ()> { | --- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:97:22 + --> $DIR/incorrect-syntax-suggestions.rs:97:23 | LL | let foo = || { | -- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:113:29 + --> $DIR/incorrect-syntax-suggestions.rs:113:17 | LL | fn foo() -> Result<(), ()> { | --- this is not `async` LL | let _ = await!(bar())?; - | ^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:121:29 + --> $DIR/incorrect-syntax-suggestions.rs:121:17 | LL | let foo = || { | -- this is not `async` LL | let _ = await!(bar())?; - | ^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to 33 previous errors diff --git a/tests/ui/async-await/clone-suggestion.fixed b/tests/ui/async-await/clone-suggestion.fixed new file mode 100644 index 000000000..3514cd63d --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.fixed @@ -0,0 +1,28 @@ +// edition: 2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +#[derive(Clone)] +struct SharedFuture; + +impl Future for SharedFuture { + type Output = (); + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<<Self as Future>::Output> { + todo!() + } +} + +async fn foo() { + let f = SharedFuture; + f.clone().await; + f.await; + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/async-await/clone-suggestion.rs b/tests/ui/async-await/clone-suggestion.rs new file mode 100644 index 000000000..5a4f70cbf --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.rs @@ -0,0 +1,28 @@ +// edition: 2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +#[derive(Clone)] +struct SharedFuture; + +impl Future for SharedFuture { + type Output = (); + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<<Self as Future>::Output> { + todo!() + } +} + +async fn foo() { + let f = SharedFuture; + f.await; + f.await; + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/async-await/clone-suggestion.stderr b/tests/ui/async-await/clone-suggestion.stderr new file mode 100644 index 000000000..c02206f6f --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.stderr @@ -0,0 +1,20 @@ +error[E0382]: use of moved value: `f` + --> $DIR/clone-suggestion.rs:24:5 + | +LL | let f = SharedFuture; + | - move occurs because `f` has type `SharedFuture`, which does not implement the `Copy` trait +LL | f.await; + | ----- `f` moved due to this await +LL | f.await; + | ^ value used here after move + | +note: `into_future` takes ownership of the receiver `self`, which moves `f` + --> $SRC_DIR/core/src/future/into_future.rs:LL:COL +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | f.clone().await; + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr index 819b64ad7..07ab8b3c9 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -5,12 +5,12 @@ LL | None { value: (), ..Default::default() }.await; | ^^^^^ `Option<_>::None` does not have this field error[E0277]: `Option<_>` is not a future - --> $DIR/drop-track-bad-field-in-fru.rs:7:45 + --> $DIR/drop-track-bad-field-in-fru.rs:7:46 | LL | None { value: (), ..Default::default() }.await; - | ^^^^^^ - | | - | `Option<_>` is not a future + | -^^^^^ + | || + | |`Option<_>` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `Option<_>` diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr index e2bba812d..80402d842 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr index b89d86804..d9141cf4e 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later note: required by a bound in `assert_send` --> $DIR/drop-track-field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr index e2bba812d..80402d842 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/feature-self-return-type.stderr b/tests/ui/async-await/feature-self-return-type.stderr index 892468368..747c54b66 100644 --- a/tests/ui/async-await/feature-self-return-type.stderr +++ b/tests/ui/async-await/feature-self-return-type.stderr @@ -4,6 +4,7 @@ error[E0597]: `bar` does not live long enough LL | let x = { | - borrow later stored here LL | let bar = 22; + | --- binding `bar` declared here LL | Foo::new(&bar).await | ^^^^ borrowed value does not live long enough LL | diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr index ac461a671..e2e64c9ae 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr index 8c9d14d62..d1df8e91a 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later note: required by a bound in `assert_send` --> $DIR/field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr index ac461a671..e2e64c9ae 100644 --- a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index eaf3e4b61..c0fbb0204 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -2,38 +2,34 @@ print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:21:21: 24:2]`: print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Suspend0`: 3077 bytes -print-type-size local `.__awaitee`: 3077 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size local `.__awaitee`: 3077 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]`: 3077 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes -print-type-size variant `Unresumed`: 2051 bytes -print-type-size padding: 1026 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size variant `Unresumed`: 1025 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size variant `Suspend0`: 2052 bytes -print-type-size local `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes -print-type-size local `..generator_field4`: 1 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size padding: 1 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size local `..generator_field4`: 1 bytes print-type-size local `.__awaitee`: 1 bytes print-type-size variant `Suspend1`: 3076 bytes -print-type-size padding: 1024 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size padding: 1026 bytes print-type-size local `..generator_field4`: 1 bytes, alignment: 1 bytes -print-type-size padding: 1 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes print-type-size local `.__awaitee`: 1025 bytes print-type-size variant `Suspend2`: 2052 bytes -print-type-size local `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes -print-type-size local `..generator_field4`: 1 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size padding: 1 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size local `..generator_field4`: 1 bytes print-type-size local `.__awaitee`: 1 bytes -print-type-size variant `Returned`: 2051 bytes -print-type-size padding: 1026 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes -print-type-size variant `Panicked`: 2051 bytes -print-type-size padding: 1026 bytes -print-type-size upvar `.fut`: 1025 bytes, alignment: 1 bytes +print-type-size variant `Returned`: 1025 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size variant `Panicked`: 1025 bytes +print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 3077 bytes, alignment: 1 bytes print-type-size field `.value`: 3077 bytes print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 3077 bytes, alignment: 1 bytes @@ -43,11 +39,11 @@ print-type-size field `.value`: 3077 bytes print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]`: 1025 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 1024 bytes -print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 1024 bytes print-type-size variant `Returned`: 1024 bytes -print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes -print-type-size upvar `.arg`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]>`: 1025 bytes, alignment: 1 bytes print-type-size field `.value`: 1025 bytes print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]>`: 1025 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/future-sizes/large-arg.stdout b/tests/ui/async-await/future-sizes/large-arg.stdout index 91db4b153..b5e95ddd7 100644 --- a/tests/ui/async-await/future-sizes/large-arg.stdout +++ b/tests/ui/async-await/future-sizes/large-arg.stdout @@ -2,20 +2,20 @@ print-type-size type: `[async fn body@$DIR/large-arg.rs:6:21: 8:2]`: 3076 bytes, print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Suspend0`: 3075 bytes -print-type-size local `.__awaitee`: 3075 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size local `.__awaitee`: 3075 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes print-type-size type: `[async fn body@$DIR/large-arg.rs:10:30: 12:2]`: 3075 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Suspend0`: 3074 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size local `.__awaitee`: 2050 bytes print-type-size variant `Returned`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:10:30: 12:2]>`: 3075 bytes, alignment: 1 bytes print-type-size field `.value`: 3075 bytes print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:10:30: 12:2]>`: 3075 bytes, alignment: 1 bytes @@ -25,14 +25,14 @@ print-type-size field `.value`: 3075 bytes print-type-size type: `[async fn body@$DIR/large-arg.rs:13:26: 15:2]`: 2050 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Suspend0`: 2049 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size local `.__awaitee`: 1025 bytes print-type-size variant `Returned`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:13:26: 15:2]>`: 2050 bytes, alignment: 1 bytes print-type-size field `.value`: 2050 bytes print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:13:26: 15:2]>`: 2050 bytes, alignment: 1 bytes @@ -42,11 +42,11 @@ print-type-size field `.value`: 2050 bytes print-type-size type: `[async fn body@$DIR/large-arg.rs:16:26: 18:2]`: 1025 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Returned`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes -print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.t`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:16:26: 18:2]>`: 1025 bytes, alignment: 1 bytes print-type-size field `.value`: 1025 bytes print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:16:26: 18:2]>`: 1025 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr deleted file mode 100644 index 2142ee232..000000000 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr deleted file mode 100644 index 2142ee232..000000000 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index dd1af93d7..99c3ba6a3 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -4,7 +4,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use use std::future::Future; diff --git a/tests/ui/async-await/in-trait/bad-signatures.current.stderr b/tests/ui/async-await/in-trait/bad-signatures.current.stderr index 5a05b080c..ae590fb05 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.current.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.current.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | -----^^^^ @@ -13,14 +13,5 @@ LL | async fn bar(&abc self); | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `<identifier>: <type>` -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-signatures.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/bad-signatures.next.stderr b/tests/ui/async-await/in-trait/bad-signatures.next.stderr index 5a05b080c..ae590fb05 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.next.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.next.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | -----^^^^ @@ -13,14 +13,5 @@ LL | async fn bar(&abc self); | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `<identifier>: <type>` -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-signatures.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs index e0093be8c..4baddd8cc 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.rs +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete trait MyTrait { async fn bar(&abc self); diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr index 1e67cdca2..eec5ab065 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr @@ -1,12 +1,3 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: async associated function in trait cannot be specialized --> $DIR/dont-project-to-specializable-projection.rs:16:5 | @@ -15,5 +6,5 @@ LL | default async fn foo(_: T) -> &'static str { | = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr index fa89c6b77..25a7f3bb5 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr @@ -1,12 +1,3 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0053]: method `foo` has an incompatible type for trait --> $DIR/dont-project-to-specializable-projection.rs:16:35 | @@ -29,6 +20,6 @@ LL | default async fn foo(_: T) -> &'static str { | = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr index 0e9477544..69e7c65ee 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:14:17 + --> $DIR/lifetime-mismatch.rs:13:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait @@ -16,6 +7,6 @@ LL | async fn foo<'a>(&self); LL | async fn foo(&self) {} | ^ lifetimes do not match method in trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr index 0e9477544..69e7c65ee 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:14:17 + --> $DIR/lifetime-mismatch.rs:13:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait @@ -16,6 +7,6 @@ LL | async fn foo<'a>(&self); LL | async fn foo(&self) {} | ^ lifetimes do not match method in trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 5ff5a01a1..46183f72b 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait MyTrait { async fn foo<'a>(&self); diff --git a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr index 319ed582e..9aa37f743 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr @@ -1,29 +1,20 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing-send-bound.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:17:20 + --> $DIR/missing-send-bound.rs:16:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:13:5 + --> $DIR/missing-send-bound.rs:12:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:21:27 + --> $DIR/missing-send-bound.rs:20:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr index 319ed582e..9aa37f743 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr @@ -1,29 +1,20 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing-send-bound.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:17:20 + --> $DIR/missing-send-bound.rs:16:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:13:5 + --> $DIR/missing-send-bound.rs:12:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:21:27 + --> $DIR/missing-send-bound.rs:20:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs index 705fcf322..b602865cb 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.rs +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait Foo { async fn bar(); diff --git a/tests/ui/async-await/in-trait/nested-rpit.rs b/tests/ui/async-await/in-trait/nested-rpit.rs index 41d72ebb4..9cdc23bbc 100644 --- a/tests/ui/async-await/in-trait/nested-rpit.rs +++ b/tests/ui/async-await/in-trait/nested-rpit.rs @@ -1,7 +1,5 @@ // edition: 2021 -// known-bug: #105197 -// failure-status:101 -// dont-check-compiler-stderr +// check-pass #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/object-safety.current.stderr b/tests/ui/async-await/in-trait/object-safety.current.stderr index 90e049a99..7f7ec3914 100644 --- a/tests/ui/async-await/in-trait/object-safety.current.stderr +++ b/tests/ui/async-await/in-trait/object-safety.current.stderr @@ -1,20 +1,11 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/object-safety.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:13:12 + --> $DIR/object-safety.rs:12:12 | LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:9:14 + --> $DIR/object-safety.rs:8:14 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -22,6 +13,6 @@ LL | async fn foo(&self); | ^^^ ...because method `foo` is `async` = help: consider moving `foo` to another trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.next.stderr b/tests/ui/async-await/in-trait/object-safety.next.stderr index 90e049a99..7f7ec3914 100644 --- a/tests/ui/async-await/in-trait/object-safety.next.stderr +++ b/tests/ui/async-await/in-trait/object-safety.next.stderr @@ -1,20 +1,11 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/object-safety.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:13:12 + --> $DIR/object-safety.rs:12:12 | LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:9:14 + --> $DIR/object-safety.rs:8:14 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -22,6 +13,6 @@ LL | async fn foo(&self); | ^^^ ...because method `foo` is `async` = help: consider moving `foo` to another trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index f67286a20..4edad1512 100644 --- a/tests/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait Foo { async fn foo(&self); diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr index a5efc7571..6a107d7be 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:10:9 + --> $DIR/return-type-suggestion.rs:9:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` @@ -18,6 +9,6 @@ LL | Ok(()) = note: expected unit type `()` found enum `Result<(), _>` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr index a5efc7571..6a107d7be 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:10:9 + --> $DIR/return-type-suggestion.rs:9:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` @@ -18,6 +9,6 @@ LL | Ok(()) = note: expected unit type `()` found enum `Result<(), _>` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index 3de66306d..d63bccefa 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait A { async fn e() { diff --git a/tests/ui/async-await/issue-101715.stderr b/tests/ui/async-await/issue-101715.stderr index a0e8d2a89..d161fb0c0 100644 --- a/tests/ui/async-await/issue-101715.stderr +++ b/tests/ui/async-await/issue-101715.stderr @@ -1,10 +1,10 @@ error[E0277]: `()` is not a future - --> $DIR/issue-101715.rs:11:9 + --> $DIR/issue-101715.rs:11:10 | LL | .await - | ^^^^^^ - | | - | `()` is not a future + | -^^^^^ + | || + | |`()` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `()` diff --git a/tests/ui/async-await/issue-61949-self-return-type.stderr b/tests/ui/async-await/issue-61949-self-return-type.stderr index 638b197bc..ac85ed288 100644 --- a/tests/ui/async-await/issue-61949-self-return-type.stderr +++ b/tests/ui/async-await/issue-61949-self-return-type.stderr @@ -13,6 +13,7 @@ error[E0597]: `bar` does not live long enough LL | let x = { | - borrow later stored here LL | let bar = 22; + | --- binding `bar` declared here LL | Foo::new(&bar).await | ^^^^ borrowed value does not live long enough LL | diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr index c4c7f26c7..56aa035f4 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | drop(x); LL | } | - `x` is later dropped here diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr index 6f43b568a..ea1bfb9f9 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_sync` --> $DIR/issue-64130-1-sync.rs:14:15 | diff --git a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr index c4c7f26c7..56aa035f4 100644 --- a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | drop(x); LL | } | - `x` is later dropped here diff --git a/tests/ui/async-await/issue-64130-1-sync.stderr b/tests/ui/async-await/issue-64130-1-sync.stderr deleted file mode 100644 index 8d5169a63..000000000 --- a/tests/ui/async-await/issue-64130-1-sync.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:24:13 - | -LL | is_sync(bar()); - | ^^^^^ future returned by `bar` is not `Sync` - | - = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` -note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 - | -LL | let x = Foo; - | - has type `Foo` which is not `Sync` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_sync` - --> $DIR/issue-64130-1-sync.rs:14:15 - | -LL | fn is_sync<T: Sync>(t: T) { } - | ^^^^ required by this bound in `is_sync` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr index b6a73c2a5..d1717ad33 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr index 560560f60..45e43525a 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_send` --> $DIR/issue-64130-2-send.rs:14:15 | diff --git a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr index b6a73c2a5..d1717ad33 100644 --- a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-64130-2-send.stderr b/tests/ui/async-await/issue-64130-2-send.stderr deleted file mode 100644 index f6505cad6..000000000 --- a/tests/ui/async-await/issue-64130-2-send.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:24:13 - | -LL | is_send(bar()); - | ^^^^^ future returned by `bar` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Foo` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 - | -LL | let x = Foo; - | - has type `Foo` which is not `Send` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_send` - --> $DIR/issue-64130-2-send.rs:14:15 - | -LL | fn is_send<T: Send>(t: T) { } - | ^^^^ required by this bound in `is_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr index d65aae8cc..b69f06da1 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_qux` diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr index 8fed69d9d..129837124 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_qux` --> $DIR/issue-64130-3-other.rs:17:14 | diff --git a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr index d65aae8cc..b69f06da1 100644 --- a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_qux` diff --git a/tests/ui/async-await/issue-64130-3-other.stderr b/tests/ui/async-await/issue-64130-3-other.stderr deleted file mode 100644 index cb36a3811..000000000 --- a/tests/ui/async-await/issue-64130-3-other.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future<Output = ()>` - --> $DIR/issue-64130-3-other.rs:27:12 - | -LL | async fn bar() { - | - within this `impl Future<Output = ()>` -... -LL | is_qux(bar()); - | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` - | -note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 - | -LL | let x = Foo; - | - has type `Foo` which does not implement `Qux` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_qux` - --> $DIR/issue-64130-3-other.rs:17:14 - | -LL | fn is_qux<T: Qux>(t: T) {} - | ^^^ required by this bound in `is_qux` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr index 0bc7cb2f2..4b575a3d3 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send { | = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:31 + --> $DIR/issue-64130-4-async-move.rs:27:32 | LL | match client.status() { | ------ has type `&Client` which is not `Send` LL | 200 => { LL | let _x = get().await; - | ^^^^^^ await occurs here, with `client` maybe used later + | ^^^^^ await occurs here, with `client` maybe used later ... LL | } | - `client` is later dropped here diff --git a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr index 1da80d98b..e044e2ca0 100644 --- a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr +++ b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr @@ -6,12 +6,12 @@ LL | is_send(foo()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, u32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-non-send-future-diags.rs:17:10 + --> $DIR/issue-64130-non-send-future-diags.rs:17:11 | LL | let g = x.lock().unwrap(); | - has type `MutexGuard<'_, u32>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `g` maybe used later + | ^^^^^ await occurs here, with `g` maybe used later LL | } | - `g` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr index fc8bcc8ae..fa2229865 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr @@ -11,12 +11,12 @@ LL | | }); | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | drop(a); LL | }); | - `a` is later dropped here diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr index a3ef7add1..8cf7bb8d9 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | spawn(async { | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:9:13 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr index fc8bcc8ae..fa2229865 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr @@ -11,12 +11,12 @@ LL | | }); | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | drop(a); LL | }); | - `a` is later dropped here diff --git a/tests/ui/async-await/issue-70594.stderr b/tests/ui/async-await/issue-70594.stderr index d3cf57d3b..9866e00bb 100644 --- a/tests/ui/async-await/issue-70594.stderr +++ b/tests/ui/async-await/issue-70594.stderr @@ -1,10 +1,10 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | async fn fun() { | --- this is not `async` LL | [1; ().await]; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0744]: `.await` is not allowed in a `const` --> $DIR/issue-70594.rs:4:9 @@ -13,18 +13,18 @@ LL | [1; ().await]; | ^^^^^^^^ error[E0744]: `.await` is not allowed in a `const` - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | [1; ().await]; - | ^^^^^^ + | ^^^^^ error[E0277]: `()` is not a future - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | [1; ().await]; - | ^^^^^^ - | | - | `()` is not a future + | -^^^^^ + | || + | |`()` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `()` diff --git a/tests/ui/async-await/issue-70818.stderr b/tests/ui/async-await/issue-70818.stderr deleted file mode 100644 index ab0698c3e..000000000 --- a/tests/ui/async-await/issue-70818.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:7:38 - | -LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | -note: captured value is not `Send` - --> $DIR/issue-70818.rs:9:18 - | -LL | async { (ty, ty1) } - | ^^^ has type `U` which is not `Send` -help: consider restricting type parameter `U` - | -LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr index 8036d82da..ef0e182e5 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr @@ -6,15 +6,15 @@ LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { | = help: the trait `Sync` is not implemented for `Sender<i32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:19:11 + --> $DIR/issue-70935-complex-spans.rs:19:12 | LL | baz(|| async{ | _____________- LL | | foo(tx.clone()); LL | | }).await; - | | - ^^^^^^- the value is later dropped here - | | | | - | |_________| await occurs here, with the value maybe used later + | | - ^^^^^- the value is later dropped here + | | | | + | |_________| await occurs here, with the value maybe used later | has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-71137.stderr b/tests/ui/async-await/issue-71137.stderr index eade6aa2d..a344246d6 100644 --- a/tests/ui/async-await/issue-71137.stderr +++ b/tests/ui/async-await/issue-71137.stderr @@ -6,12 +6,12 @@ LL | fake_spawn(wrong_mutex()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, i32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-71137.rs:14:25 + --> $DIR/issue-71137.rs:14:26 | LL | let mut guard = m.lock().unwrap(); | --------- has type `MutexGuard<'_, i32>` which is not `Send` LL | (async { "right"; }).await; - | ^^^^^^ await occurs here, with `mut guard` maybe used later + | ^^^^^ await occurs here, with `mut guard` maybe used later LL | *guard += 1; LL | } | - `mut guard` is later dropped here diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr b/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr deleted file mode 100644 index 6d19c3beb..000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-73741-type-err-drop-tracking.rs:11:7 - | -LL | 1 = 2; - | - ^ - | | - | cannot assign to this expression - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/async-await/issue-74047.stderr b/tests/ui/async-await/issue-74047.stderr index 28174825d..6bdb9ded4 100644 --- a/tests/ui/async-await/issue-74047.stderr +++ b/tests/ui/async-await/issue-74047.stderr @@ -4,8 +4,8 @@ error[E0046]: not all trait items implemented, missing: `Error`, `try_from` LL | impl TryFrom<OtherStream> for MyStream {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation | - = help: implement the missing item: `type Error = Type;` - = help: implement the missing item: `fn try_from(_: T) -> Result<Self, <Self as TryFrom<T>>::Error> { todo!() }` + = help: implement the missing item: `type Error = /* Type */;` + = help: implement the missing item: `fn try_from(_: OtherStream) -> Result<Self, <Self as TryFrom<OtherStream>>::Error> { todo!() }` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-86507.drop_tracking.stderr b/tests/ui/async-await/issue-86507.drop_tracking.stderr index 5c8b7ef1b..adb7b9bf4 100644 --- a/tests/ui/async-await/issue-86507.drop_tracking.stderr +++ b/tests/ui/async-await/issue-86507.drop_tracking.stderr @@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `[async block@$DIR/issue-86507.rs:21:17: 23:18]` to the object type `dyn Future<Output = ()> + Send` + = note: required for the cast from `Pin<Box<[async block@$DIR/issue-86507.rs:21:17: 23:18]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) diff --git a/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr b/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr index 5c8b7ef1b..adb7b9bf4 100644 --- a/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-86507.drop_tracking_mir.stderr @@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `[async block@$DIR/issue-86507.rs:21:17: 23:18]` to the object type `dyn Future<Output = ()> + Send` + = note: required for the cast from `Pin<Box<[async block@$DIR/issue-86507.rs:21:17: 23:18]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) diff --git a/tests/ui/async-await/issue-86507.no_drop_tracking.stderr b/tests/ui/async-await/issue-86507.no_drop_tracking.stderr index 5c8b7ef1b..adb7b9bf4 100644 --- a/tests/ui/async-await/issue-86507.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-86507.no_drop_tracking.stderr @@ -13,7 +13,7 @@ note: captured value is not `Send` because `&` references cannot be sent unless | LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` - = note: required for the cast from `[async block@$DIR/issue-86507.rs:21:17: 23:18]` to the object type `dyn Future<Output = ()> + Send` + = note: required for the cast from `Pin<Box<[async block@$DIR/issue-86507.rs:21:17: 23:18]>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>` help: consider further restricting this bound | LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) diff --git a/tests/ui/async-await/issue-98634.stderr b/tests/ui/async-await/issue-98634.stderr index 5b7f18a98..574904cea 100644 --- a/tests/ui/async-await/issue-98634.stderr +++ b/tests/ui/async-await/issue-98634.stderr @@ -23,10 +23,10 @@ LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync` error[E0271]: expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>` - --> $DIR/issue-98634.rs:45:33 + --> $DIR/issue-98634.rs:45:34 | LL | StructAsync { callback }.await; - | ^^^^^^ expected `Pin<Box<dyn Future<Output = ()>>>`, found future + | ^^^^^ expected `Pin<Box<dyn Future<Output = ()>>>`, found future | note: required by a bound in `StructAsync` --> $DIR/issue-98634.rs:9:35 diff --git a/tests/ui/async-await/issues/issue-102206.stderr b/tests/ui/async-await/issues/issue-102206.stderr index 750b7a886..cd8450568 100644 --- a/tests/ui/async-await/issues/issue-102206.stderr +++ b/tests/ui/async-await/issues/issue-102206.stderr @@ -2,14 +2,16 @@ error[E0308]: mismatched types --> $DIR/issue-102206.rs:6:27 | LL | std::mem::size_of_val(foo()); - | --------------------- ^^^^^ - | | | - | | expected `&_`, found future - | | help: consider borrowing here: `&foo()` + | --------------------- ^^^^^ expected `&_`, found future + | | | arguments to this function are incorrect | note: function defined here --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +help: consider borrowing here + | +LL | std::mem::size_of_val(&foo()); + | + error: aborting due to previous error diff --git a/tests/ui/async-await/issues/issue-107280.stderr b/tests/ui/async-await/issues/issue-107280.stderr index dd3e10fcc..2e69862a0 100644 --- a/tests/ui/async-await/issues/issue-107280.stderr +++ b/tests/ui/async-await/issues/issue-107280.stderr @@ -23,10 +23,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -35,10 +35,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -47,10 +47,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -59,10 +59,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -71,10 +71,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/async-await/issues/issue-112225-1.rs b/tests/ui/async-await/issues/issue-112225-1.rs new file mode 100644 index 000000000..e28cbee21 --- /dev/null +++ b/tests/ui/async-await/issues/issue-112225-1.rs @@ -0,0 +1,18 @@ +// check-pass +// edition:2021 + +use core::future::Future; + +fn main() { + do_async(async { (0,) }, { + // closure must be inside block + |info| println!("{:?}", info.0) + }); +} + +fn do_async<R, Fut, F>(_tokio_fut: Fut, _glib_closure: F) +where + Fut: Future<Output = R>, + F: FnOnce(R), +{ +} diff --git a/tests/ui/async-await/issues/issue-112225-2.rs b/tests/ui/async-await/issues/issue-112225-2.rs new file mode 100644 index 000000000..50fa1a79b --- /dev/null +++ b/tests/ui/async-await/issues/issue-112225-2.rs @@ -0,0 +1,20 @@ +// edition:2021 + +// With the current compiler logic, we cannot have both the `112225-1` case, +// and this `112225-2` case working, as the type inference depends on the evaluation +// order, and there is some explicit ordering going on. +// See the `check_closures` part in `FnCtxt::check_argument_types`. +// The `112225-1` case was a regression in real world code, whereas the `112225-2` +// case never used to work prior to 1.70. + +use core::future::Future; + +fn main() { + let x = Default::default(); + //~^ ERROR: type annotations needed + do_async( + async { x.0; }, + { || { let _: &(i32,) = &x; } }, + ); +} +fn do_async<Fut, T>(_fut: Fut, _val: T, ) {} diff --git a/tests/ui/async-await/issues/issue-112225-2.stderr b/tests/ui/async-await/issues/issue-112225-2.stderr new file mode 100644 index 000000000..5926a4f39 --- /dev/null +++ b/tests/ui/async-await/issues/issue-112225-2.stderr @@ -0,0 +1,17 @@ +error[E0282]: type annotations needed + --> $DIR/issue-112225-2.rs:13:9 + | +LL | let x = Default::default(); + | ^ +... +LL | async { x.0; }, + | - type must be known at this point + | +help: consider giving `x` an explicit type + | +LL | let x: /* Type */ = Default::default(); + | ++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/async-await/issues/issue-51719.stderr b/tests/ui/async-await/issues/issue-51719.stderr index f3ce5d1c8..19cc339ec 100644 --- a/tests/ui/async-await/issues/issue-51719.stderr +++ b/tests/ui/async-await/issues/issue-51719.stderr @@ -1,8 +1,8 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-51719.rs:8:24 + --> $DIR/issue-51719.rs:8:25 | LL | let _gen = || foo().await; - | -- ^^^^^^ only allowed inside `async` functions and blocks + | -- ^^^^^ only allowed inside `async` functions and blocks | | | this is not `async` diff --git a/tests/ui/async-await/issues/issue-51751.stderr b/tests/ui/async-await/issues/issue-51751.stderr index 8696a5b79..6dd372660 100644 --- a/tests/ui/async-await/issues/issue-51751.stderr +++ b/tests/ui/async-await/issues/issue-51751.stderr @@ -1,11 +1,11 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-51751.rs:9:26 + --> $DIR/issue-51751.rs:9:27 | LL | fn main() { | ---- this is not `async` LL | let result = inc(10000); LL | let finished = result.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/issues/issue-62009-1.stderr b/tests/ui/async-await/issues/issue-62009-1.stderr index 222afb2c7..53d0577a1 100644 --- a/tests/ui/async-await/issues/issue-62009-1.stderr +++ b/tests/ui/async-await/issues/issue-62009-1.stderr @@ -1,36 +1,36 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:6:22 + --> $DIR/issue-62009-1.rs:6:23 | LL | fn main() { | ---- this is not `async` LL | async { let (); }.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:10:6 + --> $DIR/issue-62009-1.rs:10:7 | LL | fn main() { | ---- this is not `async` ... LL | }.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:12:15 + --> $DIR/issue-62009-1.rs:12:16 | LL | fn main() { | ---- this is not `async` ... LL | (|_| 2333).await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future - --> $DIR/issue-62009-1.rs:12:15 + --> $DIR/issue-62009-1.rs:12:16 | LL | (|_| 2333).await; - | ^^^^^^ - | | - | `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future + | -^^^^^ + | || + | |`[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for closure `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` diff --git a/tests/ui/async-await/issues/issue-62009-2.stderr b/tests/ui/async-await/issues/issue-62009-2.stderr index 92e9a8a69..9c2f20df6 100644 --- a/tests/ui/async-await/issues/issue-62009-2.stderr +++ b/tests/ui/async-await/issues/issue-62009-2.stderr @@ -1,10 +1,10 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-2.rs:8:22 + --> $DIR/issue-62009-2.rs:8:23 | LL | fn main() { | ---- this is not `async` LL | (async || 2333)().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr index 8745bdd97..53d326202 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr @@ -10,12 +10,12 @@ LL | | }) | = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:17:17: 20:6]`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:35 + --> $DIR/issue-65436-raw-ptr-not-send.rs:19:36 | LL | bar(Foo(std::ptr::null())).await; - | ---------------- ^^^^^^- `std::ptr::null()` is later dropped here - | | | - | | await occurs here, with `std::ptr::null()` maybe used later + | ---------------- ^^^^^- `std::ptr::null()` is later dropped here + | | | + | | await occurs here, with `std::ptr::null()` maybe used later | has type `*const u8` which is not `Send` help: consider moving this into a `let` binding to create a shorter lived borrow --> $DIR/issue-65436-raw-ptr-not-send.rs:19:13 diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index ce9424c8b..c941b9eeb 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -6,12 +6,12 @@ LL | g(issue_67893::run()) | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` note: future is not `Send` as this value is used across an await - --> $DIR/auxiliary/issue_67893.rs:12:26 + --> $DIR/auxiliary/issue_67893.rs:12:27 | LL | f(*x.lock().unwrap()).await; - | ----------------- ^^^^^^- `x.lock().unwrap()` is later dropped here - | | | - | | await occurs here, with `x.lock().unwrap()` maybe used later + | ----------------- ^^^^^- `x.lock().unwrap()` is later dropped here + | | | + | | await occurs here, with `x.lock().unwrap()` maybe used later | has type `MutexGuard<'_, ()>` which is not `Send` note: required by a bound in `g` --> $DIR/issue-67893.rs:6:14 diff --git a/tests/ui/async-await/issues/non-async-enclosing-span.stderr b/tests/ui/async-await/issues/non-async-enclosing-span.stderr index 20b827479..b6583022c 100644 --- a/tests/ui/async-await/issues/non-async-enclosing-span.stderr +++ b/tests/ui/async-await/issues/non-async-enclosing-span.stderr @@ -1,11 +1,11 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/non-async-enclosing-span.rs:9:27 + --> $DIR/non-async-enclosing-span.rs:9:28 | LL | fn main() { | ---- this is not `async` LL | let x = move || {}; LL | let y = do_the_thing().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/multiple-lifetimes/partial-relation.rs b/tests/ui/async-await/multiple-lifetimes/partial-relation.rs index 02b105999..7375cb6d3 100644 --- a/tests/ui/async-await/multiple-lifetimes/partial-relation.rs +++ b/tests/ui/async-await/multiple-lifetimes/partial-relation.rs @@ -4,7 +4,7 @@ async fn lotsa_lifetimes<'a, 'b, 'c>(a: &'a u32, b: &'b u32, c: &'c u32) -> (&'a u32, &'b u32) where 'b: 'a { - drop((a, c)); + let _ = (a, c); (b, b) } diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr deleted file mode 100644 index 8a7317bb9..000000000 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 - | -LL | async fn rec_1() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:13:18 - | -LL | async fn rec_2() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.stderr b/tests/ui/async-await/recursive-async-impl-trait-type.stderr deleted file mode 100644 index 7e63a8da5..000000000 --- a/tests/ui/async-await/recursive-async-impl-trait-type.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/recursive-async-impl-trait-type.rs:8:40 - | -LL | async fn recursive_async_function() -> () { - | ^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.rs b/tests/ui/async-await/return-type-notation/issue-110963-early.rs new file mode 100644 index 000000000..0ecbca5c1 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.rs @@ -0,0 +1,48 @@ +// edition: 2021 +// known-bug: #110963 + +#![feature(return_type_notation)] +#![feature(async_fn_in_trait)] + +trait HealthCheck { + async fn check<'a: 'a>(&'a mut self) -> bool; +} + +async fn do_health_check_par<HC>(hc: HC) +where + HC: HealthCheck<check(): Send> + Send + 'static, +{ + spawn(async move { + let mut hc = hc; + if !hc.check().await { + log_health_check_failure().await; + } + }); +} + +async fn log_health_check_failure() {} + +fn main() {} + +// Fake tokio spawn + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +fn spawn<F>(future: F) -> JoinHandle +where + F: Future + Send + 'static, + F::Output: Send + 'static, +{ + loop {} +} + +struct JoinHandle; + +impl Future for JoinHandle { + type Output = (); + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { + loop {} + } +} diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr new file mode 100644 index 000000000..33e22dec3 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -0,0 +1,37 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-110963-early.rs:4:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:15:5 + | +LL | / spawn(async move { +LL | | let mut hc = hc; +LL | | if !hc.check().await { +LL | | log_health_check_failure().await; +LL | | } +LL | | }); + | |______^ + | + = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:15:5 + | +LL | / spawn(async move { +LL | | let mut hc = hc; +LL | | if !hc.check().await { +LL | | log_health_check_failure().await; +LL | | } +LL | | }); + | |______^ + | + = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs new file mode 100644 index 000000000..17b5d775d --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs @@ -0,0 +1,49 @@ +// edition: 2021 +// check-pass + +#![feature(return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete +#![feature(async_fn_in_trait)] + +trait HealthCheck { + async fn check(&mut self) -> bool; +} + +async fn do_health_check_par<HC>(hc: HC) +where + HC: HealthCheck<check(): Send> + Send + 'static, +{ + spawn(async move { + let mut hc = hc; + if !hc.check().await { + log_health_check_failure().await; + } + }); +} + +async fn log_health_check_failure() {} + +fn main() {} + +// Fake tokio spawn + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +fn spawn<F>(future: F) -> JoinHandle +where + F: Future + Send + 'static, + F::Output: Send + 'static, +{ + loop {} +} + +struct JoinHandle; + +impl Future for JoinHandle { + type Output = (); + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { + loop {} + } +} diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr new file mode 100644 index 000000000..9c6966537 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-110963-late.rs:4:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs new file mode 100644 index 000000000..028e526b5 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs @@ -0,0 +1,32 @@ +// edition:2021 + +#![feature(async_fn_in_trait, return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +trait Super1<'a> { + async fn test(); +} +impl Super1<'_> for () { + async fn test() {} +} + +trait Super2 { + async fn test(); +} +impl Super2 for () { + async fn test() {} +} + +trait Foo: for<'a> Super1<'a> + Super2 {} +impl Foo for () {} + +fn test<T>() +where + T: Foo<test(): Send>, + //~^ ERROR ambiguous associated function `test` for `Foo` +{ +} + +fn main() { + test::<()>(); +} diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr new file mode 100644 index 000000000..5bc8dbde4 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr @@ -0,0 +1,19 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/super-method-bound-ambig.rs:3:31 + | +LL | #![feature(async_fn_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: ambiguous associated function `test` for `Foo` + --> $DIR/super-method-bound-ambig.rs:25:12 + | +LL | T: Foo<test(): Send>, + | ^^^^^^^^^^^^ + | + = note: `test` is declared in two supertraits: `Super2` and `Super1<'a>` + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs new file mode 100644 index 000000000..58ea3578d --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound.rs @@ -0,0 +1,25 @@ +// edition:2021 +// check-pass + +#![feature(async_fn_in_trait, return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +trait Super<'a> { + async fn test(); +} +impl Super<'_> for () { + async fn test() {} +} + +trait Foo: for<'a> Super<'a> {} +impl Foo for () {} + +fn test<T>() +where + T: Foo<test(): Send>, +{ +} + +fn main() { + test::<()>(); +} diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.stderr new file mode 100644 index 000000000..ac0668d3c --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/super-method-bound.rs:4:31 + | +LL | #![feature(async_fn_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs new file mode 100644 index 000000000..19bcfe304 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(return_position_impl_trait_in_trait, return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete and may not be safe to use + +trait IntFactory { + fn stream(&self) -> impl Iterator<Item = i32>; +} +trait SendIntFactory: IntFactory<stream(): Send> + Send {} + +fn main() {} diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr new file mode 100644 index 000000000..c8cec4946 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/supertrait-bound.rs:3:49 + | +LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/unnecessary-await.rs b/tests/ui/async-await/unnecessary-await.rs index 24673777b..cd1e28714 100644 --- a/tests/ui/async-await/unnecessary-await.rs +++ b/tests/ui/async-await/unnecessary-await.rs @@ -11,4 +11,24 @@ async fn baz() -> std::io::Result<()> { std::io::Result::Ok(()) } +macro_rules! e { + () => { + () + }; +} + +macro_rules! f { + ($expr:expr) => { + $expr.await + //~^ ERROR `()` is not a future + }; +} + +async fn with_macros() { + e!().await; + //~^ ERROR `()` is not a future + + f!(()); +} + fn main() {} diff --git a/tests/ui/async-await/unnecessary-await.stderr b/tests/ui/async-await/unnecessary-await.stderr index dc3089336..9a2a035b2 100644 --- a/tests/ui/async-await/unnecessary-await.stderr +++ b/tests/ui/async-await/unnecessary-await.stderr @@ -1,8 +1,8 @@ error[E0277]: `()` is not a future - --> $DIR/unnecessary-await.rs:9:10 + --> $DIR/unnecessary-await.rs:9:11 | LL | boo().await; - | -----^^^^^^ `()` is not a future + | ----- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -19,6 +19,36 @@ help: alternatively, consider making `fn boo` asynchronous LL | async fn boo() {} | +++++ -error: aborting due to previous error +error[E0277]: `()` is not a future + --> $DIR/unnecessary-await.rs:28:10 + | +LL | e!().await; + | -^^^^^ + | || + | |`()` is not a future + | help: remove the `.await` + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required for `()` to implement `IntoFuture` + +error[E0277]: `()` is not a future + --> $DIR/unnecessary-await.rs:22:15 + | +LL | $expr.await + | ^^^^^ + | | + | `()` is not a future + | remove the `.await` +... +LL | f!(()); + | ------ in this macro invocation + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required for `()` to implement `IntoFuture` + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr index 912e2b34c..6b4a3a363 100644 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr @@ -5,10 +5,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -17,10 +17,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -29,10 +29,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr index 16d618caa..6642e90ac 100644 --- a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr @@ -5,10 +5,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -17,10 +17,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -29,10 +29,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -41,10 +41,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -53,10 +53,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/async-await/unresolved_type_param.stderr b/tests/ui/async-await/unresolved_type_param.stderr deleted file mode 100644 index 64a31b5fc..000000000 --- a/tests/ui/async-await/unresolved_type_param.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0698`. diff --git a/tests/ui/attr-bad-crate-attr.rc b/tests/ui/attr-bad-crate-attr.rs index 89ba26dfd..89ba26dfd 100644 --- a/tests/ui/attr-bad-crate-attr.rc +++ b/tests/ui/attr-bad-crate-attr.rs diff --git a/tests/ui/attr-bad-crate-attr.stderr b/tests/ui/attr-bad-crate-attr.stderr new file mode 100644 index 000000000..ff420eeea --- /dev/null +++ b/tests/ui/attr-bad-crate-attr.stderr @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attr-bad-crate-attr.rs:4:1 + | +LL | #[attr = "val"] // Unterminated + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/attributes/invalid-doc-attr.rs b/tests/ui/attributes/invalid-doc-attr.rs index de004b41e..c231e43b3 100644 --- a/tests/ui/attributes/invalid-doc-attr.rs +++ b/tests/ui/attributes/invalid-doc-attr.rs @@ -5,7 +5,7 @@ //~^ ERROR can only be applied at the crate level //~| WARN is being phased out //~| HELP to apply to the crate, use an inner attribute -//~| SUGGESTION #![doc(test(no_crate_inject))] +//~| SUGGESTION ! #[doc(inline)] //~^ ERROR can only be applied to a `use` item //~| WARN is being phased out diff --git a/tests/ui/attributes/invalid-doc-attr.stderr b/tests/ui/attributes/invalid-doc-attr.stderr index 3c66e587b..b23b8ded8 100644 --- a/tests/ui/attributes/invalid-doc-attr.stderr +++ b/tests/ui/attributes/invalid-doc-attr.stderr @@ -16,7 +16,7 @@ LL | #![deny(warnings)] help: to apply to the crate, use an inner attribute | LL | #![doc(test(no_crate_inject))] - | + | + error: this attribute can only be applied to a `use` item --> $DIR/invalid-doc-attr.rs:9:7 diff --git a/tests/ui/attributes/invalid-repr.rs b/tests/ui/attributes/invalid-repr.rs new file mode 100644 index 000000000..10a487c12 --- /dev/null +++ b/tests/ui/attributes/invalid-repr.rs @@ -0,0 +1,5 @@ +#[repr(align(16))] +//~^ ERROR attribute should be applied to a struct, enum, function, associated function, or union +pub type Foo = i32; + +fn main() {} diff --git a/tests/ui/attributes/invalid-repr.stderr b/tests/ui/attributes/invalid-repr.stderr new file mode 100644 index 000000000..98a6a24b3 --- /dev/null +++ b/tests/ui/attributes/invalid-repr.stderr @@ -0,0 +1,12 @@ +error[E0517]: attribute should be applied to a struct, enum, function, associated function, or union + --> $DIR/invalid-repr.rs:1:8 + | +LL | #[repr(align(16))] + | ^^^^^^^^^ +LL | +LL | pub type Foo = i32; + | ------------------- not a struct, enum, function, associated function, or union + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0517`. diff --git a/tests/ui/attributes/invalid_macro_export_argument.deny.stderr b/tests/ui/attributes/invalid_macro_export_argument.deny.stderr new file mode 100644 index 000000000..644acc27b --- /dev/null +++ b/tests/ui/attributes/invalid_macro_export_argument.deny.stderr @@ -0,0 +1,20 @@ +error: `#[macro_export]` can only take 1 or 0 arguments + --> $DIR/invalid_macro_export_argument.rs:7:1 + | +LL | #[macro_export(hello, world)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/invalid_macro_export_argument.rs:4:24 + | +LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `not_local_inner_macros` isn't a valid `#[macro_export]` argument + --> $DIR/invalid_macro_export_argument.rs:13:16 + | +LL | #[macro_export(not_local_inner_macros)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/attributes/invalid_macro_export_argument.rs b/tests/ui/attributes/invalid_macro_export_argument.rs index 85d009f11..a0ed5fd1c 100644 --- a/tests/ui/attributes/invalid_macro_export_argument.rs +++ b/tests/ui/attributes/invalid_macro_export_argument.rs @@ -1,10 +1,17 @@ -// check-pass -#[macro_export(hello, world)] //~ WARN `#[macro_export]` can only take 1 or 0 arguments +// revisions: deny allow +//[allow] check-pass + +#![cfg_attr(deny, deny(invalid_macro_export_arguments))] +#![cfg_attr(allow, allow(invalid_macro_export_arguments))] + +#[macro_export(hello, world)] +//[deny]~^ ERROR `#[macro_export]` can only take 1 or 0 arguments macro_rules! a { () => () } -#[macro_export(not_local_inner_macros)] //~ WARN `not_local_inner_macros` isn't a valid `#[macro_export]` argument +#[macro_export(not_local_inner_macros)] +//[deny]~^ ERROR `not_local_inner_macros` isn't a valid `#[macro_export]` argument macro_rules! b { () => () } diff --git a/tests/ui/attributes/invalid_macro_export_argument.stderr b/tests/ui/attributes/invalid_macro_export_argument.stderr deleted file mode 100644 index a4e17642c..000000000 --- a/tests/ui/attributes/invalid_macro_export_argument.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: `#[macro_export]` can only take 1 or 0 arguments - --> $DIR/invalid_macro_export_argument.rs:2:1 - | -LL | #[macro_export(hello, world)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(invalid_macro_export_arguments)]` on by default - -warning: `not_local_inner_macros` isn't a valid `#[macro_export]` argument - --> $DIR/invalid_macro_export_argument.rs:7:16 - | -LL | #[macro_export(not_local_inner_macros)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted - diff --git a/tests/ui/backtrace.rs b/tests/ui/backtrace.rs index dd73dd988..66b378f62 100644 --- a/tests/ui/backtrace.rs +++ b/tests/ui/backtrace.rs @@ -104,13 +104,17 @@ fn runtest(me: &str) { "bad output3: {}", s); // Make sure a stack trace isn't printed too many times + // + // Currently it is printed 3 times ("once", "twice" and "panic in a + // function that cannot unwind") but in the future the last one may be + // removed. let p = template(me).arg("double-fail") .env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); let mut i = 0; - for _ in 0..2 { + for _ in 0..3 { i += s[i + 10..].find("stack backtrace").unwrap() + 10; } assert!(s[i + 10..].find("stack backtrace").is_none(), diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr index 41318d0a3..349c4639a 100644 --- a/tests/ui/binding/issue-53114-safety-checks.stderr +++ b/tests/ui/binding/issue-53114-safety-checks.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &p.b; | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let (_,) = (&p.b,); | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _: _ = &p.b; | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let (_,): _ = (&p.b,); | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -40,7 +44,8 @@ error[E0793]: reference to packed field is unaligned LL | match &p.b { _ => { } } | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -49,7 +54,8 @@ error[E0793]: reference to packed field is unaligned LL | match (&p.b,) { (_,) => { } } | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0133]: access to union field is unsafe and requires unsafe function or block diff --git a/tests/ui/binop/eq-arr.rs b/tests/ui/binop/eq-arr.rs new file mode 100644 index 000000000..a77c4c5aa --- /dev/null +++ b/tests/ui/binop/eq-arr.rs @@ -0,0 +1,7 @@ +fn main() { + struct X; + //~^ HELP consider annotating `X` with `#[derive(PartialEq)]` + let xs = [X, X, X]; + let eq = xs == [X, X, X]; + //~^ ERROR binary operation `==` cannot be applied to type `[X; 3]` +} diff --git a/tests/ui/binop/eq-arr.stderr b/tests/ui/binop/eq-arr.stderr new file mode 100644 index 000000000..a22f8e3ab --- /dev/null +++ b/tests/ui/binop/eq-arr.stderr @@ -0,0 +1,22 @@ +error[E0369]: binary operation `==` cannot be applied to type `[X; 3]` + --> $DIR/eq-arr.rs:5:17 + | +LL | let eq = xs == [X, X, X]; + | -- ^^ --------- [X; 3] + | | + | [X; 3] + | +note: an implementation of `PartialEq` might be missing for `X` + --> $DIR/eq-arr.rs:2:5 + | +LL | struct X; + | ^^^^^^^^ must implement `PartialEq` +help: consider annotating `X` with `#[derive(PartialEq)]` + | +LL + #[derive(PartialEq)] +LL | struct X; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/binop/eq-vec.rs b/tests/ui/binop/eq-vec.rs new file mode 100644 index 000000000..17ce8df85 --- /dev/null +++ b/tests/ui/binop/eq-vec.rs @@ -0,0 +1,13 @@ +fn main() { + #[derive(Debug)] + enum Foo { + //~^ HELP consider annotating `Foo` with `#[derive(PartialEq)]` + Bar, + Qux, + } + + let vec1 = vec![Foo::Bar, Foo::Qux]; + let vec2 = vec![Foo::Bar, Foo::Qux]; + assert_eq!(vec1, vec2); + //~^ ERROR binary operation `==` cannot be applied to type `Vec<Foo>` +} diff --git a/tests/ui/binop/eq-vec.stderr b/tests/ui/binop/eq-vec.stderr new file mode 100644 index 000000000..0a98cddfe --- /dev/null +++ b/tests/ui/binop/eq-vec.stderr @@ -0,0 +1,24 @@ +error[E0369]: binary operation `==` cannot be applied to type `Vec<Foo>` + --> $DIR/eq-vec.rs:11:5 + | +LL | assert_eq!(vec1, vec2); + | ^^^^^^^^^^^^^^^^^^^^^^ + | | + | Vec<Foo> + | Vec<Foo> + | +note: an implementation of `PartialEq` might be missing for `Foo` + --> $DIR/eq-vec.rs:3:5 + | +LL | enum Foo { + | ^^^^^^^^ must implement `PartialEq` + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `Foo` with `#[derive(PartialEq)]` + | +LL + #[derive(PartialEq)] +LL | enum Foo { + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/binop/issue-28837.stderr b/tests/ui/binop/issue-28837.stderr index bb9f3b8af..6c98edd3a 100644 --- a/tests/ui/binop/issue-28837.stderr +++ b/tests/ui/binop/issue-28837.stderr @@ -6,11 +6,11 @@ LL | a + a; | | | A | -note: an implementation of `Add<_>` might be missing for `A` +note: an implementation of `Add` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Add<_>` + | ^^^^^^^^ must implement `Add` note: the trait `Add` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -22,11 +22,11 @@ LL | a - a; | | | A | -note: an implementation of `Sub<_>` might be missing for `A` +note: an implementation of `Sub` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Sub<_>` + | ^^^^^^^^ must implement `Sub` note: the trait `Sub` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -38,11 +38,11 @@ LL | a * a; | | | A | -note: an implementation of `Mul<_>` might be missing for `A` +note: an implementation of `Mul` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Mul<_>` + | ^^^^^^^^ must implement `Mul` note: the trait `Mul` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -54,11 +54,11 @@ LL | a / a; | | | A | -note: an implementation of `Div<_>` might be missing for `A` +note: an implementation of `Div` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Div<_>` + | ^^^^^^^^ must implement `Div` note: the trait `Div` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -70,11 +70,11 @@ LL | a % a; | | | A | -note: an implementation of `Rem<_>` might be missing for `A` +note: an implementation of `Rem` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Rem<_>` + | ^^^^^^^^ must implement `Rem` note: the trait `Rem` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -86,11 +86,11 @@ LL | a & a; | | | A | -note: an implementation of `BitAnd<_>` might be missing for `A` +note: an implementation of `BitAnd` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `BitAnd<_>` + | ^^^^^^^^ must implement `BitAnd` note: the trait `BitAnd` must be implemented --> $SRC_DIR/core/src/ops/bit.rs:LL:COL @@ -102,11 +102,11 @@ LL | a | a; | | | A | -note: an implementation of `BitOr<_>` might be missing for `A` +note: an implementation of `BitOr` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `BitOr<_>` + | ^^^^^^^^ must implement `BitOr` note: the trait `BitOr` must be implemented --> $SRC_DIR/core/src/ops/bit.rs:LL:COL @@ -118,11 +118,11 @@ LL | a << a; | | | A | -note: an implementation of `Shl<_>` might be missing for `A` +note: an implementation of `Shl` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Shl<_>` + | ^^^^^^^^ must implement `Shl` note: the trait `Shl` must be implemented --> $SRC_DIR/core/src/ops/bit.rs:LL:COL @@ -134,11 +134,11 @@ LL | a >> a; | | | A | -note: an implementation of `Shr<_>` might be missing for `A` +note: an implementation of `Shr` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `Shr<_>` + | ^^^^^^^^ must implement `Shr` note: the trait `Shr` must be implemented --> $SRC_DIR/core/src/ops/bit.rs:LL:COL @@ -150,11 +150,11 @@ LL | a == a; | | | A | -note: an implementation of `PartialEq<_>` might be missing for `A` +note: an implementation of `PartialEq` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^ must implement `PartialEq` help: consider annotating `A` with `#[derive(PartialEq)]` | LL + #[derive(PartialEq)] @@ -169,11 +169,11 @@ LL | a != a; | | | A | -note: an implementation of `PartialEq<_>` might be missing for `A` +note: an implementation of `PartialEq` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^ must implement `PartialEq` help: consider annotating `A` with `#[derive(PartialEq)]` | LL + #[derive(PartialEq)] @@ -188,11 +188,11 @@ LL | a < a; | | | A | -note: an implementation of `PartialOrd<_>` might be missing for `A` +note: an implementation of `PartialOrd` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialOrd<_>` + | ^^^^^^^^ must implement `PartialOrd` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | LL + #[derive(PartialEq, PartialOrd)] @@ -207,11 +207,11 @@ LL | a <= a; | | | A | -note: an implementation of `PartialOrd<_>` might be missing for `A` +note: an implementation of `PartialOrd` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialOrd<_>` + | ^^^^^^^^ must implement `PartialOrd` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | LL + #[derive(PartialEq, PartialOrd)] @@ -226,11 +226,11 @@ LL | a > a; | | | A | -note: an implementation of `PartialOrd<_>` might be missing for `A` +note: an implementation of `PartialOrd` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialOrd<_>` + | ^^^^^^^^ must implement `PartialOrd` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | LL + #[derive(PartialEq, PartialOrd)] @@ -245,11 +245,11 @@ LL | a >= a; | | | A | -note: an implementation of `PartialOrd<_>` might be missing for `A` +note: an implementation of `PartialOrd` might be missing for `A` --> $DIR/issue-28837.rs:1:1 | LL | struct A; - | ^^^^^^^^ must implement `PartialOrd<_>` + | ^^^^^^^^ must implement `PartialOrd` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | LL + #[derive(PartialEq, PartialOrd)] diff --git a/tests/ui/binop/issue-3820.stderr b/tests/ui/binop/issue-3820.stderr index c313ed603..cfa78a41d 100644 --- a/tests/ui/binop/issue-3820.stderr +++ b/tests/ui/binop/issue-3820.stderr @@ -6,11 +6,11 @@ LL | let w = u * 3; | | | Thing | -note: an implementation of `Mul<_>` might be missing for `Thing` +note: an implementation of `Mul<{integer}>` might be missing for `Thing` --> $DIR/issue-3820.rs:1:1 | LL | struct Thing { - | ^^^^^^^^^^^^ must implement `Mul<_>` + | ^^^^^^^^^^^^ must implement `Mul<{integer}>` note: the trait `Mul` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL diff --git a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr index 0ca14c3f3..047175626 100644 --- a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr +++ b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr @@ -1,19 +1,3 @@ -error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:36:9 - | -LL | ref foo @ [.., ref mut bar] => (), - | ^^^^^^^ ----------- value is mutably borrowed by `bar` here - | | - | value is borrowed by `foo` here - -error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9 - | -LL | ref foo @ Some(box ref mut s) => (), - | ^^^^^^^ --------- value is mutably borrowed by `s` here - | | - | value is borrowed by `foo` here - error[E0382]: borrow of moved value: `x` --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:18:5 | @@ -43,6 +27,14 @@ LL | &x; LL | drop(r); | - mutable borrow later used here +error: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:36:9 + | +LL | ref foo @ [.., ref mut bar] => (), + | ^^^^^^^ ----------- value is mutably borrowed by `bar` here + | | + | value is borrowed by `foo` here + error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:50:5 | @@ -120,6 +112,14 @@ LL | &mut x; LL | drop(r); | - immutable borrow later used here +error: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9 + | +LL | ref foo @ Some(box ref mut s) => (), + | ^^^^^^^ --------- value is mutably borrowed by `s` here + | | + | value is borrowed by `foo` here + error[E0382]: borrow of moved value: `x` --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:134:5 | diff --git a/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr b/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr index 4cc1d821d..cfc86ff0d 100644 --- a/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr +++ b/tests/ui/borrowck/borrow-raw-address-of-deref-mutability.stderr @@ -7,7 +7,7 @@ LL | let q = &raw mut *x; help: consider changing this to be a mutable reference | LL | let x = &mut 0; - | ~~~~~~ + | +++ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer --> $DIR/borrow-raw-address-of-deref-mutability.rs:14:13 @@ -18,7 +18,7 @@ LL | let q = &raw mut *x; help: consider changing this to be a mutable pointer | LL | let x = &mut 0 as *const i32; - | ~~~~~~ + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-access-permissions.stderr b/tests/ui/borrowck/borrowck-access-permissions.stderr index 26f3e2bbd..c161e2d95 100644 --- a/tests/ui/borrowck/borrowck-access-permissions.stderr +++ b/tests/ui/borrowck/borrowck-access-permissions.stderr @@ -35,7 +35,7 @@ LL | let _y1 = &mut *ref_x; help: consider changing this to be a mutable reference | LL | let ref_x = &mut x; - | ~~~~~~ + | +++ error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer --> $DIR/borrowck-access-permissions.rs:39:23 @@ -46,7 +46,7 @@ LL | let _y1 = &mut *ptr_x; help: consider changing this to be a mutable pointer | LL | let ptr_x : *const _ = &mut x; - | ~~~~~~ + | +++ error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-access-permissions.rs:48:18 @@ -57,7 +57,7 @@ LL | let _y = &mut *foo_ref.f; help: consider changing this to be a mutable reference | LL | let foo_ref = &mut foo; - | ~~~~~~~~ + | +++ error: aborting due to 6 previous errors diff --git a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index cbacc87a0..cf0c4127d 100644 --- a/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -6,8 +6,8 @@ LL | *s.pointer += 1; | help: consider changing this to be a mutable reference | -LL | fn a(s: &mut S<'_>) { - | ~~~~~~~~~~ +LL | fn a(s: &mut S) { + | +++ error[E0594]: cannot assign to `*s.pointer`, which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 @@ -17,8 +17,8 @@ LL | *s.pointer += 1; | help: consider changing this to be a mutable reference | -LL | fn c(s: &mut &mut S<'_>) { - | ~~~~~~~~~~~~~~~ +LL | fn c(s: &mut &mut S) { + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/borrowck-block-unint.rs b/tests/ui/borrowck/borrowck-block-uninit.rs index 8d13b25a3..8d13b25a3 100644 --- a/tests/ui/borrowck/borrowck-block-unint.rs +++ b/tests/ui/borrowck/borrowck-block-uninit.rs diff --git a/tests/ui/borrowck/borrowck-block-unint.stderr b/tests/ui/borrowck/borrowck-block-uninit.stderr index f47921a97..1a5969586 100644 --- a/tests/ui/borrowck/borrowck-block-unint.stderr +++ b/tests/ui/borrowck/borrowck-block-uninit.stderr @@ -1,5 +1,5 @@ error[E0381]: used binding `x` isn't initialized - --> $DIR/borrowck-block-unint.rs:4:11 + --> $DIR/borrowck-block-uninit.rs:4:11 | LL | let x: isize; | - binding declared here but left uninitialized diff --git a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index dd0817ff2..59ef61b19 100644 --- a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -27,8 +27,8 @@ LL | let x: &mut isize = &mut **t0; | help: consider changing this to be a mutable reference | -LL | fn foo4(t0: &mut &mut isize) { - | ~~~~~~~~~~~~~~~ +LL | fn foo4(t0: &mut &mut isize) { + | +++ error: aborting due to 3 previous errors diff --git a/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs b/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs index 0229ca37a..60128c941 100644 --- a/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs +++ b/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs @@ -1,6 +1,7 @@ // Check that closure captures for slice patterns are inferred correctly #![allow(unused_variables)] +#![allow(dropping_references)] // run-pass diff --git a/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs b/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs index dd6708582..78e965cc4 100644 --- a/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs +++ b/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs @@ -1,6 +1,7 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] +#![allow(dropping_copy_types)] // pretty-expanded FIXME #23616 struct A { a: isize, b: Box<isize> } diff --git a/tests/ui/borrowck/borrowck-issue-14498.stderr b/tests/ui/borrowck/borrowck-issue-14498.stderr index 374c5ee3e..12d67d536 100644 --- a/tests/ui/borrowck/borrowck-issue-14498.stderr +++ b/tests/ui/borrowck/borrowck-issue-14498.stderr @@ -7,7 +7,7 @@ LL | ***p = 2; help: consider changing this to be a mutable reference | LL | let p = &mut y; - | ~~~~~~ + | +++ error[E0506]: cannot assign to `**y` because it is borrowed --> $DIR/borrowck-issue-14498.rs:25:5 diff --git a/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr b/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr index d9590e446..fb3db4e14 100644 --- a/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr +++ b/tests/ui/borrowck/borrowck-reborrow-from-mut.stderr @@ -111,7 +111,7 @@ LL | let _bar1 = &mut foo.bar1; help: consider changing this to be a mutable reference | LL | fn borrow_mut_from_imm(foo: &mut Foo) { - | ~~~~~~~~ + | +++ error: aborting due to 11 previous errors diff --git a/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs b/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs index 1cf763f66..9acb1ec5e 100644 --- a/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs +++ b/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs @@ -1,6 +1,8 @@ // run-pass // pretty-expanded FIXME #23616 +#![allow(dropping_copy_types)] + struct A { a: isize, b: Box<isize> } fn field_copy_after_field_borrow() { diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs index 127a3f5b2..1bda7a497 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -8,7 +8,6 @@ fn a() { //~^ NOTE `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign //~^ NOTE `vec[_]` is assigned to here - //~| NOTE in this expansion of desugaring of drop and replace _a.use_ref(); //~^ NOTE borrow later used here } @@ -23,7 +22,6 @@ fn b() { //~^ `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign //~^ NOTE `vec[_]` is assigned to here - //~| NOTE in this expansion of desugaring of drop and replace _b.use_ref(); //~^ NOTE borrow later used here } diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 5e1251b05..70b9e4f44 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -6,24 +6,24 @@ LL | [box ref _a, _, _] => { LL | LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed -... +LL | LL | _a.use_ref(); | ------------ borrow later used here error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:24:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 | LL | &mut [ref _b @ ..] => { | ------ `vec[_]` is borrowed here LL | LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed -... +LL | LL | _b.use_ref(); | ------------ borrow later used here error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:36:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:34:11 | LL | match vec { | ^^^ cannot move out of here @@ -41,7 +41,7 @@ LL + [_a, | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:48:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:46:13 | LL | let a = vec[0]; | ^^^^^^ @@ -55,7 +55,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:57:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:55:11 | LL | match vec { | ^^^ cannot move out of here @@ -73,7 +73,7 @@ LL + [ | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:67:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:65:13 | LL | let a = vec[0]; | ^^^^^^ @@ -87,7 +87,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:76:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:74:11 | LL | match vec { | ^^^ cannot move out of here @@ -106,7 +106,7 @@ LL + [_a, _b, _c] => {} | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:87:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:85:13 | LL | let a = vec[0]; | ^^^^^^ diff --git a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs new file mode 100644 index 000000000..addbe5d65 --- /dev/null +++ b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.rs @@ -0,0 +1,23 @@ +// compile-flags: -Zdrop-tracking-mir +// edition:2021 + +use std::future::Future; + +trait Client { + type Connecting<'a>: Future + Send + where + Self: 'a; + + fn connect(&'_ self) -> Self::Connecting<'a>; + //~^ ERROR use of undeclared lifetime name `'a` +} + +fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send +where + C: Client + Send + Sync, +{ + async move { c.connect().await } + //~^ ERROR `C` does not live long enough +} + +fn main() {} diff --git a/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr new file mode 100644 index 000000000..53abe3dc9 --- /dev/null +++ b/tests/ui/borrowck/erase-error-in-mir-drop-tracking.stderr @@ -0,0 +1,24 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/erase-error-in-mir-drop-tracking.rs:11:46 + | +LL | fn connect(&'_ self) -> Self::Connecting<'a>; + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn connect<'a>(&'_ self) -> Self::Connecting<'a>; + | ++++ +help: consider introducing lifetime `'a` here + | +LL | trait Client<'a> { + | ++++ + +error: `C` does not live long enough + --> $DIR/erase-error-in-mir-drop-tracking.rs:19:5 + | +LL | async move { c.connect().await } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/borrowck/issue-109271-pass-self-into-closure.fixed b/tests/ui/borrowck/issue-109271-pass-self-into-closure.fixed new file mode 100644 index 000000000..4a8831dab --- /dev/null +++ b/tests/ui/borrowck/issue-109271-pass-self-into-closure.fixed @@ -0,0 +1,39 @@ +// run-rustfix +#![allow(unused)] +struct S; + +impl S { + fn call(&mut self, f: impl FnOnce((), &mut Self)) { + // change state or something ... + f((), self); + // change state or something ... + } + + fn get(&self) {} + fn set(&mut self) {} +} + +fn main() { + let mut v = S; + + v.call(|(), this: &mut S| this.get()); + //~^ error: cannot borrow `v` as mutable because it is also borrowed as immutable + v.call(|(), this: &mut S| this.set()); + //~^ error: cannot borrow `v` as mutable more than once at a time + //~| error: cannot borrow `v` as mutable more than once at a time + + v.call(|(), this: &mut S| { + //~^ error: cannot borrow `v` as mutable more than once at a time + //~| error: cannot borrow `v` as mutable more than once at a time + + _ = this; + this.set(); + this.get(); + S::get(&this); + + use std::ops::Add; + let v = 0u32; + _ = v + v; + _ = v.add(3); + }); +} diff --git a/tests/ui/borrowck/issue-109271-pass-self-into-closure.rs b/tests/ui/borrowck/issue-109271-pass-self-into-closure.rs new file mode 100644 index 000000000..fcd855f86 --- /dev/null +++ b/tests/ui/borrowck/issue-109271-pass-self-into-closure.rs @@ -0,0 +1,39 @@ +// run-rustfix +#![allow(unused)] +struct S; + +impl S { + fn call(&mut self, f: impl FnOnce((), &mut Self)) { + // change state or something ... + f((), self); + // change state or something ... + } + + fn get(&self) {} + fn set(&mut self) {} +} + +fn main() { + let mut v = S; + + v.call(|(), this: &mut S| v.get()); + //~^ error: cannot borrow `v` as mutable because it is also borrowed as immutable + v.call(|(), this: &mut S| v.set()); + //~^ error: cannot borrow `v` as mutable more than once at a time + //~| error: cannot borrow `v` as mutable more than once at a time + + v.call(|(), this: &mut S| { + //~^ error: cannot borrow `v` as mutable more than once at a time + //~| error: cannot borrow `v` as mutable more than once at a time + + _ = v; + v.set(); + v.get(); + S::get(&v); + + use std::ops::Add; + let v = 0u32; + _ = v + v; + _ = v.add(3); + }); +} diff --git a/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr new file mode 100644 index 000000000..25974e0d0 --- /dev/null +++ b/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr @@ -0,0 +1,85 @@ +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable + --> $DIR/issue-109271-pass-self-into-closure.rs:19:5 + | +LL | v.call(|(), this: &mut S| v.get()); + | ^^----^------------------^-^^^^^^^ + | | | | | + | | | | first borrow occurs due to use of `v` in closure + | | | | help: try using the closure argument: `this` + | | | immutable borrow occurs here + | | immutable borrow later used by call + | mutable borrow occurs here + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/issue-109271-pass-self-into-closure.rs:21:5 + | +LL | v.call(|(), this: &mut S| v.set()); + | ^^----^------------------^-^^^^^^^ + | | | | | + | | | | first borrow occurs due to use of `v` in closure + | | | | help: try using the closure argument: `this` + | | | first mutable borrow occurs here + | | first borrow later used by call + | second mutable borrow occurs here + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/issue-109271-pass-self-into-closure.rs:21:12 + | +LL | v.call(|(), this: &mut S| v.set()); + | -------^^^^^^^^^^^^^^^^^^--------- + | | | | | + | | | | second borrow occurs due to use of `v` in closure + | | | second mutable borrow occurs here + | | first borrow later used by call + | first mutable borrow occurs here + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/issue-109271-pass-self-into-closure.rs:25:5 + | +LL | v.call(|(), this: &mut S| { + | ^ ---- ------------------ first mutable borrow occurs here + | | | + | _____| first borrow later used by call + | | +LL | | +LL | | +LL | | +LL | | _ = v; +LL | | v.set(); + | | - first borrow occurs due to use of `v` in closure +... | +LL | | _ = v.add(3); +LL | | }); + | |______^ second mutable borrow occurs here + | +help: try using the closure argument + | +LL ~ _ = this; +LL ~ this.set(); +LL ~ this.get(); +LL ~ S::get(&this); + | + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/issue-109271-pass-self-into-closure.rs:25:12 + | +LL | v.call(|(), this: &mut S| { + | - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | _____| first borrow later used by call + | | +LL | | +LL | | +LL | | +LL | | _ = v; +LL | | v.set(); + | | - second borrow occurs due to use of `v` in closure +... | +LL | | _ = v.add(3); +LL | | }); + | |______- first mutable borrow occurs here + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/borrowck/issue-45199.rs b/tests/ui/borrowck/issue-45199.rs index 6a6b25541..ded46e56e 100644 --- a/tests/ui/borrowck/issue-45199.rs +++ b/tests/ui/borrowck/issue-45199.rs @@ -5,7 +5,6 @@ fn test_drop_replace() { b = Box::new(1); //~ NOTE first assignment b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable - //~| NOTE in this expansion of desugaring of drop and replace } fn test_call() { @@ -14,14 +13,12 @@ fn test_call() { //~| SUGGESTION mut b b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable - //~| NOTE in this expansion of desugaring of drop and replace } fn test_args(b: Box<i32>) { //~ HELP consider making this binding mutable //~| SUGGESTION mut b b = Box::new(2); //~ ERROR cannot assign to immutable argument `b` //~| NOTE cannot assign to immutable argument - //~| NOTE in this expansion of desugaring of drop and replace } fn main() {} diff --git a/tests/ui/borrowck/issue-45199.stderr b/tests/ui/borrowck/issue-45199.stderr index 163f2370b..47aa30908 100644 --- a/tests/ui/borrowck/issue-45199.stderr +++ b/tests/ui/borrowck/issue-45199.stderr @@ -10,7 +10,7 @@ LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:15:5 + --> $DIR/issue-45199.rs:14:5 | LL | let b = Box::new(1); | - @@ -22,7 +22,7 @@ LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:22:5 + --> $DIR/issue-45199.rs:20:5 | LL | fn test_args(b: Box<i32>) { | - help: consider making this binding mutable: `mut b` diff --git a/tests/ui/issues/issue-47646.rs b/tests/ui/borrowck/issue-47646.rs index ace6cdce8..ace6cdce8 100644 --- a/tests/ui/issues/issue-47646.rs +++ b/tests/ui/borrowck/issue-47646.rs diff --git a/tests/ui/issues/issue-47646.stderr b/tests/ui/borrowck/issue-47646.stderr index 84cf9237a..84cf9237a 100644 --- a/tests/ui/issues/issue-47646.stderr +++ b/tests/ui/borrowck/issue-47646.stderr diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index b4bb128cb..2985a658f 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -18,7 +18,7 @@ LL | *r = 0; help: consider changing this to be a mutable reference | LL | let r = &mut mutvar; - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to `*x`, which is behind a `&` reference --> $DIR/issue-85765.rs:19:5 diff --git a/tests/ui/borrowck/let_underscore_temporary.rs b/tests/ui/borrowck/let_underscore_temporary.rs index 37b5c5d9d..835cd2079 100644 --- a/tests/ui/borrowck/let_underscore_temporary.rs +++ b/tests/ui/borrowck/let_underscore_temporary.rs @@ -1,4 +1,4 @@ -// check-pass +// check-fail fn let_underscore(string: &Option<&str>, mut num: Option<i32>) { let _ = if let Some(s) = *string { s.len() } else { 0 }; @@ -8,6 +8,7 @@ fn let_underscore(string: &Option<&str>, mut num: Option<i32>) { s } else { &mut 0 + //~^ ERROR temporary value dropped while borrowed }; let _ = if let Some(ref s) = num { s } else { &0 }; let _ = if let Some(mut s) = num { @@ -21,6 +22,33 @@ fn let_underscore(string: &Option<&str>, mut num: Option<i32>) { s } else { &mut 0 + //~^ ERROR temporary value dropped while borrowed + }; +} + +fn let_ascribe(string: &Option<&str>, mut num: Option<i32>) { + let _: _ = if let Some(s) = *string { s.len() } else { 0 }; + let _: _ = if let Some(s) = &num { s } else { &0 }; + let _: _ = if let Some(s) = &mut num { + *s += 1; + s + } else { + &mut 0 + //~^ ERROR temporary value dropped while borrowed + }; + let _: _ = if let Some(ref s) = num { s } else { &0 }; + let _: _ = if let Some(mut s) = num { + s += 1; + s + } else { + 0 + }; + let _: _ = if let Some(ref mut s) = num { + *s += 1; + s + } else { + &mut 0 + //~^ ERROR temporary value dropped while borrowed }; } diff --git a/tests/ui/borrowck/let_underscore_temporary.stderr b/tests/ui/borrowck/let_underscore_temporary.stderr new file mode 100644 index 000000000..74f3598c4 --- /dev/null +++ b/tests/ui/borrowck/let_underscore_temporary.stderr @@ -0,0 +1,79 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/let_underscore_temporary.rs:10:14 + | +LL | let _ = if let Some(s) = &mut num { + | _____________- +LL | | *s += 1; +LL | | s +LL | | } else { +LL | | &mut 0 + | | ^ creates a temporary value which is freed while still in use +LL | | +LL | | }; + | | - + | | | + | |_____temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error[E0716]: temporary value dropped while borrowed + --> $DIR/let_underscore_temporary.rs:24:14 + | +LL | let _ = if let Some(ref mut s) = num { + | _____________- +LL | | *s += 1; +LL | | s +LL | | } else { +LL | | &mut 0 + | | ^ creates a temporary value which is freed while still in use +LL | | +LL | | }; + | | - + | | | + | |_____temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error[E0716]: temporary value dropped while borrowed + --> $DIR/let_underscore_temporary.rs:36:14 + | +LL | let _: _ = if let Some(s) = &mut num { + | ________________- +LL | | *s += 1; +LL | | s +LL | | } else { +LL | | &mut 0 + | | ^ creates a temporary value which is freed while still in use +LL | | +LL | | }; + | | - + | | | + | |_____temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error[E0716]: temporary value dropped while borrowed + --> $DIR/let_underscore_temporary.rs:50:14 + | +LL | let _: _ = if let Some(ref mut s) = num { + | ________________- +LL | | *s += 1; +LL | | s +LL | | } else { +LL | | &mut 0 + | | ^ creates a temporary value which is freed while still in use +LL | | +LL | | }; + | | - + | | | + | |_____temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/borrowck/move-error-snippets-ext.rs b/tests/ui/borrowck/move-error-snippets-ext.rs index c77f6c827..27041d55d 100644 --- a/tests/ui/borrowck/move-error-snippets-ext.rs +++ b/tests/ui/borrowck/move-error-snippets-ext.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) macro_rules! aaa { ($c:ident) => {{ diff --git a/tests/ui/borrowck/mutability-errors.stderr b/tests/ui/borrowck/mutability-errors.stderr index d7c602718..b39e57d70 100644 --- a/tests/ui/borrowck/mutability-errors.stderr +++ b/tests/ui/borrowck/mutability-errors.stderr @@ -7,7 +7,7 @@ LL | *x = (1,); help: consider changing this to be a mutable reference | LL | fn named_ref(x: &mut (i32,)) { - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to `x.0`, which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 @@ -18,7 +18,7 @@ LL | x.0 = 1; help: consider changing this to be a mutable reference | LL | fn named_ref(x: &mut (i32,)) { - | ~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/mutability-errors.rs:11:5 @@ -29,7 +29,7 @@ LL | &mut *x; help: consider changing this to be a mutable reference | LL | fn named_ref(x: &mut (i32,)) { - | ~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference --> $DIR/mutability-errors.rs:12:5 @@ -40,7 +40,7 @@ LL | &mut x.0; help: consider changing this to be a mutable reference | LL | fn named_ref(x: &mut (i32,)) { - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to data in a `&` reference --> $DIR/mutability-errors.rs:16:5 @@ -74,8 +74,8 @@ LL | *x = (1,); | help: consider changing this to be a mutable pointer | -LL | unsafe fn named_ptr(x: *mut (i32,)) { - | ~~~~~~~~~~~ +LL | unsafe fn named_ptr(x: *mut const (i32,)) { + | +++ error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 @@ -85,8 +85,8 @@ LL | (*x).0 = 1; | help: consider changing this to be a mutable pointer | -LL | unsafe fn named_ptr(x: *mut (i32,)) { - | ~~~~~~~~~~~ +LL | unsafe fn named_ptr(x: *mut const (i32,)) { + | +++ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer --> $DIR/mutability-errors.rs:25:5 @@ -96,8 +96,8 @@ LL | &mut *x; | help: consider changing this to be a mutable pointer | -LL | unsafe fn named_ptr(x: *mut (i32,)) { - | ~~~~~~~~~~~ +LL | unsafe fn named_ptr(x: *mut const (i32,)) { + | +++ error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer --> $DIR/mutability-errors.rs:26:5 @@ -107,8 +107,8 @@ LL | &mut (*x).0; | help: consider changing this to be a mutable pointer | -LL | unsafe fn named_ptr(x: *mut (i32,)) { - | ~~~~~~~~~~~ +LL | unsafe fn named_ptr(x: *mut const (i32,)) { + | +++ error[E0594]: cannot assign to data in a `*const` pointer --> $DIR/mutability-errors.rs:30:5 diff --git a/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.rs b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.rs new file mode 100644 index 000000000..c9e043577 --- /dev/null +++ b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.rs @@ -0,0 +1,11 @@ +type Lazy<T> = Box<dyn Fn() -> T + 'static>; + +fn test(x: &i32) -> Lazy<i32> { + Box::new(|| { + //~^ ERROR lifetime may not live long enough + //~| ERROR closure may outlive the current function + *x + }) +} + +fn main() {} diff --git a/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr new file mode 100644 index 000000000..28b4b4aa2 --- /dev/null +++ b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr @@ -0,0 +1,43 @@ +error: lifetime may not live long enough + --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:5 + | +LL | fn test(x: &i32) -> Lazy<i32> { + | - let's call the lifetime of this reference `'1` +LL | / Box::new(|| { +LL | | +LL | | +LL | | *x +LL | | }) + | |______^ returning this value requires that `'1` must outlive `'static` + | +help: to declare that the trait object captures data from argument `x`, you can add a lifetime parameter `'a` in the type alias + | +LL | type Lazy<'a, T> = Box<dyn Fn() -> T + 'a>; + | +++ ~~ + +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:14 + | +LL | Box::new(|| { + | ^^ may outlive borrowed value `x` +... +LL | *x + | -- `x` is borrowed here + | +note: closure is returned here + --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:5 + | +LL | / Box::new(|| { +LL | | +LL | | +LL | | *x +LL | | }) + | |______^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | Box::new(move || { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0373`. diff --git a/tests/ui/borrowck/tainted-promoteds.rs b/tests/ui/borrowck/tainted-promoteds.rs new file mode 100644 index 000000000..2b6f0ddbd --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.rs @@ -0,0 +1,12 @@ +// Regression test for issue #110856, where a borrowck error for a MIR tainted +// all promoteds within. This in turn generated a spurious "erroneous constant +// used" note when trying to evaluate a promoted. + +pub fn f() -> u32 { + let a = 0; + a = &0 * &1 * &2 * &3; + //~^ ERROR: cannot assign twice to immutable variable + a +} + +fn main() {} diff --git a/tests/ui/borrowck/tainted-promoteds.stderr b/tests/ui/borrowck/tainted-promoteds.stderr new file mode 100644 index 000000000..b276ea9ac --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.stderr @@ -0,0 +1,14 @@ +error[E0384]: cannot assign twice to immutable variable `a` + --> $DIR/tainted-promoteds.rs:7:5 + | +LL | let a = 0; + | - + | | + | first assignment to `a` + | help: consider making this binding mutable: `mut a` +LL | a = &0 * &1 * &2 * &3; + | ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/tests/ui/cfg/cfg-stmt-recovery.rs b/tests/ui/cfg/cfg-stmt-recovery.rs new file mode 100644 index 000000000..2e0839d2a --- /dev/null +++ b/tests/ui/cfg/cfg-stmt-recovery.rs @@ -0,0 +1,13 @@ +// Verify that we do not ICE when failing to parse a statement in `cfg_eval`. + +#![feature(cfg_eval)] +#![feature(stmt_expr_attributes)] + +#[cfg_eval] +fn main() { + #[cfg_eval] + let _ = #[cfg(FALSE)] 0; + //~^ ERROR removing an expression is not supported in this position + //~| ERROR expected expression, found `;` + //~| ERROR removing an expression is not supported in this position +} diff --git a/tests/ui/cfg/cfg-stmt-recovery.stderr b/tests/ui/cfg/cfg-stmt-recovery.stderr new file mode 100644 index 000000000..cb15e21fa --- /dev/null +++ b/tests/ui/cfg/cfg-stmt-recovery.stderr @@ -0,0 +1,20 @@ +error: removing an expression is not supported in this position + --> $DIR/cfg-stmt-recovery.rs:9:13 + | +LL | let _ = #[cfg(FALSE)] 0; + | ^^^^^^^^^^^^^ + +error: expected expression, found `;` + --> $DIR/cfg-stmt-recovery.rs:9:28 + | +LL | let _ = #[cfg(FALSE)] 0; + | ^ expected expression + +error: removing an expression is not supported in this position + --> $DIR/cfg-stmt-recovery.rs:9:13 + | +LL | let _ = #[cfg(FALSE)] 0; + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/cfg/conditional-compile-arch.rs b/tests/ui/cfg/conditional-compile-arch.rs index 7de561df1..e59e06f80 100644 --- a/tests/ui/cfg/conditional-compile-arch.rs +++ b/tests/ui/cfg/conditional-compile-arch.rs @@ -39,3 +39,6 @@ pub fn main() { } #[cfg(target_arch = "riscv64")] pub fn main() { } + +#[cfg(target_arch = "loongarch64")] +pub fn main() { } diff --git a/tests/ui/chalkify/bugs/async.stderr b/tests/ui/chalkify/bugs/async.stderr index 36606fd49..7e64e67f2 100644 --- a/tests/ui/chalkify/bugs/async.stderr +++ b/tests/ui/chalkify/bugs/async.stderr @@ -18,7 +18,7 @@ LL | async fn foo(x: u32) -> u32 { #3 [mir_built] building MIR for `foo` #4 [unsafety_check_result] unsafety-checking `foo` #5 [mir_const] preparing `foo` for borrow checking -#6 [mir_promoted] processing MIR for `foo` +#6 [mir_promoted] promoting constants in MIR for `foo` #7 [mir_borrowck] borrow-checking `foo` #8 [type_of] computing type of `foo::{opaque#0}` #9 [check_mod_item_types] checking item types in top-level module diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 5ca4d3b3d..70a967c0e 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition value LL | #[cfg(target(os = "linux", arch = "X"))] | ^^^^^^^^^^ | - = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, loongarch64, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 + = note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips64`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs new file mode 100644 index 000000000..49e127d07 --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.rs @@ -0,0 +1,31 @@ +// check-pass +// compile-flags: --check-cfg=names() --check-cfg=values(feature,"foo") --check-cfg=values(no_values) -Z unstable-options + +#[cfg(featur)] +//~^ WARNING unexpected `cfg` condition name +fn feature() {} + +#[cfg(featur = "foo")] +//~^ WARNING unexpected `cfg` condition name +fn feature() {} + +#[cfg(featur = "fo")] +//~^ WARNING unexpected `cfg` condition name +fn feature() {} + +#[cfg(feature = "foo")] +fn feature() {} + +#[cfg(no_value)] +//~^ WARNING unexpected `cfg` condition name +fn no_values() {} + +#[cfg(no_value = "foo")] +//~^ WARNING unexpected `cfg` condition name +fn no_values() {} + +#[cfg(no_values = "bar")] +//~^ WARNING unexpected `cfg` condition value +fn no_values() {} + +fn main() {} diff --git a/tests/ui/check-cfg/diagnotics.stderr b/tests/ui/check-cfg/diagnotics.stderr new file mode 100644 index 000000000..8b9fef09d --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.stderr @@ -0,0 +1,62 @@ +warning: unexpected `cfg` condition name + --> $DIR/diagnotics.rs:4:7 + | +LL | #[cfg(featur)] + | ^^^^^^ help: there is a config with a similar name: `feature` + | + = help: expected values for `feature` are: `foo` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name + --> $DIR/diagnotics.rs:8:7 + | +LL | #[cfg(featur = "foo")] + | ^^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` +help: there is a config with a similar name and value + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~ + +warning: unexpected `cfg` condition name + --> $DIR/diagnotics.rs:12:7 + | +LL | #[cfg(featur = "fo")] + | ^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` +help: there is a config with a similar name and different values + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~~~~~~~~~ + +warning: unexpected `cfg` condition name + --> $DIR/diagnotics.rs:19:7 + | +LL | #[cfg(no_value)] + | ^^^^^^^^ help: there is a config with a similar name: `no_values` + +warning: unexpected `cfg` condition name + --> $DIR/diagnotics.rs:23:7 + | +LL | #[cfg(no_value = "foo")] + | ^^^^^^^^^^^^^^^^ + | +help: there is a config with a similar name and no value + | +LL | #[cfg(no_values)] + | ~~~~~~~~~ + +warning: unexpected `cfg` condition value + --> $DIR/diagnotics.rs:27:7 + | +LL | #[cfg(no_values = "bar")] + | ^^^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `no_values` + +warning: 6 warnings emitted + diff --git a/tests/ui/check-cfg/invalid-cfg-name.stderr b/tests/ui/check-cfg/invalid-cfg-name.stderr index 2bd1821c9..ed09f8cb6 100644 --- a/tests/ui/check-cfg/invalid-cfg-name.stderr +++ b/tests/ui/check-cfg/invalid-cfg-name.stderr @@ -2,7 +2,7 @@ warning: unexpected `cfg` condition name --> $DIR/invalid-cfg-name.rs:7:7 | LL | #[cfg(widnows)] - | ^^^^^^^ help: did you mean: `windows` + | ^^^^^^^ help: there is a config with a similar name: `windows` | = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/invalid-cfg-value.stderr b/tests/ui/check-cfg/invalid-cfg-value.stderr index 83383ea61..776d264a7 100644 --- a/tests/ui/check-cfg/invalid-cfg-value.stderr +++ b/tests/ui/check-cfg/invalid-cfg-value.stderr @@ -4,9 +4,9 @@ warning: unexpected `cfg` condition value LL | #[cfg(feature = "sedre")] | ^^^^^^^^^^------- | | - | help: did you mean: `"serde"` + | help: there is a expected value with a similar name: `"serde"` | - = note: expected values for `feature` are: full, serde + = note: expected values for `feature` are: `full`, `serde` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value LL | #[cfg(feature = "rand")] | ^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: full, serde + = note: expected values for `feature` are: `full`, `serde` warning: unexpected condition value `rand` for condition name `feature` | diff --git a/tests/ui/check-cfg/mix.rs b/tests/ui/check-cfg/mix.rs index 4e488fc03..9adf5c46e 100644 --- a/tests/ui/check-cfg/mix.rs +++ b/tests/ui/check-cfg/mix.rs @@ -12,6 +12,10 @@ fn do_windows_stuff() {} //~^ WARNING unexpected `cfg` condition name fn do_windows_stuff() {} +#[cfg(feature)] +//~^ WARNING unexpected `cfg` condition value +fn no_feature() {} + #[cfg(feature = "foo")] fn use_foo() {} diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 9cf887ec7..07c514aed 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -2,28 +2,36 @@ warning: unexpected `cfg` condition name --> $DIR/mix.rs:11:7 | LL | #[cfg(widnows)] - | ^^^^^^^ help: did you mean: `windows` + | ^^^^^^^ help: there is a config with a similar name: `windows` | = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value - --> $DIR/mix.rs:18:7 + --> $DIR/mix.rs:15:7 + | +LL | #[cfg(feature)] + | ^^^^^^^- help: specify a config value: `= "foo"` + | + = note: expected values for `feature` are: `foo` + +warning: unexpected `cfg` condition value + --> $DIR/mix.rs:22:7 | LL | #[cfg(feature = "bar")] | ^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition value - --> $DIR/mix.rs:22:7 + --> $DIR/mix.rs:26:7 | LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition name - --> $DIR/mix.rs:26:12 + --> $DIR/mix.rs:30:12 | LL | #[cfg_attr(uu, test)] | ^^ @@ -37,146 +45,146 @@ warning: unexpected `unknown_name` as condition name = help: was set with `--cfg` but isn't in the `--check-cfg` expected names warning: unexpected `cfg` condition name - --> $DIR/mix.rs:35:10 + --> $DIR/mix.rs:39:10 | LL | cfg!(widnows); - | ^^^^^^^ help: did you mean: `windows` + | ^^^^^^^ help: there is a config with a similar name: `windows` warning: unexpected `cfg` condition value - --> $DIR/mix.rs:38:10 + --> $DIR/mix.rs:42:10 | LL | cfg!(feature = "bar"); | ^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition value - --> $DIR/mix.rs:40:10 + --> $DIR/mix.rs:44:10 | LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition name - --> $DIR/mix.rs:42:10 + --> $DIR/mix.rs:46:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:44:10 + --> $DIR/mix.rs:48:10 | LL | cfg!(xxx); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:46:14 + --> $DIR/mix.rs:50:14 | LL | cfg!(any(xxx, windows)); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:48:14 + --> $DIR/mix.rs:52:14 | LL | cfg!(any(feature = "bad", windows)); | ^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition name - --> $DIR/mix.rs:50:23 + --> $DIR/mix.rs:54:23 | LL | cfg!(any(windows, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:52:20 + --> $DIR/mix.rs:56:20 | LL | cfg!(all(unix, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:54:14 + --> $DIR/mix.rs:58:14 | LL | cfg!(all(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:54:18 + --> $DIR/mix.rs:58:18 | LL | cfg!(all(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:57:14 + --> $DIR/mix.rs:61:14 | LL | cfg!(any(aa, bb)); | ^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:57:18 + --> $DIR/mix.rs:61:18 | LL | cfg!(any(aa, bb)); | ^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:60:20 + --> $DIR/mix.rs:64:20 | LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition name - --> $DIR/mix.rs:62:14 + --> $DIR/mix.rs:66:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:62:19 + --> $DIR/mix.rs:66:19 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition name - --> $DIR/mix.rs:65:14 + --> $DIR/mix.rs:69:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ warning: unexpected `cfg` condition name - --> $DIR/mix.rs:65:25 + --> $DIR/mix.rs:69:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ warning: unexpected `cfg` condition value - --> $DIR/mix.rs:68:14 + --> $DIR/mix.rs:72:14 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition value - --> $DIR/mix.rs:68:33 + --> $DIR/mix.rs:72:33 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` warning: unexpected `cfg` condition value - --> $DIR/mix.rs:68:52 + --> $DIR/mix.rs:72:52 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | - = note: expected values for `feature` are: foo + = note: expected values for `feature` are: `foo` -warning: 27 warnings emitted +warning: 28 warnings emitted diff --git a/tests/ui/check-cfg/no-values.stderr b/tests/ui/check-cfg/no-values.stderr index 8c926d187..ffa87dc58 100644 --- a/tests/ui/check-cfg/no-values.stderr +++ b/tests/ui/check-cfg/no-values.stderr @@ -2,7 +2,9 @@ warning: unexpected `cfg` condition value --> $DIR/no-values.rs:6:7 | LL | #[cfg(feature = "foo")] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^-------- + | | + | help: remove the value | = note: no expected value for `feature` = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/order-independant.names_after.stderr b/tests/ui/check-cfg/order-independant.names_after.stderr new file mode 100644 index 000000000..91b81428b --- /dev/null +++ b/tests/ui/check-cfg/order-independant.names_after.stderr @@ -0,0 +1,19 @@ +warning: unexpected `cfg` condition value + --> $DIR/order-independant.rs:8:7 + | +LL | #[cfg(a)] + | ^- help: specify a config value: `= "b"` + | + = note: expected values for `a` are: `b` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value + --> $DIR/order-independant.rs:12:7 + | +LL | #[cfg(a = "unk")] + | ^^^^^^^^^ + | + = note: expected values for `a` are: `b` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/order-independant.names_before.stderr b/tests/ui/check-cfg/order-independant.names_before.stderr new file mode 100644 index 000000000..91b81428b --- /dev/null +++ b/tests/ui/check-cfg/order-independant.names_before.stderr @@ -0,0 +1,19 @@ +warning: unexpected `cfg` condition value + --> $DIR/order-independant.rs:8:7 + | +LL | #[cfg(a)] + | ^- help: specify a config value: `= "b"` + | + = note: expected values for `a` are: `b` + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition value + --> $DIR/order-independant.rs:12:7 + | +LL | #[cfg(a = "unk")] + | ^^^^^^^^^ + | + = note: expected values for `a` are: `b` + +warning: 2 warnings emitted + diff --git a/tests/ui/check-cfg/order-independant.rs b/tests/ui/check-cfg/order-independant.rs new file mode 100644 index 000000000..ce056b8dc --- /dev/null +++ b/tests/ui/check-cfg/order-independant.rs @@ -0,0 +1,16 @@ +// check-pass +// revisions: names_before names_after +// compile-flags: -Z unstable-options +// compile-flags: --check-cfg=names(names_before,names_after) +// [names_before]compile-flags: --check-cfg=names(a) --check-cfg=values(a,"b") +// [names_after]compile-flags: --check-cfg=values(a,"b") --check-cfg=names(a) + +#[cfg(a)] +//~^ WARNING unexpected `cfg` condition value +fn my_cfg() {} + +#[cfg(a = "unk")] +//~^ WARNING unexpected `cfg` condition value +fn my_cfg() {} + +fn main() {} diff --git a/tests/ui/check-cfg/values-target-json.stderr b/tests/ui/check-cfg/values-target-json.stderr index b58d29707..eb81535e3 100644 --- a/tests/ui/check-cfg/values-target-json.stderr +++ b/tests/ui/check-cfg/values-target-json.stderr @@ -4,9 +4,9 @@ warning: unexpected `cfg` condition value LL | #[cfg(target_os = "linuz")] | ^^^^^^^^^^^^------- | | - | help: did you mean: `"linux"` + | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, ericos, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vita, vxworks, wasi, watchos, windows, xous + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `ericos`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index bdbe4d29d..34c5d6172 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name LL | #[cfg(target_oz = "linux")] | ---------^^^^^^^^^^ | | - | help: did you mean: `target_os` + | help: there is a config with a similar name: `target_os` | = note: `#[warn(unexpected_cfgs)]` on by default @@ -14,13 +14,13 @@ warning: unexpected `cfg` condition name LL | #[cfg(features = "foo")] | --------^^^^^^^^ | | - | help: did you mean: `feature` + | help: there is a config with a similar name: `feature` warning: unexpected `cfg` condition name --> $DIR/well-known-names.rs:20:7 | LL | #[cfg(uniw)] - | ^^^^ help: did you mean: `unix` + | ^^^^ help: there is a config with a similar name: `unix` warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 69d799783..2d18cb82e 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -4,9 +4,9 @@ warning: unexpected `cfg` condition value LL | #[cfg(target_os = "linuz")] | ^^^^^^^^^^^^------- | | - | help: did you mean: `"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, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vita, vxworks, wasi, watchos, windows, xous + = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value @@ -15,9 +15,9 @@ warning: unexpected `cfg` condition value LL | #[cfg(target_has_atomic = "0")] | ^^^^^^^^^^^^^^^^^^^^--- | | - | help: did you mean: `"8"` + | help: there is a expected value with a similar name: `"8"` | - = note: expected values for `target_has_atomic` are: 128, 16, 32, 64, 8, ptr + = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` warning: unexpected `cfg` condition value --> $DIR/well-known-values.rs:21:7 diff --git a/tests/ui/closure_context/issue-26046-fn-mut.stderr b/tests/ui/closure_context/issue-26046-fn-mut.stderr index f744b71c2..e468f6be7 100644 --- a/tests/ui/closure_context/issue-26046-fn-mut.stderr +++ b/tests/ui/closure_context/issue-26046-fn-mut.stderr @@ -9,7 +9,7 @@ LL | num += 1; LL | Box::new(closure) | ----------------- the requirement to implement `Fn` derives from here | - = note: required for the cast from `[closure@$DIR/issue-26046-fn-mut.rs:4:19: 4:21]` to the object type `dyn Fn()` + = note: required for the cast from `Box<[closure@$DIR/issue-26046-fn-mut.rs:4:19: 4:21]>` to `Box<(dyn Fn() + 'static)>` error: aborting due to previous error diff --git a/tests/ui/closure_context/issue-26046-fn-once.stderr b/tests/ui/closure_context/issue-26046-fn-once.stderr index 34f94f9dc..41f60327c 100644 --- a/tests/ui/closure_context/issue-26046-fn-once.stderr +++ b/tests/ui/closure_context/issue-26046-fn-once.stderr @@ -9,7 +9,7 @@ LL | vec LL | Box::new(closure) | ----------------- the requirement to implement `Fn` derives from here | - = note: required for the cast from `[closure@$DIR/issue-26046-fn-once.rs:4:19: 4:26]` to the object type `dyn Fn() -> Vec<u8>` + = note: required for the cast from `Box<[closure@$DIR/issue-26046-fn-once.rs:4:19: 4:26]>` to `Box<(dyn Fn() -> Vec<u8> + 'static)>` error: aborting due to previous error diff --git a/tests/ui/closures/2229_closure_analysis/bad-pattern.rs b/tests/ui/closures/2229_closure_analysis/bad-pattern.rs new file mode 100644 index 000000000..a7bf9b67d --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/bad-pattern.rs @@ -0,0 +1,23 @@ +// regression test for #108683 +// edition:2021 + +enum Refutable { + A, + B, +} + +fn example(v1: u32, v2: [u32; 4], v3: Refutable) { + const PAT: u32 = 0; + let v4 = &v2[..]; + || { + let 0 = v1; //~ ERROR refutable pattern in local binding + let (0 | 1) = v1; //~ ERROR refutable pattern in local binding + let 1.. = v1; //~ ERROR refutable pattern in local binding + let [0, 0, 0, 0] = v2; //~ ERROR refutable pattern in local binding + let [0] = v4; //~ ERROR refutable pattern in local binding + let Refutable::A = v3; //~ ERROR refutable pattern in local binding + let PAT = v1; //~ ERROR refutable pattern in local binding + }; +} + +fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/bad-pattern.stderr b/tests/ui/closures/2229_closure_analysis/bad-pattern.stderr new file mode 100644 index 000000000..ca8c2a16d --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/bad-pattern.stderr @@ -0,0 +1,113 @@ +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:13:13 + | +LL | let 0 = v1; + | ^ pattern `1_u32..=u32::MAX` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `u32` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let 0 = v1 { todo!() }; + | ++ +++++++++++ +help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits + | +LL | let _0 = v1; + | + + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:14:14 + | +LL | let (0 | 1) = v1; + | ^^^^^ pattern `2_u32..=u32::MAX` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `u32` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let (0 | 1) = v1 { todo!() }; + | ++ +++++++++++ + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:15:13 + | +LL | let 1.. = v1; + | ^^^ pattern `0_u32` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `u32` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let 1.. = v1 { todo!() }; + | ++ +++++++++++ + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:16:13 + | +LL | let [0, 0, 0, 0] = v2; + | ^^^^^^^^^^^^ pattern `[1_u32..=u32::MAX, _, _, _]` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `[u32; 4]` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let [0, 0, 0, 0] = v2 { todo!() }; + | ++ +++++++++++ + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:17:13 + | +LL | let [0] = v4; + | ^^^ patterns `&[]` and `&[_, _, ..]` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `&[u32]` +help: you might want to use `if let` to ignore the variants that aren't matched + | +LL | if let [0] = v4 { todo!() }; + | ++ +++++++++++ + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:18:13 + | +LL | let Refutable::A = v3; + | ^^^^^^^^^^^^ pattern `Refutable::B` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html +note: `Refutable` defined here + --> $DIR/bad-pattern.rs:4:6 + | +LL | enum Refutable { + | ^^^^^^^^^ +LL | A, +LL | B, + | - not covered + = note: the matched value is of type `Refutable` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let Refutable::A = v3 { todo!() }; + | ++ +++++++++++ + +error[E0005]: refutable pattern in local binding + --> $DIR/bad-pattern.rs:19:13 + | +LL | let PAT = v1; + | ^^^ + | | + | pattern `1_u32..=u32::MAX` not covered + | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable + | help: introduce a variable instead: `PAT_var` + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `u32` + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr index 95f36fc04..1904faa95 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/mut_ref.stderr @@ -10,7 +10,7 @@ LL | **ref_mref_x = y; help: consider changing this to be a mutable reference | LL | let ref_mref_x = &mut mref_x; - | ~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `**mref_ref_x` as mutable, as it is behind a `&` reference --> $DIR/mut_ref.rs:26:13 diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index 9c2c43457..8c44229bc 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | println!("{}", foo.x); | ^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr b/tests/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr index ad061d93c..8a32f0d99 100644 --- a/tests/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr @@ -1,17 +1,3 @@ -error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/pattern-matching-should-fail.rs:67:23 - | -LL | let c1 = || match x { }; - | ^ - | - = note: the matched value is of type `u8` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ let c1 = || match x { -LL + _ => todo!(), -LL ~ }; - | - error[E0381]: used binding `x` isn't initialized --> $DIR/pattern-matching-should-fail.rs:8:23 | @@ -69,6 +55,20 @@ LL | let t: !; LL | match t { }; | ^ `t` used here but it isn't initialized +error[E0004]: non-exhaustive patterns: type `u8` is non-empty + --> $DIR/pattern-matching-should-fail.rs:67:23 + | +LL | let c1 = || match x { }; + | ^ + | + = note: the matched value is of type `u8` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ let c1 = || match x { +LL + _ => todo!(), +LL ~ }; + | + error[E0381]: used binding `x` isn't initialized --> $DIR/pattern-matching-should-fail.rs:67:23 | diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs index 56f5ac44d..41b09ba03 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs @@ -1,6 +1,7 @@ // edition:2021 #![feature(rustc_attrs)] +#![feature(stmt_expr_attributes)] // Should capture the discriminant since a variant of a multivariant enum is // mentioned in the match arm; the discriminant is captured by the closure regardless @@ -8,9 +9,6 @@ fn test_1_should_capture() { let variant = Some(2229); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> - || { //~^ First Pass analysis includes: //~| Min Capture analysis includes: @@ -29,8 +27,6 @@ fn test_1_should_capture() { fn test_2_should_not_capture() { let variant = Some(2229); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> || { //~^ First Pass analysis includes: match variant { @@ -50,8 +46,6 @@ enum SingleVariant { fn test_3_should_not_capture_single_variant() { let variant = SingleVariant::Points(1); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> || { //~^ First Pass analysis includes: match variant { @@ -66,8 +60,6 @@ fn test_3_should_not_capture_single_variant() { fn test_6_should_capture_single_variant() { let variant = SingleVariant::Points(1); let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> || { //~^ First Pass analysis includes: //~| Min Capture analysis includes: @@ -88,8 +80,6 @@ fn test_6_should_capture_single_variant() { fn test_4_should_not_capture_array() { let array: [i32; 3] = [0; 3]; let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> || { //~^ First Pass analysis includes: match array { @@ -112,8 +102,6 @@ enum MVariant { fn test_5_should_capture_multi_variant() { let variant = MVariant::A; let c = #[rustc_capture_analysis] - //~^ ERROR: attributes on expressions are experimental - //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> || { //~^ First Pass analysis includes: //~| Min Capture analysis includes: @@ -127,6 +115,62 @@ fn test_5_should_capture_multi_variant() { c(); } +// Even though all patterns are wild, we need to read the discriminant +// in order to test the slice length +fn test_7_should_capture_slice_len() { + let slice: &[i32] = &[1, 2, 3]; + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: + match slice { + //~^ NOTE: Capturing slice[] -> ImmBorrow + //~| NOTE: Min Capture slice[] -> ImmBorrow + [_,_,_] => {}, + _ => {} + } + }; + c(); + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: + match slice { + //~^ NOTE: Capturing slice[] -> ImmBorrow + //~| NOTE: Min Capture slice[] -> ImmBorrow + [] => {}, + _ => {} + } + }; + c(); + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + //~| Min Capture analysis includes: + match slice { + //~^ NOTE: Capturing slice[] -> ImmBorrow + //~| NOTE: Min Capture slice[] -> ImmBorrow + [_, .. ,_] => {}, + _ => {} + } + }; + c(); +} + +// Wild pattern that doesn't bind, so no capture +fn test_8_capture_slice_wild() { + let slice: &[i32] = &[1, 2, 3]; + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + match slice { + [..] => {}, + _ => {} + } + }; + c(); +} + fn main() { test_1_should_capture(); test_2_should_not_capture(); @@ -134,4 +178,6 @@ fn main() { test_6_should_capture_single_variant(); test_4_should_not_capture_array(); test_5_should_capture_multi_variant(); + test_7_should_capture_slice_len(); + test_8_capture_slice_wild(); } diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr index 460813333..e137af1a0 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr @@ -1,59 +1,5 @@ -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:10:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:31:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:52:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:68:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:90:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - -error[E0658]: attributes on expressions are experimental - --> $DIR/patterns-capture-analysis.rs:114:14 - | -LL | let c = #[rustc_capture_analysis] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information - = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable - error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:14:5 + --> $DIR/patterns-capture-analysis.rs:12:5 | LL | / || { LL | | @@ -65,13 +11,13 @@ LL | | }; | |_____^ | note: Capturing variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:17:15 + --> $DIR/patterns-capture-analysis.rs:15:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:14:5 + --> $DIR/patterns-capture-analysis.rs:12:5 | LL | / || { LL | | @@ -83,13 +29,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:17:15 + --> $DIR/patterns-capture-analysis.rs:15:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:34:5 + --> $DIR/patterns-capture-analysis.rs:30:5 | LL | / || { LL | | @@ -100,7 +46,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:55:5 + --> $DIR/patterns-capture-analysis.rs:49:5 | LL | / || { LL | | @@ -111,7 +57,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:71:5 + --> $DIR/patterns-capture-analysis.rs:63:5 | LL | / || { LL | | @@ -123,18 +69,18 @@ LL | | }; | |_____^ | note: Capturing variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:74:15 + --> $DIR/patterns-capture-analysis.rs:66:15 | LL | match variant { | ^^^^^^^ note: Capturing variant[(0, 0)] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:74:15 + --> $DIR/patterns-capture-analysis.rs:66:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:71:5 + --> $DIR/patterns-capture-analysis.rs:63:5 | LL | / || { LL | | @@ -146,13 +92,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:74:15 + --> $DIR/patterns-capture-analysis.rs:66:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:93:5 + --> $DIR/patterns-capture-analysis.rs:83:5 | LL | / || { LL | | @@ -163,7 +109,7 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:117:5 + --> $DIR/patterns-capture-analysis.rs:105:5 | LL | / || { LL | | @@ -175,13 +121,13 @@ LL | | }; | |_____^ | note: Capturing variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:120:15 + --> $DIR/patterns-capture-analysis.rs:108:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:117:5 + --> $DIR/patterns-capture-analysis.rs:105:5 | LL | / || { LL | | @@ -193,11 +139,130 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:120:15 + --> $DIR/patterns-capture-analysis.rs:108:15 | LL | match variant { | ^^^^^^^ -error: aborting due to 15 previous errors +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:123:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Capturing slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:126:15 + | +LL | match slice { + | ^^^^^ + +error: Min Capture analysis includes: + --> $DIR/patterns-capture-analysis.rs:123:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Min Capture slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:126:15 + | +LL | match slice { + | ^^^^^ + +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:135:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Capturing slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:138:15 + | +LL | match slice { + | ^^^^^ + +error: Min Capture analysis includes: + --> $DIR/patterns-capture-analysis.rs:135:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Min Capture slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:138:15 + | +LL | match slice { + | ^^^^^ + +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:147:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Capturing slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:150:15 + | +LL | match slice { + | ^^^^^ + +error: Min Capture analysis includes: + --> $DIR/patterns-capture-analysis.rs:147:5 + | +LL | / || { +LL | | +LL | | +LL | | match slice { +... | +LL | | } +LL | | }; + | |_____^ + | +note: Min Capture slice[] -> ImmBorrow + --> $DIR/patterns-capture-analysis.rs:150:15 + | +LL | match slice { + | ^^^^^ + +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:164:5 + | +LL | / || { +LL | | +LL | | match slice { +LL | | [..] => {}, +LL | | _ => {} +LL | | } +LL | | }; + | |_____^ + +error: aborting due to 16 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs index ff5d28461..98f8d5d47 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs @@ -1,6 +1,7 @@ // run-pass #![warn(rust_2021_incompatible_closure_captures)] +#![allow(dropping_references, dropping_copy_types)] fn main() { if let a = "" { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.stderr b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.stderr index 36a80e694..2609e2951 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.stderr +++ b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.stderr @@ -1,5 +1,5 @@ warning: irrefutable `if let` pattern - --> $DIR/issue-78720.rs:6:8 + --> $DIR/issue-78720.rs:7:8 | LL | if let a = "" { | ^^^^^^^^^^ diff --git a/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs b/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs index 033fd6f17..5496d0e5f 100644 --- a/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs +++ b/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs @@ -3,6 +3,7 @@ #![allow(unused)] #![allow(dead_code)] +#![allow(dropping_references)] struct Int(i32); struct B<'a>(&'a i32); diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs b/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs index 477fdd613..b5e97ec1c 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs @@ -1,6 +1,8 @@ // edition:2021 // check-pass + #![feature(rustc_attrs)] +#![allow(dropping_references)] fn main() { let mut x = 1; diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs new file mode 100644 index 000000000..72652ef60 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs @@ -0,0 +1,21 @@ +// Test precise capture of a multi-variant enum (when remaining variants are +// visibly uninhabited). +// edition:2021 +// run-pass +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +pub fn main() { + let mut r = Result::<!, (u32, u32)>::Err((0, 0)); + let mut f = || { + let Err((ref mut a, _)) = r; + *a = 1; + }; + let mut g = || { + let Err((_, ref mut b)) = r; + *b = 2; + }; + f(); + g(); + assert_eq!(r, Err((1, 2))); +} diff --git a/tests/ui/closures/binder/nested-closures-regions.stderr b/tests/ui/closures/binder/nested-closures-regions.stderr index b385e0ed6..381aadb15 100644 --- a/tests/ui/closures/binder/nested-closures-regions.stderr +++ b/tests/ui/closures/binder/nested-closures-regions.stderr @@ -9,11 +9,11 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; extern "rust-call" fn((&(),)), (), ] - = note: late-bound region is '_#4r - = note: late-bound region is '_#2r + = note: late-bound region is '?4 + = note: late-bound region is '?2 = note: number of external vids: 3 - = note: where '_#1r: '_#2r - = note: where '_#2r: '_#1r + = note: where '?1: '?2 + = note: where '?2: '?1 note: no external requirements --> $DIR/nested-closures-regions.rs:8:5 @@ -26,7 +26,7 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; extern "rust-call" fn(()), (), ] - = note: late-bound region is '_#2r + = note: late-bound region is '?2 note: no external requirements --> $DIR/nested-closures-regions.rs:7:1 diff --git a/tests/ui/issues/issue-868.rs b/tests/ui/closures/issue-868.rs index ce0a3c7ca..ce0a3c7ca 100644 --- a/tests/ui/issues/issue-868.rs +++ b/tests/ui/closures/issue-868.rs diff --git a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr index ff89dd340..381bb0c08 100644 --- a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#16t, extern "rust-call" fn(()), _#15t]]` + found closure `[mod1::f<T>::{closure#0} closure_substs=(unavailable) substs=[T, ?16t, extern "rust-call" fn(()), ?15t]]` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-generic-verbose-1.stderr b/tests/ui/closures/print/closure-print-generic-verbose-1.stderr index 3ab7c66d1..9a1f18fa8 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-1.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-1.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `c` --> $DIR/closure-print-generic-verbose-1.rs:17:5 | LL | let c = to_fn_once(move|| { - | - move occurs because `c` has type `[f<T>::{closure#0} closure_kind_ty=i32 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=(Foo<&'_#9r str>, T)]`, which does not implement the `Copy` trait + | - move occurs because `c` has type `[f<T>::{closure#0} closure_kind_ty=i32 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=(Foo<&'?9 str>, T)]`, which does not implement the `Copy` trait ... LL | c(); | --- `c` moved due to this call diff --git a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr index 5bbf84f96..2a4d16c48 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[T, _#16t, extern "rust-call" fn(()), _#15t]]` + found closure `[f<T>::{closure#0} closure_substs=(unavailable) substs=[T, ?16t, extern "rust-call" fn(()), ?15t]]` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-verbose.stderr b/tests/ui/closures/print/closure-print-verbose.stderr index 083717b33..9e219435e 100644 --- a/tests/ui/closures/print/closure-print-verbose.stderr +++ b/tests/ui/closures/print/closure-print-verbose.stderr @@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; | expected due to this | = note: expected fn pointer `fn(u8) -> u8` - found closure `[main::{closure#0} closure_substs=(unavailable) substs=[i8, extern "rust-call" fn((u8,)) -> u8, _#6t]]` + found closure `[main::{closure#0} closure_substs=(unavailable) substs=[i8, extern "rust-call" fn((u8,)) -> u8, ?6t]]` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-print-verbose.rs:10:39 | diff --git a/tests/ui/closures/static-closures-with-nonstatic-return.rs b/tests/ui/closures/static-closures-with-nonstatic-return.rs new file mode 100644 index 000000000..b5f0684ba --- /dev/null +++ b/tests/ui/closures/static-closures-with-nonstatic-return.rs @@ -0,0 +1,15 @@ +// check-pass +// known-bug: #84366 + +// Should fail. Associated types of 'static types should be `'static`, but +// argument-free closures can be `'static` and return non-`'static` types. + +#[allow(dead_code)] +fn foo<'a>() { + let closure = || -> &'a str { "" }; + assert_static(closure); +} + +fn assert_static<T: 'static>(_: T) {} + +fn main() {} diff --git a/tests/ui/codegen/freeze-on-polymorphic-projection.rs b/tests/ui/codegen/freeze-on-polymorphic-projection.rs new file mode 100644 index 000000000..edc79f8fd --- /dev/null +++ b/tests/ui/codegen/freeze-on-polymorphic-projection.rs @@ -0,0 +1,19 @@ +// build-pass +// compile-flags: -Copt-level=1 --crate-type=lib + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +pub unsafe trait Storage { + type Handle; +} + +pub unsafe trait MultipleStorage: Storage {} + +default unsafe impl<S> Storage for S where S: MultipleStorage {} + +// Make sure that we call is_freeze on `(S::Handle,)` in the param-env of `ice`, +// instead of in an empty, reveal-all param-env. +pub fn ice<S: Storage>(boxed: (S::Handle,)) -> (S::Handle,) { + boxed +} diff --git a/tests/ui/codegen/freeze-on-polymorphic-projection.stderr b/tests/ui/codegen/freeze-on-polymorphic-projection.stderr new file mode 100644 index 000000000..903cb2ff6 --- /dev/null +++ b/tests/ui/codegen/freeze-on-polymorphic-projection.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/freeze-on-polymorphic-projection.rs:4:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/codemap_tests/two_files_data.rs b/tests/ui/codemap_tests/two_files_data.rs index b4d2f5d3c..6abeac0dd 100644 --- a/tests/ui/codemap_tests/two_files_data.rs +++ b/tests/ui/codemap_tests/two_files_data.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) trait Foo { } diff --git a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr index 980da5360..b976f70ac 100644 --- a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr +++ b/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x) | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | - = note: required for the cast from `()` to the object type `dyn std::error::Error` + = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>` error[E0277]: the trait bound `(): std::error::Error` is not satisfied --> $DIR/coerce-issue-49593-box-never-windows.rs:23:49 @@ -12,7 +12,7 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | - = note: required for the cast from `()` to the object type `(dyn std::error::Error + 'static)` + = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)` error: aborting due to 2 previous errors diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr index 322681b97..0d98fa93e 100644 --- a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr +++ b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x) | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | - = note: required for the cast from `()` to the object type `dyn std::error::Error` + = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>` error[E0277]: the trait bound `(): std::error::Error` is not satisfied --> $DIR/coerce-issue-49593-box-never.rs:23:49 @@ -12,7 +12,7 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` | - = note: required for the cast from `()` to the object type `(dyn std::error::Error + 'static)` + = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)` error: aborting due to 2 previous errors diff --git a/tests/ui/coercion/coercion-slice.stderr b/tests/ui/coercion/coercion-slice.stderr index c7b856a57..17bbca7a0 100644 --- a/tests/ui/coercion/coercion-slice.stderr +++ b/tests/ui/coercion/coercion-slice.stderr @@ -2,11 +2,14 @@ error[E0308]: mismatched types --> $DIR/coercion-slice.rs:4:21 | LL | let _: &[i32] = [0]; - | ------ ^^^ - | | | - | | expected `&[i32]`, found `[{integer}; 1]` - | | help: consider borrowing here: `&[0]` + | ------ ^^^ expected `&[i32]`, found `[{integer}; 1]` + | | | expected due to this + | +help: consider borrowing here + | +LL | let _: &[i32] = &[0]; + | + error: aborting due to previous error diff --git a/tests/ui/coherence/coherence-overlap-negative-impls.rs b/tests/ui/coherence/coherence-overlap-negative-impls.rs new file mode 100644 index 000000000..cd1df53a5 --- /dev/null +++ b/tests/ui/coherence/coherence-overlap-negative-impls.rs @@ -0,0 +1,41 @@ +// check-pass +// known-bug: #74629 + +// Should fail. The `0` and `1` impls overlap, violating coherence. Eg, with +// `T = Test, F = ()`, all bounds are true, making both impls applicable. +// `Test: Fold<Nil>`, `Test: Fold<()>` are true because of `2`. +// `Is<Test>: NotNil` is true because of `auto trait` and lack of negative impl. + +#![feature(negative_impls)] +#![feature(auto_traits)] + +struct Nil; +struct Cons<H>(H); +struct Test; + +trait Fold<F> {} + +impl<T, F> Fold<F> for Cons<T> // 0 +where + T: Fold<Nil>, +{} + +impl<T, F> Fold<F> for Cons<T> // 1 +where + T: Fold<F>, + private::Is<T>: private::NotNil, +{} + +impl<F> Fold<F> for Test {} // 2 + +mod private { + use crate::Nil; + + pub struct Is<T>(T); + pub auto trait NotNil {} + + #[allow(suspicious_auto_trait_impls)] + impl !NotNil for Is<Nil> {} +} + +fn main() {} diff --git a/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs new file mode 100644 index 000000000..bb46498f9 --- /dev/null +++ b/tests/ui/coherence/indirect-impl-for-trait-obj-coherence.rs @@ -0,0 +1,25 @@ +// check-pass +// known-bug: #57893 + +// Should fail. Because we see an impl that uses a certain associated type, we +// type-check assuming that impl is used. However, this conflicts with the +// "implicit impl" that we get for trait objects, violating coherence. + +trait Object<U> { + type Output; +} + +impl<T: ?Sized, U> Object<U> for T { + type Output = U; +} + +fn foo<T: ?Sized, U>(x: <T as Object<U>>::Output) -> U { + x +} + +#[allow(dead_code)] +fn transmute<T, U>(x: T) -> U { + foo::<dyn Object<U, Output = T>, U>(x) +} + +fn main() {} diff --git a/tests/ui/conditional-compilation/module_with_cfg.rs b/tests/ui/conditional-compilation/module_with_cfg.rs index 56c4baadf..55c8381cf 100644 --- a/tests/ui/conditional-compilation/module_with_cfg.rs +++ b/tests/ui/conditional-compilation/module_with_cfg.rs @@ -1,3 +1,3 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) #![cfg_attr(all(), cfg(FALSE))] diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs new file mode 100644 index 000000000..0da68ae75 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs @@ -0,0 +1,13 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +fn check(_: impl std::marker::ConstParamTy) {} + +fn main() { + check(main); //~ error: `fn() {main}` can't be used as a const parameter type + check(|| {}); //~ error: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type + check(main as fn()); //~ error: `fn()` can't be used as a const parameter type + check(&mut ()); //~ error: `&mut ()` can't be used as a const parameter type + check(&mut () as *mut ()); //~ error: `*mut ()` can't be used as a const parameter type + check(&() as *const ()); //~ error: `*const ()` can't be used as a const parameter type +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr new file mode 100644 index 000000000..de5704ee4 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -0,0 +1,87 @@ +error[E0277]: `fn() {main}` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:7:11 + | +LL | check(main); + | ----- ^^^^ the trait `ConstParamTy` is not implemented for fn item `fn() {main}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:8:11 + | +LL | check(|| {}); + | ----- ^^^^^ the trait `ConstParamTy` is not implemented for closure `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `fn()` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:9:11 + | +LL | check(main as fn()); + | ----- ^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `fn()` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `&mut ()` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:10:11 + | +LL | check(&mut ()); + | ----- ^^^^^^^ the trait `ConstParamTy` is not implemented for `&mut ()` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `*mut ()` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:11:11 + | +LL | check(&mut () as *mut ()); + | ----- ^^^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*mut ()` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `*const ()` can't be used as a const parameter type + --> $DIR/const_param_ty_bad.rs:12:11 + | +LL | check(&() as *const ()); + | ----- ^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*const ()` + | | + | required by a bound introduced by this call + | +note: required by a bound in `check` + --> $DIR/const_param_ty_bad.rs:4:18 + | +LL | fn check(_: impl std::marker::ConstParamTy) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs new file mode 100644 index 000000000..b0e3b13cc --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs @@ -0,0 +1,12 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +#[derive(PartialEq, Eq)] +struct NotParam; + +fn check<T: std::marker::ConstParamTy>() {} + +fn main() { + check::<[NotParam; 0]>(); + //~^ error: `NotParam` can't be used as a const parameter type +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr new file mode 100644 index 000000000..ef55242df --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr @@ -0,0 +1,16 @@ +error[E0277]: `NotParam` can't be used as a const parameter type + --> $DIR/const_param_ty_bad_empty_array.rs:10:13 + | +LL | check::<[NotParam; 0]>(); + | ^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam` + | + = note: required for `[NotParam; 0]` to implement `ConstParamTy` +note: required by a bound in `check` + --> $DIR/const_param_ty_bad_empty_array.rs:7:13 + | +LL | fn check<T: std::marker::ConstParamTy>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs new file mode 100644 index 000000000..e4dc76703 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs @@ -0,0 +1,13 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +#[derive(PartialEq, Eq)] +struct NotParam; + +fn check<T: std::marker::ConstParamTy + ?Sized>() {} + +fn main() { + check::<&NotParam>(); //~ error: `NotParam` can't be used as a const parameter type + check::<[NotParam]>(); //~ error: `NotParam` can't be used as a const parameter type + check::<[NotParam; 17]>(); //~ error: `NotParam` can't be used as a const parameter type +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr new file mode 100644 index 000000000..86d1c94e8 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr @@ -0,0 +1,42 @@ +error[E0277]: `NotParam` can't be used as a const parameter type + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:10:13 + | +LL | check::<&NotParam>(); + | ^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam` + | + = note: required for `&NotParam` to implement `ConstParamTy` +note: required by a bound in `check` + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13 + | +LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `NotParam` can't be used as a const parameter type + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:11:13 + | +LL | check::<[NotParam]>(); + | ^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam` + | + = note: required for `[NotParam]` to implement `ConstParamTy` +note: required by a bound in `check` + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13 + | +LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error[E0277]: `NotParam` can't be used as a const parameter type + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:12:13 + | +LL | check::<[NotParam; 17]>(); + | ^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam` + | + = note: required for `[NotParam; 17]` to implement `ConstParamTy` +note: required by a bound in `check` + --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13 + | +LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs new file mode 100644 index 000000000..87ae83dd9 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs @@ -0,0 +1,53 @@ +// check-pass +#![allow(incomplete_features)] +#![feature(adt_const_params)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq)] +struct S<T> { + field: u8, + gen: T, +} + +impl<T: ConstParamTy> ConstParamTy for S<T> {} + +#[derive(PartialEq, Eq, ConstParamTy)] +struct D<T> { + field: u8, + gen: T, +} + + +fn check<T: ConstParamTy + ?Sized>() {} + +fn main() { + check::<u8>(); + check::<u16>(); + check::<u32>(); + check::<u64>(); + check::<u128>(); + + check::<i8>(); + check::<i16>(); + check::<i32>(); + check::<i64>(); + check::<i128>(); + + check::<char>(); + check::<bool>(); + check::<str>(); + + check::<&u8>(); + check::<&str>(); + check::<[usize]>(); + check::<[u16; 0]>(); + check::<[u8; 42]>(); + + check::<S<u8>>(); + check::<S<[&[bool]; 8]>>(); + + check::<D<u8>>(); + check::<D<[&[bool]; 8]>>(); + + // FIXME: test tuples +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs new file mode 100644 index 000000000..74283a37a --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs @@ -0,0 +1,17 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +#[derive(PartialEq, Eq)] +struct NotParam; + +#[derive(PartialEq, Eq)] +struct CantParam(NotParam); + +impl std::marker::ConstParamTy for CantParam {} +//~^ error: the trait `ConstParamTy` cannot be implemented for this type + +#[derive(std::marker::ConstParamTy, Eq, PartialEq)] +//~^ error: the trait `ConstParamTy` cannot be implemented for this type +struct CantParamDerive(NotParam); + +fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr new file mode 100644 index 000000000..52b65d606 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr @@ -0,0 +1,23 @@ +error[E0204]: the trait `ConstParamTy` cannot be implemented for this type + --> $DIR/const_param_ty_impl_bad_field.rs:10:36 + | +LL | struct CantParam(NotParam); + | -------- this field does not implement `ConstParamTy` +LL | +LL | impl std::marker::ConstParamTy for CantParam {} + | ^^^^^^^^^ + +error[E0204]: the trait `ConstParamTy` cannot be implemented for this type + --> $DIR/const_param_ty_impl_bad_field.rs:13:10 + | +LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct CantParamDerive(NotParam); + | -------- this field does not implement `ConstParamTy` + | + = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0204`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs new file mode 100644 index 000000000..37986de48 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs @@ -0,0 +1,21 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params)] + +#[derive(PartialEq, Eq)] +struct ImplementsConstParamTy; +impl std::marker::ConstParamTy for ImplementsConstParamTy {} + +struct CantParam(ImplementsConstParamTy); + +impl std::marker::ConstParamTy for CantParam {} +//~^ error: the type `CantParam` does not `#[derive(Eq)]` + +#[derive(std::marker::ConstParamTy)] +//~^ error: the type `CantParamDerive` does not `#[derive(Eq)]` +struct CantParamDerive(ImplementsConstParamTy); + +fn check<T: std::marker::ConstParamTy>() {} + +fn main() { + check::<ImplementsConstParamTy>(); +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr new file mode 100644 index 000000000..52701d559 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr @@ -0,0 +1,22 @@ +error[E0277]: the type `CantParam` does not `#[derive(Eq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 + | +LL | impl std::marker::ConstParamTy for CantParam {} + | ^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParam` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:13:10 + | +LL | #[derive(std::marker::ConstParamTy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs new file mode 100644 index 000000000..d70377a20 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs @@ -0,0 +1,33 @@ +#![allow(incomplete_features)] +#![feature(adt_const_params, structural_match)] + +union Union { + a: u8, +} + +impl PartialEq for Union { + fn eq(&self, other: &Union) -> bool { + true + } +} +impl Eq for Union {} +impl std::marker::StructuralEq for Union {} + +impl std::marker::ConstParamTy for Union {} + +#[derive(std::marker::ConstParamTy)] +//~^ ERROR this trait cannot be derived for unions +union UnionDerive { + a: u8, +} + +impl PartialEq for UnionDerive { + fn eq(&self, other: &UnionDerive) -> bool { + true + } +} +impl Eq for UnionDerive {} +impl std::marker::StructuralEq for UnionDerive {} + + +fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr new file mode 100644 index 000000000..293703046 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr @@ -0,0 +1,8 @@ +error: this trait cannot be derived for unions + --> $DIR/const_param_ty_impl_union.rs:18:10 + | +LL | #[derive(std::marker::ConstParamTy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.rs b/tests/ui/const-generics/assoc_const_as_type_argument.rs new file mode 100644 index 000000000..ffc7f116a --- /dev/null +++ b/tests/ui/const-generics/assoc_const_as_type_argument.rs @@ -0,0 +1,13 @@ +trait Trait { + const ASSOC: usize; +} + +fn bar<const N: usize>() {} + +fn foo<T: Trait>() { + bar::<<T as Trait>::ASSOC>(); + //~^ ERROR: expected associated type, found associated constant `Trait::ASSOC` + //~| ERROR: unresolved item provided when a constant was expected +} + +fn main() {} diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.stderr b/tests/ui/const-generics/assoc_const_as_type_argument.stderr new file mode 100644 index 000000000..ac0095461 --- /dev/null +++ b/tests/ui/const-generics/assoc_const_as_type_argument.stderr @@ -0,0 +1,21 @@ +error[E0575]: expected associated type, found associated constant `Trait::ASSOC` + --> $DIR/assoc_const_as_type_argument.rs:8:11 + | +LL | bar::<<T as Trait>::ASSOC>(); + | ^^^^^^^^^^^^^^^^^^^ not a associated type + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/assoc_const_as_type_argument.rs:8:11 + | +LL | bar::<<T as Trait>::ASSOC>(); + | ^^^^^^^^^^^^^^^^^^^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | bar::<{ <T as Trait>::ASSOC }>(); + | + + + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0575, E0747. +For more information about an error, try `rustc --explain E0575`. diff --git a/tests/ui/const-generics/assoc_const_eq_diagnostic.rs b/tests/ui/const-generics/assoc_const_eq_diagnostic.rs index 4d0aaf88e..bf8202ac1 100644 --- a/tests/ui/const-generics/assoc_const_eq_diagnostic.rs +++ b/tests/ui/const-generics/assoc_const_eq_diagnostic.rs @@ -10,6 +10,7 @@ pub trait Parse { pub trait CoolStuff: Parse<MODE = Mode::Cool> {} //~^ ERROR expected associated constant bound +//~| ERROR expected associated constant bound //~| ERROR expected type fn no_help() -> Mode::Cool {} diff --git a/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr b/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr index ba727ee0e..d7e5e50cb 100644 --- a/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr +++ b/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr @@ -8,7 +8,7 @@ LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {} | help: try using the variant's enum: `Mode` error[E0573]: expected type, found variant `Mode::Cool` - --> $DIR/assoc_const_eq_diagnostic.rs:15:17 + --> $DIR/assoc_const_eq_diagnostic.rs:16:17 | LL | fn no_help() -> Mode::Cool {} | ^^^^^^^^^^ @@ -28,6 +28,18 @@ note: associated constant defined here LL | const MODE: Mode; | ^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: expected associated constant bound, found type + --> $DIR/assoc_const_eq_diagnostic.rs:11:28 + | +LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {} + | ^^^^^^^^^^^^^^^^^ help: if equating a const, try wrapping with braces: `MODE = { const }` + | +note: associated constant defined here + --> $DIR/assoc_const_eq_diagnostic.rs:8:5 + | +LL | const MODE: Mode; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0573`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr deleted file mode 100644 index 463a37d7e..000000000 --- a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr +++ /dev/null @@ -1,163 +0,0 @@ -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:18:23 - | -LL | let _: [u8; faz::<'a>(&())]; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:21:23 - | -LL | let _: [u8; faz::<'b>(&())]; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:41:24 - | -LL | let _: Foo<{ faz::<'a>(&()) }>; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:44:24 - | -LL | let _: Foo<{ faz::<'b>(&()) }>; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:13:12 - | -LL | let _: [u8; foo::<T>()]; - | ^^^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); foo::<T>()]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:15:12 - | -LL | let _: [u8; bar::<N>()]; - | ^^^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); bar::<N>()]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:36:12 - | -LL | let _: Foo<{ foo::<T>() }>; - | ^^^^^^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); { foo::<T>() }]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:38:12 - | -LL | let _: Foo<{ bar::<N>() }>; - | ^^^^^^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); { bar::<N>() }]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:25:17 - | -LL | let _ = [0; foo::<T>()]; - | ^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); foo::<T>()]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:27:17 - | -LL | let _ = [0; bar::<N>()]; - | ^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); bar::<N>()]:` - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:30:23 - | -LL | let _ = [0; faz::<'a>(&())]; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:33:23 - | -LL | let _ = [0; faz::<'b>(&())]; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:47:19 - | -LL | let _ = Foo::<{ foo::<T>() }>; - | ^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); { foo::<T>() }]:` - -error: unconstrained generic constant - --> $DIR/const-arg-in-const-arg.rs:49:19 - | -LL | let _ = Foo::<{ bar::<N>() }>; - | ^^^^^^^^^^^^^^ - | - = help: try adding a `where` bound using this expression: `where [(); { bar::<N>() }]:` - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:52:27 - | -LL | let _ = Foo::<{ faz::<'a>(&()) }>; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:55:27 - | -LL | let _ = Foo::<{ faz::<'b>(&()) }>; - | ^^ - | -note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 - | -LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } - | ^^ - -error: aborting due to 16 previous errors - -For more information about this error, try `rustc --explain E0794`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr index a7bd9c62b..f1f22e234 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:13:23 + --> $DIR/const-arg-in-const-arg.rs:15:23 | LL | let _: [u8; foo::<T>()]; | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | let _: [u8; foo::<T>()]; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:15:23 + --> $DIR/const-arg-in-const-arg.rs:16:23 | LL | let _: [u8; bar::<N>()]; | ^ cannot perform const operation using `N` @@ -16,44 +16,44 @@ LL | let _: [u8; bar::<N>()]; = help: const parameters may only be used as standalone arguments, i.e. `N` = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:18:23 | LL | let _: [u8; faz::<'a>(&())]; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:20:23 | LL | let _: [u8; baz::<'a>(&())]; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:21:23 | LL | let _: [u8; faz::<'b>(&())]; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/const-arg-in-const-arg.rs:23:23 | LL | let _: [u8; baz::<'b>(&())]; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:27:23 + --> $DIR/const-arg-in-const-arg.rs:26:23 | LL | let _ = [0; bar::<N>()]; | ^ cannot perform const operation using `N` @@ -61,44 +61,44 @@ LL | let _ = [0; bar::<N>()]; = help: const parameters may only be used as standalone arguments, i.e. `N` = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:30:23 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:28:23 | LL | let _ = [0; faz::<'a>(&())]; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:32:23 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:30:23 | LL | let _ = [0; baz::<'a>(&())]; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:33:23 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:31:23 | LL | let _ = [0; faz::<'b>(&())]; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:35:23 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:33:23 | LL | let _ = [0; baz::<'b>(&())]; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:36:24 + --> $DIR/const-arg-in-const-arg.rs:34:24 | LL | let _: Foo<{ foo::<T>() }>; | ^ cannot perform const operation using `T` @@ -107,7 +107,7 @@ LL | let _: Foo<{ foo::<T>() }>; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:38:24 + --> $DIR/const-arg-in-const-arg.rs:35:24 | LL | let _: Foo<{ bar::<N>() }>; | ^ cannot perform const operation using `N` @@ -115,44 +115,44 @@ LL | let _: Foo<{ bar::<N>() }>; = help: const parameters may only be used as standalone arguments, i.e. `N` = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:41:24 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:37:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:43:24 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:39:24 | LL | let _: Foo<{ baz::<'a>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:44:24 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:40:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:46:24 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:42:24 | LL | let _: Foo<{ baz::<'b>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:47:27 + --> $DIR/const-arg-in-const-arg.rs:43:27 | LL | let _ = Foo::<{ foo::<T>() }>; | ^ cannot perform const operation using `T` @@ -161,7 +161,7 @@ LL | let _ = Foo::<{ foo::<T>() }>; = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:49:27 + --> $DIR/const-arg-in-const-arg.rs:44:27 | LL | let _ = Foo::<{ bar::<N>() }>; | ^ cannot perform const operation using `N` @@ -169,44 +169,44 @@ LL | let _ = Foo::<{ bar::<N>() }>; = help: const parameters may only be used as standalone arguments, i.e. `N` = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:52:27 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:46:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:54:27 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:48:27 | LL | let _ = Foo::<{ baz::<'a>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:55:27 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:49:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:57:27 +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:51:27 | LL | let _ = Foo::<{ baz::<'b>(&()) }>; - | ^^ + | ^^ cannot perform const operation using `'b` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error[E0747]: unresolved item provided when a constant was expected - --> $DIR/const-arg-in-const-arg.rs:15:23 + --> $DIR/const-arg-in-const-arg.rs:16:23 | LL | let _: [u8; bar::<N>()]; | ^ @@ -223,7 +223,7 @@ LL | let _: [u8; faz::<'a>(&())]; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ @@ -235,13 +235,13 @@ LL | let _: [u8; faz::<'b>(&())]; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error[E0747]: unresolved item provided when a constant was expected - --> $DIR/const-arg-in-const-arg.rs:38:24 + --> $DIR/const-arg-in-const-arg.rs:35:24 | LL | let _: Foo<{ bar::<N>() }>; | ^ @@ -252,25 +252,25 @@ LL | let _: Foo<{ bar::<{ N }>() }>; | + + error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:41:24 + --> $DIR/const-arg-in-const-arg.rs:37:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:44:24 + --> $DIR/const-arg-in-const-arg.rs:40:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ @@ -284,7 +284,7 @@ LL | let _ = [0; foo::<T>()]; = note: this may fail depending on what value the parameter takes error[E0747]: unresolved item provided when a constant was expected - --> $DIR/const-arg-in-const-arg.rs:27:23 + --> $DIR/const-arg-in-const-arg.rs:26:23 | LL | let _ = [0; bar::<N>()]; | ^ @@ -295,31 +295,31 @@ LL | let _ = [0; bar::<{ N }>()]; | + + error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:30:23 + --> $DIR/const-arg-in-const-arg.rs:28:23 | LL | let _ = [0; faz::<'a>(&())]; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:33:23 + --> $DIR/const-arg-in-const-arg.rs:31:23 | LL | let _ = [0; faz::<'b>(&())]; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error[E0747]: unresolved item provided when a constant was expected - --> $DIR/const-arg-in-const-arg.rs:49:27 + --> $DIR/const-arg-in-const-arg.rs:44:27 | LL | let _ = Foo::<{ bar::<N>() }>; | ^ @@ -330,30 +330,30 @@ LL | let _ = Foo::<{ bar::<{ N }>() }>; | + + error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:52:27 + --> $DIR/const-arg-in-const-arg.rs:46:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/const-arg-in-const-arg.rs:55:27 + --> $DIR/const-arg-in-const-arg.rs:49:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; | ^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/const-arg-in-const-arg.rs:8:14 + --> $DIR/const-arg-in-const-arg.rs:10:14 | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ error: aborting due to 36 previous errors -Some errors have detailed explanations: E0658, E0747, E0794. -For more information about an error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0747, E0794. +For more information about an error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.rs b/tests/ui/const-generics/const-arg-in-const-arg.rs index 44a4f560a..9eaa54347 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.rs +++ b/tests/ui/const-generics/const-arg-in-const-arg.rs @@ -1,4 +1,6 @@ -// revisions: full min +// revisions: min +// we use a single revision because t his shoudl have a `full` revision +// but right now that ICEs and I(@BoxyUwU) could not get stderr normalization to work #![cfg_attr(full, feature(generic_const_exprs))] #![cfg_attr(full, allow(incomplete_features))] @@ -11,50 +13,42 @@ const fn baz<'a>(_: &'a ()) -> usize where &'a (): Sized { 13 } struct Foo<const N: usize>; fn test<'a, 'b, T, const N: usize>() where &'b (): Sized { let _: [u8; foo::<T>()]; //[min]~ ERROR generic parameters may not - //[full]~^ ERROR unconstrained generic constant let _: [u8; bar::<N>()]; //[min]~ ERROR generic parameters may not //[min]~^ ERROR unresolved item provided when a constant was expected - //[full]~^^ ERROR unconstrained generic constant - let _: [u8; faz::<'a>(&())]; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _: [u8; baz::<'a>(&())]; //[min]~ ERROR a non-static lifetime - let _: [u8; faz::<'b>(&())]; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _: [u8; baz::<'b>(&())]; //[min]~ ERROR a non-static lifetime + let _: [u8; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _: [u8; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not + let _: [u8; faz::<'b>(&())]; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _: [u8; baz::<'b>(&())]; //[min]~ ERROR generic parameters may not let _ = [0; foo::<T>()]; //[min]~ ERROR constant expression depends on a generic parameter - //[full]~^ ERROR unconstrained generic constant let _ = [0; bar::<N>()]; //[min]~ ERROR generic parameters may not //[min]~^ ERROR unresolved item provided when a constant was expected - //[full]~^^ ERROR unconstrained generic constant - let _ = [0; faz::<'a>(&())]; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _ = [0; baz::<'a>(&())]; //[min]~ ERROR a non-static lifetime - let _ = [0; faz::<'b>(&())]; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _ = [0; baz::<'b>(&())]; //[min]~ ERROR a non-static lifetime + let _ = [0; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _ = [0; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not + let _ = [0; faz::<'b>(&())]; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _ = [0; baz::<'b>(&())]; //[min]~ ERROR generic parameters may not let _: Foo<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not - //[full]~^ ERROR unconstrained generic constant let _: Foo<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not //[min]~^ ERROR unresolved item provided when a constant was expected - //[full]~^^ ERROR unconstrained generic constant - let _: Foo<{ faz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _: Foo<{ baz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime - let _: Foo<{ faz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _: Foo<{ baz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime + let _: Foo<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _: Foo<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not + let _: Foo<{ faz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _: Foo<{ baz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not let _ = Foo::<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not - //[full]~^ ERROR unconstrained generic constant let _ = Foo::<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not //[min]~^ ERROR unresolved item provided when a constant was expected - //[full]~^^ ERROR unconstrained generic constant - let _ = Foo::<{ faz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _ = Foo::<{ baz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime - let _ = Foo::<{ faz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime - //~^ ERROR cannot specify lifetime arguments - let _ = Foo::<{ baz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime + let _ = Foo::<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _ = Foo::<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not + let _ = Foo::<{ faz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not + //[min]~^ ERROR cannot specify lifetime arguments + let _ = Foo::<{ baz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not } fn main() {} diff --git a/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr b/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr index 82030731c..310ca75fd 100644 --- a/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr +++ b/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr @@ -1,12 +1,11 @@ -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/const-argument-non-static-lifetime.rs:14:17 | LL | let _: &'a (); - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/const-generics/const-argument-non-static-lifetime.rs b/tests/ui/const-generics/const-argument-non-static-lifetime.rs index 0357e4ed5..df2f3b791 100644 --- a/tests/ui/const-generics/const-argument-non-static-lifetime.rs +++ b/tests/ui/const-generics/const-argument-non-static-lifetime.rs @@ -11,7 +11,7 @@ fn test<const N: usize>() {} fn wow<'a>() -> &'a () { test::<{ - let _: &'a (); //[min]~ ERROR a non-static lifetime + let _: &'a (); //[min]~ ERROR generic parameters may not be used in const operations 3 }>(); &() diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr index f639e276f..539d840f0 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr @@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index 24aa40521..f829526ca 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/const-param-type-depends-on-const-param.rs:11:47 diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr index 9c5c97bef..c5160d1c3 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct B<T, const N: T>(PhantomData<[T; N]>); | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index 32f7dea82..938fb08b7 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error[E0392]: parameter `T` is never used --> $DIR/const-param-type-depends-on-type-param.rs:11:22 diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index 32f7dea82..938fb08b7 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error[E0392]: parameter `T` is never used --> $DIR/const-param-type-depends-on-type-param.rs:11:22 diff --git a/tests/ui/const-generics/defaults/trait_objects_fail.stderr b/tests/ui/const-generics/defaults/trait_objects_fail.stderr index 0e8334d03..481d77728 100644 --- a/tests/ui/const-generics/defaults/trait_objects_fail.stderr +++ b/tests/ui/const-generics/defaults/trait_objects_fail.stderr @@ -5,7 +5,7 @@ LL | foo(&10_u32); | ^^^^^^^ the trait `Trait` is not implemented for `u32` | = help: the trait `Trait<2>` is implemented for `u32` - = note: required for the cast from `u32` to the object type `dyn Trait` + = note: required for the cast from `&u32` to `&dyn Trait` error[E0277]: the trait bound `bool: Traitor<_>` is not satisfied --> $DIR/trait_objects_fail.rs:28:9 @@ -14,7 +14,7 @@ LL | bar(&true); | ^^^^^ the trait `Traitor<_>` is not implemented for `bool` | = help: the trait `Traitor<2, 3>` is implemented for `bool` - = note: required for the cast from `bool` to the object type `dyn Traitor<_>` + = note: required for the cast from `&bool` to `&dyn Traitor<_>` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 6b3396a25..3a7f3cd0b 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -8,6 +8,9 @@ LL | let _ = const_evaluatable_lib::test1::<T>(); note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10 | +LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] + | ----- required by a bound in this function +LL | where LL | [u8; std::mem::size_of::<T>() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` @@ -34,6 +37,9 @@ LL | let _ = const_evaluatable_lib::test1::<T>(); note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10 | +LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] + | ----- required by a bound in this function +LL | where LL | [u8; std::mem::size_of::<T>() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-74713.rs b/tests/ui/const-generics/generic_const_exprs/issue-74713.rs index 0bcb997d9..205d031d4 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-74713.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-74713.rs @@ -1,7 +1,7 @@ fn bug<'a>() where [(); { //~ ERROR mismatched types - let _: &'a (); //~ ERROR a non-static lifetime is not allowed in a `const` + let _: &'a (); //~ ERROR generic parameters may not be used in const operations }]: {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr b/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr index e7673df0a..f0e0a4b97 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr @@ -1,11 +1,11 @@ -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/issue-74713.rs:4:17 | LL | let _: &'a (); - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error[E0308]: mismatched types --> $DIR/issue-74713.rs:3:10 @@ -18,5 +18,4 @@ LL | | }]: error: aborting due to 2 previous errors -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs b/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs index d45a6465b..18a993986 100644 --- a/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs +++ b/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs @@ -2,28 +2,30 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features, unused_parens, unused_braces)] -fn zero_init<const N: usize>() -> Substs1<{ (N) }> +fn zero_init<const N: usize>() -> Substs1<{{ N }}> where - [u8; { (N) }]: , + [u8; {{ N }}]: , { - Substs1([0; { (N) }]) + Substs1([0; {{ N }}]) } -struct Substs1<const N: usize>([u8; { (N) }]) +struct Substs1<const N: usize>([u8; {{ N }}]) where - [(); { (N) }]: ; + [(); {{ N }}]: ; -fn substs2<const M: usize>() -> Substs1<{ (M) }> { - zero_init::<{ (M) }>() +fn substs2<const M: usize>() -> Substs1<{{ M }}> { + zero_init::<{{ M }}>() } -fn substs3<const L: usize>() -> Substs1<{ (L) }> { - substs2::<{ (L) }>() +fn substs3<const L: usize>() -> Substs1<{{ L }}> { + substs2::<{{ L }}>() } fn main() { assert_eq!(substs3::<2>().0, [0; 2]); } -// Test that the implicit ``{ (L) }`` bound on ``substs3`` satisfies the -// ``{ (N) }`` bound on ``Substs1`` +// Test that the implicit ``{{ L }}`` bound on ``substs3`` satisfies the +// ``{{ N }}`` bound on ``Substs1`` +// FIXME(generic_const_exprs): come up with a less brittle test for this using assoc consts +// once normalization is implemented for them. diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs index 85345d65c..b22cab7c7 100644 --- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs @@ -1,7 +1,7 @@ -// check-pass +// known-bug: #110395 // known-bug: #97156 -#![feature(const_type_id, generic_const_exprs)] +#![feature(const_type_id, const_trait_impl, generic_const_exprs)] #![allow(incomplete_features)] use std::any::TypeId; @@ -26,7 +26,10 @@ impl<T: 'static> AssocCt for T { trait WithAssoc<U> { type Assoc; } -impl<T: 'static> WithAssoc<()> for T where [(); <T as AssocCt>::ASSOC]: { +impl<T: 'static> WithAssoc<()> for T +where + [(); <T as AssocCt>::ASSOC]:, +{ type Assoc = [u8; <T as AssocCt>::ASSOC]; } @@ -38,7 +41,6 @@ where x } - fn unsound<T>(x: <One as WithAssoc<T>>::Assoc) -> <Two as WithAssoc<T>>::Assoc where One: WithAssoc<T>, diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr new file mode 100644 index 000000000..8cbd12654 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `TypeId` in a pattern, `TypeId` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/typeid-equality-by-subtyping.rs:18:9 + | +LL | WHAT_A_TYPE => 0, + | ^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs index c0404d35b..ae9207cf8 100644 --- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs +++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(generic_const_exprs, adt_const_params, const_trait_impl)] #![allow(incomplete_features)] @@ -26,7 +28,6 @@ struct Evaluatable2<const N: usize>; fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) { bar2::<{ std::ops::Add::add(N, N) }>(); - //~^ error: unconstrained generic constant // FIXME(generic_const_exprs) make this not an error } diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr index d18c7916f..7f28771ce 100644 --- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr @@ -1,10 +1,11 @@ -error: unconstrained generic constant - --> $DIR/unify-op-with-fn-call.rs:28:12 +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/unify-op-with-fn-call.rs:10:12 | -LL | bar2::<{ std::ops::Add::add(N, N) }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl const std::ops::Add for Foo { + | ^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:` + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs new file mode 100644 index 000000000..96aeec77c --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn foo() -> [(); { + let a: &'a (); + //~^ ERROR: use of undeclared lifetime name `'a` + 10_usize +}] { + loop {} +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr new file mode 100644 index 000000000..976f03706 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr @@ -0,0 +1,11 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/unresolved_lifetimes_error.rs:5:13 + | +LL | fn foo() -> [(); { + | - help: consider introducing lifetime `'a` here: `<'a>` +LL | let a: &'a (); + | ^^ undeclared lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/const-generics/issue-46511.rs b/tests/ui/const-generics/issue-46511.rs index 71c50e2f3..78baba818 100644 --- a/tests/ui/const-generics/issue-46511.rs +++ b/tests/ui/const-generics/issue-46511.rs @@ -2,7 +2,7 @@ struct Foo<'a> //~ ERROR parameter `'a` is never used [E0392] { - _a: [u8; std::mem::size_of::<&'a mut u8>()] //~ ERROR a non-static lifetime is not allowed in a `const` + _a: [u8; std::mem::size_of::<&'a mut u8>()] //~ ERROR generic parameters may not be used in const operations } pub fn main() {} diff --git a/tests/ui/const-generics/issue-46511.stderr b/tests/ui/const-generics/issue-46511.stderr index b21afa56d..58c93a1fa 100644 --- a/tests/ui/const-generics/issue-46511.stderr +++ b/tests/ui/const-generics/issue-46511.stderr @@ -1,11 +1,11 @@ -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/issue-46511.rs:5:35 | LL | _a: [u8; std::mem::size_of::<&'a mut u8>()] - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error[E0392]: parameter `'a` is never used --> $DIR/issue-46511.rs:3:12 @@ -17,5 +17,4 @@ LL | struct Foo<'a> error: aborting due to 2 previous errors -Some errors have detailed explanations: E0392, E0658. -For more information about an error, try `rustc --explain E0392`. +For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/const-generics/issues/issue-105821.rs b/tests/ui/const-generics/issues/issue-105821.rs index cba2e22c4..6cfabb65e 100644 --- a/tests/ui/const-generics/issues/issue-105821.rs +++ b/tests/ui/const-generics/issues/issue-105821.rs @@ -1,7 +1,7 @@ // check-pass #![allow(incomplete_features)] -#![feature(adt_const_params, const_ptr_read, generic_const_exprs)] +#![feature(adt_const_params, generic_const_exprs)] #![allow(dead_code)] const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1] diff --git a/tests/ui/const-generics/issues/issue-56445-1.full.stderr b/tests/ui/const-generics/issues/issue-56445-1.full.stderr index 179643a75..5fc0ec260 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.full.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.full.stderr @@ -1,11 +1,11 @@ -error[E0771]: use of non-static lifetime `'a` in const generic +error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-56445-1.rs:9:26 | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^ + | ^^ the type must not depend on the parameter `'a` | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + = note: lifetime parameters may not be used in the type of const parameters error: aborting due to previous error -For more information about this error, try `rustc --explain E0771`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr index 9f8801341..71a7051f2 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr @@ -1,10 +1,10 @@ -error[E0771]: use of non-static lifetime `'a` in const generic +error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-56445-1.rs:9:26 | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^ + | ^^ the type must not depend on the parameter `'a` | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + = note: lifetime parameters may not be used in the type of const parameters error: `&str` is forbidden as the type of a const generic parameter --> $DIR/issue-56445-1.rs:9:25 @@ -17,4 +17,4 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0771`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-56445-1.rs b/tests/ui/const-generics/issues/issue-56445-1.rs index 0741c3796..d862bf24a 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.rs +++ b/tests/ui/const-generics/issues/issue-56445-1.rs @@ -7,7 +7,7 @@ use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); -//~^ ERROR: use of non-static lifetime `'a` in const generic +//~^ ERROR: the type of const parameters must not depend on other generic parameters //[min]~| ERROR: `&str` is forbidden as the type of a const generic parameter impl Bug<'_, ""> {} diff --git a/tests/ui/const-generics/issues/issue-62878.full.stderr b/tests/ui/const-generics/issues/issue-62878.full.stderr index 3a2b291d7..c658b5a6e 100644 --- a/tests/ui/const-generics/issues/issue-62878.full.stderr +++ b/tests/ui/const-generics/issues/issue-62878.full.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index 5a721720d..9c0e5179c 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` + | + = note: const parameters may not be used in the type of const parameters error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/issue-62878.rs:5:33 diff --git a/tests/ui/const-generics/issues/issue-71169.full.stderr b/tests/ui/const-generics/issues/issue-71169.full.stderr index 1f5880f36..ccdfbbd54 100644 --- a/tests/ui/const-generics/issues/issue-71169.full.stderr +++ b/tests/ui/const-generics/issues/issue-71169.full.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` + | + = note: const parameters may not be used in the type of const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index 998b16a79..ebfb24bec 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` + | + = note: const parameters may not be used in the type of const parameters error: `[u8; LEN]` is forbidden as the type of a const generic parameter --> $DIR/issue-71169.rs:5:38 diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr index e17cf96aa..962eaf75b 100644 --- a/tests/ui/const-generics/issues/issue-71381.full.stderr +++ b/tests/ui/const-generics/issues/issue-71381.full.stderr @@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` + | + = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` + | + = note: type parameters may not be used in the type of const parameters error[E0741]: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:14:61 diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index 3950317b3..e1e140071 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` + | + = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` + | + = note: type parameters may not be used in the type of const parameters error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:14:61 diff --git a/tests/ui/const-generics/issues/issue-71611.full.stderr b/tests/ui/const-generics/issues/issue-71611.full.stderr index 656aa29e1..e109459f2 100644 --- a/tests/ui/const-generics/issues/issue-71611.full.stderr +++ b/tests/ui/const-generics/issues/issue-71611.full.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` + | + = note: type parameters may not be used in the type of const parameters error[E0741]: using function pointers as const generic parameters is forbidden --> $DIR/issue-71611.rs:5:21 diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr index 01a85b745..b33d7cf98 100644 --- a/tests/ui/const-generics/issues/issue-71611.min.stderr +++ b/tests/ui/const-generics/issues/issue-71611.min.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` + | + = note: type parameters may not be used in the type of const parameters error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71611.rs:5:21 diff --git a/tests/ui/const-generics/issues/issue-77357.rs b/tests/ui/const-generics/issues/issue-77357.rs deleted file mode 100644 index 3cb8d3846..000000000 --- a/tests/ui/const-generics/issues/issue-77357.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -trait MyTrait<T> {} - -fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { - //~^ ERROR overly complex generic constant - todo!() -} - -fn main() {} diff --git a/tests/ui/const-generics/issues/issue-77357.stderr b/tests/ui/const-generics/issues/issue-77357.stderr deleted file mode 100644 index 68b35a38b..000000000 --- a/tests/ui/const-generics/issues/issue-77357.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: overly complex generic constant - --> $DIR/issue-77357.rs:6:46 - | -LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constants - | - = help: consider moving this anonymous constant into a `const` function - = note: this operation may be supported in the future - -error: aborting due to previous error - diff --git a/tests/ui/const-generics/issues/issue-83993.rs b/tests/ui/const-generics/issues/issue-83993.rs deleted file mode 100644 index f2f05d952..000000000 --- a/tests/ui/const-generics/issues/issue-83993.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass - -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -fn bug<'a>() -where - for<'b> [(); { - let x: &'b (); - 0 - }]: -{} - -fn main() {} diff --git a/tests/ui/const-generics/issues/issue-88997.stderr b/tests/ui/const-generics/issues/issue-88997.stderr index 505ba0da2..b49d52dd0 100644 --- a/tests/ui/const-generics/issues/issue-88997.stderr +++ b/tests/ui/const-generics/issues/issue-88997.stderr @@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T) | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-88997.rs:8:54 | LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T) | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-90364.stderr b/tests/ui/const-generics/issues/issue-90364.stderr index e85bd136e..23424d7b9 100644 --- a/tests/ui/const-generics/issues/issue-90364.stderr +++ b/tests/ui/const-generics/issues/issue-90364.stderr @@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Foo<T, const H: T>(T) | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.rs b/tests/ui/const-generics/late-bound-vars/in_closure.rs index 5294cc3b5..00fb535f0 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.rs +++ b/tests/ui/const-generics/late-bound-vars/in_closure.rs @@ -1,4 +1,22 @@ -// run-pass +// failure-status: 101 +// known-bug: unknown +// error-pattern:internal compiler error +// normalize-stderr-test "internal compiler error.*" -> "" +// normalize-stderr-test "DefId\([^)]*\)" -> "..." +// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "stack backtrace:\n" -> "" +// normalize-stderr-test "\s\d{1,}: .*\n" -> "" +// normalize-stderr-test "\s at .*\n" -> "" +// normalize-stderr-test ".*note: Some details.*\n" -> "" +// normalize-stderr-test "\n\n[ ]*\n" -> "" +// normalize-stderr-test "compiler/.*: projection" -> "projection" +// this should run-pass + #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.stderr b/tests/ui/const-generics/late-bound-vars/in_closure.stderr new file mode 100644 index 000000000..557fbea2e --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/in_closure.stderr @@ -0,0 +1,13 @@ +error: query stack during panic: +#0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}` +#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}` +#2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE +#3 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` +#4 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` +#5 [eval_to_valtree] evaluating type-level constant +#6 [typeck] type-checking `test` +#7 [used_trait_imports] finding used_trait_imports `test` +#8 [analysis] running analysis passes on this crate +end of query stack +error: aborting due to previous error + diff --git a/tests/ui/const-generics/late-bound-vars/simple.rs b/tests/ui/const-generics/late-bound-vars/simple.rs index 6da5395ef..5d19aaf0b 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.rs +++ b/tests/ui/const-generics/late-bound-vars/simple.rs @@ -1,4 +1,21 @@ -// run-pass +// failure-status: 101 +// known-bug: unknown +// error-pattern:internal compiler error +// normalize-stderr-test "internal compiler error.*" -> "" +// normalize-stderr-test "DefId\([^)]*\)" -> "..." +// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "thread.*panicked.*\n" -> "" +// normalize-stderr-test "stack backtrace:\n" -> "" +// normalize-stderr-test "\s\d{1,}: .*\n" -> "" +// normalize-stderr-test "\s at .*\n" -> "" +// normalize-stderr-test ".*note: Some details.*\n" -> "" +// normalize-stderr-test "\n\n[ ]*\n" -> "" +// normalize-stderr-test "compiler/.*: projection" -> "projection" + #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/simple.stderr b/tests/ui/const-generics/late-bound-vars/simple.stderr new file mode 100644 index 000000000..c0568f5a5 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/simple.stderr @@ -0,0 +1,13 @@ +error: query stack during panic: +#0 [mir_borrowck] borrow-checking `test::{constant#1}` +#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{constant#1}` +#2 [mir_for_ctfe] caching mir of `test::{constant#1}` for CTFE +#3 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}` +#4 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}` +#5 [eval_to_valtree] evaluating type-level constant +#6 [typeck] type-checking `test` +#7 [used_trait_imports] finding used_trait_imports `test` +#8 [analysis] running analysis passes on this crate +end of query stack +error: aborting due to previous error + diff --git a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs index 6215b7d93..86f2bc9c7 100644 --- a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs +++ b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs @@ -5,7 +5,7 @@ fn test<const N: usize>() {} fn issue_75323_and_74447_1<'a>() -> &'a () { test::<{ let _: &'a (); 3 },>(); - //~^ ERROR a non-static lifetime is not allowed in a `const` + //~^ ERROR generic parameters may not be used in const operations &() } @@ -19,7 +19,7 @@ fn issue_75323_and_74447_3() { fn issue_73375<'a>() { [(); (|_: &'a u8| (), 0).1]; - //~^ ERROR a non-static lifetime is not allowed in a `const` + //~^ ERROR generic parameters may not be used in const operations } fn main() {} diff --git a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr index 5f641b070..7726016eb 100644 --- a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr +++ b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr @@ -1,21 +1,20 @@ -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/forbid-non-static-lifetimes.rs:7:22 | LL | test::<{ let _: &'a (); 3 },>(); - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/forbid-non-static-lifetimes.rs:21:16 | LL | [(); (|_: &'a u8| (), 0).1]; - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/const-generics/nested-type.rs b/tests/ui/const-generics/nested-type.rs index 5240f5c3b..ff9501806 100644 --- a/tests/ui/const-generics/nested-type.rs +++ b/tests/ui/const-generics/nested-type.rs @@ -3,7 +3,7 @@ #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] -struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden +struct Foo<const N: [u8; { struct Foo<const N: usize>; impl<const N: usize> Foo<N> { @@ -15,5 +15,9 @@ struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden Foo::<17>::value() //~^ ERROR cannot call non-const fn }]>; +//[min]~^^^^^^^^^^^^ ERROR `[u8; { + +// N.B. it is important that the comment above is not inside the array length, +// otherwise it may check for itself, instead of the actual error fn main() {} diff --git a/tests/ui/const-generics/occurs-check/unused-substs-2.rs b/tests/ui/const-generics/occurs-check/unused-substs-2.rs index 9b1212694..84e24d1a3 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-2.rs +++ b/tests/ui/const-generics/occurs-check/unused-substs-2.rs @@ -1,9 +1,9 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] -// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst. +// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(?1t)` subst. // -// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an +// If we are then able to infer `ty::Infer(TyVar(?1t) := Ty<ct>` we introduced an // artificial inference cycle. struct Foo<const N: usize>; @@ -20,8 +20,8 @@ impl<T> Bind<T> for Foo<{ 6 + 1 }> { fn main() { let (mut t, foo) = Foo::bind(); - // `t` is `ty::Infer(TyVar(_#1t))` - // `foo` contains `ty::Infer(TyVar(_#1t))` in its substs + // `t` is `ty::Infer(TyVar(?1t))` + // `foo` contains `ty::Infer(TyVar(?1t))` in its substs t = foo; //~^ ERROR mismatched types //~| NOTE cyclic type diff --git a/tests/ui/const-generics/occurs-check/unused-substs-3.rs b/tests/ui/const-generics/occurs-check/unused-substs-3.rs index d5aeab47e..6db18d587 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-3.rs +++ b/tests/ui/const-generics/occurs-check/unused-substs-3.rs @@ -1,9 +1,9 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] -// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst. +// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(?1t)` subst. // -// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an +// If we are then able to infer `ty::Infer(TyVar(?1t) := Ty<ct>` we introduced an // artificial inference cycle. fn bind<T>() -> (T, [u8; 6 + 1]) { todo!() @@ -11,8 +11,8 @@ fn bind<T>() -> (T, [u8; 6 + 1]) { fn main() { let (mut t, foo) = bind(); - // `t` is `ty::Infer(TyVar(_#1t))` - // `foo` contains `ty::Infer(TyVar(_#1t))` in its substs + // `t` is `ty::Infer(TyVar(?1t))` + // `foo` contains `ty::Infer(TyVar(?1t))` in its substs t = foo; //~^ ERROR mismatched types //~| NOTE cyclic type diff --git a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs index 3018439af..de710b0e3 100644 --- a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs +++ b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs @@ -2,7 +2,7 @@ struct Foo< 'a, const N: usize = { let x: &'a (); - //~^ ERROR use of non-static lifetime `'a` in const generic + //~^ ERROR generic parameters may not be used in const operations 3 }, >(&'a ()); diff --git a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr index 9d9555d3f..6b0d18f19 100644 --- a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr +++ b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr @@ -1,11 +1,11 @@ -error[E0771]: use of non-static lifetime `'a` in const generic +error: generic parameters may not be used in const operations --> $DIR/outer-lifetime-in-const-generic-default.rs:4:17 | LL | let x: &'a (); - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to previous error -For more information about this error, try `rustc --explain E0771`. diff --git a/tests/ui/const-generics/sneaky-array-repeat-expr.rs b/tests/ui/const-generics/sneaky-array-repeat-expr.rs index b147c246b..cd1607608 100644 --- a/tests/ui/const-generics/sneaky-array-repeat-expr.rs +++ b/tests/ui/const-generics/sneaky-array-repeat-expr.rs @@ -10,6 +10,7 @@ impl<const N: usize> Trait<N> for () { pub const fn foo<const N: usize>() where (): Trait<N> { let bar = [(); <()>::Assoc]; //~^ error: constant expression depends on a generic parameter + //~| error: constant expression depends on a generic parameter } trait Trait2<const N: usize> { @@ -24,6 +25,7 @@ impl<const N: usize> Trait2<N> for () { pub const fn foo2<const N: usize>() where (): Trait2<N> { let bar2 = [(); <()>::Assoc2]; //~^ error: constant expression depends on a generic parameter + //~| error: constant expression depends on a generic parameter } fn main() { diff --git a/tests/ui/const-generics/sneaky-array-repeat-expr.stderr b/tests/ui/const-generics/sneaky-array-repeat-expr.stderr index 5c77375d3..e532f27a1 100644 --- a/tests/ui/const-generics/sneaky-array-repeat-expr.stderr +++ b/tests/ui/const-generics/sneaky-array-repeat-expr.stderr @@ -7,12 +7,28 @@ LL | let bar = [(); <()>::Assoc]; = note: this may fail depending on what value the parameter takes error: constant expression depends on a generic parameter - --> $DIR/sneaky-array-repeat-expr.rs:25:21 + --> $DIR/sneaky-array-repeat-expr.rs:11:15 + | +LL | let bar = [(); <()>::Assoc]; + | ^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/sneaky-array-repeat-expr.rs:26:21 | LL | let bar2 = [(); <()>::Assoc2]; | ^^^^^^^^^^^^ | = note: this may fail depending on what value the parameter takes -error: aborting due to 2 previous errors +error: constant expression depends on a generic parameter + --> $DIR/sneaky-array-repeat-expr.rs:26:16 + | +LL | let bar2 = [(); <()>::Assoc2]; + | ^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr index 41b098135..3d1197afd 100644 --- a/tests/ui/const-generics/transmute-fail.stderr +++ b/tests/ui/const-generics/transmute-fail.stderr @@ -4,8 +4,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | std::mem::transmute(v) | ^^^^^^^^^^^^^^^^^^^ | - = note: source type: `[[u32; H+1]; W]` (generic size [const expr]) - = note: target type: `[[u32; W+1]; H]` (generic size [const expr]) + = note: source type: `[[u32; H+1]; W]` (generic size {const expr}) + = note: target type: `[[u32; W+1]; H]` (generic size {const expr}) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> $DIR/transmute-fail.rs:16:5 @@ -34,8 +34,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | std::mem::transmute(v) | ^^^^^^^^^^^^^^^^^^^ | - = note: source type: `[[u32; H]; W]` (generic size [const expr]) - = note: target type: `[u32; W * H * H]` (generic size [const expr]) + = note: source type: `[[u32; H]; W]` (generic size {const expr}) + = note: target type: `[u32; W * H * H]` (generic size {const expr}) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> $DIR/transmute-fail.rs:30:5 diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr b/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr new file mode 100644 index 000000000..2f03b8e1f --- /dev/null +++ b/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr @@ -0,0 +1,34 @@ +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:7:15 + | +LL | Variant = N, + | ^ cannot perform const operation using `N` + | + = note: const parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:12:17 + | +LL | Variant = { N + 1 }, + | ^ cannot perform const operation using `N` + | + = note: const parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:18:37 + | +LL | Variant = { std::mem::size_of::<T>() as isize }, + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:25:17 + | +LL | let a: &'a (); + | ^^ cannot perform const operation using `'a` + | + = note: lifetime parameters may not be used in enum discriminant values + +error: aborting due to 4 previous errors + diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr b/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr new file mode 100644 index 000000000..2f03b8e1f --- /dev/null +++ b/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr @@ -0,0 +1,34 @@ +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:7:15 + | +LL | Variant = N, + | ^ cannot perform const operation using `N` + | + = note: const parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:12:17 + | +LL | Variant = { N + 1 }, + | ^ cannot perform const operation using `N` + | + = note: const parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:18:37 + | +LL | Variant = { std::mem::size_of::<T>() as isize }, + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in enum discriminant values + +error: generic parameters may not be used in enum discriminant values + --> $DIR/variant-discrimiant-no-generics.rs:25:17 + | +LL | let a: &'a (); + | ^^ cannot perform const operation using `'a` + | + = note: lifetime parameters may not be used in enum discriminant values + +error: aborting due to 4 previous errors + diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.rs b/tests/ui/const-generics/variant-discrimiant-no-generics.rs new file mode 100644 index 000000000..e286aa9a6 --- /dev/null +++ b/tests/ui/const-generics/variant-discrimiant-no-generics.rs @@ -0,0 +1,32 @@ +// revisions: full min + +#![cfg_attr(full, feature(generic_const_exprs))] +#![cfg_attr(full, allow(incomplete_features))] + +enum Foo<const N: isize> { + Variant = N, + //~^ ERROR: generic parameters may not be used in enum discriminant values +} + +enum Owo<const N: isize> { + Variant = { N + 1 }, + //~^ ERROR: generic parameters may not be used in enum discriminant values +} + +#[repr(isize)] +enum Bar<T> { + Variant = { std::mem::size_of::<T>() as isize }, + Other(T), //~^ ERROR: generic parameters may not be used in enum discriminant values +} + +#[repr(isize)] +enum UwU<'a> { + Variant = { + let a: &'a (); + //~^ ERROR: generic parameters may not be used in enum discriminant values + 10_isize + }, + Other(&'a ()), +} + +fn main() {} diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index b42361872..817cfb0ac 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -131,8 +131,6 @@ error[E0080]: could not evaluate static initializer | = note: out-of-bounds pointer arithmetic: allocN has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds | -note: inside `ptr::const_ptr::<impl *const u32>::offset` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `ptr::const_ptr::<impl *const u32>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `R2` @@ -195,8 +193,6 @@ error[E0080]: could not evaluate static initializer | = note: out-of-bounds pointer arithmetic: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds | -note: inside `ptr::const_ptr::<impl *const u64>::offset` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `ptr::const_ptr::<impl *const u64>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `R8` diff --git a/tests/ui/const-ptr/out_of_bounds_read.rs b/tests/ui/const-ptr/out_of_bounds_read.rs index 9dd669180..a371aa93c 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.rs +++ b/tests/ui/const-ptr/out_of_bounds_read.rs @@ -1,7 +1,5 @@ // error-pattern: evaluation of constant value failed -#![feature(const_ptr_read)] - fn main() { use std::ptr; diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 89536f53f..c5c0a1cde 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -6,7 +6,7 @@ error[E0080]: evaluation of constant value failed note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `_READ` - --> $DIR/out_of_bounds_read.rs:12:33 + --> $DIR/out_of_bounds_read.rs:10:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ note: inside `std::ptr::read::<u32>` note: inside `ptr::const_ptr::<impl *const u32>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `_CONST_READ` - --> $DIR/out_of_bounds_read.rs:13:39 + --> $DIR/out_of_bounds_read.rs:11:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ note: inside `std::ptr::read::<u32>` note: inside `ptr::mut_ptr::<impl *mut u32>::read` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL note: inside `_MUT_READ` - --> $DIR/out_of_bounds_read.rs:14:37 + --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-prop-ice.rs b/tests/ui/const_prop/const-prop-ice.rs index 5bffe0206..5bffe0206 100644 --- a/tests/ui/consts/const-prop-ice.rs +++ b/tests/ui/const_prop/const-prop-ice.rs diff --git a/tests/ui/consts/const-prop-ice.stderr b/tests/ui/const_prop/const-prop-ice.stderr index 3bcf2b2de..3bcf2b2de 100644 --- a/tests/ui/consts/const-prop-ice.stderr +++ b/tests/ui/const_prop/const-prop-ice.stderr diff --git a/tests/ui/consts/const-prop-ice2.rs b/tests/ui/const_prop/const-prop-ice2.rs index d533e394c..d533e394c 100644 --- a/tests/ui/consts/const-prop-ice2.rs +++ b/tests/ui/const_prop/const-prop-ice2.rs diff --git a/tests/ui/consts/const-prop-ice2.stderr b/tests/ui/const_prop/const-prop-ice2.stderr index 2b65ffc2d..2b65ffc2d 100644 --- a/tests/ui/consts/const-prop-ice2.stderr +++ b/tests/ui/const_prop/const-prop-ice2.stderr diff --git a/tests/ui/consts/const-prop-ice3.rs b/tests/ui/const_prop/const-prop-ice3.rs index 8ab011661..8ab011661 100644 --- a/tests/ui/consts/const-prop-ice3.rs +++ b/tests/ui/const_prop/const-prop-ice3.rs diff --git a/tests/ui/consts/const-prop-overflowing-casts.rs b/tests/ui/const_prop/const-prop-overflowing-casts.rs index 8cc5b9825..8cc5b9825 100644 --- a/tests/ui/consts/const-prop-overflowing-casts.rs +++ b/tests/ui/const_prop/const-prop-overflowing-casts.rs diff --git a/tests/ui/consts/const-prop-read-static-in-const.rs b/tests/ui/const_prop/const-prop-read-static-in-const.rs index 214262059..214262059 100644 --- a/tests/ui/consts/const-prop-read-static-in-const.rs +++ b/tests/ui/const_prop/const-prop-read-static-in-const.rs diff --git a/tests/ui/consts/const-prop-read-static-in-const.stderr b/tests/ui/const_prop/const-prop-read-static-in-const.stderr index 793da6285..793da6285 100644 --- a/tests/ui/consts/const-prop-read-static-in-const.stderr +++ b/tests/ui/const_prop/const-prop-read-static-in-const.stderr diff --git a/tests/ui/const_prop/unsized-local-ice.rs b/tests/ui/const_prop/unsized-local-ice.rs new file mode 100644 index 000000000..c725b3238 --- /dev/null +++ b/tests/ui/const_prop/unsized-local-ice.rs @@ -0,0 +1,9 @@ +// build-pass +//! Regression test for <https://github.com/rust-lang/rust/issues/68538>. +#![feature(unsized_fn_params)] + +pub fn take_unsized_slice(s: [u8]) { + s[0]; +} + +fn main() {} diff --git a/tests/ui/consts/auxiliary/external_macro.rs b/tests/ui/consts/auxiliary/external_macro.rs index d260634c9..fea24703d 100644 --- a/tests/ui/consts/auxiliary/external_macro.rs +++ b/tests/ui/consts/auxiliary/external_macro.rs @@ -9,6 +9,6 @@ macro_rules! static_assert { ($test:expr) => { #[allow(dead_code)] - const _: () = [()][!($test: bool) as usize]; + const _: () = [()][!($test) as usize]; } } diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index 42aa0216b..3704a1a5a 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -11,15 +11,9 @@ impl Drop for UnconstDrop { fn drop(&mut self) {} } -struct NonDrop; - -impl !Drop for NonDrop {} - fn main() { const { f(UnconstDrop); //~^ ERROR can't drop - f(NonDrop); - //~^ ERROR can't drop } } diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index fef4914fa..caf24e7af 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,5 +1,5 @@ error[E0277]: can't drop `UnconstDrop` in const contexts - --> $DIR/const-block-const-bound.rs:20:9 + --> $DIR/const-block-const-bound.rs:16:9 | LL | f(UnconstDrop); | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` @@ -12,20 +12,6 @@ LL | &f(UnconstDrop); LL | &mut f(UnconstDrop); | ++++ -error[E0277]: can't drop `NonDrop` in const contexts - --> $DIR/const-block-const-bound.rs:22:9 - | -LL | f(NonDrop); - | ^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` - | - = note: the trait bound `NonDrop: ~const Destruct` is not satisfied -help: consider borrowing here - | -LL | &f(NonDrop); - | + -LL | &mut f(NonDrop); - | ++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr index f19917001..05f33c339 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | = [0; (i8::MAX + 1u8) as usize]; | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` in const contexts +error[E0277]: cannot add `u8` to `i8` --> $DIR/const-eval-overflow-3b.rs:16:20 | LL | = [0; (i8::MAX + 1u8) as usize]; | ^ no implementation for `i8 + u8` | - = help: the trait `~const Add<u8>` is not implemented for `i8` + = help: the trait `Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a i8 as Add<i8>> <&i8 as Add<&i8>> diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr index 1f8e40231..d019f5920 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -4,13 +4,13 @@ error[E0308]: mismatched types LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` -error[E0277]: cannot add `u8` to `i8` in const contexts +error[E0277]: cannot add `u8` to `i8` --> $DIR/const-eval-overflow-4b.rs:9:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` | - = help: the trait `~const Add<u8>` is not implemented for `i8` + = help: the trait `Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: <&'a i8 as Add<i8>> <&i8 as Add<&i8>> diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops.rs b/tests/ui/consts/const-eval/const_raw_ptr_ops.rs index cd7c98007..432a05756 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops.rs +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops.rs @@ -1,6 +1,6 @@ fn main() {} // unconst and bad, will thus error in miri -const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare +const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR pointers cannot // unconst and bad, will thus error in miri -const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare +const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR pointers cannot diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr index 12244450e..1f5bca273 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -1,29 +1,18 @@ -error[E0277]: can't compare `*const i32` with `_` in const contexts - --> $DIR/const_raw_ptr_ops.rs:4:43 +error: pointers cannot be reliably compared during const eval + --> $DIR/const_raw_ptr_ops.rs:4:26 | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; - | ^^ no implementation for `*const i32 == _` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: the trait `~const PartialEq<_>` is not implemented for `*const i32` -note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const` - --> $DIR/const_raw_ptr_ops.rs:4:43 - | -LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; - | ^^ + = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information -error[E0277]: can't compare `*const i32` with `_` in const contexts - --> $DIR/const_raw_ptr_ops.rs:6:44 +error: pointers cannot be reliably compared during const eval + --> $DIR/const_raw_ptr_ops.rs:6:27 | LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; - | ^^ no implementation for `*const i32 == _` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: the trait `~const PartialEq<_>` is not implemented for `*const i32` -note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const` - --> $DIR/const_raw_ptr_ops.rs:6:44 - | -LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; - | ^^ + = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 70a1abb0a..434b07443 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -43,62 +43,6 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used - --> $DIR/format.rs:2:12 - | -LL | panic!("{:?}", 0); - | ^^^^^^ - -note: erroneous constant used - --> $DIR/format.rs:2:12 - | -LL | panic!("{:?}", 0); - | ^^^^^^ - -note: erroneous constant used - --> $DIR/format.rs:2:20 - | -LL | panic!("{:?}", 0); - | ^ - | - = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: erroneous constant used - --> $DIR/format.rs:2:20 - | -LL | panic!("{:?}", 0); - | ^ - | - = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: erroneous constant used - --> $DIR/format.rs:8:14 - | -LL | println!("{:?}", 0); - | ^^^^^^ - -note: erroneous constant used - --> $DIR/format.rs:8:14 - | -LL | println!("{:?}", 0); - | ^^^^^^ - -note: erroneous constant used - --> $DIR/format.rs:8:22 - | -LL | println!("{:?}", 0); - | ^ - | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: erroneous constant used - --> $DIR/format.rs:8:22 - | -LL | println!("{:?}", 0); - | ^ - | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-eval/generic-slice.stderr b/tests/ui/consts/const-eval/generic-slice.stderr index c38088df4..ff1dc29cc 100644 --- a/tests/ui/consts/const-eval/generic-slice.stderr +++ b/tests/ui/consts/const-eval/generic-slice.stderr @@ -4,6 +4,8 @@ error[E0597]: `x` does not live long enough LL | impl<'a, T: 'static> Generic<'a, T> { | -- lifetime `'a` defined here ... +LL | let x: &'static [T] = &[]; + | - binding `x` declared here LL | &x | ^^ | | @@ -16,6 +18,8 @@ LL | }; error[E0597]: `x` does not live long enough --> $DIR/generic-slice.rs:27:5 | +LL | let x: &[_] = &[]; + | - binding `x` declared here LL | &x | ^^ | | diff --git a/tests/ui/consts/const-eval/issue-100878.rs b/tests/ui/consts/const-eval/issue-100878.rs index 353ce5050..bd56f854c 100644 --- a/tests/ui/consts/const-eval/issue-100878.rs +++ b/tests/ui/consts/const-eval/issue-100878.rs @@ -1,6 +1,8 @@ // This checks that the const-eval ICE in issue #100878 does not recur. // // build-pass + +#[allow(arithmetic_overflow)] pub fn bitshift_data(data: [u8; 1]) -> u8 { data[0] << 8 } diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index a0f8dd097..a93b561e5 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -465,7 +465,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { - 00 10 00 00 00 00 00 00 │ ........ + 00 00 00 00 00 10 00 00 │ ........ } error[E0080]: it is undefined behavior to use this value @@ -476,7 +476,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { - 09 00 00 00 03 00 00 00 │ ........ + 03 00 00 00 09 00 00 00 │ ........ } error[E0080]: it is undefined behavior to use this value diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 9706f3ec2..a32d4863a 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -465,7 +465,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { - 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 │ ................ } error[E0080]: it is undefined behavior to use this value @@ -476,7 +476,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { - 09 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 │ ................ + 03 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 │ ................ } error[E0080]: it is undefined behavior to use this value diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 369e45194..a5d2ea014 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -3,7 +3,6 @@ // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" #![allow(invalid_value)] -#![feature(const_ptr_read)] use std::mem; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 080568b51..1d19dfff5 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:16:1 + --> $DIR/ub-ref-ptr.rs:15:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -10,7 +10,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:20:1 + --> $DIR/ub-ref-ptr.rs:19:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -21,7 +21,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:24:1 + --> $DIR/ub-ref-ptr.rs:23:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:27:1 + --> $DIR/ub-ref-ptr.rs:26:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:34:1 + --> $DIR/ub-ref-ptr.rs:33:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:37:39 + --> $DIR/ub-ref-ptr.rs:36:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant used - --> $DIR/ub-ref-ptr.rs:37:38 + --> $DIR/ub-ref-ptr.rs:36:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:40:86 + --> $DIR/ub-ref-ptr.rs:39:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant used - --> $DIR/ub-ref-ptr.rs:40:85 + --> $DIR/ub-ref-ptr.rs:39:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:43:1 + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:46:1 + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:49:41 + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:53:1 + --> $DIR/ub-ref-ptr.rs:52:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:55:38 + --> $DIR/ub-ref-ptr.rs:54:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:58:1 + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:60:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer @@ -158,7 +158,7 @@ note: inside `std::ptr::read::<u32>` note: inside `ptr::const_ptr::<impl *const u32>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `UNALIGNED_READ` - --> $DIR/ub-ref-ptr.rs:67:5 + --> $DIR/ub-ref-ptr.rs:66:5 | LL | ptr.read(); | ^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs index d9a74b4f3..ebc5543b3 100644 --- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(const_slice_index)] const A: [(); 5] = [(), (), (), (), ()]; diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr index 775e475df..403fb5e09 100644 --- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr @@ -1,18 +1,11 @@ -error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/slice/index.rs:LL:COL - | - = note: overflow executing `unchecked_sub` - | -note: inside `<std::ops::Range<usize> as SliceIndex<[()]>>::get_unchecked` - --> $SRC_DIR/core/src/slice/index.rs:LL:COL -note: inside `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` - --> $SRC_DIR/core/src/slice/mod.rs:LL:COL -note: inside `B` - --> $DIR/ub-slice-get-unchecked.rs:7:27 +error[E0015]: cannot call non-const fn `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants + --> $DIR/ub-slice-get-unchecked.rs:9:29 | LL | const B: &[()] = unsafe { A.get_unchecked(3..1) }; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-float-classify.rs b/tests/ui/consts/const-float-classify.rs index 74238d0dd..3a5d5bb46 100644 --- a/tests/ui/consts/const-float-classify.rs +++ b/tests/ui/consts/const-float-classify.rs @@ -8,11 +8,33 @@ // Don't promote const fn nop<T>(x: T) -> T { x } +// FIXME(const-hack): replace with PartialEq +#[const_trait] +trait MyEq<T> { + fn eq(self, b: T) -> bool; +} + +impl const MyEq<bool> for bool { + fn eq(self, b: bool) -> bool { + self == b + } +} + +impl const MyEq<NonDet> for bool { + fn eq(self, _: NonDet) -> bool { + true + } +} + +const fn eq<A: ~const MyEq<B>, B>(x: A, y: B) -> bool { + x.eq(y) +} + macro_rules! const_assert { ($a:expr, $b:expr) => { { - const _: () = assert!($a == $b); - assert_eq!(nop($a), nop($b)); + const _: () = assert!(eq($a, $b)); + assert!(eq(nop($a), nop($b))); } }; } @@ -47,15 +69,6 @@ macro_rules! suite_inner { #[derive(Debug)] struct NonDet; -impl const PartialEq<NonDet> for bool { - fn eq(&self, _: &NonDet) -> bool { - true - } - fn ne(&self, _: &NonDet) -> bool { - false - } -} - // The result of the `is_sign` methods are not checked for correctness, since LLVM does not // guarantee anything about the signedness of NaNs. See // https://github.com/rust-lang/rust/issues/55131. diff --git a/tests/ui/consts/const-fn-error.rs b/tests/ui/consts/const-fn-error.rs index dabbd58db..50b7ce1f8 100644 --- a/tests/ui/consts/const-fn-error.rs +++ b/tests/ui/consts/const-fn-error.rs @@ -7,7 +7,6 @@ const fn f(x: usize) -> usize { //~| ERROR `for` is not allowed in a `const fn` //~| ERROR mutable references are not allowed in constant functions //~| ERROR cannot call non-const fn - //~| ERROR the trait bound sum += i; } sum diff --git a/tests/ui/consts/const-fn-error.stderr b/tests/ui/consts/const-fn-error.stderr index 73d235d6a..f735b3d53 100644 --- a/tests/ui/consts/const-fn-error.stderr +++ b/tests/ui/consts/const-fn-error.stderr @@ -5,7 +5,7 @@ LL | / for i in 0..x { LL | | LL | | LL | | -... | +LL | | LL | | sum += i; LL | | } | |_____^ @@ -33,19 +33,6 @@ LL | for i in 0..x { = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<usize>: Iterator` is not satisfied - --> $DIR/const-fn-error.rs:5:14 - | -LL | for i in 0..x { - | ^^^^ `std::ops::Range<usize>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<usize>` -note: the trait `Iterator` is implemented for `std::ops::Range<usize>`, but that implementation is not `const` - --> $DIR/const-fn-error.rs:5:14 - | -LL | for i in 0..x { - | ^^^^ - error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions --> $DIR/const-fn-error.rs:5:14 | @@ -55,7 +42,7 @@ LL | for i in 0..x { = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0015, E0277, E0658. +Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-for.rs b/tests/ui/consts/const-for.rs index ff9c977f7..8db248535 100644 --- a/tests/ui/consts/const-for.rs +++ b/tests/ui/consts/const-for.rs @@ -5,7 +5,6 @@ const _: () = { for _ in 0..5 {} //~^ error: cannot call //~| error: cannot convert - //~| error: the trait bound }; fn main() {} diff --git a/tests/ui/consts/const-for.stderr b/tests/ui/consts/const-for.stderr index 64f2f603b..3fb9787c0 100644 --- a/tests/ui/consts/const-for.stderr +++ b/tests/ui/consts/const-for.stderr @@ -9,19 +9,6 @@ note: impl defined here, but it is not `const` = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<i32>: Iterator` is not satisfied - --> $DIR/const-for.rs:5:14 - | -LL | for _ in 0..5 {} - | ^^^^ `std::ops::Range<i32>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<i32>` -note: the trait `Iterator` is implemented for `std::ops::Range<i32>`, but that implementation is not `const` - --> $DIR/const-for.rs:5:14 - | -LL | for _ in 0..5 {} - | ^^^^ - error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants --> $DIR/const-for.rs:5:14 | @@ -31,7 +18,6 @@ LL | for _ in 0..5 {} = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-integer-bool-ops.rs b/tests/ui/consts/const-integer-bool-ops.rs index 4110ae3e4..35915a7a6 100644 --- a/tests/ui/consts/const-integer-bool-ops.rs +++ b/tests/ui/consts/const-integer-bool-ops.rs @@ -6,7 +6,6 @@ const X: usize = 42 && 39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR: [i32; X] = [99; 34]; -//~^ constant const X1: usize = 42 || 39; //~^ ERROR mismatched types @@ -16,7 +15,6 @@ const X1: usize = 42 || 39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR1: [i32; X1] = [99; 47]; -//~^ constant const X2: usize = -42 || -39; //~^ ERROR mismatched types @@ -26,7 +24,6 @@ const X2: usize = -42 || -39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR2: [i32; X2] = [99; 18446744073709551607]; -//~^ constant const X3: usize = -42 && -39; //~^ ERROR mismatched types @@ -36,43 +33,36 @@ const X3: usize = -42 && -39; //~| ERROR mismatched types //~| expected `usize`, found `bool` const ARR3: [i32; X3] = [99; 6]; -//~^ constant const Y: usize = 42.0 == 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR: [i32; Y] = [99; 1]; -//~^ constant const Y1: usize = 42.0 >= 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR1: [i32; Y1] = [99; 1]; -//~^ constant const Y2: usize = 42.0 <= 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR2: [i32; Y2] = [99; 1]; -//~^ constant const Y3: usize = 42.0 > 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR3: [i32; Y3] = [99; 0]; -//~^ constant const Y4: usize = 42.0 < 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR4: [i32; Y4] = [99; 0]; -//~^ constant const Y5: usize = 42.0 != 42.0; //~^ ERROR mismatched types //~| expected `usize`, found `bool` const ARRR5: [i32; Y5] = [99; 0]; -//~^ constant fn main() { let _ = ARR; diff --git a/tests/ui/consts/const-integer-bool-ops.stderr b/tests/ui/consts/const-integer-bool-ops.stderr index b5c3b22fd..4e503e5a5 100644 --- a/tests/ui/consts/const-integer-bool-ops.stderr +++ b/tests/ui/consts/const-integer-bool-ops.stderr @@ -16,156 +16,96 @@ error[E0308]: mismatched types LL | const X: usize = 42 && 39; | ^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:8:18 - | -LL | const ARR: [i32; X] = [99; 34]; - | ^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:11:19 + --> $DIR/const-integer-bool-ops.rs:10:19 | LL | const X1: usize = 42 || 39; | ^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:11:25 + --> $DIR/const-integer-bool-ops.rs:10:25 | LL | const X1: usize = 42 || 39; | ^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:11:19 + --> $DIR/const-integer-bool-ops.rs:10:19 | LL | const X1: usize = 42 || 39; | ^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:18:19 - | -LL | const ARR1: [i32; X1] = [99; 47]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:21:19 + --> $DIR/const-integer-bool-ops.rs:19:19 | LL | const X2: usize = -42 || -39; | ^^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:21:26 + --> $DIR/const-integer-bool-ops.rs:19:26 | LL | const X2: usize = -42 || -39; | ^^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:21:19 + --> $DIR/const-integer-bool-ops.rs:19:19 | LL | const X2: usize = -42 || -39; | ^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:28:19 - | -LL | const ARR2: [i32; X2] = [99; 18446744073709551607]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:31:19 + --> $DIR/const-integer-bool-ops.rs:28:19 | LL | const X3: usize = -42 && -39; | ^^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:31:26 + --> $DIR/const-integer-bool-ops.rs:28:26 | LL | const X3: usize = -42 && -39; | ^^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:31:19 + --> $DIR/const-integer-bool-ops.rs:28:19 | LL | const X3: usize = -42 && -39; | ^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:38:19 - | -LL | const ARR3: [i32; X3] = [99; 6]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:41:18 + --> $DIR/const-integer-bool-ops.rs:37:18 | LL | const Y: usize = 42.0 == 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:44:19 - | -LL | const ARRR: [i32; Y] = [99; 1]; - | ^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:47:19 + --> $DIR/const-integer-bool-ops.rs:42:19 | LL | const Y1: usize = 42.0 >= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:50:20 - | -LL | const ARRR1: [i32; Y1] = [99; 1]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:53:19 + --> $DIR/const-integer-bool-ops.rs:47:19 | LL | const Y2: usize = 42.0 <= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:56:20 - | -LL | const ARRR2: [i32; Y2] = [99; 1]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:59:19 + --> $DIR/const-integer-bool-ops.rs:52:19 | LL | const Y3: usize = 42.0 > 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:62:20 - | -LL | const ARRR3: [i32; Y3] = [99; 0]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:65:19 + --> $DIR/const-integer-bool-ops.rs:57:19 | LL | const Y4: usize = 42.0 < 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:68:20 - | -LL | const ARRR4: [i32; Y4] = [99; 0]; - | ^^ - error[E0308]: mismatched types - --> $DIR/const-integer-bool-ops.rs:71:19 + --> $DIR/const-integer-bool-ops.rs:62:19 | LL | const Y5: usize = 42.0 != 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` -note: erroneous constant used - --> $DIR/const-integer-bool-ops.rs:74:20 - | -LL | const ARRR5: [i32; Y5] = [99; 0]; - | ^^ - error: aborting due to 18 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/const-mut-refs/issue-76510.32bit.stderr b/tests/ui/consts/const-mut-refs/issue-76510.32bit.stderr index 109d15a8e..61b00be34 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.32bit.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.32bit.stderr @@ -19,12 +19,6 @@ error[E0596]: cannot borrow data in a `&` reference as mutable LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ cannot borrow as mutable -note: erroneous constant used - --> $DIR/issue-76510.rs:11:70 - | -LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - | ^ - error: aborting due to 3 previous errors Some errors have detailed explanations: E0596, E0658, E0764. diff --git a/tests/ui/consts/const-mut-refs/issue-76510.64bit.stderr b/tests/ui/consts/const-mut-refs/issue-76510.64bit.stderr index 109d15a8e..61b00be34 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.64bit.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.64bit.stderr @@ -19,12 +19,6 @@ error[E0596]: cannot borrow data in a `&` reference as mutable LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ cannot borrow as mutable -note: erroneous constant used - --> $DIR/issue-76510.rs:11:70 - | -LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - | ^ - error: aborting due to 3 previous errors Some errors have detailed explanations: E0596, E0658, E0764. diff --git a/tests/ui/consts/const-mut-refs/issue-76510.rs b/tests/ui/consts/const-mut-refs/issue-76510.rs index b853e2737..143d2fb6b 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.rs +++ b/tests/ui/consts/const-mut-refs/issue-76510.rs @@ -9,7 +9,6 @@ const S: &'static mut str = &mut " hello "; const fn trigger() -> [(); unsafe { let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); - //~^ constant 0 }] { [(); 0] diff --git a/tests/ui/consts/const-try.rs b/tests/ui/consts/const-try.rs index e199fd9ff..6b7ba8f1e 100644 --- a/tests/ui/consts/const-try.rs +++ b/tests/ui/consts/const-try.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 // Demonstrates what's needed to make use of `?` in const contexts. diff --git a/tests/ui/consts/const-try.stderr b/tests/ui/consts/const-try.stderr new file mode 100644 index 000000000..37014f9b8 --- /dev/null +++ b/tests/ui/consts/const-try.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` + --> $DIR/const-try.rs:15:12 + | +LL | impl const FromResidual<Error> for TryMe { + | ^^^^^^^^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `Try` which is not marked with `#[const_trait]` + --> $DIR/const-try.rs:21:12 + | +LL | impl const Try for TryMe { + | ^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: aborting due to 2 previous errors + diff --git a/tests/ui/consts/const-tup-index-span.rs b/tests/ui/consts/const-tup-index-span.rs index 18f4f59d3..e77d392e6 100644 --- a/tests/ui/consts/const-tup-index-span.rs +++ b/tests/ui/consts/const-tup-index-span.rs @@ -4,7 +4,6 @@ const TUP: (usize,) = 5usize << 64; //~^ ERROR mismatched types //~| expected `(usize,)`, found `usize` const ARR: [i32; TUP.0] = []; -//~^ constant fn main() { } diff --git a/tests/ui/consts/const-tup-index-span.stderr b/tests/ui/consts/const-tup-index-span.stderr index 65f0520f8..d5df0df95 100644 --- a/tests/ui/consts/const-tup-index-span.stderr +++ b/tests/ui/consts/const-tup-index-span.stderr @@ -11,12 +11,6 @@ help: use a trailing comma to create a tuple with one element LL | const TUP: (usize,) = (5usize << 64,); | + ++ -note: erroneous constant used - --> $DIR/const-tup-index-span.rs:6:18 - | -LL | const ARR: [i32; TUP.0] = []; - | ^^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/const_cmp_type_id.rs b/tests/ui/consts/const_cmp_type_id.rs index f10d1c24f..19cee2022 100644 --- a/tests/ui/consts/const_cmp_type_id.rs +++ b/tests/ui/consts/const_cmp_type_id.rs @@ -1,4 +1,4 @@ -// run-pass +// known-bug: #110395 #![feature(const_type_id)] #![feature(const_trait_impl)] diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr new file mode 100644 index 000000000..dc2c702d8 --- /dev/null +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -0,0 +1,74 @@ +error[E0277]: can't compare `TypeId` with `TypeId` in const contexts + --> $DIR/const_cmp_type_id.rs:8:13 + | +LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` + | + = help: the trait `~const PartialEq` is not implemented for `TypeId` +note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/const_cmp_type_id.rs:8:13 + | +LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/const_cmp_type_id.rs:8:13 + | +LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error[E0277]: can't compare `TypeId` with `TypeId` in const contexts + --> $DIR/const_cmp_type_id.rs:9:13 + | +LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` + | + = help: the trait `~const PartialEq` is not implemented for `TypeId` +note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/const_cmp_type_id.rs:9:13 + | +LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/const_cmp_type_id.rs:9:13 + | +LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error[E0277]: can't compare `TypeId` with `TypeId` in const contexts + --> $DIR/const_cmp_type_id.rs:10:22 + | +LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId` + | + = help: the trait `~const PartialOrd` is not implemented for `TypeId` +note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/const_cmp_type_id.rs:10:22 + | +LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constants + --> $DIR/const_cmp_type_id.rs:10:22 + | +LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const_forget.rs b/tests/ui/consts/const_forget.rs index ec7dde8c9..f06149f2c 100644 --- a/tests/ui/consts/const_forget.rs +++ b/tests/ui/consts/const_forget.rs @@ -1,5 +1,7 @@ // check-pass +#![allow(forgetting_copy_types)] + use std::mem::forget; const _: () = forget(0i32); diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs index e2f814988..6a3c93ce7 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -1,7 +1,6 @@ // revisions: no_flag with_flag // [no_flag] check-pass // [with_flag] compile-flags: -Zextra-const-ub-checks -#![feature(const_ptr_read)] use std::mem::transmute; diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index b2a5fd901..3970baefc 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:9:20 + --> $DIR/detect-extra-ub.rs:8:20 | LL | let _x: bool = transmute(3u8); | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:15:21 + --> $DIR/detect-extra-ub.rs:14:21 | LL | let _x: usize = transmute(&3u8); | ^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -14,7 +14,7 @@ LL | let _x: usize = transmute(&3u8); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:21:30 + --> $DIR/detect-extra-ub.rs:20:30 | LL | let _x: (usize, usize) = transmute(x); | ^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -23,7 +23,7 @@ LL | let _x: (usize, usize) = transmute(x); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:26:20 + --> $DIR/detect-extra-ub.rs:25:20 | LL | let _x: &u32 = transmute(&[0u8; 4]); | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) diff --git a/tests/ui/consts/fn_trait_refs.rs b/tests/ui/consts/fn_trait_refs.rs index b50749297..be11ac726 100644 --- a/tests/ui/consts/fn_trait_refs.rs +++ b/tests/ui/consts/fn_trait_refs.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(const_fn_trait_ref_impls)] #![feature(fn_traits)] diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr new file mode 100644 index 000000000..bfebf6670 --- /dev/null +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -0,0 +1,15 @@ +error[E0635]: unknown feature `const_fn_trait_ref_impls` + --> $DIR/fn_trait_refs.rs:3:12 + | +LL | #![feature(const_fn_trait_ref_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0635]: unknown feature `const_cmp` + --> $DIR/fn_trait_refs.rs:8:12 + | +LL | #![feature(const_cmp)] + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/consts/issue-104155.rs b/tests/ui/consts/issue-104155.rs index 1cc8f81b0..7b375dc05 100644 --- a/tests/ui/consts/issue-104155.rs +++ b/tests/ui/consts/issue-104155.rs @@ -1,4 +1,7 @@ // check-pass + +#![allow(forgetting_copy_types)] + const _: () = core::mem::forget(Box::<u32>::default); const _: () = core::mem::forget(|| Box::<u32>::default()); diff --git a/tests/ui/consts/issue-25826.rs b/tests/ui/consts/issue-25826.rs index c340c30a1..f5ed5aeed 100644 --- a/tests/ui/consts/issue-25826.rs +++ b/tests/ui/consts/issue-25826.rs @@ -1,6 +1,6 @@ fn id<T>(t: T) -> T { t } fn main() { const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; - //~^ ERROR can't compare + //~^ ERROR pointers cannot println!("{}", A); } diff --git a/tests/ui/consts/issue-25826.stderr b/tests/ui/consts/issue-25826.stderr index 905c5ee6e..780edd214 100644 --- a/tests/ui/consts/issue-25826.stderr +++ b/tests/ui/consts/issue-25826.stderr @@ -1,16 +1,10 @@ -error[E0277]: can't compare `*const ()` with `*const ()` in const contexts - --> $DIR/issue-25826.rs:3:52 +error: pointers cannot be reliably compared during const eval + --> $DIR/issue-25826.rs:3:30 | LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; - | ^ no implementation for `*const () < *const ()` and `*const () > *const ()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: the trait `~const PartialOrd` is not implemented for `*const ()` -note: the trait `PartialOrd` is implemented for `*const ()`, but that implementation is not `const` - --> $DIR/issue-25826.rs:3:52 - | -LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () }; - | ^ + = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/issue-50439.rs b/tests/ui/consts/issue-50439.rs index 0be7c4054..d42347e13 100644 --- a/tests/ui/consts/issue-50439.rs +++ b/tests/ui/consts/issue-50439.rs @@ -22,7 +22,9 @@ impl<T: Sized> PinDropInternal for Bears<T> { where Self: ReflectDrop, { - let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; //~ ERROR constant expression depends on a generic parameter + let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; + //~^ ERROR constant expression depends on a generic parameter + //~| ERROR constant expression depends on a generic parameter } } diff --git a/tests/ui/consts/issue-50439.stderr b/tests/ui/consts/issue-50439.stderr index 3fbdf33b2..7a8cd45ec 100644 --- a/tests/ui/consts/issue-50439.stderr +++ b/tests/ui/consts/issue-50439.stderr @@ -6,5 +6,13 @@ LL | let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usi | = note: this may fail depending on what value the parameter takes -error: aborting due to previous error +error: constant expression depends on a generic parameter + --> $DIR/issue-50439.rs:25:17 + | +LL | let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-54954.rs b/tests/ui/consts/issue-54954.rs index 520bf508f..7bcfa0570 100644 --- a/tests/ui/consts/issue-54954.rs +++ b/tests/ui/consts/issue-54954.rs @@ -9,8 +9,6 @@ trait Tt { } fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - //~^ constant - //~| constant z } diff --git a/tests/ui/consts/issue-54954.stderr b/tests/ui/consts/issue-54954.stderr index 850558287..b0701bab7 100644 --- a/tests/ui/consts/issue-54954.stderr +++ b/tests/ui/consts/issue-54954.stderr @@ -16,18 +16,6 @@ LL | | core::mem::size_of::<T>() LL | | } | |_____- `Tt::const_val` defined here -note: erroneous constant used - --> $DIR/issue-54954.rs:11:15 - | -LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - | ^^^^^^^ - -note: erroneous constant used - --> $DIR/issue-54954.rs:11:34 - | -LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { - | ^^^^^^^ - error: aborting due to 2 previous errors Some errors have detailed explanations: E0379, E0790. diff --git a/tests/ui/consts/issue-56164.stderr b/tests/ui/consts/issue-56164.stderr index 003f84744..e46c649fa 100644 --- a/tests/ui/consts/issue-56164.stderr +++ b/tests/ui/consts/issue-56164.stderr @@ -28,18 +28,6 @@ error: function pointer calls are not allowed in constant functions LL | input() | ^^^^^^^ -note: erroneous constant used - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^ - -note: erroneous constant used - --> $DIR/issue-56164.rs:1:18 - | -LL | const fn foo() { (||{})() } - | ^^^^^^ - error: aborting due to 3 previous errors Some errors have detailed explanations: E0015, E0277. diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr index e9a3fced6..f4898fd97 100644 --- a/tests/ui/consts/issue-66693.stderr +++ b/tests/ui/consts/issue-66693.stderr @@ -22,17 +22,5 @@ LL | panic!(&1); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used - --> $DIR/issue-66693.rs:11:12 - | -LL | panic!(&1); - | ^^ - -note: erroneous constant used - --> $DIR/issue-66693.rs:11:12 - | -LL | panic!(&1); - | ^^ - error: aborting due to 3 previous errors diff --git a/tests/ui/consts/issue-73976-monomorphic.rs b/tests/ui/consts/issue-73976-monomorphic.rs index addcc1eaa..a3b951003 100644 --- a/tests/ui/consts/issue-73976-monomorphic.rs +++ b/tests/ui/consts/issue-73976-monomorphic.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 // // This test is complement to the test in issue-73976-polymorphic.rs. // In that test we ensure that polymorphic use of type_id and type_name in patterns diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr new file mode 100644 index 000000000..09661d3f3 --- /dev/null +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -0,0 +1,27 @@ +error[E0277]: can't compare `TypeId` with `TypeId` in const contexts + --> $DIR/issue-73976-monomorphic.rs:21:5 + | +LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId` + | + = help: the trait `~const PartialEq` is not implemented for `TypeId` +note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/issue-73976-monomorphic.rs:21:5 + | +LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/issue-73976-monomorphic.rs:21:5 + | +LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/any.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index ce21ebdb9..38c8129b8 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -7,8 +7,9 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec<u32>) { self.bar[0] = baz.len(); - //~^ the trait bound `Vec<usize>: ~const Index<_>` is not satisfied - //~| the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied + //~^ ERROR: cannot call + //~| ERROR: cannot call + //~| ERROR: the trait bound } } diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index f4683f7f5..b4e5db44e 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -1,15 +1,10 @@ -error[E0277]: the trait bound `Vec<usize>: ~const Index<_>` is not satisfied - --> $DIR/issue-94675.rs:9:9 +error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions + --> $DIR/issue-94675.rs:9:27 | LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize` - | - = help: the trait `~const Index<_>` is not implemented for `Vec<usize>` -note: the trait `Index<_>` is implemented for `Vec<usize>`, but that implementation is not `const` - --> $DIR/issue-94675.rs:9:9 + | ^^^^^ | -LL | self.bar[0] = baz.len(); - | ^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied --> $DIR/issue-94675.rs:9:9 @@ -24,6 +19,17 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl LL | self.bar[0] = baz.len(); | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/issue-94675.rs:9:9 + | +LL | self.bar[0] = baz.len(); + | ^^^^^^^^^^^ + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-miri-1910.rs b/tests/ui/consts/issue-miri-1910.rs index 29e0ea950..3798332df 100644 --- a/tests/ui/consts/issue-miri-1910.rs +++ b/tests/ui/consts/issue-miri-1910.rs @@ -1,6 +1,5 @@ // error-pattern unable to turn pointer into raw bytes // normalize-stderr-test: "alloc[0-9]+\+0x[a-z0-9]+" -> "ALLOC" -#![feature(const_ptr_read)] const C: () = unsafe { let foo = Some(&42 as *const i32); diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index a10eea9de..fb758d406 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -10,7 +10,7 @@ note: inside `std::ptr::read::<u8>` note: inside `ptr::const_ptr::<impl *const u8>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `C` - --> $DIR/issue-miri-1910.rs:8:5 + --> $DIR/issue-miri-1910.rs:7:5 | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/min_const_fn/cmp_fn_pointers.rs b/tests/ui/consts/min_const_fn/cmp_fn_pointers.rs index 9a2775688..c5990a7f5 100644 --- a/tests/ui/consts/min_const_fn/cmp_fn_pointers.rs +++ b/tests/ui/consts/min_const_fn/cmp_fn_pointers.rs @@ -1,6 +1,6 @@ const fn cmp(x: fn(), y: fn()) -> bool { unsafe { x == y } - //~^ ERROR can't compare + //~^ ERROR pointers cannot } fn main() {} diff --git a/tests/ui/consts/min_const_fn/cmp_fn_pointers.stderr b/tests/ui/consts/min_const_fn/cmp_fn_pointers.stderr index 8a1b20a33..3845068d8 100644 --- a/tests/ui/consts/min_const_fn/cmp_fn_pointers.stderr +++ b/tests/ui/consts/min_const_fn/cmp_fn_pointers.stderr @@ -1,16 +1,10 @@ -error[E0277]: can't compare `fn()` with `_` in const contexts - --> $DIR/cmp_fn_pointers.rs:2:16 +error: pointers cannot be reliably compared during const eval + --> $DIR/cmp_fn_pointers.rs:2:14 | LL | unsafe { x == y } - | ^^ no implementation for `fn() == _` + | ^^^^^^ | - = help: the trait `~const PartialEq<_>` is not implemented for `fn()` -note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const` - --> $DIR/cmp_fn_pointers.rs:2:16 - | -LL | unsafe { x == y } - | ^^ + = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/non-sync-references-in-const.rs b/tests/ui/consts/non-sync-references-in-const.rs new file mode 100644 index 000000000..0f668b8d4 --- /dev/null +++ b/tests/ui/consts/non-sync-references-in-const.rs @@ -0,0 +1,38 @@ +// check-pass +// known-bug: #49206 + +// Should fail. Compiles and prints 2 identical addresses, which shows 2 threads +// with the same `'static` reference to non-`Sync` struct. The problem is that +// promotion to static does not check if the type is `Sync`. + +#[allow(dead_code)] +#[derive(Debug)] +struct Foo { + value: u32, +} + +// stable negative impl trick from https://crates.io/crates/negative-impl +// see https://github.com/taiki-e/pin-project/issues/102#issuecomment-540472282 +// for details. +struct Wrapper<'a, T>(::std::marker::PhantomData<&'a ()>, T); +unsafe impl<T> Sync for Wrapper<'_, T> where T: Sync {} +unsafe impl<'a> std::marker::Sync for Foo where Wrapper<'a, *const ()>: Sync {} +fn _assert_sync<T: Sync>() {} + +fn inspect() { + let foo: &'static Foo = &Foo { value: 1 }; + println!( + "I am in thread {:?}, address: {:p}", + std::thread::current().id(), + foo as *const Foo, + ); +} + +fn main() { + // _assert_sync::<Foo>(); // uncomment this line causes compile error + // "`*const ()` cannot be shared between threads safely" + + let handle = std::thread::spawn(inspect); + inspect(); + handle.join().unwrap(); +} diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index 30ae73053..dae6cafae 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs @@ -1,7 +1,9 @@ #![feature(const_mut_refs)] #![feature(const_trait_impl)] + struct Panic; impl const Drop for Panic { fn drop(&mut self) { panic!(); } } + pub const fn id<T>(x: T) -> T { x } pub const C: () = { let _: &'static _ = &id(&Panic); diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 83cc16f6f..1cbd8cbe6 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:7:26 + --> $DIR/promoted_const_call.rs:9:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -10,7 +10,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:7:30 + --> $DIR/promoted_const_call.rs:9:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -19,7 +19,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:13:26 + --> $DIR/promoted_const_call.rs:15:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -30,7 +30,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:13:30 + --> $DIR/promoted_const_call.rs:15:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -39,7 +39,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:16:26 + --> $DIR/promoted_const_call.rs:18:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -50,7 +50,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:16:27 + --> $DIR/promoted_const_call.rs:18:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use diff --git a/tests/ui/consts/rustc-impl-const-stability.rs b/tests/ui/consts/rustc-impl-const-stability.rs index 0c18efa0a..a1a741e80 100644 --- a/tests/ui/consts/rustc-impl-const-stability.rs +++ b/tests/ui/consts/rustc-impl-const-stability.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![crate_type = "lib"] #![feature(staged_api)] diff --git a/tests/ui/consts/rustc-impl-const-stability.stderr b/tests/ui/consts/rustc-impl-const-stability.stderr new file mode 100644 index 000000000..e6930da71 --- /dev/null +++ b/tests/ui/consts/rustc-impl-const-stability.stderr @@ -0,0 +1,11 @@ +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/rustc-impl-const-stability.rs:15:12 + | +LL | impl const Default for Data { + | ^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: aborting due to previous error + diff --git a/tests/ui/consts/try-operator.rs b/tests/ui/consts/try-operator.rs index fe43b132c..ed69f492f 100644 --- a/tests/ui/consts/try-operator.rs +++ b/tests/ui/consts/try-operator.rs @@ -1,4 +1,4 @@ -// run-pass +// known-bug: #110395 #![feature(try_trait_v2)] #![feature(const_trait_impl)] diff --git a/tests/ui/consts/try-operator.stderr b/tests/ui/consts/try-operator.stderr new file mode 100644 index 000000000..f6a651c5e --- /dev/null +++ b/tests/ui/consts/try-operator.stderr @@ -0,0 +1,9 @@ +error[E0635]: unknown feature `const_convert` + --> $DIR/try-operator.rs:6:12 + | +LL | #![feature(const_convert)] + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/crate-leading-sep.rs b/tests/ui/crate-leading-sep.rs index ca5905fab..fce97d9ba 100644 --- a/tests/ui/crate-leading-sep.rs +++ b/tests/ui/crate-leading-sep.rs @@ -1,6 +1,8 @@ // run-pass // pretty-expanded FIXME #23616 +#![allow(dropping_copy_types)] + fn main() { use ::std::mem; mem::drop(2_usize); diff --git a/tests/ui/cross/cross-file-errors/main.stderr b/tests/ui/cross/cross-file-errors/main.stderr index 293a300ed..56eb6ad42 100644 --- a/tests/ui/cross/cross-file-errors/main.stderr +++ b/tests/ui/cross/cross-file-errors/main.stderr @@ -1,5 +1,5 @@ error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/underscore.rs:8:9 + --> $DIR/underscore.rs:6:9 | LL | _ | ^ `_` not allowed here diff --git a/tests/ui/cross/cross-file-errors/underscore.rs b/tests/ui/cross/cross-file-errors/underscore.rs index 76e72a93f..4dd91c13e 100644 --- a/tests/ui/cross/cross-file-errors/underscore.rs +++ b/tests/ui/cross/cross-file-errors/underscore.rs @@ -1,6 +1,4 @@ -// We want this file only so we can test cross-file error -// messages, but we don't want it in an external crate. -// ignore-test +// ignore-test (auxiliary, used by other tests) #![crate_type = "lib"] macro_rules! underscore { diff --git a/tests/ui/custom_test_frameworks/mismatch.stderr b/tests/ui/custom_test_frameworks/mismatch.stderr index 61061ae52..31b18b2df 100644 --- a/tests/ui/custom_test_frameworks/mismatch.stderr +++ b/tests/ui/custom_test_frameworks/mismatch.stderr @@ -6,7 +6,7 @@ LL | #[test] LL | fn wrong_kind(){} | ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn` | - = note: required for the cast from `TestDescAndFn` to the object type `dyn Testable` + = note: required for the cast from `&TestDescAndFn` to `&dyn Testable` = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/issues/issue-12511.rs b/tests/ui/cycle-trait/issue-12511.rs index ea83e3fd9..ea83e3fd9 100644 --- a/tests/ui/issues/issue-12511.rs +++ b/tests/ui/cycle-trait/issue-12511.rs diff --git a/tests/ui/issues/issue-12511.stderr b/tests/ui/cycle-trait/issue-12511.stderr index 558aad109..558aad109 100644 --- a/tests/ui/issues/issue-12511.stderr +++ b/tests/ui/cycle-trait/issue-12511.stderr diff --git a/tests/ui/deployment-target/invalid-target.rs b/tests/ui/deployment-target/invalid-target.rs new file mode 100644 index 000000000..336624320 --- /dev/null +++ b/tests/ui/deployment-target/invalid-target.rs @@ -0,0 +1,4 @@ +// compile-flags: --target x86_64-unknown-linux-gnu --print deployment-target +// needs-llvm-components: x86 + +fn main() {} diff --git a/tests/ui/deployment-target/invalid-target.stderr b/tests/ui/deployment-target/invalid-target.stderr new file mode 100644 index 000000000..eb4ac131c --- /dev/null +++ b/tests/ui/deployment-target/invalid-target.stderr @@ -0,0 +1,2 @@ +error: only Apple targets currently support deployment version info + diff --git a/tests/ui/deployment-target/macos-target.rs b/tests/ui/deployment-target/macos-target.rs new file mode 100644 index 000000000..701ccf479 --- /dev/null +++ b/tests/ui/deployment-target/macos-target.rs @@ -0,0 +1,7 @@ +// only-macos +// compile-flags: --print deployment-target +// normalize-stdout-test: "\d+\." -> "$$CURRENT_MAJOR_VERSION." +// normalize-stdout-test: "\d+" -> "$$CURRENT_MINOR_VERSION" +// check-pass + +fn main() {} diff --git a/tests/ui/deployment-target/macos-target.stdout b/tests/ui/deployment-target/macos-target.stdout new file mode 100644 index 000000000..f55ef568e --- /dev/null +++ b/tests/ui/deployment-target/macos-target.stdout @@ -0,0 +1 @@ +deployment_target=$CURRENT_MAJOR_VERSION.$CURRENT_MINOR_VERSION diff --git a/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr b/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr index 9fc25f2ad..e3b17431f 100644 --- a/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr @@ -7,11 +7,11 @@ LL | #[derive(PartialEq)] LL | x: Error | ^^^^^^^^ | -note: an implementation of `PartialEq<_>` might be missing for `Error` +note: an implementation of `PartialEq` might be missing for `Error` --> $DIR/derives-span-PartialEq-enum-struct-variant.rs:4:1 | LL | struct Error; - | ^^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^^ must implement `PartialEq` = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | diff --git a/tests/ui/derives/derives-span-PartialEq-enum.stderr b/tests/ui/derives/derives-span-PartialEq-enum.stderr index f56e78447..d1631732a 100644 --- a/tests/ui/derives/derives-span-PartialEq-enum.stderr +++ b/tests/ui/derives/derives-span-PartialEq-enum.stderr @@ -7,11 +7,11 @@ LL | #[derive(PartialEq)] LL | Error | ^^^^^ | -note: an implementation of `PartialEq<_>` might be missing for `Error` +note: an implementation of `PartialEq` might be missing for `Error` --> $DIR/derives-span-PartialEq-enum.rs:4:1 | LL | struct Error; - | ^^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^^ must implement `PartialEq` = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | diff --git a/tests/ui/derives/derives-span-PartialEq-struct.stderr b/tests/ui/derives/derives-span-PartialEq-struct.stderr index 76c0b0104..ab6c6951f 100644 --- a/tests/ui/derives/derives-span-PartialEq-struct.stderr +++ b/tests/ui/derives/derives-span-PartialEq-struct.stderr @@ -7,11 +7,11 @@ LL | struct Struct { LL | x: Error | ^^^^^^^^ | -note: an implementation of `PartialEq<_>` might be missing for `Error` +note: an implementation of `PartialEq` might be missing for `Error` --> $DIR/derives-span-PartialEq-struct.rs:4:1 | LL | struct Error; - | ^^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^^ must implement `PartialEq` = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | diff --git a/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr b/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr index 7dae01dbb..865ecad0e 100644 --- a/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr @@ -7,11 +7,11 @@ LL | struct Struct( LL | Error | ^^^^^ | -note: an implementation of `PartialEq<_>` might be missing for `Error` +note: an implementation of `PartialEq` might be missing for `Error` --> $DIR/derives-span-PartialEq-tuple-struct.rs:4:1 | LL | struct Error; - | ^^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^^ must implement `PartialEq` = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | diff --git a/tests/ui/derives/deriving-no-inner-impl-error-message.stderr b/tests/ui/derives/deriving-no-inner-impl-error-message.stderr index 10af5d36e..ab99ba9fa 100644 --- a/tests/ui/derives/deriving-no-inner-impl-error-message.stderr +++ b/tests/ui/derives/deriving-no-inner-impl-error-message.stderr @@ -7,11 +7,11 @@ LL | struct E { LL | x: NoCloneOrEq | ^^^^^^^^^^^^^^ | -note: an implementation of `PartialEq<_>` might be missing for `NoCloneOrEq` +note: an implementation of `PartialEq` might be missing for `NoCloneOrEq` --> $DIR/deriving-no-inner-impl-error-message.rs:1:1 | LL | struct NoCloneOrEq; - | ^^^^^^^^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^^^^^^^^ must implement `PartialEq` = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NoCloneOrEq` with `#[derive(PartialEq)]` | diff --git a/tests/ui/issues/issue-15689-1.rs b/tests/ui/deriving/issue-15689-1.rs index d143926b2..d143926b2 100644 --- a/tests/ui/issues/issue-15689-1.rs +++ b/tests/ui/deriving/issue-15689-1.rs diff --git a/tests/ui/issues/issue-15689-2.rs b/tests/ui/deriving/issue-15689-2.rs index 83dcb1406..83dcb1406 100644 --- a/tests/ui/issues/issue-15689-2.rs +++ b/tests/ui/deriving/issue-15689-2.rs diff --git a/tests/ui/destructuring-assignment/note-unsupported.stderr b/tests/ui/destructuring-assignment/note-unsupported.stderr index 8a88332b7..f55633007 100644 --- a/tests/ui/destructuring-assignment/note-unsupported.stderr +++ b/tests/ui/destructuring-assignment/note-unsupported.stderr @@ -44,11 +44,11 @@ LL | S { x: a, y: b } += s; | | | cannot use `+=` on type `S` | -note: an implementation of `AddAssign<_>` might be missing for `S` +note: an implementation of `AddAssign` might be missing for `S` --> $DIR/note-unsupported.rs:1:1 | LL | struct S { x: u8, y: u8 } - | ^^^^^^^^ must implement `AddAssign<_>` + | ^^^^^^^^ must implement `AddAssign` note: the trait `AddAssign` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL diff --git a/tests/ui/diagnostic-width/E0271.stderr b/tests/ui/diagnostic-width/E0271.stderr index ed7b6651d..52f415037 100644 --- a/tests/ui/diagnostic-width/E0271.stderr +++ b/tests/ui/diagnostic-width/E0271.stderr @@ -15,8 +15,8 @@ note: expected this to be `Foo` | LL | type Error = E; | ^ - = note: required for the cast from `Result<Result<..., ...>, ...>` to the object type `dyn Future<Error = Foo>` - = note: the full name for the casted type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271/E0271.long-type-hash.txt' + = note: required for the cast from `Box<Result<..., ...>>` to `Box<(dyn Future<Error = Foo> + 'static)>` + = note: the full name for the source type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271/E0271.long-type-hash.txt' error: aborting due to previous error diff --git a/tests/ui/did_you_mean/issue-38147-4.stderr b/tests/ui/did_you_mean/issue-38147-4.stderr index d33399893..43647fa56 100644 --- a/tests/ui/did_you_mean/issue-38147-4.stderr +++ b/tests/ui/did_you_mean/issue-38147-4.stderr @@ -6,8 +6,8 @@ LL | f.s.push('x'); | help: consider changing this to be a mutable reference | -LL | fn f(x: usize, f: &mut Foo<'_>) { - | ~~~~~~~~~~~~ +LL | fn f(x: usize, f: &mut Foo) { + | +++ error: aborting due to previous error diff --git a/tests/ui/did_you_mean/issue-39544.stderr b/tests/ui/did_you_mean/issue-39544.stderr index 8dc0512a9..8ccb4cbb0 100644 --- a/tests/ui/did_you_mean/issue-39544.stderr +++ b/tests/ui/did_you_mean/issue-39544.stderr @@ -40,7 +40,7 @@ LL | let _ = &mut other.x; help: consider changing this to be a mutable reference | LL | fn foo1(&self, other: &mut Z) { - | ~~~~~~ + | +++ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:25:17 @@ -62,7 +62,7 @@ LL | let _ = &mut other.x; help: consider changing this to be a mutable reference | LL | fn foo2<'a>(&'a self, other: &mut Z) { - | ~~~~~~ + | +++ error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:30:17 @@ -73,7 +73,7 @@ LL | let _ = &mut self.x; help: consider changing this to be a mutable reference | LL | fn foo3<'a>(self: &'a mut Self, other: &Z) { - | ~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:31:17 @@ -84,7 +84,7 @@ LL | let _ = &mut other.x; help: consider changing this to be a mutable reference | LL | fn foo3<'a>(self: &'a Self, other: &mut Z) { - | ~~~~~~ + | +++ error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference --> $DIR/issue-39544.rs:35:17 @@ -95,7 +95,7 @@ LL | let _ = &mut other.x; help: consider changing this to be a mutable reference | LL | fn foo4(other: &mut Z) { - | ~~~~~~ + | +++ error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable --> $DIR/issue-39544.rs:41:13 @@ -117,7 +117,7 @@ LL | let _ = &mut w.x; help: consider changing this to be a mutable reference | LL | pub fn with_arg(z: Z, w: &mut Z) { - | ~~~~~~ + | +++ error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference --> $DIR/issue-39544.rs:48:5 diff --git a/tests/ui/did_you_mean/issue-40823.stderr b/tests/ui/did_you_mean/issue-40823.stderr index aadd69889..ba94a5702 100644 --- a/tests/ui/did_you_mean/issue-40823.stderr +++ b/tests/ui/did_you_mean/issue-40823.stderr @@ -7,7 +7,7 @@ LL | buf.iter_mut(); help: consider changing this to be a mutable reference | LL | let mut buf = &mut [1, 2, 3, 4]; - | ~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr b/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr index a3c607b59..6d92fa5e1 100644 --- a/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr +++ b/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr @@ -65,6 +65,7 @@ error: unexpected `,` in pattern LL | let women, men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned() | ^ | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> help: try adding parentheses to match on a tuple | LL | let (women, men): (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned() diff --git a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 81f3f2694..26986684f 100644 --- a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -15,13 +15,13 @@ help: Unicode character '−' (Minus Sign) looks like '-' (Minus/Hyphen), but it LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kgâ»Â¹â‹…sâ»Â² | ~ -error[E0277]: cannot subtract `{integer}` from `{float}` in const contexts +error[E0277]: cannot subtract `{integer}` from `{float}` --> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53 | LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kgâ»Â¹â‹…sâ»Â² | ^ no implementation for `{float} - {integer}` | - = help: the trait `~const Sub<{integer}>` is not implemented for `{float}` + = help: the trait `Sub<{integer}>` is not implemented for `{float}` = help: the following other types implement trait `Sub<Rhs>`: <&'a f32 as Sub<f32>> <&'a f64 as Sub<f64>> diff --git a/tests/ui/drop/dropck-eyepatch-manuallydrop.rs b/tests/ui/drop/dropck-eyepatch-manuallydrop.rs new file mode 100644 index 000000000..ff100cd94 --- /dev/null +++ b/tests/ui/drop/dropck-eyepatch-manuallydrop.rs @@ -0,0 +1,22 @@ +// check-pass +//! This test checks that dropck knows that ManuallyDrop does not drop its field. +#![feature(dropck_eyepatch)] + +use std::mem::ManuallyDrop; + +struct S<T>(ManuallyDrop<T>); + +unsafe impl<#[may_dangle] T> Drop for S<T> { + fn drop(&mut self) {} +} + +struct NonTrivialDrop<'a>(&'a str); +impl<'a> Drop for NonTrivialDrop<'a> { + fn drop(&mut self) {} +} + +fn main() { + let s = String::from("string"); + let _t = S(ManuallyDrop::new(NonTrivialDrop(&s))); + drop(s); +} diff --git a/tests/ui/drop/issue-110682.rs b/tests/ui/drop/issue-110682.rs new file mode 100644 index 000000000..35f9c7e8d --- /dev/null +++ b/tests/ui/drop/issue-110682.rs @@ -0,0 +1,92 @@ +// build-pass +// compile-flags: -Zmir-opt-level=3 + +use std::fmt::Debug; +use std::mem::ManuallyDrop; +use std::ptr; + +pub trait BitRegister {} + +macro_rules! register { + ($($t:ty),+ $(,)?) => { $( + impl BitRegister for $t { + } + )* }; +} + +register!(u8, u16, u32); + +pub trait BitStore: Sized + Debug { + /// The register type that the implementor describes. + type Mem: BitRegister + Into<Self>; +} + +macro_rules! store { + ($($t:ty),+ $(,)?) => { $( + impl BitStore for $t { + type Mem = Self; + } + )+ }; +} + +store!(u8, u16, u32,); + +#[repr(C)] +pub struct BitVec<T> +where + T: BitStore, +{ + /// Region pointer describing the live portion of the owned buffer. + pointer: ptr::NonNull<T>, + /// Allocated capacity, in elements `T`, of the owned buffer. + capacity: usize, +} + +impl<T> BitVec<T> +where + T: BitStore, +{ + pub fn new() -> Self { + let pointer = ptr::NonNull::<T>::new(ptr::null_mut()).unwrap(); + + BitVec { pointer, capacity: 10 } + } + + pub fn clear(&mut self) { + unsafe { + self.set_len(0); + } + } + + #[inline] + pub unsafe fn set_len(&mut self, new_len: usize) {} + + fn with_vec<F, R>(&mut self, func: F) -> R + where + F: FnOnce(&mut ManuallyDrop<Vec<T::Mem>>) -> R, + { + let cap = self.capacity; + let elts = 10; + let mut vec = ManuallyDrop::new(unsafe { Vec::from_raw_parts(ptr::null_mut(), elts, cap) }); + let out = func(&mut vec); + + out + } +} + +impl<T> Drop for BitVec<T> +where + T: BitStore, +{ + #[inline] + fn drop(&mut self) { + // The buffer elements do not have destructors. + self.clear(); + // Run the `Vec` destructor to deällocate the buffer. + self.with_vec(|vec| unsafe { ManuallyDrop::drop(vec) }); + } +} + +fn main() { + let bitvec = BitVec::<u32>::new(); +} diff --git a/tests/ui/issues/issue-979.rs b/tests/ui/drop/issue-979.rs index 57a99b325..57a99b325 100644 --- a/tests/ui/issues/issue-979.rs +++ b/tests/ui/drop/issue-979.rs diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs index 8fd46ecaf..0afb4bb11 100644 --- a/tests/ui/drop/repeat-drop.rs +++ b/tests/ui/drop/repeat-drop.rs @@ -1,6 +1,8 @@ // run-pass // needs-unwind +#![allow(dropping_references, dropping_copy_types)] + static mut CHECK: usize = 0; struct DropChecker(usize); diff --git a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr new file mode 100644 index 000000000..3b506c7e7 --- /dev/null +++ b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/explicit-drop-bounds.rs:27:18 + | +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +note: required by a bound in `DropMe` + --> $DIR/explicit-drop-bounds.rs:7:18 + | +LL | struct DropMe<T: Copy>(T); + | ^^^^ required by this bound in `DropMe` +help: consider further restricting type parameter `T` + | +LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply `T: Copy` + | ~~~~~~~~~~~~~~~~~~~~~~ + +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/explicit-drop-bounds.rs:32:13 + | +LL | fn drop(&mut self) {} + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +note: required by a bound in `DropMe` + --> $DIR/explicit-drop-bounds.rs:7:18 + | +LL | struct DropMe<T: Copy>(T); + | ^^^^ required by this bound in `DropMe` +help: consider further restricting type parameter `T` + | +LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply `T: Copy` + | ~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr new file mode 100644 index 000000000..832af3e52 --- /dev/null +++ b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/explicit-drop-bounds.rs:37:18 + | +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +note: required by a bound in `DropMe` + --> $DIR/explicit-drop-bounds.rs:7:18 + | +LL | struct DropMe<T: Copy>(T); + | ^^^^ required by this bound in `DropMe` +help: consider restricting type parameter `T` + | +LL | impl<T: std::marker::Copy> Drop for DropMe<T> + | +++++++++++++++++++ + +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/explicit-drop-bounds.rs:40:13 + | +LL | fn drop(&mut self) {} + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +note: required by a bound in `DropMe` + --> $DIR/explicit-drop-bounds.rs:7:18 + | +LL | struct DropMe<T: Copy>(T); + | ^^^^ required by this bound in `DropMe` +help: consider restricting type parameter `T` + | +LL | impl<T: std::marker::Copy> Drop for DropMe<T> + | +++++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dropck/explicit-drop-bounds.rs b/tests/ui/dropck/explicit-drop-bounds.rs new file mode 100644 index 000000000..ab6f33c09 --- /dev/null +++ b/tests/ui/dropck/explicit-drop-bounds.rs @@ -0,0 +1,44 @@ +// revisions: good1 good2 bad1 bad2 +//[good1] check-pass +//[good2] check-pass + +use std::ops::Drop; + +struct DropMe<T: Copy>(T); + +#[cfg(good1)] +impl<T> Drop for DropMe<T> +where + T: Copy + Clone, +{ + fn drop(&mut self) {} +} + +#[cfg(good2)] +impl<T> Drop for DropMe<T> +where + T: Copy, + [T; 1]: Copy, // Trivial bound implied by `T: Copy` +{ + fn drop(&mut self) {} +} + +#[cfg(bad1)] +impl<T> Drop for DropMe<T> +//[bad1]~^ ERROR the trait bound `T: Copy` is not satisfied +where + [T; 1]: Copy, // But `[T; 1]: Copy` does not imply `T: Copy` +{ + fn drop(&mut self) {} + //[bad1]~^ ERROR the trait bound `T: Copy` is not satisfied +} + +#[cfg(bad2)] +impl<T> Drop for DropMe<T> +//[bad2]~^ ERROR the trait bound `T: Copy` is not satisfied +{ + fn drop(&mut self) {} + //[bad2]~^ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() {} diff --git a/tests/ui/dropck/explicit-implied-outlives.bad1.stderr b/tests/ui/dropck/explicit-implied-outlives.bad1.stderr new file mode 100644 index 000000000..bf6d70e7d --- /dev/null +++ b/tests/ui/dropck/explicit-implied-outlives.bad1.stderr @@ -0,0 +1,15 @@ +error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not + --> $DIR/explicit-implied-outlives.rs:28:8 + | +LL | T: 'static, + | ^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/explicit-implied-outlives.rs:7:1 + | +LL | struct DropMe<'a, T>(&'a T); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0367`. diff --git a/tests/ui/dropck/explicit-implied-outlives.bad2.stderr b/tests/ui/dropck/explicit-implied-outlives.bad2.stderr new file mode 100644 index 000000000..27a15170b --- /dev/null +++ b/tests/ui/dropck/explicit-implied-outlives.bad2.stderr @@ -0,0 +1,15 @@ +error[E0367]: `Drop` impl requires `'a: 'static` but the struct it is implemented for does not + --> $DIR/explicit-implied-outlives.rs:37:9 + | +LL | 'a: 'static, + | ^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/explicit-implied-outlives.rs:7:1 + | +LL | struct DropMe<'a, T>(&'a T); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0367`. diff --git a/tests/ui/dropck/explicit-implied-outlives.rs b/tests/ui/dropck/explicit-implied-outlives.rs new file mode 100644 index 000000000..fa446591f --- /dev/null +++ b/tests/ui/dropck/explicit-implied-outlives.rs @@ -0,0 +1,43 @@ +// revisions: good1 good2 bad1 bad2 +//[good1] check-pass +//[good2] check-pass + +use std::ops::Drop; + +struct DropMe<'a, T>(&'a T); + +#[cfg(good1)] +impl<'a, T> Drop for DropMe<'a, T> +where + T: 'a, // Implied by struct, explicit on impl +{ + fn drop(&mut self) {} +} + +#[cfg(good2)] +impl<'a, T> Drop for DropMe<'a, T> +where + 'static: 'a, // Trivial bound +{ + fn drop(&mut self) {} +} + +#[cfg(bad1)] +impl<'a, T> Drop for DropMe<'a, T> +where + T: 'static, + //[bad1]~^ ERROR `Drop` impl requires `T: 'static` +{ + fn drop(&mut self) {} +} + +#[cfg(bad2)] +impl<'a, T> Drop for DropMe<'a, T> +where + 'a: 'static, + //[bad2]~^ ERROR `Drop` impl requires `'a: 'static` +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/dropck/negative.rs b/tests/ui/dropck/negative.rs new file mode 100644 index 000000000..ae63632b5 --- /dev/null +++ b/tests/ui/dropck/negative.rs @@ -0,0 +1,7 @@ +#![feature(negative_impls)] + +struct NonDrop; +impl !Drop for NonDrop {} +//~^ ERROR negative `Drop` impls are not supported + +fn main() {} diff --git a/tests/ui/dropck/negative.stderr b/tests/ui/dropck/negative.stderr new file mode 100644 index 000000000..d613e30b5 --- /dev/null +++ b/tests/ui/dropck/negative.stderr @@ -0,0 +1,8 @@ +error: negative `Drop` impls are not supported + --> $DIR/negative.rs:4:1 + | +LL | impl !Drop for NonDrop {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/dropck/reservation.rs b/tests/ui/dropck/reservation.rs new file mode 100644 index 000000000..f7199d4ec --- /dev/null +++ b/tests/ui/dropck/reservation.rs @@ -0,0 +1,10 @@ +#![feature(rustc_attrs)] + +struct ReservedDrop; +#[rustc_reservation_impl = "message"] +impl Drop for ReservedDrop { +//~^ ERROR reservation `Drop` impls are not supported + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/dropck/reservation.stderr b/tests/ui/dropck/reservation.stderr new file mode 100644 index 000000000..19325d6ed --- /dev/null +++ b/tests/ui/dropck/reservation.stderr @@ -0,0 +1,8 @@ +error: reservation `Drop` impls are not supported + --> $DIR/reservation.rs:5:1 + | +LL | impl Drop for ReservedDrop { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/dropck/transitive-outlives-2.rs b/tests/ui/dropck/transitive-outlives-2.rs new file mode 100644 index 000000000..87154e25d --- /dev/null +++ b/tests/ui/dropck/transitive-outlives-2.rs @@ -0,0 +1,18 @@ +// check-pass + +use std::marker::PhantomData; +use std::ops::Drop; + +// a >= b >= c >= a implies a = b = c +struct DropMe<'a: 'b, 'b: 'c, 'c: 'a>( + PhantomData<&'a ()>, + PhantomData<&'b ()>, + PhantomData<&'c ()>, +); + +// a >= b, a >= c, b >= a, c >= a implies a = b = c +impl<'a: 'b + 'c, 'b: 'a, 'c: 'a> Drop for DropMe<'a, 'b, 'c> { + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/dropck/transitive-outlives.bad.stderr b/tests/ui/dropck/transitive-outlives.bad.stderr new file mode 100644 index 000000000..da5088b27 --- /dev/null +++ b/tests/ui/dropck/transitive-outlives.bad.stderr @@ -0,0 +1,15 @@ +error[E0367]: `Drop` impl requires `'a: 'c` but the struct it is implemented for does not + --> $DIR/transitive-outlives.rs:20:9 + | +LL | 'a: 'c, + | ^^ + | +note: the implementor must specify the same requirement + --> $DIR/transitive-outlives.rs:7:1 + | +LL | struct DropMe<'a, 'b: 'a, 'c: 'b>(PhantomData<&'a ()>, PhantomData<&'b ()>, PhantomData<&'c ()>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0367`. diff --git a/tests/ui/dropck/transitive-outlives.rs b/tests/ui/dropck/transitive-outlives.rs new file mode 100644 index 000000000..d071664ab --- /dev/null +++ b/tests/ui/dropck/transitive-outlives.rs @@ -0,0 +1,26 @@ +// revisions: good bad +//[good] check-pass + +use std::marker::PhantomData; +use std::ops::Drop; + +struct DropMe<'a, 'b: 'a, 'c: 'b>(PhantomData<&'a ()>, PhantomData<&'b ()>, PhantomData<&'c ()>); + +#[cfg(good)] +impl<'a, 'b, 'c> Drop for DropMe<'a, 'b, 'c> +where + 'c: 'a, +{ + fn drop(&mut self) {} +} + +#[cfg(bad)] +impl<'a, 'b, 'c> Drop for DropMe<'a, 'b, 'c> +where + 'a: 'c, + //[bad]~^ ERROR `Drop` impl requires `'a: 'c` +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/dropck/trivial-impl-bounds.rs b/tests/ui/dropck/trivial-impl-bounds.rs new file mode 100644 index 000000000..a8f5d2c35 --- /dev/null +++ b/tests/ui/dropck/trivial-impl-bounds.rs @@ -0,0 +1,34 @@ +// revisions: good1 good2 good3 +// check-pass + +use std::ops::Drop; + +struct Foo; + +const X: usize = 1; + +#[cfg(good1)] +impl Drop for Foo +where + [(); X]:, // Trivial WF bound +{ + fn drop(&mut self) {} +} + +#[cfg(good2)] +impl Drop for Foo +where + for<'a> &'a (): Copy, // Trivial trait bound +{ + fn drop(&mut self) {} +} + +#[cfg(good3)] +impl Drop for Foo +where + for<'a> &'a (): 'a, // Trivial outlives bound +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/dst/dst-bad-coerce1.stderr b/tests/ui/dst/dst-bad-coerce1.stderr index ff77bd4ce..2c75518c2 100644 --- a/tests/ui/dst/dst-bad-coerce1.stderr +++ b/tests/ui/dst/dst-bad-coerce1.stderr @@ -15,7 +15,7 @@ error[E0277]: the trait bound `Foo: Bar` is not satisfied LL | let f3: &Fat<dyn Bar> = f2; | ^^ the trait `Bar` is not implemented for `Foo` | - = note: required for the cast from `Foo` to the object type `dyn Bar` + = note: required for the cast from `&Fat<Foo>` to `&Fat<dyn Bar>` error[E0308]: mismatched types --> $DIR/dst-bad-coerce1.rs:28:27 @@ -34,7 +34,7 @@ error[E0277]: the trait bound `Foo: Bar` is not satisfied LL | let f3: &(dyn Bar,) = f2; | ^^ the trait `Bar` is not implemented for `Foo` | - = note: required for the cast from `Foo` to the object type `dyn Bar` + = note: required for the cast from `&(Foo,)` to `&(dyn Bar,)` error: aborting due to 4 previous errors diff --git a/tests/ui/dst/dst-object-from-unsized-type.stderr b/tests/ui/dst/dst-object-from-unsized-type.stderr index e24c96ebe..d5e464aed 100644 --- a/tests/ui/dst/dst-object-from-unsized-type.stderr +++ b/tests/ui/dst/dst-object-from-unsized-type.stderr @@ -6,7 +6,7 @@ LL | fn test1<T: ?Sized + Foo>(t: &T) { LL | let u: &dyn Foo = t; | ^ doesn't have a size known at compile-time | - = note: required for the cast from `T` to the object type `dyn Foo` + = note: required for the cast from `&T` to `&dyn Foo` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn test1<T: ?Sized + Foo>(t: &T) { @@ -21,7 +21,7 @@ LL | fn test2<T: ?Sized + Foo>(t: &T) { LL | let v: &dyn Foo = t as &dyn Foo; | ^ doesn't have a size known at compile-time | - = note: required for the cast from `T` to the object type `dyn Foo` + = note: required for the cast from `&T` to `&dyn Foo` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn test2<T: ?Sized + Foo>(t: &T) { @@ -35,7 +35,7 @@ LL | let _: &[&dyn Foo] = &["hi"]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn Foo` + = note: required for the cast from `&'static str` to `&dyn Foo` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/dst-object-from-unsized-type.rs:23:23 @@ -44,7 +44,7 @@ LL | let _: &dyn Foo = x as &dyn Foo; | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: required for the cast from `[u8]` to the object type `dyn Foo` + = note: required for the cast from `&[u8]` to `&dyn Foo` error: aborting due to 4 previous errors diff --git a/tests/ui/dupe-first-attr.rc b/tests/ui/dupe-first-attr.rs index 8b7025b7b..d950743b4 100644 --- a/tests/ui/dupe-first-attr.rc +++ b/tests/ui/dupe-first-attr.rs @@ -1,24 +1,26 @@ +// run-pass + // Regression test for a problem with the first mod attribute // being applied to every mod // pretty-expanded FIXME #23616 #[cfg(target_os = "linux")] -mod hello; +mod hello {} #[cfg(target_os = "macos")] -mod hello; +mod hello {} #[cfg(target_os = "windows")] -mod hello; +mod hello {} #[cfg(target_os = "freebsd")] -mod hello; +mod hello {} #[cfg(target_os = "dragonfly")] -mod hello; +mod hello {} #[cfg(target_os = "android")] -mod hello; +mod hello {} -pub fn main() { } +fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr index 8726fae79..ba42f619a 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr @@ -1,5 +1,5 @@ error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15 + --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 | LL | dyn_debug(t); | ^ `&T` needs to be a pointer-like type diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr new file mode 100644 index 000000000..ba42f619a --- /dev/null +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: `&T` needs to have the same ABI as a pointer + --> $DIR/check-size-at-cast-polymorphic-bad.rs:14:15 + | +LL | dyn_debug(t); + | ^ `&T` needs to be a pointer-like type + | + = help: the trait `PointerLike` is not implemented for `&T` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerLike { + | +++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs index 913c2faac..9846f8714 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(dyn_star)] #![allow(incomplete_features)] diff --git a/tests/ui/dyn-star/param-env-infer.current.stderr b/tests/ui/dyn-star/param-env-infer.current.stderr new file mode 100644 index 000000000..b3af7be79 --- /dev/null +++ b/tests/ui/dyn-star/param-env-infer.current.stderr @@ -0,0 +1,18 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/param-env-infer.rs:5:12 + | +LL | #![feature(dyn_star, pointer_like_trait)] + | ^^^^^^^^ + | + = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0282]: type annotations needed + --> $DIR/param-env-infer.rs:13:10 + | +LL | t as _ + | ^ cannot infer type + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-infer.next.stderr b/tests/ui/dyn-star/param-env-infer.next.stderr new file mode 100644 index 000000000..64d76bb04 --- /dev/null +++ b/tests/ui/dyn-star/param-env-infer.next.stderr @@ -0,0 +1,73 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/param-env-infer.rs:5:12 + | +LL | #![feature(dyn_star, pointer_like_trait)] + | ^^^^^^^^ + | + = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}` + --> $DIR/param-env-infer.rs:11:60 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires promoting constants in MIR for `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires preparing `make_dyn_star` for borrow checking... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires unsafety-checking `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires building MIR for `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires match-checking `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires building THIR for `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires type-checking `make_dyn_star`... + --> $DIR/param-env-infer.rs:11:1 + | +LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing layout of `make_dyn_star::{opaque#0}`... + = note: ...which requires normalizing `make_dyn_star::{opaque#0}`... + = note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/param-env-infer.rs:5:1 + | +LL | / #![feature(dyn_star, pointer_like_trait)] +LL | | +LL | | +LL | | use std::fmt::Debug; +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/dyn-star/param-env-infer.rs b/tests/ui/dyn-star/param-env-infer.rs new file mode 100644 index 000000000..1fb16d768 --- /dev/null +++ b/tests/ui/dyn-star/param-env-infer.rs @@ -0,0 +1,17 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next +// incremental + +#![feature(dyn_star, pointer_like_trait)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::fmt::Debug; +use std::marker::PointerLike; + +fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + //[next]~^ ERROR cycle detected when computing type of `make_dyn_star::{opaque#0}` + t as _ + //[current]~^ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/editions/edition-raw-pointer-method-2018.rs b/tests/ui/editions/edition-raw-pointer-method-2018.rs index af0b2d6bd..0bae65a9a 100644 --- a/tests/ui/editions/edition-raw-pointer-method-2018.rs +++ b/tests/ui/editions/edition-raw-pointer-method-2018.rs @@ -7,5 +7,5 @@ fn main() { let x = 0; let y = &x as *const _; let _ = y.is_null(); - //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0699] + //~^ error: cannot call a method on a raw pointer with an unknown pointee type [E0699] } diff --git a/tests/ui/editions/edition-raw-pointer-method-2018.stderr b/tests/ui/editions/edition-raw-pointer-method-2018.stderr index 23452495b..b9afa0133 100644 --- a/tests/ui/editions/edition-raw-pointer-method-2018.stderr +++ b/tests/ui/editions/edition-raw-pointer-method-2018.stderr @@ -1,4 +1,4 @@ -error[E0699]: the type of this value must be known to call a method on a raw pointer on it +error[E0699]: cannot call a method on a raw pointer with an unknown pointee type --> $DIR/edition-raw-pointer-method-2018.rs:9:15 | LL | let _ = y.is_null(); diff --git a/tests/ui/issues/auxiliary/issue-41394.rs b/tests/ui/enum-discriminant/auxiliary/issue-41394.rs index 2e650efc7..2e650efc7 100644 --- a/tests/ui/issues/auxiliary/issue-41394.rs +++ b/tests/ui/enum-discriminant/auxiliary/issue-41394.rs diff --git a/tests/ui/issues/issue-41394-rpass.rs b/tests/ui/enum-discriminant/issue-41394-rpass.rs index 37c652523..37c652523 100644 --- a/tests/ui/issues/issue-41394-rpass.rs +++ b/tests/ui/enum-discriminant/issue-41394-rpass.rs diff --git a/tests/ui/issues/issue-41394.rs b/tests/ui/enum-discriminant/issue-41394.rs index 07cad8796..06a330813 100644 --- a/tests/ui/issues/issue-41394.rs +++ b/tests/ui/enum-discriminant/issue-41394.rs @@ -5,7 +5,6 @@ enum Foo { enum Bar { A = Foo::A as isize - //~^ const } fn main() {} diff --git a/tests/ui/issues/issue-41394.stderr b/tests/ui/enum-discriminant/issue-41394.stderr index 1b5c64628..fa95ca9c1 100644 --- a/tests/ui/issues/issue-41394.stderr +++ b/tests/ui/enum-discriminant/issue-41394.stderr @@ -6,12 +6,6 @@ LL | A = "" + 1 | | | &str -note: erroneous constant used - --> $DIR/issue-41394.rs:7:9 - | -LL | A = Foo::A as isize - | ^^^^^^^^^^^^^^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs index ad9fcc25b..62137c0c8 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs @@ -7,7 +7,7 @@ use core::intrinsics::discriminant_value; enum MyWeirdOption<T> { None = 0, Some(T) = std::mem::size_of::<T>(), - //~^ ERROR generic parameters may not be used in const operations + //~^ ERROR generic parameters may not be used in enum discriminant values } fn main() { diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr index e4e10468d..2cb159ee2 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-generics-in-discr-ice-2.rs:9:35 | LL | Some(T) = std::mem::size_of::<T>(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error: aborting due to previous error diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs index a0fb788a5..093c57534 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs @@ -8,7 +8,7 @@ enum MyWeirdOption<T> { //~^ ERROR parameter `T` is never used None = 0, Some = std::mem::size_of::<T>(), - //~^ ERROR generic parameters may not be used in const operations + //~^ ERROR generic parameters may not be used in enum discriminant values } fn main() { diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr index 7ea8a3912..fac3ce07a 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-generics-in-discr-ice.rs:10:32 | LL | Some = std::mem::size_of::<T>(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error[E0392]: parameter `T` is never used --> $DIR/issue-70453-generics-in-discr-ice.rs:7:20 diff --git a/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr b/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr index 0a7a63160..15cd6d303 100644 --- a/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr +++ b/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-polymorphic-ctfe.rs:9:41 | LL | Some(T) = core::mem::size_of::<*mut T>(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error: aborting due to previous error diff --git a/tests/ui/issues/issue-1821.rs b/tests/ui/enum/issue-1821.rs index 76ee9c3ed..76ee9c3ed 100644 --- a/tests/ui/issues/issue-1821.rs +++ b/tests/ui/enum/issue-1821.rs diff --git a/tests/ui/enum/issue-67945-1.stderr b/tests/ui/enum/issue-67945-1.stderr index 8f1b5b38e..878fa322f 100644 --- a/tests/ui/enum/issue-67945-1.stderr +++ b/tests/ui/enum/issue-67945-1.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-67945-1.rs:3:16 | LL | let x: S = 0; | ^ cannot perform const operation using `S` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error[E0392]: parameter `S` is never used --> $DIR/issue-67945-1.rs:1:10 diff --git a/tests/ui/enum/issue-67945-2.stderr b/tests/ui/enum/issue-67945-2.stderr index 63d3521af..f8ec12d47 100644 --- a/tests/ui/enum/issue-67945-2.stderr +++ b/tests/ui/enum/issue-67945-2.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-67945-2.rs:4:28 | LL | Var = type_ascribe!(0, S), | ^ cannot perform const operation using `S` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error[E0392]: parameter `S` is never used --> $DIR/issue-67945-2.rs:3:10 diff --git a/tests/ui/error-codes/E0026-teach.stderr b/tests/ui/error-codes/E0026-teach.stderr index 1a80edcbb..3d460490e 100644 --- a/tests/ui/error-codes/E0026-teach.stderr +++ b/tests/ui/error-codes/E0026-teach.stderr @@ -4,7 +4,7 @@ error[E0026]: struct `Thing` does not have a field named `z` LL | Thing { x, y, z } => {} | ^ struct `Thing` does not have this field | - = note: This error indicates that a struct pattern attempted to extract a non-existent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched. + = note: This error indicates that a struct pattern attempted to extract a nonexistent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched. If you are using shorthand field patterns but want to refer to the struct field by a different name, you should rename it explicitly. diff --git a/tests/ui/error-codes/E0277.stderr b/tests/ui/error-codes/E0277.stderr index 2b4784d7e..440e43dff 100644 --- a/tests/ui/error-codes/E0277.stderr +++ b/tests/ui/error-codes/E0277.stderr @@ -5,7 +5,8 @@ LL | fn f(p: Path) { } | ^ doesn't have a size known at compile-time | = help: within `Path`, the trait `Sized` is not implemented for `[u8]` - = note: required because it appears within the type `Path` +note: required because it appears within the type `Path` + --> $SRC_DIR/std/src/path.rs:LL:COL = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | diff --git a/tests/ui/error-codes/E0389.stderr b/tests/ui/error-codes/E0389.stderr index 51c4c92ad..e4001856c 100644 --- a/tests/ui/error-codes/E0389.stderr +++ b/tests/ui/error-codes/E0389.stderr @@ -7,7 +7,7 @@ LL | fancy_ref.num = 6; help: consider changing this to be a mutable reference | LL | let fancy_ref = &mut (&mut fancy); - | ~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/error-codes/E0719.rs b/tests/ui/error-codes/E0719.rs index 3311e1909..cbf1bb219 100644 --- a/tests/ui/error-codes/E0719.rs +++ b/tests/ui/error-codes/E0719.rs @@ -1,5 +1,6 @@ trait Foo: Iterator<Item = i32, Item = i32> {} //~^ ERROR is already specified +//~| ERROR is already specified type Unit = (); diff --git a/tests/ui/error-codes/E0719.stderr b/tests/ui/error-codes/E0719.stderr index b342d6343..e302f406d 100644 --- a/tests/ui/error-codes/E0719.stderr +++ b/tests/ui/error-codes/E0719.stderr @@ -7,13 +7,21 @@ LL | trait Foo: Iterator<Item = i32, Item = i32> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified - --> $DIR/E0719.rs:6:42 + --> $DIR/E0719.rs:1:33 + | +LL | trait Foo: Iterator<Item = i32, Item = i32> {} + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified + --> $DIR/E0719.rs:7:42 | LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> { | --------- ^^^^^^^^^^^ re-bound here | | | `Item` bound here first -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0719`. diff --git a/tests/ui/error-codes/E0746.fixed b/tests/ui/error-codes/E0746.fixed deleted file mode 100644 index ca8319aa0..000000000 --- a/tests/ui/error-codes/E0746.fixed +++ /dev/null @@ -1,18 +0,0 @@ -// run-rustfix -#![allow(dead_code)] -struct Struct; -trait Trait {} -impl Trait for Struct {} -impl Trait for u32 {} - -fn foo() -> impl Trait { Struct } -//~^ ERROR E0746 - -fn bar() -> impl Trait { //~ ERROR E0746 - if true { - return 0; - } - 42 -} - -fn main() {} diff --git a/tests/ui/error-codes/E0746.rs b/tests/ui/error-codes/E0746.rs index bf5ba8fff..86b5b7444 100644 --- a/tests/ui/error-codes/E0746.rs +++ b/tests/ui/error-codes/E0746.rs @@ -1,5 +1,5 @@ -// run-rustfix #![allow(dead_code)] + struct Struct; trait Trait {} impl Trait for Struct {} diff --git a/tests/ui/error-codes/E0746.stderr b/tests/ui/error-codes/E0746.stderr index 2153b59ad..9fe90ab7b 100644 --- a/tests/ui/error-codes/E0746.stderr +++ b/tests/ui/error-codes/E0746.stderr @@ -4,11 +4,14 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn foo() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `Struct`, which implements `Trait` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn foo() -> impl Trait { Struct } - | ~~~~~~~~~~ + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn foo() -> Box<dyn Trait> { Box::new(Struct) } + | ++++ + +++++++++ + error[E0746]: return type cannot have an unboxed trait object --> $DIR/E0746.rs:11:13 @@ -16,11 +19,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bar() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `{integer}`, which implements `Trait` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn bar() -> impl Trait { - | ~~~~~~~~~~ + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bar() -> Box<dyn Trait> { +LL | if true { +LL ~ return Box::new(0); +LL | } +LL ~ Box::new(42) + | error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0771.rs b/tests/ui/error-codes/E0771.rs index 67e7d106a..c0a2e98a7 100644 --- a/tests/ui/error-codes/E0771.rs +++ b/tests/ui/error-codes/E0771.rs @@ -1,7 +1,7 @@ #![feature(adt_const_params)] //~^ WARN the feature `adt_const_params` is incomplete -fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0771 +fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0770 fn main() { function_with_str::<"Hello, world!">() diff --git a/tests/ui/error-codes/E0771.stderr b/tests/ui/error-codes/E0771.stderr index b759399a9..9450c61c2 100644 --- a/tests/ui/error-codes/E0771.stderr +++ b/tests/ui/error-codes/E0771.stderr @@ -1,10 +1,10 @@ -error[E0771]: use of non-static lifetime `'a` in const generic +error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/E0771.rs:4:41 | LL | fn function_with_str<'a, const STRING: &'a str>() {} - | ^^ + | ^^ the type must not depend on the parameter `'a` | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + = note: lifetime parameters may not be used in the type of const parameters warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/E0771.rs:1:12 @@ -17,4 +17,4 @@ LL | #![feature(adt_const_params)] error: aborting due to previous error; 1 warning emitted -For more information about this error, try `rustc --explain E0771`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed index 47c4c9f67..bb093a4af 100644 --- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed +++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed @@ -1,4 +1,7 @@ // run-rustfix + +#![allow(dropping_references)] + struct Foo { x: isize } diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs index c698de50c..1a9f89c05 100644 --- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs +++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs @@ -1,4 +1,7 @@ // run-rustfix + +#![allow(dropping_references)] + struct Foo { x: isize } diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr b/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr index 7f5106eb5..c70671173 100644 --- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr +++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.stderr @@ -1,5 +1,5 @@ error[E0040]: explicit use of destructor method - --> $DIR/explicit-call-to-supertrait-dtor.rs:19:14 + --> $DIR/explicit-call-to-supertrait-dtor.rs:22:14 | LL | self.drop(); | -----^^^^-- diff --git a/tests/ui/extenv/extenv-escaped-var.rs b/tests/ui/extenv/extenv-escaped-var.rs new file mode 100644 index 000000000..d898feb78 --- /dev/null +++ b/tests/ui/extenv/extenv-escaped-var.rs @@ -0,0 +1,3 @@ +fn main() { + env!("\t"); //~ERROR environment variable `\t` not defined at compile time +} diff --git a/tests/ui/extenv/extenv-escaped-var.stderr b/tests/ui/extenv/extenv-escaped-var.stderr new file mode 100644 index 000000000..25e218c63 --- /dev/null +++ b/tests/ui/extenv/extenv-escaped-var.stderr @@ -0,0 +1,11 @@ +error: environment variable `\t` not defined at compile time + --> $DIR/extenv-escaped-var.rs:2:5 + | +LL | env!("\t"); + | ^^^^^^^^^^ + | + = help: use `std::env::var("\t")` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/extenv/issue-110547.rs b/tests/ui/extenv/issue-110547.rs new file mode 100644 index 000000000..a6fb96ac0 --- /dev/null +++ b/tests/ui/extenv/issue-110547.rs @@ -0,0 +1,7 @@ +// compile-flags: -C debug-assertions + +fn main() { + env!{"\t"}; //~ ERROR not defined at compile time + env!("\t"); //~ ERROR not defined at compile time + env!("\u{2069}"); //~ ERROR not defined at compile time +} diff --git a/tests/ui/extenv/issue-110547.stderr b/tests/ui/extenv/issue-110547.stderr new file mode 100644 index 000000000..10589ec2f --- /dev/null +++ b/tests/ui/extenv/issue-110547.stderr @@ -0,0 +1,29 @@ +error: environment variable `\t` not defined at compile time + --> $DIR/issue-110547.rs:4:5 + | +LL | env!{"\t"}; + | ^^^^^^^^^^ + | + = help: use `std::env::var("\t")` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: environment variable `\t` not defined at compile time + --> $DIR/issue-110547.rs:5:5 + | +LL | env!("\t"); + | ^^^^^^^^^^ + | + = help: use `std::env::var("\t")` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: environment variable `\u{2069}` not defined at compile time + --> $DIR/issue-110547.rs:6:5 + | +LL | env!("\u{2069}"); + | ^^^^^^^^^^^^^^^^ + | + = help: use `std::env::var("\u{2069}")` to read the variable at run time + = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + diff --git a/tests/ui/extern-flag/auxiliary/panic_handler.rs b/tests/ui/extern-flag/auxiliary/panic_handler.rs new file mode 100644 index 000000000..a625761a8 --- /dev/null +++ b/tests/ui/extern-flag/auxiliary/panic_handler.rs @@ -0,0 +1,17 @@ +#![feature(lang_items)] +#![no_std] + +// Since `rustc` generally passes `-nodefaultlibs` to the linker, +// Rust programs link necessary system libraries via `#[link()]` +// attributes in the `libc` crate. `libc` is a dependency of `std`, +// but as we are `#![no_std]`, we need to include it manually. +#![feature(rustc_private)] +extern crate libc; + +#[panic_handler] +pub fn begin_panic_handler(_info: &core::panic::PanicInfo<'_>) -> ! { + loop {} +} + +#[lang = "eh_personality"] +extern "C" fn eh_personality() {} diff --git a/tests/ui/extern-flag/force-extern.rs b/tests/ui/extern-flag/force-extern.rs new file mode 100644 index 000000000..f56b53782 --- /dev/null +++ b/tests/ui/extern-flag/force-extern.rs @@ -0,0 +1,9 @@ +// check-pass +// ignore-cross-compile (needs dylibs and compiletest doesn't have a more specific header) +// aux-crate:force:panic_handler=panic_handler.rs +// compile-flags: -Zunstable-options --crate-type dylib +// edition:2018 + +#![no_std] + +fn foo() {} diff --git a/tests/ui/extern-flag/no-force-extern.rs b/tests/ui/extern-flag/no-force-extern.rs new file mode 100644 index 000000000..ce9cbfe1c --- /dev/null +++ b/tests/ui/extern-flag/no-force-extern.rs @@ -0,0 +1,10 @@ +// aux-crate:panic_handler=panic_handler.rs +// ignore-cross-compile (needs dylibs and compiletest doesn't have a more specific header) +// compile_flags: -Zunstable-options --crate-type dylib +// error-pattern: `#[panic_handler]` function required, but not found +// dont-check-compiler-stderr +// edition: 2018 + +#![no_std] + +fn foo() {} diff --git a/tests/ui/extern-flag/redundant-force-extern.rs b/tests/ui/extern-flag/redundant-force-extern.rs new file mode 100644 index 000000000..a4091616d --- /dev/null +++ b/tests/ui/extern-flag/redundant-force-extern.rs @@ -0,0 +1,11 @@ +// check-pass +// ignore-cross-compile (needs dylibs and compiletest doesn't have a more specific header) +// aux-crate:force:panic_handler=panic_handler.rs +// compile-flags: -Zunstable-options --crate-type dylib +// edition:2018 + +#![no_std] + +extern crate panic_handler; + +fn foo() {} diff --git a/tests/ui/extern/auxiliary/invalid-utf8.txt b/tests/ui/extern/auxiliary/invalid-utf8.txt deleted file mode 100644 index dc1115b82..000000000 --- a/tests/ui/extern/auxiliary/invalid-utf8.txt +++ /dev/null @@ -1 +0,0 @@ -Ã(
\ No newline at end of file diff --git a/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis b/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis deleted file mode 100644 index 6eb47e3d8..000000000 --- a/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> -</AutoVisualizer> diff --git a/tests/ui/feature-gates/feature-gate-builtin_syntax.rs b/tests/ui/feature-gates/feature-gate-builtin_syntax.rs new file mode 100644 index 000000000..832bb5a96 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-builtin_syntax.rs @@ -0,0 +1,7 @@ +struct Foo { + v: u8, + w: u8, +} +fn main() { + builtin # offset_of(Foo, v); //~ ERROR `builtin #` syntax is unstable +} diff --git a/tests/ui/feature-gates/feature-gate-builtin_syntax.stderr b/tests/ui/feature-gates/feature-gate-builtin_syntax.stderr new file mode 100644 index 000000000..3bc7848f6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-builtin_syntax.stderr @@ -0,0 +1,12 @@ +error[E0658]: `builtin #` syntax is unstable + --> $DIR/feature-gate-builtin_syntax.rs:6:15 + | +LL | builtin # offset_of(Foo, v); + | ^^^^^^^^^ + | + = note: see issue #110680 <https://github.com/rust-lang/rust/issues/110680> for more information + = help: add `#![feature(builtin_syntax)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.rs b/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.rs new file mode 100644 index 000000000..cb265aa7f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.rs @@ -0,0 +1,6 @@ +#![crate_type = "lib"] + +#[cfg(overflow_checks)] //~ ERROR `cfg(overflow_checks)` is experimental +pub fn cast(v: i64)->u32{ + todo!() +} diff --git a/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.stderr b/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.stderr new file mode 100644 index 000000000..79aba7945 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_overflow_checks.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(overflow_checks)` is experimental and subject to change + --> $DIR/feature-gate-cfg_overflow_checks.rs:3:7 + | +LL | #[cfg(overflow_checks)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #111466 <https://github.com/rust-lang/rust/issues/111466> for more information + = help: add `#![feature(cfg_overflow_checks)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfi_encoding.rs b/tests/ui/feature-gates/feature-gate-cfi_encoding.rs new file mode 100644 index 000000000..3cef81560 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfi_encoding.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[cfi_encoding = "3Bar"] //~ERROR 3:1: 3:25: the `#[cfi_encoding]` attribute is an experimental feature [E0658] +pub struct Foo(i32); diff --git a/tests/ui/feature-gates/feature-gate-cfi_encoding.stderr b/tests/ui/feature-gates/feature-gate-cfi_encoding.stderr new file mode 100644 index 000000000..b10a15088 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfi_encoding.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[cfi_encoding]` attribute is an experimental feature + --> $DIR/feature-gate-cfi_encoding.rs:3:1 + | +LL | #[cfi_encoding = "3Bar"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information + = help: add `#![feature(cfi_encoding)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs b/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs deleted file mode 100644 index 4c4dc450d..000000000 --- a/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![debugger_visualizer(natvis_file = "auxiliary/debugger-visualizer.natvis")] //~ ERROR the `#[debugger_visualizer]` attribute is an experimental feature - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr b/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr deleted file mode 100644 index e9367fbc6..000000000 --- a/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: the `#[debugger_visualizer]` attribute is an experimental feature - --> $DIR/feature-gate-debugger-visualizer.rs:1:1 - | -LL | #![debugger_visualizer(natvis_file = "auxiliary/debugger-visualizer.natvis")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #95939 <https://github.com/rust-lang/rust/issues/95939> for more information - = help: add `#![feature(debugger_visualizer)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr index d81eade8e..303700c7a 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr @@ -31,14 +31,7 @@ LL | trait Trait { | ----- this trait cannot be made into an object... LL | fn ptr(self: Ptr<Self>); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on -note: required for `Ptr<{integer}>` to implement `CoerceUnsized<Ptr<dyn Trait>>` - --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:20:40 - | -LL | impl<T: Unsize<U> + ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T> {} - | --------- ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ - | | - | unsatisfied trait bound introduced here - = note: required by cast to type `Ptr<dyn Trait>` + = note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>` error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-negative_bounds.rs b/tests/ui/feature-gates/feature-gate-negative_bounds.rs new file mode 100644 index 000000000..533cb0ce5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-negative_bounds.rs @@ -0,0 +1,4 @@ +fn test<T: !Copy>() {} +//~^ ERROR negative bounds are not supported + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-negative_bounds.stderr b/tests/ui/feature-gates/feature-gate-negative_bounds.stderr new file mode 100644 index 000000000..ae010fdf3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-negative_bounds.stderr @@ -0,0 +1,8 @@ +error: negative bounds are not supported + --> $DIR/feature-gate-negative_bounds.rs:1:12 + | +LL | fn test<T: !Copy>() {} + | ^ + +error: aborting due to previous error + diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs b/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs deleted file mode 100644 index fc47a9061..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// only-x86 -#[link(name = "foo")] -extern "C" { - #[link_ordinal(42)] - //~^ ERROR: `#[link_ordinal]` is unstable on x86 - fn foo(); - #[link_ordinal(5)] - //~^ ERROR: `#[link_ordinal]` is unstable on x86 - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr deleted file mode 100644 index 0e900760d..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: `#[link_ordinal]` is unstable on x86 - --> $DIR/feature-gate-raw-dylib-2.rs:4:5 - | -LL | #[link_ordinal(42)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -error[E0658]: `#[link_ordinal]` is unstable on x86 - --> $DIR/feature-gate-raw-dylib-2.rs:7:5 - | -LL | #[link_ordinal(5)] - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -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-raw-dylib-import-name-type.rs b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs deleted file mode 100644 index 295f502d6..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs +++ /dev/null @@ -1,8 +0,0 @@ -// only-windows -// only-x86 -#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] -//~^ ERROR link kind `raw-dylib` is unstable on x86 -//~| ERROR import name type is unstable -extern "C" {} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr deleted file mode 100644 index d6b165b76..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: link kind `raw-dylib` is unstable on x86 - --> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:29 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] - | ^^^^^^^^^^^ - | - = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -error[E0658]: import name type is unstable - --> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:61 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] - | ^^^^^^^^^^^ - | - = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -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-raw-dylib.rs b/tests/ui/feature-gates/feature-gate-raw-dylib.rs deleted file mode 100644 index 291cca8fd..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib.rs +++ /dev/null @@ -1,7 +0,0 @@ -// only-windows -// only-x86 -#[link(name = "foo", kind = "raw-dylib")] -//~^ ERROR: link kind `raw-dylib` is unstable on x86 -extern "C" {} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib.stderr deleted file mode 100644 index f02241e49..000000000 --- a/tests/ui/feature-gates/feature-gate-raw-dylib.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: link kind `raw-dylib` is unstable on x86 - --> $DIR/feature-gate-raw-dylib.rs:3:29 - | -LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^ - | - = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information - = help: add `#![feature(raw_dylib)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr index c3a371e25..1bdb2574e 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr @@ -1,5 +1,5 @@ error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ @@ -7,17 +7,8 @@ LL | fn foo<T: Trait<m(): Send>>() {} = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = help: add `#![feature(return_type_notation)]` to the crate attributes to enable -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:7:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: parenthesized generic arguments cannot be used in associated type constraints - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^-- @@ -25,12 +16,12 @@ LL | fn foo<T: Trait<m(): Send>>() {} | help: remove these parentheses error[E0220]: associated type `m` not found for `Trait` - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^ associated type `m` not found -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 3 previous errors Some errors have detailed explanations: E0220, E0658. For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr index 52c90c156..dd6ebb610 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:7:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - warning: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ @@ -18,5 +9,5 @@ LL | fn foo<T: Trait<m(): Send>>() {} = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs index 5028b9ec9..d9bcb65fe 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -5,7 +5,6 @@ // Since we're not adding new syntax, `cfg`'d out RTN must pass. #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn m(); diff --git a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.rs b/tests/ui/feature-gates/feature-gate-thiscall.rs index 0a323e50f..97a732bcf 100644 --- a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.rs +++ b/tests/ui/feature-gates/feature-gate-thiscall.rs @@ -1,5 +1,4 @@ // gate-test-abi_thiscall -// gate-test-c_unwind // needs-llvm-components: x86 // compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib #![no_core] @@ -7,8 +6,8 @@ #[lang="sized"] trait Sized { } -// Test that the "thiscall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. +// Test that the "thiscall" ABI is feature-gated, and cannot be used when +// the `abi_thiscall` feature gate is not used. extern "thiscall-unwind" fn fu() {} //~ ERROR thiscall-unwind ABI is experimental extern "thiscall" fn f() {} //~ ERROR thiscall is experimental diff --git a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.stderr b/tests/ui/feature-gates/feature-gate-thiscall.stderr index 9ca00a55c..346e45952 100644 --- a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.stderr +++ b/tests/ui/feature-gates/feature-gate-thiscall.stderr @@ -1,14 +1,13 @@ error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:13:8 + --> $DIR/feature-gate-thiscall.rs:12:8 | LL | extern "thiscall-unwind" fn fu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:14:8 + --> $DIR/feature-gate-thiscall.rs:13:8 | LL | extern "thiscall" fn f() {} | ^^^^^^^^^^ @@ -16,7 +15,7 @@ LL | extern "thiscall" fn f() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:17:12 + --> $DIR/feature-gate-thiscall.rs:16:12 | LL | extern "thiscall" fn m(); | ^^^^^^^^^^ @@ -24,16 +23,15 @@ LL | extern "thiscall" fn m(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:18:12 + --> $DIR/feature-gate-thiscall.rs:17:12 | LL | extern "thiscall-unwind" fn mu(); | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:20:12 + --> $DIR/feature-gate-thiscall.rs:19:12 | LL | extern "thiscall" fn dm() {} | ^^^^^^^^^^ @@ -41,16 +39,15 @@ LL | extern "thiscall" fn dm() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:21:12 + --> $DIR/feature-gate-thiscall.rs:20:12 | LL | extern "thiscall-unwind" fn dmu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:26:12 + --> $DIR/feature-gate-thiscall.rs:25:12 | LL | extern "thiscall" fn m() {} | ^^^^^^^^^^ @@ -58,16 +55,15 @@ LL | extern "thiscall" fn m() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:27:12 + --> $DIR/feature-gate-thiscall.rs:26:12 | LL | extern "thiscall-unwind" fn mu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:31:12 + --> $DIR/feature-gate-thiscall.rs:30:12 | LL | extern "thiscall" fn im() {} | ^^^^^^^^^^ @@ -75,16 +71,15 @@ LL | extern "thiscall" fn im() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:32:12 + --> $DIR/feature-gate-thiscall.rs:31:12 | LL | extern "thiscall-unwind" fn imu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:35:18 + --> $DIR/feature-gate-thiscall.rs:34:18 | LL | type TA = extern "thiscall" fn(); | ^^^^^^^^^^ @@ -92,16 +87,15 @@ LL | type TA = extern "thiscall" fn(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:36:19 + --> $DIR/feature-gate-thiscall.rs:35:19 | LL | type TAU = extern "thiscall-unwind" fn(); | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:38:8 + --> $DIR/feature-gate-thiscall.rs:37:8 | LL | extern "thiscall" {} | ^^^^^^^^^^ @@ -109,13 +103,12 @@ LL | extern "thiscall" {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:39:8 + --> $DIR/feature-gate-thiscall.rs:38:8 | LL | extern "thiscall-unwind" {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error: aborting due to 14 previous errors diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.rs b/tests/ui/feature-gates/feature-gate-type_ascription.rs index 7a5971573..5c3f0e37d 100644 --- a/tests/ui/feature-gates/feature-gate-type_ascription.rs +++ b/tests/ui/feature-gates/feature-gate-type_ascription.rs @@ -1,5 +1,5 @@ // Type ascription is unstable fn main() { - let a = 10: u8; //~ ERROR type ascription is experimental + let a = type_ascribe!(10, u8); //~ ERROR use of unstable library feature 'type_ascription': placeholder syntax for type ascription } diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.stderr b/tests/ui/feature-gates/feature-gate-type_ascription.stderr index 615d5b9a1..d747aea6d 100644 --- a/tests/ui/feature-gates/feature-gate-type_ascription.stderr +++ b/tests/ui/feature-gates/feature-gate-type_ascription.stderr @@ -1,8 +1,8 @@ -error[E0658]: type ascription is experimental +error[E0658]: use of unstable library feature 'type_ascription': placeholder syntax for type ascription --> $DIR/feature-gate-type_ascription.rs:4:13 | -LL | let a = 10: u8; - | ^^^^^^ +LL | let a = type_ascribe!(10, u8); + | ^^^^^^^^^^^^ | = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information = help: add `#![feature(type_ascription)]` to the crate attributes to enable diff --git a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs index 0680d2344..dce94c9ea 100644 --- a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs +++ b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs @@ -13,5 +13,4 @@ fn non_unsafe_pin_new_unchecked<T>(pointer: &mut T) -> Pin<&mut T> { fn main() { let mut self_referential = PhantomPinned; let _: Pin<&mut PhantomPinned> = non_unsafe_pin_new_unchecked(&mut self_referential); - core::mem::forget(self_referential); // move and disable drop glue! } diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.rs b/tests/ui/feature-gates/feature-gate-vectorcall.rs index 5a6c6d288..706780dfd 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.rs +++ b/tests/ui/feature-gates/feature-gate-vectorcall.rs @@ -6,8 +6,8 @@ #[lang="sized"] trait Sized { } -// Test that the "vectorcall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. +// Test that the "vectorcall" ABI is feature-gated, and cannot be used when +// the `vectorcall` feature gate is not used. extern "vectorcall" fn f() {} //~ ERROR vectorcall is experimental diff --git a/tests/ui/fmt/format-string-error.rs b/tests/ui/fmt/format-string-error.rs index eae4f3cb5..9b436e2c4 100644 --- a/tests/ui/fmt/format-string-error.rs +++ b/tests/ui/fmt/format-string-error.rs @@ -17,7 +17,7 @@ fn main() { let _ = format!("}"); //~^ ERROR invalid format string: unmatched `}` found let _ = format!("{\\}"); - //~^ ERROR invalid format string: expected `'}'`, found `'\\'` + //~^ ERROR invalid format string: expected `'}'`, found `'\'` let _ = format!("\n\n\n{\n\n\n"); //~^ ERROR invalid format string let _ = format!(r###" diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr index bf18fb315..ed008c454 100644 --- a/tests/ui/fmt/ifmt-bad-arg.stderr +++ b/tests/ui/fmt/ifmt-bad-arg.stderr @@ -307,7 +307,7 @@ LL | println!("{} {:.*} {}", 1, 3.2, 4); = note: expected reference `&usize` found reference `&{float}` note: associated function defined here - --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types @@ -321,7 +321,7 @@ LL | println!("{} {:07$.*} {}", 1, 3.2, 4); = note: expected reference `&usize` found reference `&{float}` note: associated function defined here - --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 38 previous errors diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index dc2dee3f3..b0dddd3b1 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -15,11 +15,11 @@ LL | format!("{:X}", "3"); NonZeroI64 NonZeroI8 NonZeroIsize - and 21 others + and 20 others = note: required for `&str` to implement `UpperHex` -note: required by a bound in `core::fmt::ArgumentV1::<'a>::new_upper_hex` - --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL - = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `arg_new` (in Nightly builds, run with -Z macro-backtrace for more info) +note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/fmt/send-sync.stderr b/tests/ui/fmt/send-sync.stderr index d43f4f0d9..e3ebe6cdc 100644 --- a/tests/ui/fmt/send-sync.stderr +++ b/tests/ui/fmt/send-sync.stderr @@ -1,37 +1,41 @@ -error[E0277]: `core::fmt::Opaque` cannot be shared between threads safely +error[E0277]: `core::fmt::rt::Opaque` cannot be shared between threads safely --> $DIR/send-sync.rs:8:10 | LL | send(format_args!("{:?}", c)); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::Opaque` cannot be shared between threads safely + | ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::rt::Opaque` cannot be shared between threads safely | | | required by a bound introduced by this call | - = help: within `[core::fmt::ArgumentV1<'_>]`, the trait `Sync` is not implemented for `core::fmt::Opaque` - = note: required because it appears within the type `&core::fmt::Opaque` - = note: required because it appears within the type `ArgumentV1<'_>` - = note: required because it appears within the type `[ArgumentV1<'_>]` - = note: required for `&[core::fmt::ArgumentV1<'_>]` to implement `Send` - = note: required because it appears within the type `Arguments<'_>` + = help: within `[core::fmt::rt::Argument<'_>]`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque` + = note: required because it appears within the type `&core::fmt::rt::Opaque` +note: required because it appears within the type `Argument<'_>` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: required because it appears within the type `[Argument<'_>]` + = note: required for `&[core::fmt::rt::Argument<'_>]` to implement `Send` +note: required because it appears within the type `Arguments<'_>` + --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL note: required by a bound in `send` --> $DIR/send-sync.rs:1:12 | LL | fn send<T: Send>(_: T) {} | ^^^^ required by this bound in `send` -error[E0277]: `core::fmt::Opaque` cannot be shared between threads safely +error[E0277]: `core::fmt::rt::Opaque` cannot be shared between threads safely --> $DIR/send-sync.rs:9:10 | LL | sync(format_args!("{:?}", c)); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::Opaque` cannot be shared between threads safely + | ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::rt::Opaque` cannot be shared between threads safely | | | required by a bound introduced by this call | - = help: within `Arguments<'_>`, the trait `Sync` is not implemented for `core::fmt::Opaque` - = note: required because it appears within the type `&core::fmt::Opaque` - = note: required because it appears within the type `ArgumentV1<'_>` - = note: required because it appears within the type `[ArgumentV1<'_>]` - = note: required because it appears within the type `&[ArgumentV1<'_>]` - = note: required because it appears within the type `Arguments<'_>` + = help: within `Arguments<'_>`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque` + = note: required because it appears within the type `&core::fmt::rt::Opaque` +note: required because it appears within the type `Argument<'_>` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: required because it appears within the type `[Argument<'_>]` + = note: required because it appears within the type `&[Argument<'_>]` +note: required because it appears within the type `Arguments<'_>` + --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL note: required by a bound in `sync` --> $DIR/send-sync.rs:2:12 | diff --git a/tests/ui/fn/fn-item-lifetime-bounds.rs b/tests/ui/fn/fn-item-lifetime-bounds.rs new file mode 100644 index 000000000..68a1d0ce9 --- /dev/null +++ b/tests/ui/fn/fn-item-lifetime-bounds.rs @@ -0,0 +1,37 @@ +// check-pass +// known-bug: #84533 + +// Should fail. Lifetimes are checked correctly when `foo` is called, but NOT +// when only the lifetime parameters are instantiated. + +use std::marker::PhantomData; + +#[allow(dead_code)] +fn foo<'b, 'a>() -> PhantomData<&'b &'a ()> { + PhantomData +} + +#[allow(dead_code)] +#[allow(path_statements)] +fn caller<'b, 'a>() { + foo::<'b, 'a>; +} + +// In contrast to above, below code correctly does NOT compile. +// fn caller<'b, 'a>() { +// foo::<'b, 'a>(); +// } + +// error: lifetime may not live long enough +// --> src/main.rs:22:5 +// | +// 21 | fn caller<'b, 'a>() { +// | -- -- lifetime `'a` defined here +// | | +// | lifetime `'b` defined here +// 22 | foo::<'b, 'a>(); +// | ^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b` +// | +// = help: consider adding the following bound: `'a: 'b` + +fn main() {} diff --git a/tests/ui/fn/implied-bounds-impl-header-projections.rs b/tests/ui/fn/implied-bounds-impl-header-projections.rs new file mode 100644 index 000000000..28cec8050 --- /dev/null +++ b/tests/ui/fn/implied-bounds-impl-header-projections.rs @@ -0,0 +1,31 @@ +// check-pass +// known-bug: #100051 + +// Should fail. Implied bounds from projections in impl headers can create +// improper lifetimes. Variant of issue #98543 which was fixed by #99217. + +trait Trait { + type Type; +} + +impl<T> Trait for T { + type Type = (); +} + +trait Extend<'a, 'b> { + fn extend(self, s: &'a str) -> &'b str; +} + +impl<'a, 'b> Extend<'a, 'b> for <&'b &'a () as Trait>::Type +where + for<'what, 'ever> &'what &'ever (): Trait, +{ + fn extend(self, s: &'a str) -> &'b str { + s + } +} + +fn main() { + let y = <() as Extend<'_, '_>>::extend((), &String::from("Hello World")); + println!("{}", y); +} diff --git a/tests/ui/issues/issue-3099.rs b/tests/ui/fn/issue-3099.rs index ee75b3593..ee75b3593 100644 --- a/tests/ui/issues/issue-3099.rs +++ b/tests/ui/fn/issue-3099.rs diff --git a/tests/ui/issues/issue-3099.stderr b/tests/ui/fn/issue-3099.stderr index 32ee2e1d2..32ee2e1d2 100644 --- a/tests/ui/issues/issue-3099.stderr +++ b/tests/ui/fn/issue-3099.stderr diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr index 165748d44..b2a5b92ed 100644 --- a/tests/ui/generator/auto-trait-regions.drop_tracking.stderr +++ b/tests/ui/generator/auto-trait-regions.drop_tracking.stderr @@ -9,7 +9,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut binding, &mut true, No); + | error[E0716]: temporary value dropped while borrowed --> $DIR/auto-trait-regions.rs:48:35 @@ -22,7 +26,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut true, &mut binding, No); + | error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:34:5 diff --git a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr b/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr index 165748d44..b2a5b92ed 100644 --- a/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr +++ b/tests/ui/generator/auto-trait-regions.drop_tracking_mir.stderr @@ -9,7 +9,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut binding, &mut true, No); + | error[E0716]: temporary value dropped while borrowed --> $DIR/auto-trait-regions.rs:48:35 @@ -22,7 +26,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut true, &mut binding, No); + | error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:34:5 diff --git a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr b/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr index 165748d44..b2a5b92ed 100644 --- a/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr +++ b/tests/ui/generator/auto-trait-regions.no_drop_tracking.stderr @@ -9,7 +9,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut binding, &mut true, No); + | error[E0716]: temporary value dropped while borrowed --> $DIR/auto-trait-regions.rs:48:35 @@ -22,7 +26,11 @@ LL | let a = A(&mut true, &mut true, No); LL | assert_foo(a); | - borrow later used here | - = note: consider using a `let` binding to create a longer lived value +help: consider using a `let` binding to create a longer lived value + | +LL ~ let binding = true; +LL ~ let a = A(&mut true, &mut binding, No); + | error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:34:5 diff --git a/tests/ui/generator/auto-trait-regions.stderr b/tests/ui/generator/auto-trait-regions.stderr deleted file mode 100644 index 165748d44..000000000 --- a/tests/ui/generator/auto-trait-regions.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:48:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:34:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:54:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/generator/borrowing.stderr deleted file mode 100644 index 96e3c327f..000000000 --- a/tests/ui/generator/borrowing.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/drop-env.rs b/tests/ui/generator/drop-env.rs index 66dfb8c2c..137a40793 100644 --- a/tests/ui/generator/drop-env.rs +++ b/tests/ui/generator/drop-env.rs @@ -4,6 +4,7 @@ //[nomiropt]compile-flags: -Z mir-opt-level=0 #![feature(generators, generator_trait)] +#![allow(dropping_copy_types)] use std::ops::Generator; use std::pin::Pin; diff --git a/tests/ui/generator/drop-tracking-error-body.rs b/tests/ui/generator/drop-tracking-error-body.rs new file mode 100644 index 000000000..f99d9ab6b --- /dev/null +++ b/tests/ui/generator/drop-tracking-error-body.rs @@ -0,0 +1,18 @@ +// compile-flags: -Zdrop-tracking-mir --edition=2021 + +#![feature(generators)] + +pub async fn async_bad_body() { + match true {} //~ ERROR non-exhaustive patterns: type `bool` is non-empty +} + +pub fn generator_bad_body() { + || { + // 'non-exhaustive pattern' only seems to be reported once, so this annotation doesn't work + // keep the function around so we can make sure it doesn't ICE + match true {}; // ERROR non-exhaustive patterns: type `bool` is non-empty + yield (); + }; +} + +fn main() {} diff --git a/tests/ui/generator/drop-tracking-error-body.stderr b/tests/ui/generator/drop-tracking-error-body.stderr new file mode 100644 index 000000000..28a689233 --- /dev/null +++ b/tests/ui/generator/drop-tracking-error-body.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `bool` is non-empty + --> $DIR/drop-tracking-error-body.rs:6:11 + | +LL | match true {} + | ^^^^ + | + = note: the matched value is of type `bool` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match true { +LL + _ => todo!(), +LL ~ } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs new file mode 100644 index 000000000..9408acc15 --- /dev/null +++ b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs @@ -0,0 +1,12 @@ +// edition:2021 +// compile-flags: -Zdrop-tracking-mir=yes +#![feature(generators)] + +fn main() { + let x = &mut (); + || { + let _c = || yield *&mut *x; + || _ = &mut *x; + //~^ cannot borrow `*x` as mutable more than once at a time + }; +} diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr new file mode 100644 index 000000000..4d72ebe79 --- /dev/null +++ b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr @@ -0,0 +1,18 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/issue-110929-generator-conflict-error-ice.rs:9:9 + | +LL | let _c = || yield *&mut *x; + | -- -- first borrow occurs due to use of `*x` in generator + | | + | first mutable borrow occurs here +LL | || _ = &mut *x; + | ^^ -- second borrow occurs due to use of `*x` in closure + | | + | second mutable borrow occurs here +LL | +LL | }; + | - first borrow might be used here, when `_c` is dropped and runs the destructor for generator + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/issue-57017.no_drop_tracking.stderr b/tests/ui/generator/issue-57017.no_drop_tracking.stderr index 06d2d23b9..f7b8e198c 100644 --- a/tests/ui/generator/issue-57017.no_drop_tracking.stderr +++ b/tests/ui/generator/issue-57017.no_drop_tracking.stderr @@ -1,5 +1,5 @@ error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:31:25 + --> $DIR/issue-57017.rs:32:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -15,7 +15,7 @@ LL | | ); | = help: the trait `Sync` is not implemented for `copy::unsync::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:29:28 + --> $DIR/issue-57017.rs:30:28 | LL | let g = move || match drop(&$name::unsync::Client::default()) { | --------------------------------- has type `©::unsync::Client` which is not `Send` @@ -33,14 +33,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:43:25 + --> $DIR/issue-57017.rs:44:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -54,9 +54,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:40:21: 40:28]`, the trait `Send` is not implemented for `copy::unsend::Client` + = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `copy::unsend::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:41:28 + --> $DIR/issue-57017.rs:42:28 | LL | let g = move || match drop($name::unsend::Client::default()) { | -------------------------------- has type `copy::unsend::Client` which is not `Send` @@ -74,14 +74,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:31:25 + --> $DIR/issue-57017.rs:32:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -97,7 +97,7 @@ LL | | ); | = help: the trait `Sync` is not implemented for `derived_drop::unsync::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:29:28 + --> $DIR/issue-57017.rs:30:28 | LL | let g = move || match drop(&$name::unsync::Client::default()) { | --------------------------------- has type `&derived_drop::unsync::Client` which is not `Send` @@ -115,14 +115,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:43:25 + --> $DIR/issue-57017.rs:44:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -136,9 +136,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:40:21: 40:28]`, the trait `Send` is not implemented for `derived_drop::unsend::Client` + = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `derived_drop::unsend::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:41:28 + --> $DIR/issue-57017.rs:42:28 | LL | let g = move || match drop($name::unsend::Client::default()) { | -------------------------------- has type `derived_drop::unsend::Client` which is not `Send` @@ -156,14 +156,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:31:25 + --> $DIR/issue-57017.rs:32:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -179,7 +179,7 @@ LL | | ); | = help: the trait `Sync` is not implemented for `significant_drop::unsync::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:29:28 + --> $DIR/issue-57017.rs:30:28 | LL | let g = move || match drop(&$name::unsync::Client::default()) { | --------------------------------- has type `&significant_drop::unsync::Client` which is not `Send` @@ -197,14 +197,14 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: generator cannot be sent between threads safely - --> $DIR/issue-57017.rs:43:25 + --> $DIR/issue-57017.rs:44:25 | LL | assert_send(g); | ^ generator is not `Send` @@ -218,9 +218,9 @@ LL | | } LL | | ); | |_____- in this macro invocation | - = help: within `[generator@$DIR/issue-57017.rs:40:21: 40:28]`, the trait `Send` is not implemented for `significant_drop::unsend::Client` + = help: within `[generator@$DIR/issue-57017.rs:41:21: 41:28]`, the trait `Send` is not implemented for `significant_drop::unsend::Client` note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-57017.rs:41:28 + --> $DIR/issue-57017.rs:42:28 | LL | let g = move || match drop($name::unsend::Client::default()) { | -------------------------------- has type `significant_drop::unsend::Client` which is not `Send` @@ -238,7 +238,7 @@ LL | | } LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/issue-57017.rs:51:19 + --> $DIR/issue-57017.rs:52:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index 03b00ac99..381897c77 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -5,6 +5,7 @@ // [drop_tracking_mir] build-pass #![feature(generators, negative_impls)] +#![allow(dropping_references, dropping_copy_types)] macro_rules! type_combinations { ( diff --git a/tests/ui/generator/issue-57084.rs b/tests/ui/generator/issue-57084.rs index 2a5c3dd05..fbed78ff2 100644 --- a/tests/ui/generator/issue-57084.rs +++ b/tests/ui/generator/issue-57084.rs @@ -1,5 +1,5 @@ // This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly). -// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '_#1r" +// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '?1" // run-pass // edition:2018 #![feature(generators,generator_trait)] diff --git a/tests/ui/generator/non-static-is-unpin.rs b/tests/ui/generator/non-static-is-unpin.rs index 17e23f5bc..a5dde3912 100644 --- a/tests/ui/generator/non-static-is-unpin.rs +++ b/tests/ui/generator/non-static-is-unpin.rs @@ -3,6 +3,7 @@ // run-pass #![feature(generators, generator_trait)] +#![allow(dropping_copy_types)] use std::marker::{PhantomPinned, Unpin}; diff --git a/tests/ui/generator/resume-arg-size.rs b/tests/ui/generator/resume-arg-size.rs index b93dc54f7..195166f97 100644 --- a/tests/ui/generator/resume-arg-size.rs +++ b/tests/ui/generator/resume-arg-size.rs @@ -1,4 +1,5 @@ #![feature(generators)] +#![allow(dropping_copy_types)] // run-pass diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/generator/retain-resume-ref.stderr deleted file mode 100644 index 7122a951e..000000000 --- a/tests/ui/generator/retain-resume-ref.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr index 9e1fed54c..dec0141ab 100644 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr +++ b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr @@ -1,10 +1,10 @@ error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ---------------------------^^^^^^ - | | | - | | `[(); _]` is not a future + | ----------------------------^^^^^ + | | || + | | |`[(); _]` is not a future | | help: remove the `.await` | this call returns `[(); _]` | @@ -19,10 +19,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -31,10 +31,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -43,10 +43,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -55,10 +55,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -67,10 +67,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/generator/unresolved-ct-var.stderr b/tests/ui/generator/unresolved-ct-var.stderr index fdf00dfad..ace254178 100644 --- a/tests/ui/generator/unresolved-ct-var.stderr +++ b/tests/ui/generator/unresolved-ct-var.stderr @@ -1,10 +1,10 @@ error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ---------------------------^^^^^^ - | | | - | | `[(); _]` is not a future + | ----------------------------^^^^^ + | | || + | | |`[(); _]` is not a future | | help: remove the `.await` | this call returns `[(); _]` | @@ -19,10 +19,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -31,10 +31,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -43,10 +43,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -55,10 +55,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -67,10 +67,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs b/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs new file mode 100644 index 000000000..5b10aab4b --- /dev/null +++ b/tests/ui/generic-associated-types/auxiliary/missing-item-sugg.rs @@ -0,0 +1,5 @@ +pub trait Foo { + type Gat<T> + where + T: std::fmt::Display; +} diff --git a/tests/ui/generic-associated-types/equality-bound.stderr b/tests/ui/generic-associated-types/equality-bound.stderr index d78f7a7fb..b21ff30a2 100644 --- a/tests/ui/generic-associated-types/equality-bound.stderr +++ b/tests/ui/generic-associated-types/equality-bound.stderr @@ -36,7 +36,10 @@ error[E0433]: failed to resolve: use of undeclared type `I` --> $DIR/equality-bound.rs:9:41 | LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 { - | ^ use of undeclared type `I` + | ^ + | | + | use of undeclared type `I` + | help: a type parameter with a similar name exists: `J` error: aborting due to 4 previous errors diff --git a/tests/ui/generic-associated-types/issue-76535.base.stderr b/tests/ui/generic-associated-types/issue-76535.base.stderr index 52c6e3eec..370329b9f 100644 --- a/tests/ui/generic-associated-types/issue-76535.base.stderr +++ b/tests/ui/generic-associated-types/issue-76535.base.stderr @@ -43,8 +43,7 @@ LL | pub trait SuperTrait { LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait - = note: required for `Box<SuperStruct>` to implement `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>` - = note: required by cast to type `Box<dyn SuperTrait<SubType = SubStruct<'_>>>` + = note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType = SubStruct<'_>>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr index f1de77bc3..ad704f5e9 100644 --- a/tests/ui/generic-associated-types/issue-79422.base.stderr +++ b/tests/ui/generic-associated-types/issue-79422.base.stderr @@ -43,8 +43,7 @@ LL | trait MapLike<K, V> { LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait - = note: required for `Box<BTreeMap<u8, u8>>` to implement `CoerceUnsized<Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>>` - = note: required by cast to type `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>` + = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-79422.extended.stderr b/tests/ui/generic-associated-types/issue-79422.extended.stderr index 04184fce9..14492266c 100644 --- a/tests/ui/generic-associated-types/issue-79422.extended.stderr +++ b/tests/ui/generic-associated-types/issue-79422.extended.stderr @@ -27,7 +27,7 @@ LL | type VRefCont<'a> = &'a V where Self: 'a; | ^^^^^ = note: expected trait object `(dyn RefCont<'_, u8> + 'static)` found reference `&u8` - = note: required for the cast from `BTreeMap<u8, u8>` to the object type `dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>` + = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>` error: aborting due to 2 previous errors diff --git a/tests/ui/generic-associated-types/issue-88595.rs b/tests/ui/generic-associated-types/issue-88595.rs index 5a40a6129..7de906e7e 100644 --- a/tests/ui/generic-associated-types/issue-88595.rs +++ b/tests/ui/generic-associated-types/issue-88595.rs @@ -19,4 +19,5 @@ impl<'a> A<'a> for C { type B<'b> = impl Clone; fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope + //~^ ERROR: mismatched types } diff --git a/tests/ui/generic-associated-types/issue-88595.stderr b/tests/ui/generic-associated-types/issue-88595.stderr index 79d3479af..d6caed854 100644 --- a/tests/ui/generic-associated-types/issue-88595.stderr +++ b/tests/ui/generic-associated-types/issue-88595.stderr @@ -1,16 +1,34 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-88595.rs:21:35 + --> $DIR/issue-88595.rs:21:5 | LL | fn a(&'a self) -> Self::B<'a> {} - | ^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice | -note: lifetime used multiple times - --> $DIR/issue-88595.rs:18:6 +note: for this opaque type + --> $DIR/issue-88595.rs:19:18 | -LL | impl<'a> A<'a> for C { - | ^^ LL | type B<'b> = impl Clone; - | ^^ + | ^^^^^^^^^^ -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/issue-88595.rs:21:23 + | +LL | type B<'b> = impl Clone; + | ---------- the expected opaque type +LL | +LL | fn a(&'a self) -> Self::B<'a> {} + | - ^^^^^^^^^^^ expected opaque type, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected opaque type `<C as A<'a>>::B<'a>` + found unit type `()` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/issue-88595.rs:21:5 + | +LL | fn a(&'a self) -> Self::B<'a> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generic-associated-types/missing-item-sugg.rs b/tests/ui/generic-associated-types/missing-item-sugg.rs new file mode 100644 index 000000000..35d573d81 --- /dev/null +++ b/tests/ui/generic-associated-types/missing-item-sugg.rs @@ -0,0 +1,11 @@ +// aux-build:missing-item-sugg.rs + +extern crate missing_item_sugg; + +struct Local; +impl missing_item_sugg::Foo for Local { + //~^ ERROR not all trait items implemented, missing: `Gat` +} +//~^ HELP implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;` + +fn main() {} diff --git a/tests/ui/generic-associated-types/missing-item-sugg.stderr b/tests/ui/generic-associated-types/missing-item-sugg.stderr new file mode 100644 index 000000000..378115f6d --- /dev/null +++ b/tests/ui/generic-associated-types/missing-item-sugg.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `Gat` + --> $DIR/missing-item-sugg.rs:6:1 + | +LL | impl missing_item_sugg::Foo for Local { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Gat` in implementation + | + = help: implement the missing item: `type Gat<T> = /* Type */ where T: std::fmt::Display;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs index ecabf8943..b7b93ef1c 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs +++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.rs @@ -5,9 +5,6 @@ trait X { const _: () = { fn f1<'a>(arg : Box<dyn X< : 32 >>) {} //~^ ERROR: expected one of `>`, a const expression, lifetime, or type, found `:` - //~| ERROR: expected parameter name, found `>` - //~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` - //~| ERROR: constant provided when a type was expected }; const _: () = { diff --git a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr index 10ceccedc..bfddb6dc6 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr +++ b/tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr @@ -3,41 +3,14 @@ error: expected one of `>`, a const expression, lifetime, or type, found `:` | LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} | ^ expected one of `>`, a const expression, lifetime, or type - | -help: expressions must be enclosed in braces to be used as const generic arguments - | -LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {} - | + + - -error: expected parameter name, found `>` - --> $DIR/trait-path-missing-gen_arg.rs:6:36 - | -LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} - | ^ expected parameter name - -error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>` - --> $DIR/trait-path-missing-gen_arg.rs:6:36 - | -LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} - | ^ - | | - | expected one of `!`, `)`, `+`, `,`, or `::` - | help: missing `,` error: expected one of `>`, a const expression, lifetime, or type, found `=` - --> $DIR/trait-path-missing-gen_arg.rs:14:30 + --> $DIR/trait-path-missing-gen_arg.rs:11:30 | LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {} | - ^ expected one of `>`, a const expression, lifetime, or type | | | maybe try to close unmatched angle bracket -error[E0747]: constant provided when a type was expected - --> $DIR/trait-path-missing-gen_arg.rs:6:23 - | -LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {} - | ^^^^^^^^^^^ - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/generic-associated-types/self-outlives-lint.rs b/tests/ui/generic-associated-types/self-outlives-lint.rs index 673891fc3..0ea81b5ae 100644 --- a/tests/ui/generic-associated-types/self-outlives-lint.rs +++ b/tests/ui/generic-associated-types/self-outlives-lint.rs @@ -189,7 +189,7 @@ trait MultipleMethods { } // We would normally require `Self: 'a`, but we can prove that `Self: 'static` -// because of the the bounds on the trait, so the bound is proven +// because of the bounds on the trait, so the bound is proven trait Trait: 'static { type Assoc<'a>; fn make_assoc(_: &u32) -> Self::Assoc<'_>; diff --git a/tests/ui/generics/issue-79605.rs b/tests/ui/generics/issue-79605.rs new file mode 100644 index 000000000..6f4c31e57 --- /dev/null +++ b/tests/ui/generics/issue-79605.rs @@ -0,0 +1,6 @@ +struct X<'a, T>(&'a T); + +impl X<'_, _> {} +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for implementations + +fn main() {} diff --git a/tests/ui/generics/issue-79605.stderr b/tests/ui/generics/issue-79605.stderr new file mode 100644 index 000000000..c5584962d --- /dev/null +++ b/tests/ui/generics/issue-79605.stderr @@ -0,0 +1,14 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations + --> $DIR/issue-79605.rs:3:12 + | +LL | impl X<'_, _> {} + | ^ not allowed in type signatures + | +help: use type parameters instead + | +LL | impl<T> X<'_, T> {} + | +++ ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/generics/single-colon-path-not-const-generics.rs b/tests/ui/generics/single-colon-path-not-const-generics.rs index 55a7ae0bb..dff00b0b7 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.rs +++ b/tests/ui/generics/single-colon-path-not-const-generics.rs @@ -6,8 +6,8 @@ pub mod foo { pub struct Foo { a: Vec<foo::bar:A>, - //~^ ERROR expected - //~| HELP path separator + //~^ ERROR path separator must be a double colon + //~| HELP use a double colon instead } fn main() {} diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr index 3eafa9fa5..96f07e190 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.stderr +++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr @@ -1,11 +1,12 @@ -error: expected one of `,` or `>`, found `:` +error: path separator must be a double colon --> $DIR/single-colon-path-not-const-generics.rs:8:18 | +LL | pub struct Foo { + | --- while parsing this struct LL | a: Vec<foo::bar:A>, - | ^ - | | - | expected one of `,` or `>` - | help: write a path separator here: `::` + | ^ help: use a double colon instead: `::` + | + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs b/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs index cf65de2bc..721bb7281 100644 --- a/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs +++ b/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs @@ -1,6 +1,7 @@ // check-pass #![feature(decl_macro)] +#![allow(dropping_copy_types)] macro mac() { mod m { diff --git a/tests/ui/illegal-ufcs-drop.fixed b/tests/ui/illegal-ufcs-drop.fixed index d73b391be..c088c8279 100644 --- a/tests/ui/illegal-ufcs-drop.fixed +++ b/tests/ui/illegal-ufcs-drop.fixed @@ -1,4 +1,7 @@ // run-rustfix + +#![allow(dropping_references)] + struct Foo; impl Drop for Foo { diff --git a/tests/ui/illegal-ufcs-drop.rs b/tests/ui/illegal-ufcs-drop.rs index 11411f554..1389b1121 100644 --- a/tests/ui/illegal-ufcs-drop.rs +++ b/tests/ui/illegal-ufcs-drop.rs @@ -1,4 +1,7 @@ // run-rustfix + +#![allow(dropping_references)] + struct Foo; impl Drop for Foo { diff --git a/tests/ui/illegal-ufcs-drop.stderr b/tests/ui/illegal-ufcs-drop.stderr index 91f47d5e4..7a5c0612c 100644 --- a/tests/ui/illegal-ufcs-drop.stderr +++ b/tests/ui/illegal-ufcs-drop.stderr @@ -1,5 +1,5 @@ error[E0040]: explicit use of destructor method - --> $DIR/illegal-ufcs-drop.rs:9:5 + --> $DIR/illegal-ufcs-drop.rs:12:5 | LL | Drop::drop(&mut Foo) | ^^^^^^^^^^ diff --git a/tests/ui/impl-trait/arg-position-impl-trait-too-long.rs b/tests/ui/impl-trait/arg-position-impl-trait-too-long.rs new file mode 100644 index 000000000..8ef9281c9 --- /dev/null +++ b/tests/ui/impl-trait/arg-position-impl-trait-too-long.rs @@ -0,0 +1,22 @@ +struct Header; +struct EntryMetadata; +struct Entry<A, B>(A, B); + +trait Tr { + type EncodedKey; + type EncodedValue; +} + +fn test<C: Tr, R>( + // This APIT is long, however we shouldn't render the type name with a newline in it. + y: impl FnOnce( + &mut Header, + &mut [EntryMetadata], + &mut [Entry<C::EncodedKey, C::EncodedValue>] + ) -> R, +) { + let () = y; + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr new file mode 100644 index 000000000..40446a3d3 --- /dev/null +++ b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/arg-position-impl-trait-too-long.rs:18:9 + | +LL | y: impl FnOnce( + | ________- +LL | | &mut Header, +LL | | &mut [EntryMetadata], +LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>] +LL | | ) -> R, + | |__________- this type parameter +LL | ) { +LL | let () = y; + | ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R` + | | + | expected type parameter `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`, found `()` + | + = note: expected type parameter `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R` + found unit type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr index e6c750d0e..aa4ee75bb 100644 --- a/tests/ui/impl-trait/auto-trait-leak.stderr +++ b/tests/ui/impl-trait/auto-trait-leak.stderr @@ -9,7 +9,7 @@ note: ...which requires borrow-checking `cycle1`... | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle1`... +note: ...which requires promoting constants in MIR for `cycle1`... --> $DIR/auto-trait-leak.rs:12:1 | LL | fn cycle1() -> impl Clone { @@ -55,7 +55,7 @@ note: ...which requires borrow-checking `cycle2`... | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle2`... +note: ...which requires promoting constants in MIR for `cycle2`... --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { 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 cbf1daabe..af368203d 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 @@ -26,7 +26,7 @@ fn bax() -> dyn Trait { //~ ERROR E0746 if true { Struct } else { - 42 //~ ERROR `if` and `else` have incompatible types + 42 } } fn bam() -> Box<dyn Trait> { 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 dc1e40ea5..ed9261d0d 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 @@ -46,11 +46,10 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bap() -> Trait { Struct } | ^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `Struct`, which implements `Trait` +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | fn bap() -> impl Trait { Struct } - | ~~~~~~~~~~ +LL | fn bap() -> Box<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 @@ -58,11 +57,14 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn ban() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `Struct`, which implements `Trait` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn ban() -> impl Trait { Struct } - | ~~~~~~~~~~ + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) } + | ++++ + +++++++++ + error[E0746]: return type cannot have an unboxed trait object --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 @@ -70,14 +72,14 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bak() -> dyn Trait { unimplemented!() } | ^^^^^^^^^ doesn't have a size known at compile-time | -help: use `impl Trait` as the return type if all return paths have the same type but you want to expose only the trait in the signature +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn bak() -> impl Trait { unimplemented!() } - | ~~~~~~~~~~ -help: use a boxed trait object if all return paths implement trait `Trait` + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | fn bak() -> Box<dyn Trait> { unimplemented!() } - | ++++ + +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 @@ -85,34 +87,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bal() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl Trait` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | -LL | fn bal() -> Box<dyn Trait> { - | ++++ + -help: ... and box this value +LL | fn bal() -> impl Trait { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | return Box::new(Struct); - | +++++++++ + -help: ... and box this value +LL ~ fn bal() -> Box<dyn Trait> { +LL | if true { +LL ~ return Box::new(Struct); +LL | } +LL ~ Box::new(42) | -LL | Box::new(42) - | +++++++++ + - -error[E0308]: `if` and `else` have incompatible types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:29:9 - | -LL | / if true { -LL | | Struct - | | ------ expected because of this -LL | | } else { -LL | | 42 - | | ^^ expected `Struct`, found integer -LL | | } - | |_____- `if` and `else` have incompatible types error[E0746]: return type cannot have an unboxed trait object --> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13 @@ -120,22 +106,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bax() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl Trait` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | -LL | fn bax() -> Box<dyn Trait> { - | ++++ + -help: ... and box this value +LL | fn bax() -> impl Trait { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | Box::new(Struct) - | +++++++++ + -help: ... and box this value +LL ~ fn bax() -> Box<dyn Trait> { +LL | if true { +LL ~ Box::new(Struct) +LL | } else { +LL ~ Box::new(42) | -LL | Box::new(42) - | +++++++++ + error[E0308]: mismatched types --> $DIR/dyn-trait-return-should-be-impl-trait.rs:34:16 @@ -279,11 +261,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bat() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `{integer}`, which implements `Trait` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn bat() -> impl Trait { - | ~~~~~~~~~~ + | ~~~~ +help: 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 @@ -291,13 +280,20 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn bay() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Trait` as the return type, as all return paths are of type `{integer}`, which implements `Trait` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn bay() -> impl Trait { - | ~~~~~~~~~~ + | ~~~~ +help: 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 20 previous errors +error: aborting due to 19 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/extra-impl-in-trait-impl.fixed b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed new file mode 100644 index 000000000..cd4f2610d --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.fixed @@ -0,0 +1,19 @@ +// run-rustfix + +struct S<T>(T); +struct S2; + +impl<T: Default> Default for S<T> { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + +impl Default for S2 { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + + +fn main() {} diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.rs b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs new file mode 100644 index 000000000..024b703e6 --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.rs @@ -0,0 +1,19 @@ +// run-rustfix + +struct S<T>(T); +struct S2; + +impl<T: Default> impl Default for S<T> { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + +impl impl Default for S2 { + //~^ ERROR: unexpected `impl` keyword + //~| HELP: remove the extra `impl` + fn default() -> Self { todo!() } +} + + +fn main() {} diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr new file mode 100644 index 000000000..5aafc8b64 --- /dev/null +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr @@ -0,0 +1,26 @@ +error: unexpected `impl` keyword + --> $DIR/extra-impl-in-trait-impl.rs:6:18 + | +LL | impl<T: Default> impl Default for S<T> { + | ^^^^^ help: remove the extra `impl` + | +note: this is parsed as an `impl Trait` type, but a trait is expected at this position + --> $DIR/extra-impl-in-trait-impl.rs:6:18 + | +LL | impl<T: Default> impl Default for S<T> { + | ^^^^^^^^^^^^ + +error: unexpected `impl` keyword + --> $DIR/extra-impl-in-trait-impl.rs:12:6 + | +LL | impl impl Default for S2 { + | ^^^^^ help: remove the extra `impl` + | +note: this is parsed as an `impl Trait` type, but a trait is expected at this position + --> $DIR/extra-impl-in-trait-impl.rs:12:6 + | +LL | impl impl Default for S2 { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.rs b/tests/ui/impl-trait/in-assoc-type-unconstrained.rs new file mode 100644 index 000000000..c395b4195 --- /dev/null +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.rs @@ -0,0 +1,27 @@ +#![feature(impl_trait_in_assoc_type)] + +mod compare_ty { + trait Trait { + type Ty: IntoIterator<Item = ()>; + } + impl Trait for () { + type Ty = Option<impl Sized>; + //~^ ERROR: unconstrained opaque type + //~| ERROR: type mismatch resolving `<Option<<() as Trait>::Ty::{opaque#0}> as IntoIterator>::Item == ()` + } +} + +mod compare_method { + trait Trait { + type Ty; + fn method() -> Self::Ty; + } + impl Trait for () { + type Ty = impl Sized; + //~^ ERROR: unconstrained opaque type + fn method() -> () {} + //~^ ERROR: method `method` has an incompatible type for trait + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr new file mode 100644 index 000000000..1097cd0f4 --- /dev/null +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -0,0 +1,59 @@ +error[E0271]: type mismatch resolving `<Option<<() as Trait>::Ty::{opaque#0}> as IntoIterator>::Item == ()` + --> $DIR/in-assoc-type-unconstrained.rs:8:19 + | +LL | type Ty = Option<impl Sized>; + | ^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type + | + = note: expected unit type `()` + found opaque type `<() as compare_ty::Trait>::Ty::{opaque#0}` +note: required by a bound in `compare_ty::Trait::Ty` + --> $DIR/in-assoc-type-unconstrained.rs:5:31 + | +LL | type Ty: IntoIterator<Item = ()>; + | ^^^^^^^^^ required by this bound in `Trait::Ty` + +error: unconstrained opaque type + --> $DIR/in-assoc-type-unconstrained.rs:8:26 + | +LL | type Ty = Option<impl Sized>; + | ^^^^^^^^^^ + | + = note: `Ty` must be used in combination with a concrete type within the same impl + +error[E0053]: method `method` has an incompatible type for trait + --> $DIR/in-assoc-type-unconstrained.rs:22:24 + | +LL | type Ty = impl Sized; + | ---------- the expected opaque type +LL | +LL | fn method() -> () {} + | ^^ + | | + | expected opaque type, found `()` + | help: change the output type to match the trait: `<() as compare_method::Trait>::Ty` + | +note: type in trait + --> $DIR/in-assoc-type-unconstrained.rs:17:24 + | +LL | fn method() -> Self::Ty; + | ^^^^^^^^ + = note: expected signature `fn() -> <() as compare_method::Trait>::Ty` + found signature `fn()` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/in-assoc-type-unconstrained.rs:22:9 + | +LL | fn method() -> () {} + | ^^^^^^^^^^^^^^^^^ + +error: unconstrained opaque type + --> $DIR/in-assoc-type-unconstrained.rs:20:19 + | +LL | type Ty = impl Sized; + | ^^^^^^^^^^ + | + = note: `Ty` must be used in combination with a concrete type within the same impl + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0053, E0271. +For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-assoc-type.rs b/tests/ui/impl-trait/in-assoc-type.rs new file mode 100644 index 000000000..36c54bdd6 --- /dev/null +++ b/tests/ui/impl-trait/in-assoc-type.rs @@ -0,0 +1,21 @@ +#![feature(impl_trait_in_assoc_type)] + +trait Foo<T> { + type Bar; + fn foo(&self) -> <Self as Foo<()>>::Bar + where + Self: Foo<()>; +} + +impl Foo<()> for () { + type Bar = impl std::fmt::Debug; + fn foo(&self) -> Self::Bar {} +} + +impl Foo<i32> for () { + type Bar = u32; + fn foo(&self) -> <Self as Foo<()>>::Bar {} + //~^ ERROR: mismatched types +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-assoc-type.stderr b/tests/ui/impl-trait/in-assoc-type.stderr new file mode 100644 index 000000000..f0a272dc2 --- /dev/null +++ b/tests/ui/impl-trait/in-assoc-type.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/in-assoc-type.rs:17:22 + | +LL | type Bar = impl std::fmt::Debug; + | -------------------- the expected opaque type +... +LL | fn foo(&self) -> <Self as Foo<()>>::Bar {} + | --- ^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected opaque type `<() as Foo<()>>::Bar` + found unit type `()` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/in-assoc-type.rs:17:5 + | +LL | fn foo(&self) -> <Self as Foo<()>>::Bar {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs index ffeabe5c2..776006124 100644 --- a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs +++ b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs @@ -5,10 +5,10 @@ use std::ops::Deref; pub trait Foo { - fn bar() -> impl Deref<Target = impl Sized>; + fn bar(self) -> impl Deref<Target = impl Sized>; } pub struct Foreign; impl Foo for Foreign { - fn bar() -> &'static () { &() } + fn bar(self) -> &'static () { &() } } diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr deleted file mode 100644 index 05c025cc1..000000000 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr deleted file mode 100644 index 05c025cc1..000000000 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index 163bb4fcf..f5290a5f4 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete struct TestA {} struct TestB {} diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr deleted file mode 100644 index a0c0589b9..000000000 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-binder-shifting.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr deleted file mode 100644 index a0c0589b9..000000000 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-binder-shifting.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs index de82544f2..187039f44 100644 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait Trait { type Type; diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr deleted file mode 100644 index 7bb79911f..000000000 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:7:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr deleted file mode 100644 index 7bb79911f..000000000 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:7:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index e85fe3c86..4f0bf2e7d 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -5,7 +5,6 @@ // This didn't work in the previous default RPITIT method hack attempt #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait Foo { fn bar(x: bool) -> impl Sized { diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr index b8a793e1a..d4d0124a6 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 | LL | fn foo(&self) -> impl Sized; | ---------------------------- `foo` from trait @@ -16,6 +7,6 @@ LL | fn foo(&self) -> impl Sized; LL | impl MyTrait for i32 { | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr index b8a793e1a..d4d0124a6 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 | LL | fn foo(&self) -> impl Sized; | ---------------------------- `foo` from trait @@ -16,6 +7,6 @@ LL | fn foo(&self) -> impl Sized; LL | impl MyTrait for i32 { | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs index 8329ce1f8..4d50b8c92 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs @@ -2,7 +2,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait MyTrait { fn foo(&self) -> impl Sized; diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs b/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs new file mode 100644 index 000000000..ecb5e62c4 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs @@ -0,0 +1,8 @@ +// aux-build: rpitit.rs + +extern crate rpitit; + +fn main() { + let _: &dyn rpitit::Foo = todo!(); + //~^ ERROR the trait `Foo` cannot be made into an object +} diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr new file mode 100644 index 000000000..6eef392c0 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -0,0 +1,15 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/foreign-dyn-error.rs:6:12 + | +LL | let _: &dyn rpitit::Foo = todo!(); + | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/auxiliary/rpitit.rs:8:21 + | +LL | fn bar(self) -> impl Deref<Target = impl Sized>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index f4972d948..98417b343 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -5,17 +5,18 @@ extern crate rpitit; +use rpitit::{Foo, Foreign}; use std::sync::Arc; // Implement an RPITIT from another crate. struct Local; -impl rpitit::Foo for Local { - fn bar() -> Arc<String> { Arc::new(String::new()) } +impl Foo for Local { + fn bar(self) -> Arc<String> { Arc::new(String::new()) } } fn main() { // Witness an RPITIT from another crate. - let &() = <rpitit::Foreign as rpitit::Foo>::bar(); + let &() = Foreign.bar(); - let x: Arc<String> = <Local as rpitit::Foo>::bar(); + let x: Arc<String> = Local.bar(); } diff --git a/tests/ui/impl-trait/in-trait/object-safety.current.stderr b/tests/ui/impl-trait/in-trait/object-safety.current.stderr index b7f2b019a..2c340a023 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.current.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.current.stderr @@ -42,8 +42,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>` - = note: required by cast to type `Box<dyn Foo>` + = note: required for the cast from `Box<u32>` to `Box<dyn Foo>` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/in-trait/object-safety.next.stderr b/tests/ui/impl-trait/in-trait/object-safety.next.stderr index b7f2b019a..2c340a023 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.next.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.next.stderr @@ -42,8 +42,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>` - = note: required by cast to type `Box<dyn Foo>` + = note: required for the cast from `Box<u32>` to `Box<dyn Foo>` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/issue-103181-1.stderr b/tests/ui/impl-trait/issue-103181-1.current.stderr index cd026607d..e87a9d28a 100644 --- a/tests/ui/impl-trait/issue-103181-1.stderr +++ b/tests/ui/impl-trait/issue-103181-1.current.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `Error` - --> $DIR/issue-103181-1.rs:9:5 + --> $DIR/issue-103181-1.rs:11:5 | LL | type Error; | ---------- `Error` from trait diff --git a/tests/ui/impl-trait/issue-103181-1.next.stderr b/tests/ui/impl-trait/issue-103181-1.next.stderr new file mode 100644 index 000000000..e87a9d28a --- /dev/null +++ b/tests/ui/impl-trait/issue-103181-1.next.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Error` + --> $DIR/issue-103181-1.rs:11:5 + | +LL | type Error; + | ---------- `Error` from trait +LL | } +LL | impl HttpBody for () { + | ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/issue-103181-1.rs b/tests/ui/impl-trait/issue-103181-1.rs index 197aedf9d..5154abcd6 100644 --- a/tests/ui/impl-trait/issue-103181-1.rs +++ b/tests/ui/impl-trait/issue-103181-1.rs @@ -1,3 +1,5 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next // edition:2021 mod hyper { diff --git a/tests/ui/impl-trait/issue-108591.rs b/tests/ui/impl-trait/issue-108591.rs new file mode 100644 index 000000000..6b9d14941 --- /dev/null +++ b/tests/ui/impl-trait/issue-108591.rs @@ -0,0 +1,30 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +struct MyTy<'a>(Vec<u8>, &'a ()); + +impl MyTy<'_> { + fn one(&mut self) -> &mut impl Sized { + &mut self.0 + } + fn two(&mut self) -> &mut (impl Sized + 'static) { + self.one() + } +} + +type Opaque<'a> = impl Sized; +fn define<'a>() -> Opaque<'a> {} + +fn test<'a>() { + None::<&'static Opaque<'a>>; +} + +fn one<'a, 'b: 'b>() -> &'a impl Sized { + &() +} +fn two<'a, 'b>() { + one::<'a, 'b>(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/issue-108592.rs b/tests/ui/impl-trait/issue-108592.rs new file mode 100644 index 000000000..58a0ed9bf --- /dev/null +++ b/tests/ui/impl-trait/issue-108592.rs @@ -0,0 +1,21 @@ +// check-pass +#![feature(type_alias_impl_trait)] + +fn opaque<'a: 'a>() -> impl Sized {} +fn assert_static<T: 'static>(_: T) {} + +fn test_closure() { + let closure = |_| { + assert_static(opaque()); + }; + closure(&opaque()); +} + +type Opaque<'a> = impl Sized; +fn define<'a>() -> Opaque<'a> {} + +fn test_tait(_: &Opaque<'_>) { + None::<&'static Opaque<'_>>; +} + +fn main() {} diff --git a/tests/ui/issues/issue-36792.rs b/tests/ui/impl-trait/issue-36792.rs index 99ae633dd..99ae633dd 100644 --- a/tests/ui/issues/issue-36792.rs +++ b/tests/ui/impl-trait/issue-36792.rs diff --git a/tests/ui/impl-trait/issues/issue-86800.rs b/tests/ui/impl-trait/issues/issue-86800.rs index 351243c67..ec4fda322 100644 --- a/tests/ui/impl-trait/issues/issue-86800.rs +++ b/tests/ui/impl-trait/issues/issue-86800.rs @@ -1,14 +1,12 @@ #![feature(type_alias_impl_trait)] // edition:2021 -// unset-rustc-env:RUST_BACKTRACE // compile-flags:-Z treat-err-as-bug=1 -// error-pattern:stack backtrace: +// error-pattern: aborting due to `-Z treat-err-as-bug=1` // failure-status:101 -// normalize-stderr-test "note: .*" -> "" -// normalize-stderr-test "thread 'rustc' .*" -> "" -// normalize-stderr-test " +[0-9]+:.*\n" -> "" -// normalize-stderr-test " +at .*\n" -> "" +// normalize-stderr-test ".*note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// rustc-env:RUST_BACKTRACE=0 use std::future::Future; diff --git a/tests/ui/impl-trait/issues/issue-86800.stderr b/tests/ui/impl-trait/issues/issue-86800.stderr index f3a773837..facab390d 100644 --- a/tests/ui/impl-trait/issues/issue-86800.stderr +++ b/tests/ui/impl-trait/issues/issue-86800.stderr @@ -1,24 +1,12 @@ error: unconstrained opaque type - --> $DIR/issue-86800.rs:33:34 + --> $DIR/issue-86800.rs:31:34 | LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = - - -stack backtrace: - error: the compiler unexpectedly panicked. this is a bug. - - - - - - query stack during panic: #0 [type_of] computing type of `TransactionFuture::{opaque#0}` #1 [check_mod_item_types] checking item types in top-level module -#2 [analysis] running analysis passes on this crate end of query stack diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.rs b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs new file mode 100644 index 000000000..c3a6f09f8 --- /dev/null +++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs @@ -0,0 +1,12 @@ +trait Trait {} +impl Trait for () {} + +fn foo<T: Trait, U: Trait>() -> impl Trait { + //~^ WARN function cannot return without recursing [unconditional_recursion] + let a: T = foo::<T, U>(); + //~^ ERROR concrete type differs from previous defining opaque type use + loop {} + let _: T = foo::<U, T>(); +} + +fn main() {} diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr new file mode 100644 index 000000000..06991749b --- /dev/null +++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr @@ -0,0 +1,26 @@ +warning: function cannot return without recursing + --> $DIR/multiple-defining-usages-in-body.rs:4:1 + | +LL | fn foo<T: Trait, U: Trait>() -> impl Trait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | +LL | let a: T = foo::<T, U>(); + | ------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +error: concrete type differs from previous defining opaque type use + --> $DIR/multiple-defining-usages-in-body.rs:6:16 + | +LL | let a: T = foo::<T, U>(); + | ^^^^^^^^^^^^^ expected `U`, got `T` + | +note: previous use here + --> $DIR/multiple-defining-usages-in-body.rs:9:16 + | +LL | let _: T = foo::<U, T>(); + | ^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + 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 fa7664a83..a8a6288eb 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 @@ -77,7 +77,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 match 13 { 0 => 0i32, - 1 => 1u32, //~ ERROR `match` arms have incompatible types + 1 => 1u32, _ => 2u32, } } @@ -86,7 +86,7 @@ fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed if false { 0i32 } else { - 1u32 //~ ERROR `if` and `else` have incompatible types + 1u32 } } 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 3c65fd998..9205d7450 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 @@ -171,39 +171,20 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn hat() -> dyn std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead - | -LL | fn hat() -> Box<dyn std::fmt::Display> { - | ++++ + -help: ... and box this value - | -LL | return Box::new(0i32); - | +++++++++ + -help: ... and box this value - | -LL | Box::new(1u32) - | +++++++++ + - -error[E0308]: `match` arms have incompatible types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:80:14 +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | -LL | / match 13 { -LL | | 0 => 0i32, - | | ---- this is found to be of type `i32` -LL | | 1 => 1u32, - | | ^^^^ expected `i32`, found `u32` -LL | | _ => 2u32, -LL | | } - | |_____- `match` arms have incompatible types +LL | fn hat() -> impl std::fmt::Display { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -help: change the type of the numeric literal from `u32` to `i32` +LL ~ fn hat() -> Box<dyn std::fmt::Display> { +LL | match 13 { +LL | 0 => { +LL ~ return Box::new(0i32); +LL | } +LL | _ => { +LL ~ Box::new(1u32) | -LL | 1 => 1i32, - | ~~~ error[E0746]: return type cannot have an unboxed trait object --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13 @@ -211,43 +192,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn pug() -> dyn std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead - | -LL | fn pug() -> Box<dyn std::fmt::Display> { - | ++++ + -help: ... and box this value +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | -LL | 0 => Box::new(0i32), - | +++++++++ + -help: ... and box this value - | -LL | 1 => Box::new(1u32), - | +++++++++ + -help: ... and box this value - | -LL | _ => Box::new(2u32), - | +++++++++ + - -error[E0308]: `if` and `else` have incompatible types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:89:9 +LL | fn pug() -> impl std::fmt::Display { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | / if false { -LL | | 0i32 - | | ---- expected because of this -LL | | } else { -LL | | 1u32 - | | ^^^^ expected `i32`, found `u32` -LL | | } - | |_____- `if` and `else` have incompatible types - | -help: change the type of the numeric literal from `u32` to `i32` +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), | -LL | 1i32 - | ~~~ error[E0746]: return type cannot have an unboxed trait object --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13 @@ -255,24 +211,20 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn man() -> dyn std::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | -LL | fn man() -> Box<dyn std::fmt::Display> { - | ++++ + -help: ... and box this value +LL | fn man() -> impl std::fmt::Display { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | Box::new(0i32) - | +++++++++ + -help: ... and box this value +LL ~ fn man() -> Box<dyn std::fmt::Display> { +LL | if false { +LL ~ Box::new(0i32) +LL | } else { +LL ~ Box::new(1u32) | -LL | Box::new(1u32) - | +++++++++ + -error: aborting due to 14 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0308, E0746. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index f7aff4195..fe62a8f32 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -43,6 +43,11 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool { | = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _` found signature `fn(&b::Bar, &(b::Bar, i32)) -> _` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:9 + | +LL | fn eq(&self, _other: &(Bar, i32)) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/wf-eval-order.rs b/tests/ui/impl-trait/wf-eval-order.rs index c7d6bb870..8638fc2e7 100644 --- a/tests/ui/impl-trait/wf-eval-order.rs +++ b/tests/ui/impl-trait/wf-eval-order.rs @@ -31,9 +31,9 @@ fn main() { // // - `wf(typeof(x))` because we use a projection candidate. // - `<i32 as B>::V: Clone` because that's a bound on the trait. - // - `<i32 as B>::V` normalizes to `_#1` where `<i32 as A>::U == _#1` + // - `<i32 as B>::V` normalizes to `?1t` where `<i32 as A>::U == ?1t` // - // This all works if we evaluate `<i32 as A>::U == _#1` before + // This all works if we evaluate `<i32 as A>::U == ?1t` before // `<i32 as B>::V`, but we previously had the opposite order. let x = hide(X(0)); } diff --git a/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs b/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs new file mode 100644 index 000000000..1f5562497 --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-on-nested-references-plus-variance.rs @@ -0,0 +1,16 @@ +// check-pass +// known-bug: #25860 + +// Should fail. The combination of variance and implied bounds for nested +// references allows us to infer a longer lifetime than we can prove. + +static UNIT: &'static &'static () = &&(); + +fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v } + +fn bad<'a, T>(x: &'a T) -> &'static T { + let f: fn(_, &'a T) -> &'static T = foo; + f(UNIT, x) +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy.rs b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy.rs new file mode 100644 index 000000000..9c26cd59d --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy.rs @@ -0,0 +1,39 @@ +// check-pass +// known-bug: #84591 + +// Should fail. Subtrait can incorrectly extend supertrait lifetimes even when +// supertrait has weaker implied bounds than subtrait. Strongly related to +// issue #25860. + +trait Subtrait<T>: Supertrait {} +trait Supertrait { + fn action(self); +} + +fn subs_to_soup<T, U>(x: T) +where + T: Subtrait<U>, +{ + soup(x) +} + +fn soup<T: Supertrait>(x: T) { + x.action(); +} + +impl<'a, 'b: 'a> Supertrait for (&'b str, &mut &'a str) { + fn action(self) { + *self.1 = self.0; + } +} + +impl<'a, 'b> Subtrait<&'a &'b str> for (&'b str, &mut &'a str) {} + +fn main() { + let mut d = "hi"; + { + let x = "Hello World".to_string(); + subs_to_soup((x.as_str(), &mut d)); + } + println!("{}", d); +} diff --git a/tests/ui/implied-bounds/issue-110161.rs b/tests/ui/implied-bounds/issue-110161.rs new file mode 100644 index 000000000..e52c8356b --- /dev/null +++ b/tests/ui/implied-bounds/issue-110161.rs @@ -0,0 +1,26 @@ +// ICE regression relating to unconstrained lifetimes in implied +// bounds. See #110161. + +// compile-flags: --crate-type=lib + +trait LtTrait { + type Ty; +} + +// erroneous `Ty` impl +impl LtTrait for () { +//~^ ERROR not all trait items implemented, missing: `Ty` [E0046] +} + +// `'lt` is not constrained by the erroneous `Ty` +impl<'lt, T> LtTrait for Box<T> +where + T: LtTrait<Ty = &'lt ()>, +{ + type Ty = &'lt (); +} + +// unconstrained lifetime appears in implied bounds +fn test(_: <Box<()> as LtTrait>::Ty) {} + +fn test2<'x>(_: &'x <Box<()> as LtTrait>::Ty) {} diff --git a/tests/ui/implied-bounds/issue-110161.stderr b/tests/ui/implied-bounds/issue-110161.stderr new file mode 100644 index 000000000..9e0188694 --- /dev/null +++ b/tests/ui/implied-bounds/issue-110161.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Ty` + --> $DIR/issue-110161.rs:11:1 + | +LL | type Ty; + | ------- `Ty` from trait +... +LL | impl LtTrait for () { + | ^^^^^^^^^^^^^^^^^^^ missing `Ty` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/imports/issue-109148.rs b/tests/ui/imports/issue-109148.rs new file mode 100644 index 000000000..694cb494a --- /dev/null +++ b/tests/ui/imports/issue-109148.rs @@ -0,0 +1,15 @@ +// edition: 2021 + +// https://github.com/rust-lang/rust/pull/111761#issuecomment-1557777314 +macro_rules! m { + () => { + extern crate core as std; + //~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern` + } +} + +m!(); + +use std::mem; + +fn main() {} diff --git a/tests/ui/imports/issue-109148.stderr b/tests/ui/imports/issue-109148.stderr new file mode 100644 index 000000000..6cc1221cf --- /dev/null +++ b/tests/ui/imports/issue-109148.stderr @@ -0,0 +1,13 @@ +error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` + --> $DIR/issue-109148.rs:6:9 + | +LL | extern crate core as std; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + | + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/imports/issue-109343.rs b/tests/ui/imports/issue-109343.rs new file mode 100644 index 000000000..0c10259bc --- /dev/null +++ b/tests/ui/imports/issue-109343.rs @@ -0,0 +1,10 @@ +#![crate_type = "lib"] + +pub mod f {} +pub use unresolved::f; +//~^ ERROR unresolved import `unresolved` + +/// [g] +pub use f as g; + +fn main() {} diff --git a/tests/ui/imports/issue-109343.stderr b/tests/ui/imports/issue-109343.stderr new file mode 100644 index 000000000..8d9a3aee9 --- /dev/null +++ b/tests/ui/imports/issue-109343.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/issue-109343.rs:4:9 + | +LL | pub use unresolved::f; + | ^^^^^^^^^^ maybe a missing crate `unresolved`? + | + = help: consider adding `extern crate unresolved` to use the `unresolved` crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/inference/deref-suggestion.rs b/tests/ui/inference/deref-suggestion.rs index 0d8e7289d..dc39cc9db 100644 --- a/tests/ui/inference/deref-suggestion.rs +++ b/tests/ui/inference/deref-suggestion.rs @@ -72,4 +72,13 @@ fn main() { } else { &0 }; + + #[derive(PartialEq, Eq)] + struct Foo; + let foo = Foo; + let bar = &Foo; + + if foo == bar { + //~^ ERROR mismatched types + } } diff --git a/tests/ui/inference/deref-suggestion.stderr b/tests/ui/inference/deref-suggestion.stderr index 1626032ae..c58aab422 100644 --- a/tests/ui/inference/deref-suggestion.stderr +++ b/tests/ui/inference/deref-suggestion.stderr @@ -98,19 +98,23 @@ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:40:17 | LL | let s = S { u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `u: &u` + | ^ expected `&u32`, found integer + | +help: consider borrowing here + | +LL | let s = S { u: &u }; + | ++++ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:42:20 | LL | let s = S { u: u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `&u` + | ^ expected `&u32`, found integer + | +help: consider borrowing here + | +LL | let s = S { u: &u }; + | + error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:45:17 @@ -175,6 +179,19 @@ LL | || }; | |_____`if` and `else` have incompatible types | expected `i32`, found `&{integer}` -error: aborting due to 13 previous errors +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:81:15 + | +LL | if foo == bar { + | --- ^^^ expected `Foo`, found `&Foo` + | | + | expected because this is `Foo` + | +help: consider dereferencing the borrow + | +LL | if foo == *bar { + | + + +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/issue-70082.rs b/tests/ui/inference/issue-70082.rs new file mode 100644 index 000000000..d54d0a1a4 --- /dev/null +++ b/tests/ui/inference/issue-70082.rs @@ -0,0 +1,10 @@ +fn main() { + // this closure is fine, and should not get any error annotations + let em = |v: f64| -> f64 { v }; + + let x: f64 = em(1i16.into()); + + let y: f64 = 0.01f64 * 1i16.into(); + //~^ ERROR type annotations needed + //~| HELP try using a fully qualified path +} diff --git a/tests/ui/inference/issue-70082.stderr b/tests/ui/inference/issue-70082.stderr new file mode 100644 index 000000000..47229a5fe --- /dev/null +++ b/tests/ui/inference/issue-70082.stderr @@ -0,0 +1,17 @@ +error[E0284]: type annotations needed + --> $DIR/issue-70082.rs:7:33 + | +LL | let y: f64 = 0.01f64 * 1i16.into(); + | - ^^^^ + | | + | type must be known at this point + | + = note: cannot satisfy `<f64 as Mul<_>>::Output == f64` +help: try using a fully qualified path to specify the expected types + | +LL | let y: f64 = 0.01f64 * <i16 as Into<T>>::into(1i16); + | +++++++++++++++++++++++ ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/issues/issue-71584.rs b/tests/ui/inference/issue-71584.rs index 7bf3ed60e..7bf3ed60e 100644 --- a/tests/ui/issues/issue-71584.rs +++ b/tests/ui/inference/issue-71584.rs diff --git a/tests/ui/issues/issue-71584.stderr b/tests/ui/inference/issue-71584.stderr index 6ddb76573..6ddb76573 100644 --- a/tests/ui/issues/issue-71584.stderr +++ b/tests/ui/inference/issue-71584.stderr diff --git a/tests/ui/inline-const/const-match-pat-lifetime-err.rs b/tests/ui/inline-const/const-match-pat-lifetime-err.rs index 436b8037f..366ad26bb 100644 --- a/tests/ui/inline-const/const-match-pat-lifetime-err.rs +++ b/tests/ui/inline-const/const-match-pat-lifetime-err.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (This is currently broken) #![allow(incomplete_features)] #![feature(const_mut_refs)] diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr index 034d22591..0c3be7ca6 100644 --- a/tests/ui/interior-mutability/interior-mutability.stderr +++ b/tests/ui/interior-mutability/interior-mutability.stderr @@ -7,7 +7,8 @@ LL | catch_unwind(|| { x.set(23); }); | required by a bound introduced by this call | = help: within `Cell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>` - = note: required because it appears within the type `Cell<i32>` +note: required because it appears within the type `Cell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell<i32>` to implement `UnwindSafe` note: required because it's used within this closure --> $DIR/interior-mutability.rs:5:18 diff --git a/tests/ui/invalid/foo.natvis.xml b/tests/ui/invalid/foo.natvis.xml new file mode 100644 index 000000000..c341a4039 --- /dev/null +++ b/tests/ui/invalid/foo.natvis.xml @@ -0,0 +1 @@ +<!-- empty --> diff --git a/tests/ui/invalid/invalid-debugger-visualizer-option.rs b/tests/ui/invalid/invalid-debugger-visualizer-option.rs index 5645a30cc..150723898 100644 --- a/tests/ui/invalid/invalid-debugger-visualizer-option.rs +++ b/tests/ui/invalid/invalid-debugger-visualizer-option.rs @@ -1,7 +1,6 @@ // normalize-stderr-test: "foo.random:.*\(" -> "foo.random: $$FILE_NOT_FOUND_MSG (" // normalize-stderr-test: "os error \d+" -> "os error $$FILE_NOT_FOUND_CODE" -#![feature(debugger_visualizer)] #![debugger_visualizer(random_file = "../foo.random")] //~ ERROR invalid argument #![debugger_visualizer(natvis_file = "../foo.random")] //~ ERROR fn main() {} diff --git a/tests/ui/invalid/invalid-debugger-visualizer-option.stderr b/tests/ui/invalid/invalid-debugger-visualizer-option.stderr index afb8d16ee..6fbb4d641 100644 --- a/tests/ui/invalid/invalid-debugger-visualizer-option.stderr +++ b/tests/ui/invalid/invalid-debugger-visualizer-option.stderr @@ -1,5 +1,5 @@ error: invalid argument - --> $DIR/invalid-debugger-visualizer-option.rs:5:24 + --> $DIR/invalid-debugger-visualizer-option.rs:4:24 | LL | #![debugger_visualizer(random_file = "../foo.random")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![debugger_visualizer(random_file = "../foo.random")] = note: expected: `gdb_script_file = "..."` error: couldn't read $DIR/../foo.random: $FILE_NOT_FOUND_MSG (os error $FILE_NOT_FOUND_CODE) - --> $DIR/invalid-debugger-visualizer-option.rs:6:24 + --> $DIR/invalid-debugger-visualizer-option.rs:5:24 | LL | #![debugger_visualizer(natvis_file = "../foo.random")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/invalid/invalid-debugger-visualizer-target.rs b/tests/ui/invalid/invalid-debugger-visualizer-target.rs index f0aba6a75..1efb9555c 100644 --- a/tests/ui/invalid/invalid-debugger-visualizer-target.rs +++ b/tests/ui/invalid/invalid-debugger-visualizer-target.rs @@ -1,4 +1,2 @@ -#![feature(debugger_visualizer)] - -#[debugger_visualizer(natvis_file = "../foo.natvis")] //~ ERROR attribute should be applied to a module +#[debugger_visualizer(natvis_file = "./foo.natvis.xml")] //~ ERROR attribute should be applied to a module fn main() {} diff --git a/tests/ui/invalid/invalid-debugger-visualizer-target.stderr b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr index 3555bbb16..c8a4d6813 100644 --- a/tests/ui/invalid/invalid-debugger-visualizer-target.stderr +++ b/tests/ui/invalid/invalid-debugger-visualizer-target.stderr @@ -1,8 +1,8 @@ error: attribute should be applied to a module - --> $DIR/invalid-debugger-visualizer-target.rs:3:1 + --> $DIR/invalid-debugger-visualizer-target.rs:1:1 | -LL | #[debugger_visualizer(natvis_file = "../foo.natvis")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[debugger_visualizer(natvis_file = "./foo.natvis.xml")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/io-checks/inaccessbile-temp-dir.rs b/tests/ui/io-checks/inaccessbile-temp-dir.rs deleted file mode 100644 index 9c0aa0135..000000000 --- a/tests/ui/io-checks/inaccessbile-temp-dir.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Issue #66530: We would ICE if someone compiled with `-o /dev/null`, -// because we would try to generate auxiliary files in `/dev/` (which -// at least the OS X file system rejects). -// -// An attempt to `-o` into a directory we cannot write into should indeed -// be an error; but not an ICE. -// -// However, some folks run tests as root, which can write `/dev/` and end -// up clobbering `/dev/null`. Instead we'll use a non-existent path, which -// also used to ICE, but even root can't magically write there. - -// compile-flags: -Z temps-dir=/does-not-exist/output - -// The error-pattern check occurs *before* normalization, and the error patterns -// are wildly different between build environments. So this is a cop-out (and we -// rely on the checking of the normalized stderr output as our actual -// "verification" of the diagnostic). - -// error-pattern: error - -// On Mac OS X, we get an error like the below -// normalize-stderr-test "failed to write bytecode to /does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying /does-not-exist/" - -// On Linux, we get an error like the below -// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /does-not-exist/" - -// ignore-windows - this is a unix-specific test -// ignore-emscripten - the file-system issues do not replicate here -// ignore-wasm - the file-system issues do not replicate here -// ignore-arm - the file-system issues do not replicate here, at least on armhf-gnu - -#![crate_type = "lib"] -#![cfg_attr(not(feature = "std"), no_std)] -pub mod task { - pub mod __internal { - use crate::task::Waker; - } - pub use core::task::Waker; -} diff --git a/tests/ui/io-checks/inaccessbile-temp-dir.stderr b/tests/ui/io-checks/inaccessbile-temp-dir.stderr deleted file mode 100644 index 2fc5f93ef..000000000 --- a/tests/ui/io-checks/inaccessbile-temp-dir.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: failed to find or create the directory specified by `--temps-dir` - -error: aborting due to previous error - diff --git a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs index 134e7d420..6ec81a943 100644 --- a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs +++ b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.rs @@ -9,7 +9,7 @@ // up clobbering `/dev/null`. Instead we'll use a non-existent path, which // also used to ICE, but even root can't magically write there. -// compile-flags: -o /does-not-exist/output +// compile-flags: -o ./does-not-exist/output // The error-pattern check occurs *before* normalization, and the error patterns // are wildly different between build environments. So this is a cop-out (and we @@ -19,22 +19,14 @@ // error-pattern: error // On Mac OS X, we get an error like the below -// normalize-stderr-test "failed to write bytecode to /does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying /does-not-exist/" +// normalize-stderr-test "failed to write bytecode to ./does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying ./does-not-exist/" // On Linux, we get an error like the below -// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /does-not-exist/" +// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying ./does-not-exist/" // ignore-windows - this is a unix-specific test // ignore-emscripten - the file-system issues do not replicate here // ignore-wasm - the file-system issues do not replicate here // ignore-arm - the file-system issues do not replicate here, at least on armhf-gnu -#![crate_type="lib"] - -#![cfg_attr(not(feature = "std"), no_std)] -pub mod task { - pub mod __internal { - use crate::task::Waker; - } - pub use core::task::Waker; -} +#![crate_type = "lib"] diff --git a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr index edadecf27..f1d9ed8ac 100644 --- a/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr +++ b/tests/ui/io-checks/non-ice-error-on-worker-io-fail.stderr @@ -1,6 +1,6 @@ warning: ignoring --out-dir flag due to -o flag -error: io error modifying /does-not-exist/ +error: io error modifying ./does-not-exist/ error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/issues/auxiliary/issue-111011.rs b/tests/ui/issues/auxiliary/issue-111011.rs new file mode 100644 index 000000000..927134a58 --- /dev/null +++ b/tests/ui/issues/auxiliary/issue-111011.rs @@ -0,0 +1,12 @@ +#![feature(async_closure)] + +// edition:2021 + +fn foo<X>(x: impl FnOnce() -> Box<X>) {} +// just to make sure async closures can still be suggested for boxing. +fn bar<X>(x: Box<dyn FnOnce() -> X>) {} + +fn main() { + foo(async move || {}); //~ ERROR mismatched types + bar(async move || {}); //~ ERROR mismatched types +} diff --git a/tests/ui/issues/auxiliary/issue-111011.stderr b/tests/ui/issues/auxiliary/issue-111011.stderr new file mode 100644 index 000000000..082f0f035 --- /dev/null +++ b/tests/ui/issues/auxiliary/issue-111011.stderr @@ -0,0 +1,34 @@ +error[E0308]: mismatched types + --> $DIR/issue-111011.rs:10:23 + | +LL | foo(async move || {}); + | ^^ expected `Box<_>`, found `async` closure body + | + = note: expected struct `Box<_>` + found `async` closure body `[async closure body@$DIR/issue-111011.rs:10:23: 10:25]` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html + +error[E0308]: mismatched types + --> $DIR/issue-111011.rs:11:9 + | +LL | bar(async move || {}); + | --- ^^^^^^^^^^^^^^^^ expected `Box<dyn FnOnce() -> _>`, found closure + | | + | arguments to this function are incorrect + | + = note: expected struct `Box<(dyn FnOnce() -> _ + 'static)>` + found closure `[closure@$DIR/issue-111011.rs:11:9: 11:22]` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +note: function defined here + --> $DIR/issue-111011.rs:7:4 + | +LL | fn bar<X>(x: Box<dyn FnOnce() -> X>) {} + | ^^^ ------------------------- +help: store this in the heap by calling `Box::new` + | +LL | bar(Box::new(async move || {})); + | +++++++++ + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/auxiliary/issue-3136-a.rc b/tests/ui/issues/auxiliary/issue-3136-a.rc deleted file mode 100644 index cd5fd3145..000000000 --- a/tests/ui/issues/auxiliary/issue-3136-a.rc +++ /dev/null @@ -1,4 +0,0 @@ -#![crate_type = "lib"] - -#[path = "issue-3136-a.rs"] -pub mod issue_3136_a; diff --git a/tests/ui/issues/auxiliary/issue-3136-a.rs b/tests/ui/issues/auxiliary/issue-3136-a.rs index 9bb546ab3..22bb1c8f9 100644 --- a/tests/ui/issues/auxiliary/issue-3136-a.rs +++ b/tests/ui/issues/auxiliary/issue-3136-a.rs @@ -1,11 +1,14 @@ +#![crate_type = "lib"] + trait x { fn use_x<T>(&self); } struct y(()); impl x for y { fn use_x<T>(&self) { - struct foo { //~ ERROR quux - i: () + struct foo { + //~ ERROR quux + i: (), } fn new_foo<T>(i: ()) -> foo { foo { i: i } diff --git a/tests/ui/issues/issue-11374.stderr b/tests/ui/issues/issue-11374.stderr index 6e1fb1540..879dc5b76 100644 --- a/tests/ui/issues/issue-11374.stderr +++ b/tests/ui/issues/issue-11374.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-11374.rs:26:15 | LL | c.read_to(v); - | ------- ^ - | | | - | | expected `&mut [u8]`, found `Vec<_>` - | | help: consider mutably borrowing here: `&mut v` + | ------- ^ expected `&mut [u8]`, found `Vec<_>` + | | | arguments to this method are incorrect | = note: expected mutable reference `&mut [u8]` @@ -15,6 +13,10 @@ note: method defined here | LL | pub fn read_to(&mut self, vec: &mut [u8]) { | ^^^^^^^ -------------- +help: consider mutably borrowing here + | +LL | c.read_to(&mut v); + | ++++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-14366.stderr b/tests/ui/issues/issue-14366.stderr index 10a73b245..df61aabf0 100644 --- a/tests/ui/issues/issue-14366.stderr +++ b/tests/ui/issues/issue-14366.stderr @@ -5,8 +5,8 @@ LL | let _x = "test" as &dyn (::std::any::Any); | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn Any` -help: consider borrowing the value, since `&str` can be coerced into `dyn Any` + = note: required for the cast from `&'static str` to `&(dyn Any + 'static)` +help: consider borrowing the value, since `&&'static str` can be coerced into `&(dyn Any + 'static)` | LL | let _x = &"test" as &dyn (::std::any::Any); | + diff --git a/tests/ui/issues/issue-17033.stderr b/tests/ui/issues/issue-17033.stderr index f26bee5ff..3419c0798 100644 --- a/tests/ui/issues/issue-17033.stderr +++ b/tests/ui/issues/issue-17033.stderr @@ -2,11 +2,14 @@ error[E0308]: mismatched types --> $DIR/issue-17033.rs:2:10 | LL | (*p)(()) - | ---- ^^ - | | | - | | expected `&mut ()`, found `()` - | | help: consider mutably borrowing here: `&mut ()` + | ---- ^^ expected `&mut ()`, found `()` + | | | arguments to this function are incorrect + | +help: consider mutably borrowing here + | +LL | (*p)(&mut ()) + | ++++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-18107.stderr b/tests/ui/issues/issue-18107.stderr index 1669b550a..cf4e06316 100644 --- a/tests/ui/issues/issue-18107.stderr +++ b/tests/ui/issues/issue-18107.stderr @@ -4,14 +4,18 @@ error[E0746]: return type cannot have an unboxed trait object LL | dyn AbstractRenderer | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -help: use `impl AbstractRenderer` as the return type if all return paths have the same type but you want to expose only the trait in the signature +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | impl AbstractRenderer + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -help: use a boxed trait object if all return paths implement trait `AbstractRenderer` +LL ~ Box<dyn AbstractRenderer> +LL | +LL | { +LL | match 0 { +LL ~ _ => Box::new(unimplemented!()) | -LL | Box<dyn AbstractRenderer> - | ++++ + error: aborting due to previous error diff --git a/tests/ui/issues/issue-18819.stderr b/tests/ui/issues/issue-18819.stderr index 1fc974b60..40098f962 100644 --- a/tests/ui/issues/issue-18819.stderr +++ b/tests/ui/issues/issue-18819.stderr @@ -19,7 +19,7 @@ LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) { help: consider borrowing here | LL | print_x(&X); - | ~~ + | + help: provide the argument | LL | print_x(/* &dyn Foo<Item = bool> */, /* &str */); diff --git a/tests/ui/issues/issue-21763.rs b/tests/ui/issues/issue-21763.rs index 5beb1d8b8..38103ff4f 100644 --- a/tests/ui/issues/issue-21763.rs +++ b/tests/ui/issues/issue-21763.rs @@ -1,5 +1,7 @@ // Regression test for HashMap only impl'ing Send/Sync if its contents do +// normalize-stderr-test: "\S+hashbrown-\S+" -> "$$HASHBROWN_SRC_LOCATION" + use std::collections::HashMap; use std::rc::Rc; diff --git a/tests/ui/issues/issue-21763.stderr b/tests/ui/issues/issue-21763.stderr index 04379f07b..df50118ac 100644 --- a/tests/ui/issues/issue-21763.stderr +++ b/tests/ui/issues/issue-21763.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/issue-21763.rs:9:11 + --> $DIR/issue-21763.rs:11:11 | LL | foo::<HashMap<Rc<()>, Rc<()>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely @@ -7,10 +7,15 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>(); = help: within `(Rc<()>, Rc<()>)`, the trait `Send` is not implemented for `Rc<()>` = note: required because it appears within the type `(Rc<()>, Rc<()>)` = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` - = note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` - = note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` +note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` + --> $HASHBROWN_SRC_LOCATION + | +LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> { + | ^^^^^^^ +note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` + --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL note: required by a bound in `foo` - --> $DIR/issue-21763.rs:6:11 + --> $DIR/issue-21763.rs:8:11 | LL | fn foo<T: Send>() {} | ^^^^ required by this bound in `foo` diff --git a/tests/ui/issues/issue-22034.stderr b/tests/ui/issues/issue-22034.stderr index b32de5b24..9833e559c 100644 --- a/tests/ui/issues/issue-22034.stderr +++ b/tests/ui/issues/issue-22034.stderr @@ -6,7 +6,7 @@ LL | &mut *(ptr as *mut dyn Fn()) | = help: the trait `Fn<()>` is not implemented for `()` = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` - = note: required for the cast from `()` to the object type `dyn Fn()` + = note: required for the cast from `*mut ()` to `*mut dyn Fn()` error: aborting due to previous error diff --git a/tests/ui/issues/issue-22644.rs b/tests/ui/issues/issue-22644.rs index b1d69dcd8..e3ada6504 100644 --- a/tests/ui/issues/issue-22644.rs +++ b/tests/ui/issues/issue-22644.rs @@ -1,18 +1,12 @@ -#![feature(type_ascription)] - fn main() { - let a : usize = 0; - let long_name : usize = 0; + let a: usize = 0; + let long_name: usize = 0; println!("{}", a as usize > long_name); println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as a start of generic println!("{}{}", a as usize < long_name, long_name); //~^ ERROR `<` is interpreted as a start of generic println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start of generic - println!("{}", a: usize > long_name); - println!("{}{}", a: usize < long_name, long_name); - //~^ ERROR `<` is interpreted as a start of generic - println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start of generic println!("{}", a as @@ -30,6 +24,4 @@ fn main() { 5); println!("{}", a as usize << long_name); //~ ERROR `<<` is interpreted as a start of generic - - println!("{}", a: &mut 4); //~ ERROR expected type, found `4` } diff --git a/tests/ui/issues/issue-22644.stderr b/tests/ui/issues/issue-22644.stderr index 45027afa7..0799e9ef1 100644 --- a/tests/ui/issues/issue-22644.stderr +++ b/tests/ui/issues/issue-22644.stderr @@ -1,5 +1,5 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:8:31 + --> $DIR/issue-22644.rs:6:31 | LL | println!("{}", a as usize < long_name); | ^ --------- interpreted as generic arguments @@ -12,7 +12,7 @@ LL | println!("{}", (a as usize) < long_name); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:9:33 + --> $DIR/issue-22644.rs:7:33 | LL | println!("{}{}", a as usize < long_name, long_name); | ^ -------------------- interpreted as generic arguments @@ -25,7 +25,7 @@ LL | println!("{}{}", (a as usize) < long_name, long_name); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:11:31 + --> $DIR/issue-22644.rs:9:31 | LL | println!("{}", a as usize < 4); | ^ - interpreted as generic arguments @@ -38,33 +38,7 @@ LL | println!("{}", (a as usize) < 4); | + + error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:13:31 - | -LL | println!("{}{}", a: usize < long_name, long_name); - | ^ -------------------- interpreted as generic arguments - | | - | not interpreted as comparison - | -help: try comparing the cast value - | -LL | println!("{}{}", (a: usize) < long_name, long_name); - | + + - -error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:15:29 - | -LL | println!("{}", a: usize < 4); - | ^ - interpreted as generic arguments - | | - | not interpreted as comparison - | -help: try comparing the cast value - | -LL | println!("{}", (a: usize) < 4); - | + + - -error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:20:20 + --> $DIR/issue-22644.rs:14:20 | LL | < | ^ not interpreted as comparison @@ -79,7 +53,7 @@ LL ~ usize) | error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:29:20 + --> $DIR/issue-22644.rs:23:20 | LL | < | ^ not interpreted as comparison @@ -96,7 +70,7 @@ LL ~ usize) | error: `<<` is interpreted as a start of generic arguments for `usize`, not a shift - --> $DIR/issue-22644.rs:32:31 + --> $DIR/issue-22644.rs:26:31 | LL | println!("{}", a as usize << long_name); | ^^ --------- interpreted as generic arguments @@ -108,16 +82,5 @@ help: try shifting the cast value LL | println!("{}", (a as usize) << long_name); | + + -error: expected type, found `4` - --> $DIR/issue-22644.rs:34:28 - | -LL | println!("{}", a: &mut 4); - | - ^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information - -error: aborting due to 9 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/issues/issue-22872.stderr b/tests/ui/issues/issue-22872.stderr index 951019719..63222d25c 100644 --- a/tests/ui/issues/issue-22872.stderr +++ b/tests/ui/issues/issue-22872.stderr @@ -13,7 +13,7 @@ LL | impl<'b, P> Wrap<'b> for Wrapper<P> LL | where P: Process<'b>, LL | <P as Process<'b>>::Item: Iterator { | -------- unsatisfied trait bound introduced here - = note: required for the cast from `Wrapper<P>` to the object type `dyn for<'b> Wrap<'b>` + = note: required for the cast from `Box<Wrapper<P>>` to `Box<dyn for<'b> Wrap<'b>>` help: consider further restricting the associated type | LL | fn push_process<P>(process: P) where P: Process<'static>, <P as Process<'_>>::Item: Iterator { diff --git a/tests/ui/issues/issue-25901.rs b/tests/ui/issues/issue-25901.rs index 1f7b341a9..85e12463a 100644 --- a/tests/ui/issues/issue-25901.rs +++ b/tests/ui/issues/issue-25901.rs @@ -2,7 +2,7 @@ struct A; struct B; static S: &'static B = &A; -//~^ ERROR the trait bound +//~^ ERROR cannot perform deref coercion use std::ops::Deref; diff --git a/tests/ui/issues/issue-25901.stderr b/tests/ui/issues/issue-25901.stderr index b9cac3222..1427e4385 100644 --- a/tests/ui/issues/issue-25901.stderr +++ b/tests/ui/issues/issue-25901.stderr @@ -1,15 +1,24 @@ -error[E0277]: the trait bound `A: Deref` is not satisfied +error[E0015]: cannot perform deref coercion on `A` in statics --> $DIR/issue-25901.rs:4:24 | LL | static S: &'static B = &A; - | ^^ the trait `~const Deref` is not implemented for `A` + | ^^ | -note: the trait `Deref` is implemented for `A`, but that implementation is not `const` - --> $DIR/issue-25901.rs:4:24 + = note: attempting to deref into `B` +note: deref defined here + --> $DIR/issue-25901.rs:10:5 | -LL | static S: &'static B = &A; - | ^^ +LL | type Target = B; + | ^^^^^^^^^^^ +note: impl defined here, but it is not `const` + --> $DIR/issue-25901.rs:9:1 + | +LL | impl Deref for A { + | ^^^^^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/issues/issue-2748-a.rs b/tests/ui/issues/issue-2748-a.rs deleted file mode 100644 index cbb9bcc28..000000000 --- a/tests/ui/issues/issue-2748-a.rs +++ /dev/null @@ -1,17 +0,0 @@ -// build-pass -#![allow(dead_code)] -#![allow(non_snake_case)] - -// pretty-expanded FIXME #23616 - -struct CMap<'a> { - buf: &'a [u8], -} - -fn CMap(buf: &[u8]) -> CMap { - CMap { - buf: buf - } -} - -pub fn main() { } diff --git a/tests/ui/issues/issue-3136-b.rs b/tests/ui/issues/issue-3136-b.rs index c4ca7236e..33d97fe7c 100644 --- a/tests/ui/issues/issue-3136-b.rs +++ b/tests/ui/issues/issue-3136-b.rs @@ -1,5 +1,5 @@ // run-pass -// aux-build:issue-3136-a.rc +// aux-build:issue-3136-a.rs // pretty-expanded FIXME #23616 diff --git a/tests/ui/issues/issue-32709.stderr b/tests/ui/issues/issue-32709.stderr index 1d595ca56..a4ba5da4d 100644 --- a/tests/ui/issues/issue-32709.stderr +++ b/tests/ui/issues/issue-32709.stderr @@ -7,9 +7,16 @@ LL | Err(5)?; | ^ the trait `From<{integer}>` is not implemented for `()` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the following other types implement trait `FromResidual<R>`: - <Result<T, F> as FromResidual<Result<Infallible, E>>> - <Result<T, F> as FromResidual<Yeet<E>>> + = help: the following other types implement trait `From<T>`: + <(T, T) as From<[T; 2]>> + <(T, T, T) as From<[T; 3]>> + <(T, T, T, T) as From<[T; 4]>> + <(T, T, T, T, T) as From<[T; 5]>> + <(T, T, T, T, T, T) as From<[T; 6]>> + <(T, T, T, T, T, T, T) as From<[T; 7]>> + <(T, T, T, T, T, T, T, T) as From<[T; 8]>> + <(T, T, T, T, T, T, T, T, T) as From<[T; 9]>> + and 4 others = note: required for `Result<i32, ()>` to implement `FromResidual<Result<Infallible, {integer}>>` error: aborting due to previous error diff --git a/tests/ui/issues/issue-33287.rs b/tests/ui/issues/issue-33287.rs index 770eb7c02..b3f873057 100644 --- a/tests/ui/issues/issue-33287.rs +++ b/tests/ui/issues/issue-33287.rs @@ -1,6 +1,7 @@ // build-pass #![allow(dead_code)] #![allow(unused_variables)] +#![allow(unconditional_panic)] const A: [u32; 1] = [0]; fn test() { diff --git a/tests/ui/issues/issue-3344.stderr b/tests/ui/issues/issue-3344.stderr index 11d599967..e849f5d04 100644 --- a/tests/ui/issues/issue-3344.stderr +++ b/tests/ui/issues/issue-3344.stderr @@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `partial_cmp` LL | impl PartialOrd for Thing { | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `partial_cmp` in implementation | - = help: implement the missing item: `fn partial_cmp(&self, _: &Rhs) -> Option<std::cmp::Ordering> { todo!() }` + = help: implement the missing item: `fn partial_cmp(&self, _: &Thing) -> Option<std::cmp::Ordering> { todo!() }` error: aborting due to previous error diff --git a/tests/ui/issues/issue-46302.stderr b/tests/ui/issues/issue-46302.stderr index a6f97c3c9..6e126038c 100644 --- a/tests/ui/issues/issue-46302.stderr +++ b/tests/ui/issues/issue-46302.stderr @@ -2,10 +2,12 @@ error[E0308]: mismatched types --> $DIR/issue-46302.rs:3:27 | LL | let u: &str = if true { s[..2] } else { s }; - | ^^^^^^ - | | - | expected `&str`, found `str` - | help: consider borrowing here: `&s[..2]` + | ^^^^^^ expected `&str`, found `str` + | +help: consider borrowing here + | +LL | let u: &str = if true { &s[..2] } else { s }; + | + error: aborting due to previous error diff --git a/tests/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr b/tests/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr index e874ded8e..211dd5128 100644 --- a/tests/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr +++ b/tests/ui/issues/issue-46756-consider-borrowing-cast-or-binexpr.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:12:42 | LL | light_flows_our_war_of_mocking_words(behold as usize); - | ------------------------------------ ^^^^^^^^^^^^^^^ - | | | - | | expected `&usize`, found `usize` - | | help: consider borrowing here: `&(behold as usize)` + | ------------------------------------ ^^^^^^^^^^^^^^^ expected `&usize`, found `usize` + | | | arguments to this function are incorrect | note: function defined here @@ -13,15 +11,17 @@ note: function defined here | LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- +help: consider borrowing here + | +LL | light_flows_our_war_of_mocking_words(&(behold as usize)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42 | LL | light_flows_our_war_of_mocking_words(with_tears + 4); - | ------------------------------------ ^^^^^^^^^^^^^^ - | | | - | | expected `&usize`, found `usize` - | | help: consider borrowing here: `&(with_tears + 4)` + | ------------------------------------ ^^^^^^^^^^^^^^ expected `&usize`, found `usize` + | | | arguments to this function are incorrect | note: function defined here @@ -29,6 +29,10 @@ note: function defined here | LL | fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- +help: consider borrowing here + | +LL | light_flows_our_war_of_mocking_words(&(with_tears + 4)); + | ++ + error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-49298.rs b/tests/ui/issues/issue-49298.rs index e3ffa8e7c..6e58fa12c 100644 --- a/tests/ui/issues/issue-49298.rs +++ b/tests/ui/issues/issue-49298.rs @@ -6,7 +6,7 @@ // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // -// ignore-test +// ignore-test (#54987) // This test is checking that the space allocated for `x.1` does not // overlap with `y`. (The reason why such a thing happened at one diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/issues/issue-50582.stderr index 53ecc6112..3d527eb6b 100644 --- a/tests/ui/issues/issue-50582.stderr +++ b/tests/ui/issues/issue-50582.stderr @@ -7,13 +7,13 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); = note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: cannot add `()` to `{integer}` in const contexts +error[E0277]: cannot add `()` to `{integer}` --> $DIR/issue-50582.rs:2:18 | LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | ^ no implementation for `{integer} + ()` | - = help: the trait `~const Add<()>` is not implemented for `{integer}` + = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: <&'a f32 as Add<f32>> <&'a f64 as Add<f64>> diff --git a/tests/ui/issues/issue-51515.rs b/tests/ui/issues/issue-51515.rs index 84e09afac..33a9bf85e 100644 --- a/tests/ui/issues/issue-51515.rs +++ b/tests/ui/issues/issue-51515.rs @@ -1,7 +1,6 @@ fn main() { let foo = &16; //~^ HELP consider changing this to be a mutable reference - //~| SUGGESTION &mut 16 *foo = 32; //~^ ERROR cannot assign to `*foo`, which is behind a `&` reference let bar = foo; diff --git a/tests/ui/issues/issue-51515.stderr b/tests/ui/issues/issue-51515.stderr index 94e5c9f1b..88b8d2109 100644 --- a/tests/ui/issues/issue-51515.stderr +++ b/tests/ui/issues/issue-51515.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference - --> $DIR/issue-51515.rs:5:5 + --> $DIR/issue-51515.rs:4:5 | LL | *foo = 32; | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written @@ -7,10 +7,10 @@ LL | *foo = 32; help: consider changing this to be a mutable reference | LL | let foo = &mut 16; - | ~~~~~~~ + | +++ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference - --> $DIR/issue-51515.rs:9:5 + --> $DIR/issue-51515.rs:8:5 | LL | *bar = 64; | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/issues/issue-58857.stderr b/tests/ui/issues/issue-58857.stderr index e2acec47e..6aef35f0b 100644 --- a/tests/ui/issues/issue-58857.stderr +++ b/tests/ui/issues/issue-58857.stderr @@ -1,8 +1,8 @@ error: negative bounds are not supported - --> $DIR/issue-58857.rs:4:7 + --> $DIR/issue-58857.rs:4:9 | LL | impl<A: !Valid> Conj<A>{} - | ^^^^^^^^ negative bounds are not supported + | ^ error: aborting due to previous error diff --git a/tests/ui/issues/issue-59756.rs b/tests/ui/issues/issue-59756.rs index d6df0592b..3742f31ab 100644 --- a/tests/ui/issues/issue-59756.rs +++ b/tests/ui/issues/issue-59756.rs @@ -1,5 +1,5 @@ // run-rustfix -// ignore-test +// ignore-test (rustfix needs multiple suggestions) // // FIXME: Re-enable this test once we support choosing // between multiple mutually exclusive suggestions for the same span diff --git a/tests/ui/issues/issue-61106.stderr b/tests/ui/issues/issue-61106.stderr index eff3e6e78..aa922e268 100644 --- a/tests/ui/issues/issue-61106.stderr +++ b/tests/ui/issues/issue-61106.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-61106.rs:3:9 | LL | foo(x.clone()); - | --- ^^^^^^^^^ - | | | - | | expected `&str`, found `String` - | | help: consider borrowing here: `&x` + | --- ^^^^^^^^^ expected `&str`, found `String` + | | | arguments to this function are incorrect | note: function defined here @@ -13,6 +11,10 @@ note: function defined here | LL | fn foo(_: &str) {} | ^^^ ------- +help: consider borrowing here + | +LL | foo(&x.clone()); + | + error: aborting due to previous error diff --git a/tests/ui/issues/issue-61623.stderr b/tests/ui/issues/issue-61623.stderr index 5fcc33855..bedea3890 100644 --- a/tests/ui/issues/issue-61623.stderr +++ b/tests/ui/issues/issue-61623.stderr @@ -7,7 +7,7 @@ LL | f2(|| x.0, f1(x.1)) help: consider changing this to be a mutable reference | LL | fn f3<'a>(x: &'a mut ((), &'a mut ())) { - | ~~~~~~~~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-62375.stderr b/tests/ui/issues/issue-62375.stderr index a6fd3700e..f6d7968c0 100644 --- a/tests/ui/issues/issue-62375.stderr +++ b/tests/ui/issues/issue-62375.stderr @@ -6,16 +6,20 @@ LL | a == A::Value; | | | A | -note: an implementation of `PartialEq<_>` might be missing for `A` +note: an implementation of `PartialEq<fn(()) -> A {A::Value}>` might be missing for `A` --> $DIR/issue-62375.rs:1:1 | LL | enum A { - | ^^^^^^ must implement `PartialEq<_>` + | ^^^^^^ must implement `PartialEq<fn(()) -> A {A::Value}>` help: consider annotating `A` with `#[derive(PartialEq)]` | LL + #[derive(PartialEq)] LL | enum A { | +help: use parentheses to construct this tuple variant + | +LL | a == A::Value(/* () */); + | ++++++++++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-6458-1.rs b/tests/ui/issues/issue-6458-1.rs deleted file mode 100644 index 184e4832b..000000000 --- a/tests/ui/issues/issue-6458-1.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-fail -// error-pattern:explicit panic -// ignore-emscripten no processes - -fn foo<T>(t: T) {} -fn main() { - foo(panic!()) -} diff --git a/tests/ui/issues/issue-6458-2.rs b/tests/ui/issues/issue-6458-2.rs deleted file mode 100644 index b18cae3ed..000000000 --- a/tests/ui/issues/issue-6458-2.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - // Unconstrained type: - format!("{:?}", None); - //~^ ERROR type annotations needed [E0282] -} diff --git a/tests/ui/issues/issue-6458-2.stderr b/tests/ui/issues/issue-6458-2.stderr deleted file mode 100644 index 8dbdd9a27..000000000 --- a/tests/ui/issues/issue-6458-2.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-6458-2.rs:3:21 - | -LL | format!("{:?}", None); - | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` - | -help: consider specifying the generic argument - | -LL | format!("{:?}", None::<T>); - | +++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-6458-3.rs b/tests/ui/issues/issue-6458-3.rs deleted file mode 100644 index d4f8886e9..000000000 --- a/tests/ui/issues/issue-6458-3.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::mem; - -fn main() { - mem::transmute(0); - //~^ ERROR type annotations needed [E0282] -} diff --git a/tests/ui/issues/issue-6458-3.stderr b/tests/ui/issues/issue-6458-3.stderr deleted file mode 100644 index 520efccae..000000000 --- a/tests/ui/issues/issue-6458-3.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-6458-3.rs:4:5 - | -LL | mem::transmute(0); - | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `Dst` declared on the function `transmute` - | -help: consider specifying the generic arguments - | -LL | mem::transmute::<i32, Dst>(0); - | ++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-6458-4.rs b/tests/ui/issues/issue-6458-4.rs deleted file mode 100644 index 054a5c15c..000000000 --- a/tests/ui/issues/issue-6458-4.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn foo(b: bool) -> Result<bool,String> { //~ ERROR mismatched types - Err("bar".to_string()); -} - -fn main() { - foo(false); -} diff --git a/tests/ui/issues/issue-6458-4.stderr b/tests/ui/issues/issue-6458-4.stderr deleted file mode 100644 index 66ccfdff2..000000000 --- a/tests/ui/issues/issue-6458-4.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-6458-4.rs:1:20 - | -LL | fn foo(b: bool) -> Result<bool,String> { - | --- ^^^^^^^^^^^^^^^^^^^ expected `Result<bool, String>`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression -LL | Err("bar".to_string()); - | - help: remove this semicolon to return this value - | - = note: expected enum `Result<bool, String>` - found unit type `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-6458.rs b/tests/ui/issues/issue-6458.rs deleted file mode 100644 index 16718e90d..000000000 --- a/tests/ui/issues/issue-6458.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::marker; - -pub struct TypeWithState<State>(marker::PhantomData<State>); -pub struct MyState; - -pub fn foo<State>(_: TypeWithState<State>) {} - -pub fn bar() { - foo(TypeWithState(marker::PhantomData)); - //~^ ERROR type annotations needed [E0282] -} - -fn main() { -} diff --git a/tests/ui/issues/issue-6458.stderr b/tests/ui/issues/issue-6458.stderr deleted file mode 100644 index 2e93c1385..000000000 --- a/tests/ui/issues/issue-6458.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/issue-6458.rs:9:22 - | -LL | foo(TypeWithState(marker::PhantomData)); - | ^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` - | -help: consider specifying the generic argument - | -LL | foo(TypeWithState(marker::PhantomData::<T>)); - | +++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-7364.stderr b/tests/ui/issues/issue-7364.stderr index aee73380f..7449fe697 100644 --- a/tests/ui/issues/issue-7364.stderr +++ b/tests/ui/issues/issue-7364.stderr @@ -7,7 +7,8 @@ LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); = help: the trait `Sync` is not implemented for `RefCell<isize>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead = note: required for `Unique<RefCell<isize>>` to implement `Sync` - = note: required because it appears within the type `Box<RefCell<isize>>` +note: required because it appears within the type `Box<RefCell<isize>>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: shared static variables must have a type that implements `Sync` error: aborting due to previous error diff --git a/tests/ui/iterators/collect-into-slice.rs b/tests/ui/iterators/collect-into-slice.rs index 5a8aacb1a..045d40a6f 100644 --- a/tests/ui/iterators/collect-into-slice.rs +++ b/tests/ui/iterators/collect-into-slice.rs @@ -14,4 +14,10 @@ fn main() { //~| NOTE doesn't have a size known at compile-time //~| NOTE doesn't have a size known at compile-time process_slice(&some_generated_vec); + + let some_generated_vec = (0..10).collect(); + //~^ ERROR a slice of type `&[i32]` cannot be built since we need to store the elements somewhere + //~| NOTE try explicitly collecting into a `Vec<{integer}>` + //~| NOTE required by a bound in `collect` + process_slice(some_generated_vec); } diff --git a/tests/ui/iterators/collect-into-slice.stderr b/tests/ui/iterators/collect-into-slice.stderr index 29fff8c51..07dc561f0 100644 --- a/tests/ui/iterators/collect-into-slice.stderr +++ b/tests/ui/iterators/collect-into-slice.stderr @@ -28,6 +28,16 @@ LL | let some_generated_vec = (0..10).collect(); note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 3 previous errors +error[E0277]: a slice of type `&[i32]` cannot be built since we need to store the elements somewhere + --> $DIR/collect-into-slice.rs:18:38 + | +LL | let some_generated_vec = (0..10).collect(); + | ^^^^^^^ try explicitly collecting into a `Vec<{integer}>` + | + = help: the trait `FromIterator<{integer}>` is not implemented for `&[i32]` +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/kindck/kindck-impl-type-params.stderr b/tests/ui/kindck/kindck-impl-type-params.stderr index efb25bf83..53c194049 100644 --- a/tests/ui/kindck/kindck-impl-type-params.stderr +++ b/tests/ui/kindck/kindck-impl-type-params.stderr @@ -11,7 +11,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>` + = note: required for the cast from `&S<T>` to `&dyn Gettable<T>` help: consider restricting type parameter `T` | LL | fn f<T: std::marker::Send>(val: T) { @@ -30,7 +30,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>` + = note: required for the cast from `&S<T>` to `&dyn Gettable<T>` help: consider restricting type parameter `T` | LL | fn f<T: std::marker::Copy>(val: T) { @@ -49,7 +49,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>` + = note: required for the cast from `&S<T>` to `&dyn Gettable<T>` help: consider restricting type parameter `T` | LL | fn g<T: std::marker::Send>(val: T) { @@ -68,7 +68,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>` + = note: required for the cast from `&S<T>` to `&dyn Gettable<T>` help: consider restricting type parameter `T` | LL | fn g<T: std::marker::Copy>(val: T) { @@ -88,7 +88,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<String>` to the object type `dyn Gettable<String>` + = note: required for the cast from `Box<S<String>>` to `Box<dyn Gettable<String>>` error[E0277]: the trait bound `Foo: Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:43:37 @@ -104,7 +104,7 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | ---- ^^^^^^^^^^^ ^^^^ | | | unsatisfied trait bound introduced here - = note: required for the cast from `S<Foo>` to the object type `dyn Gettable<Foo>` + = note: required for the cast from `Box<S<Foo>>` to `Box<dyn Gettable<Foo>>` help: consider annotating `Foo` with `#[derive(Copy)]` | LL + #[derive(Copy)] diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr index 8d45748a6..294951765 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -46,8 +46,7 @@ LL | trait Foo : Copy { | --- ^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&Box<{integer}>` to implement `CoerceUnsized<&dyn Foo>` - = note: required by cast to type `&dyn Foo` + = note: required for the cast from `&Box<{integer}>` to `&dyn Foo` error: aborting due to 3 previous errors diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr index 2fbb5a98a..3e164ebf5 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr @@ -32,8 +32,7 @@ LL | trait Foo : Copy { | --- ^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&Box<i32>` to implement `CoerceUnsized<&dyn Foo>` - = note: required by cast to type `&dyn Foo` + = note: required for the cast from `&Box<i32>` to `&dyn Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/kindck/kindck-send-object.stderr b/tests/ui/kindck/kindck-send-object.stderr index e9bbeeacd..284d5dcec 100644 --- a/tests/ui/kindck/kindck-send-object.stderr +++ b/tests/ui/kindck/kindck-send-object.stderr @@ -20,7 +20,8 @@ LL | assert_send::<Box<dyn Dummy>>(); | = help: the trait `Send` is not implemented for `dyn Dummy` = note: required for `Unique<dyn Dummy>` to implement `Send` - = note: required because it appears within the type `Box<dyn Dummy>` +note: required because it appears within the type `Box<dyn Dummy>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` --> $DIR/kindck-send-object.rs:5:18 | diff --git a/tests/ui/kindck/kindck-send-object1.stderr b/tests/ui/kindck/kindck-send-object1.stderr index 19ef4f6fc..269193f73 100644 --- a/tests/ui/kindck/kindck-send-object1.stderr +++ b/tests/ui/kindck/kindck-send-object1.stderr @@ -20,7 +20,8 @@ LL | assert_send::<Box<dyn Dummy + 'a>>(); | = help: the trait `Send` is not implemented for `(dyn Dummy + 'a)` = note: required for `Unique<(dyn Dummy + 'a)>` to implement `Send` - = note: required because it appears within the type `Box<dyn Dummy>` +note: required because it appears within the type `Box<dyn Dummy>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` --> $DIR/kindck-send-object1.rs:5:18 | diff --git a/tests/ui/kindck/kindck-send-object2.stderr b/tests/ui/kindck/kindck-send-object2.stderr index b8af33d0d..6b8df6022 100644 --- a/tests/ui/kindck/kindck-send-object2.stderr +++ b/tests/ui/kindck/kindck-send-object2.stderr @@ -20,7 +20,8 @@ LL | assert_send::<Box<dyn Dummy>>(); | = help: the trait `Send` is not implemented for `dyn Dummy` = note: required for `Unique<dyn Dummy>` to implement `Send` - = note: required because it appears within the type `Box<dyn Dummy>` +note: required because it appears within the type `Box<dyn Dummy>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` --> $DIR/kindck-send-object2.rs:3:18 | diff --git a/tests/ui/kindck/kindck-send-owned.stderr b/tests/ui/kindck/kindck-send-owned.stderr index b03f56465..dc1bb6206 100644 --- a/tests/ui/kindck/kindck-send-owned.stderr +++ b/tests/ui/kindck/kindck-send-owned.stderr @@ -6,7 +6,8 @@ LL | assert_send::<Box<*mut u8>>(); | = help: the trait `Send` is not implemented for `*mut u8` = note: required for `Unique<*mut u8>` to implement `Send` - = note: required because it appears within the type `Box<*mut u8>` +note: required because it appears within the type `Box<*mut u8>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` --> $DIR/kindck-send-owned.rs:3:18 | diff --git a/tests/ui/kindck/kindck-send-unsafe.rs b/tests/ui/kindck/kindck-send-unsafe.rs index 4ef30a71f..eb1f2a549 100644 --- a/tests/ui/kindck/kindck-send-unsafe.rs +++ b/tests/ui/kindck/kindck-send-unsafe.rs @@ -1,11 +1,15 @@ extern crate core; -fn assert_send<T:Send>() { } +fn assert_send<T: Send>() {} + +fn test70() { + assert_send::<*mut isize>(); + //~^ ERROR `*mut isize` cannot be sent between threads safely +} fn test71<'a>() { assert_send::<*mut &'a isize>(); //~^ ERROR `*mut &'a isize` cannot be sent between threads safely } -fn main() { -} +fn main() {} diff --git a/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master b/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master deleted file mode 100644 index 3f0444ec9..000000000 --- a/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master +++ /dev/null @@ -1,12 +0,0 @@ -fn assert_send<T:Send>() { } - -// unsafe ptrs are ok unless they point at unsendable things -fn test70() { - assert_send::<*mut int>(); -} -fn test71<'a>() { - assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime -} - -fn main() { -} diff --git a/tests/ui/kindck/kindck-send-unsafe.stderr b/tests/ui/kindck/kindck-send-unsafe.stderr index ceed0053c..f1a5054ab 100644 --- a/tests/ui/kindck/kindck-send-unsafe.stderr +++ b/tests/ui/kindck/kindck-send-unsafe.stderr @@ -1,16 +1,29 @@ -error[E0277]: `*mut &'a isize` cannot be sent between threads safely +error[E0277]: `*mut isize` cannot be sent between threads safely --> $DIR/kindck-send-unsafe.rs:6:19 | +LL | assert_send::<*mut isize>(); + | ^^^^^^^^^^ `*mut isize` cannot be sent between threads safely + | + = help: the trait `Send` is not implemented for `*mut isize` +note: required by a bound in `assert_send` + --> $DIR/kindck-send-unsafe.rs:3:19 + | +LL | fn assert_send<T: Send>() {} + | ^^^^ required by this bound in `assert_send` + +error[E0277]: `*mut &'a isize` cannot be sent between threads safely + --> $DIR/kindck-send-unsafe.rs:11:19 + | LL | assert_send::<*mut &'a isize>(); | ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely | = help: the trait `Send` is not implemented for `*mut &'a isize` note: required by a bound in `assert_send` - --> $DIR/kindck-send-unsafe.rs:3:18 + --> $DIR/kindck-send-unsafe.rs:3:19 | -LL | fn assert_send<T:Send>() { } - | ^^^^ required by this bound in `assert_send` +LL | fn assert_send<T: Send>() {} + | ^^^^ required by this bound in `assert_send` -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/debug.rs b/tests/ui/layout/debug.rs index a282e7123..46171880a 100644 --- a/tests/ui/layout/debug.rs +++ b/tests/ui/layout/debug.rs @@ -1,8 +1,9 @@ // normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN" -#![feature(never_type, rustc_attrs, type_alias_impl_trait)] +#![feature(never_type, rustc_attrs, type_alias_impl_trait, repr_simd)] #![crate_type = "lib"] #[rustc_layout(debug)] +#[derive(Copy, Clone)] enum E { Foo, Bar(!, i32, i32) } //~ ERROR: layout_of #[rustc_layout(debug)] @@ -17,6 +18,51 @@ type Test = Result<i32, i32>; //~ ERROR: layout_of #[rustc_layout(debug)] type T = impl std::fmt::Debug; //~ ERROR: layout_of +#[rustc_layout(debug)] +pub union V { //~ ERROR: layout_of + a: [u16; 0], + b: u8, +} + +#[rustc_layout(debug)] +pub union W { //~ ERROR: layout_of + b: u8, + a: [u16; 0], +} + +#[rustc_layout(debug)] +pub union Y { //~ ERROR: layout_of + b: [u8; 0], + a: [u16; 0], +} + +#[rustc_layout(debug)] +#[repr(packed(1))] +union P1 { x: u32 } //~ ERROR: layout_of + +#[rustc_layout(debug)] +#[repr(packed(1))] +union P2 { x: (u32, u32) } //~ ERROR: layout_of + +#[repr(simd)] +#[derive(Copy, Clone)] +struct F32x4(f32, f32, f32, f32); + +#[rustc_layout(debug)] +#[repr(packed(1))] +union P3 { x: F32x4 } //~ ERROR: layout_of + +#[rustc_layout(debug)] +#[repr(packed(1))] +union P4 { x: E } //~ ERROR: layout_of + +#[rustc_layout(debug)] +#[repr(packed(1))] +union P5 { zst: [u16; 0], byte: u8 } //~ ERROR: layout_of + +#[rustc_layout(debug)] +type X = std::mem::MaybeUninit<u8>; //~ ERROR: layout_of + fn f() -> T { 0i32 } diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index c5e1c41d1..b9fa1b299 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -81,7 +81,7 @@ error: layout_of(E) = Layout { ], }, } - --> $DIR/debug.rs:6:1 + --> $DIR/debug.rs:7:1 | LL | enum E { Foo, Bar(!, i32, i32) } | ^^^^^^ @@ -125,7 +125,7 @@ error: layout_of(S) = Layout { index: 0, }, } - --> $DIR/debug.rs:9:1 + --> $DIR/debug.rs:10:1 | LL | struct S { f1: i32, f2: (), f3: i32 } | ^^^^^^^^ @@ -147,7 +147,7 @@ error: layout_of(U) = Layout { index: 0, }, } - --> $DIR/debug.rs:12:1 + --> $DIR/debug.rs:13:1 | LL | union U { f1: (i32, i32), f3: i32 } | ^^^^^^^ @@ -276,7 +276,7 @@ error: layout_of(std::result::Result<i32, i32>) = Layout { ], }, } - --> $DIR/debug.rs:15:1 + --> $DIR/debug.rs:16:1 | LL | type Test = Result<i32, i32>; | ^^^^^^^^^ @@ -302,10 +302,218 @@ error: layout_of(i32) = Layout { index: 0, }, } - --> $DIR/debug.rs:18:1 + --> $DIR/debug.rs:19:1 | LL | type T = impl std::fmt::Debug; | ^^^^^^ -error: aborting due to 5 previous errors +error: layout_of(V) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 2, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:22:1 + | +LL | pub union V { + | ^^^^^^^^^^^ + +error: layout_of(W) = Layout { + size: Size(2 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 2, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:28:1 + | +LL | pub union W { + | ^^^^^^^^^^^ + +error: layout_of(Y) = Layout { + size: Size(0 bytes), + align: AbiAndPrefAlign { + abi: Align(2 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 2, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:34:1 + | +LL | pub union Y { + | ^^^^^^^^^^^ + +error: layout_of(P1) = Layout { + size: Size(4 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 1, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:41:1 + | +LL | union P1 { x: u32 } + | ^^^^^^^^ + +error: layout_of(P2) = Layout { + size: Size(8 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 1, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:45:1 + | +LL | union P2 { x: (u32, u32) } + | ^^^^^^^^ + +error: layout_of(P3) = Layout { + size: Size(16 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 1, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:53:1 + | +LL | union P3 { x: F32x4 } + | ^^^^^^^^ + +error: layout_of(P4) = Layout { + size: Size(12 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Aggregate { + sized: true, + }, + fields: Union( + 1, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:57:1 + | +LL | union P4 { x: E } + | ^^^^^^^^ + +error: layout_of(P5) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Scalar( + Union { + value: Int( + I8, + false, + ), + }, + ), + fields: Union( + 2, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:61:1 + | +LL | union P5 { zst: [u16; 0], byte: u8 } + | ^^^^^^^^ + +error: layout_of(std::mem::MaybeUninit<u8>) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $PREF_ALIGN, + }, + abi: Scalar( + Union { + value: Int( + I8, + false, + ), + }, + ), + fields: Union( + 2, + ), + largest_niche: None, + variants: Single { + index: 0, + }, + } + --> $DIR/debug.rs:64:1 + | +LL | type X = std::mem::MaybeUninit<u8>; + | ^^^^^^ + +error: aborting due to 14 previous errors diff --git a/tests/ui/layout/issue-112048-unsizing-field-order.rs b/tests/ui/layout/issue-112048-unsizing-field-order.rs new file mode 100644 index 000000000..ebc4b9e98 --- /dev/null +++ b/tests/ui/layout/issue-112048-unsizing-field-order.rs @@ -0,0 +1,25 @@ +// run-pass + +// Check that unsizing doesn't reorder fields. + +#![allow(dead_code)] + +use std::fmt::Debug; + +#[derive(Debug)] +struct GcNode<T: ?Sized> { + gets_swapped_with_next: usize, + next: Option<&'static GcNode<dyn Debug>>, + tail: T, +} + +fn main() { + let node: Box<GcNode<dyn Debug>> = Box::new(GcNode { + gets_swapped_with_next: 42, + next: None, + tail: Box::new(1), + }); + + assert_eq!(node.gets_swapped_with_next, 42); + assert!(node.next.is_none()); +} diff --git a/tests/ui/layout/issue-112048-unsizing-niche.rs b/tests/ui/layout/issue-112048-unsizing-niche.rs new file mode 100644 index 000000000..23588ba36 --- /dev/null +++ b/tests/ui/layout/issue-112048-unsizing-niche.rs @@ -0,0 +1,30 @@ +// run-pass + +// Check that unsizing does not change which field is considered for niche layout. + +#![feature(offset_of)] +#![allow(dead_code)] + +#[derive(Clone)] +struct WideptrField<T: ?Sized> { + first: usize, + second: usize, + niche: NicheAtEnd, + tail: T, +} + +#[derive(Clone)] +#[repr(C)] +struct NicheAtEnd { + arr: [u8; 7], + b: bool, +} + +type Tail = [bool; 8]; + +fn main() { + assert_eq!( + core::mem::offset_of!(WideptrField<Tail>, niche), + core::mem::offset_of!(WideptrField<dyn Send>, niche) + ); +} diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index 20d4c418e..8c7c91535 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -370,23 +370,23 @@ error: layout_of(NicheFirst) = Layout { pref: $PREF_ALIGN, }, abi: ScalarPair( - Union { + Initialized { value: Int( I8, false, ), + valid_range: 0..=4, }, - Initialized { + Union { value: Int( I8, false, ), - valid_range: 0..=4, }, ), fields: Arbitrary { offsets: [ - Size(1 bytes), + Size(0 bytes), ], memory_index: [ 0, @@ -394,7 +394,7 @@ error: layout_of(NicheFirst) = Layout { }, largest_niche: Some( Niche { - offset: Size(1 bytes), + offset: Size(0 bytes), value: Int( I8, false, @@ -429,29 +429,29 @@ error: layout_of(NicheFirst) = Layout { I8, false, ), - valid_range: 0..=255, + valid_range: 0..=2, }, Initialized { value: Int( I8, false, ), - valid_range: 0..=2, + valid_range: 0..=255, }, ), fields: Arbitrary { offsets: [ - Size(1 bytes), Size(0 bytes), + Size(1 bytes), ], memory_index: [ - 1, 0, + 1, ], }, largest_niche: Some( Niche { - offset: Size(1 bytes), + offset: Size(0 bytes), value: Int( I8, false, @@ -514,23 +514,23 @@ error: layout_of(NicheSecond) = Layout { pref: $PREF_ALIGN, }, abi: ScalarPair( - Union { + Initialized { value: Int( I8, false, ), + valid_range: 0..=4, }, - Initialized { + Union { value: Int( I8, false, ), - valid_range: 0..=4, }, ), fields: Arbitrary { offsets: [ - Size(1 bytes), + Size(0 bytes), ], memory_index: [ 0, @@ -538,7 +538,7 @@ error: layout_of(NicheSecond) = Layout { }, largest_niche: Some( Niche { - offset: Size(1 bytes), + offset: Size(0 bytes), value: Int( I8, false, @@ -573,29 +573,29 @@ error: layout_of(NicheSecond) = Layout { I8, false, ), - valid_range: 0..=255, + valid_range: 0..=2, }, Initialized { value: Int( I8, false, ), - valid_range: 0..=2, + valid_range: 0..=255, }, ), fields: Arbitrary { offsets: [ - Size(0 bytes), Size(1 bytes), + Size(0 bytes), ], memory_index: [ - 0, 1, + 0, ], }, largest_niche: Some( Niche { - offset: Size(1 bytes), + offset: Size(0 bytes), value: Int( I8, false, diff --git a/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs b/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs new file mode 100644 index 000000000..69a7b61ba --- /dev/null +++ b/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs @@ -0,0 +1,20 @@ +// Verify that elided lifetimes inside anonymous constants are not forced to be `'static`. +// check-pass + +fn foo() -> [(); { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }] { + [(); 10] +} + +fn bar() -> [(); 10] { + [(); { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }] +} + +fn main() {} diff --git a/tests/ui/lifetimes/issue-105675.rs b/tests/ui/lifetimes/issue-105675.rs new file mode 100644 index 000000000..58d8be8b6 --- /dev/null +++ b/tests/ui/lifetimes/issue-105675.rs @@ -0,0 +1,14 @@ +fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + +fn main() { + let f = | _ , y: &u32 , z | (); + thing(f); + //~^ ERROR mismatched types + //~^^ ERROR mismatched types + let f = | x, y: _ , z: u32 | (); + thing(f); + //~^ ERROR mismatched types + //~^^ ERROR mismatched types + //~^^^ ERROR implementation of `FnOnce` is not general enough + //~^^^^ ERROR implementation of `FnOnce` is not general enough +} diff --git a/tests/ui/lifetimes/issue-105675.stderr b/tests/ui/lifetimes/issue-105675.stderr new file mode 100644 index 000000000..66415f72b --- /dev/null +++ b/tests/ui/lifetimes/issue-105675.stderr @@ -0,0 +1,109 @@ +error[E0308]: mismatched types + --> $DIR/issue-105675.rs:5:5 + | +LL | thing(f); + | ^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a u32, &'b u32, u32)>` + found trait `for<'a> FnOnce<(&u32, &'a u32, u32)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-105675.rs:4:13 + | +LL | let f = | _ , y: &u32 , z | (); + | ^^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-105675.rs:1:18 + | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: consider specifying the type of the closure parameters + | +LL | let f = |_: &_, y: &u32, z| (); + | ~~~~~~~~~~~~~~~~~~~ + +error[E0308]: mismatched types + --> $DIR/issue-105675.rs:5:5 + | +LL | thing(f); + | ^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a u32, &'b u32, u32)>` + found trait `for<'a> FnOnce<(&u32, &'a u32, u32)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-105675.rs:4:13 + | +LL | let f = | _ , y: &u32 , z | (); + | ^^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-105675.rs:1:18 + | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-105675.rs:9:5 + | +LL | thing(f); + | ^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a u32, &'b u32, u32)>` + found trait `FnOnce<(&u32, &u32, u32)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-105675.rs:8:13 + | +LL | let f = | x, y: _ , z: u32 | (); + | ^^^^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-105675.rs:1:18 + | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: consider specifying the type of the closure parameters + | +LL | let f = |x: &_, y: &_, z: u32| (); + | ~~~~~~~~~~~~~~~~~~~~~~ + +error[E0308]: mismatched types + --> $DIR/issue-105675.rs:9:5 + | +LL | thing(f); + | ^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a u32, &'b u32, u32)>` + found trait `FnOnce<(&u32, &u32, u32)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-105675.rs:8:13 + | +LL | let f = | x, y: _ , z: u32 | (); + | ^^^^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-105675.rs:1:18 + | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: consider specifying the type of the closure parameters + | +LL | let f = |x: &_, y: &_, z: u32| (); + | ~~~~~~~~~~~~~~~~~~~~~~ + +error: implementation of `FnOnce` is not general enough + --> $DIR/issue-105675.rs:9:5 + | +LL | thing(f); + | ^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` + +error: implementation of `FnOnce` is not general enough + --> $DIR/issue-105675.rs:9:5 + | +LL | thing(f); + | ^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&u32, &'2 u32, u32)>`, for some specific lifetime `'2` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-36744-without-calls.rs b/tests/ui/lifetimes/issue-36744-without-calls.rs index dc5dc4f13..dc5dc4f13 100644 --- a/tests/ui/issues/issue-36744-without-calls.rs +++ b/tests/ui/lifetimes/issue-36744-without-calls.rs diff --git a/tests/ui/lifetimes/issue-64173-unused-lifetimes.rs b/tests/ui/lifetimes/issue-64173-unused-lifetimes.rs index 8080dd7dc..3879784d0 100644 --- a/tests/ui/lifetimes/issue-64173-unused-lifetimes.rs +++ b/tests/ui/lifetimes/issue-64173-unused-lifetimes.rs @@ -13,7 +13,7 @@ const fn foo<T>() -> usize { } struct Bar<'a> { //~ ERROR: parameter `'a` is never used - beta: [(); foo::<&'a ()>()], //~ ERROR: a non-static lifetime is not allowed in a `const` + beta: [(); foo::<&'a ()>()], //~ ERROR: generic parameters may not be used in const operations } fn main() {} diff --git a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr index a487cbea5..02ca10b2e 100644 --- a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr +++ b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr @@ -1,11 +1,11 @@ -error[E0658]: a non-static lifetime is not allowed in a `const` +error: generic parameters may not be used in const operations --> $DIR/issue-64173-unused-lifetimes.rs:16:23 | LL | beta: [(); foo::<&'a ()>()], - | ^^ + | ^^ cannot perform const operation using `'a` | - = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information - = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + = note: lifetime parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic `Self` types are currently not permitted in anonymous constants --> $DIR/issue-64173-unused-lifetimes.rs:4:28 @@ -31,5 +31,4 @@ LL | struct Bar<'a> { error: aborting due to 4 previous errors -Some errors have detailed explanations: E0392, E0658. -For more information about an error, try `rustc --explain E0392`. +For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/lifetimes/issue-69314.stderr b/tests/ui/lifetimes/issue-69314.stderr index 7ae678928..3879f3550 100644 --- a/tests/ui/lifetimes/issue-69314.stderr +++ b/tests/ui/lifetimes/issue-69314.stderr @@ -12,6 +12,8 @@ LL | async fn f2(m: Msg<'_>) {} error[E0597]: `buf` does not live long enough --> $DIR/issue-69314.rs:14:19 | +LL | let mut buf = [0; 512]; + | ------- binding `buf` declared here LL | let m2 = &buf[..]; | ^^^ borrowed value does not live long enough LL | let m = Self::g(m2).await; diff --git a/tests/ui/lifetimes/issue-79187-2.stderr b/tests/ui/lifetimes/issue-79187-2.stderr index c5f654b37..75fd87b3f 100644 --- a/tests/ui/lifetimes/issue-79187-2.stderr +++ b/tests/ui/lifetimes/issue-79187-2.stderr @@ -43,6 +43,10 @@ note: the lifetime requirement is introduced here | LL | fn take_foo(_: impl Foo) {} | ^^^ +help: consider specifying the type of the closure parameters + | +LL | take_foo(|a: &_| a); + | ~~~~~~~ error[E0308]: mismatched types --> $DIR/issue-79187-2.rs:11:5 diff --git a/tests/ui/lifetimes/issue-79187.stderr b/tests/ui/lifetimes/issue-79187.stderr index ee6e7b89d..209f2b7b7 100644 --- a/tests/ui/lifetimes/issue-79187.stderr +++ b/tests/ui/lifetimes/issue-79187.stderr @@ -16,6 +16,10 @@ note: the lifetime requirement is introduced here | LL | fn thing(x: impl FnOnce(&u32)) {} | ^^^^^^^^^^^^ +help: consider specifying the type of the closure parameters + | +LL | let f = |_: &_| (); + | ~~~~~~~ error: implementation of `FnOnce` is not general enough --> $DIR/issue-79187.rs:5:5 diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 0ae68ad04..2f5ba9844 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -27,7 +27,7 @@ fn d<const C: S>() {} trait Foo<'a> {} struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; -//~^ ERROR use of non-static lifetime `'a` in const generic +//~^ ERROR the type of const parameters must not depend on other generic parameters //~| ERROR `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 20163d289..4994e4dc4 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -9,13 +9,13 @@ help: consider introducing a named lifetime parameter LL | fn d<'a, const C: S<'a>>() {} | +++ ++++ -error[E0771]: use of non-static lifetime `'a` in const generic +error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/unusual-rib-combinations.rs:29:22 | LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; - | ^^ + | ^^ the type must not depend on the parameter `'a` | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + = note: lifetime parameters may not be used in the type of const parameters error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/unusual-rib-combinations.rs:7:16 @@ -74,5 +74,5 @@ LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; error: aborting due to 9 previous errors -Some errors have detailed explanations: E0106, E0214, E0308, E0771. +Some errors have detailed explanations: E0106, E0214, E0308, E0770. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui-fulldeps/lint-group-denied-lint-allowed.rs b/tests/ui/lint-group-denied-lint-allowed.rs index 7498745f2..8156b6ef6 100644 --- a/tests/ui-fulldeps/lint-group-denied-lint-allowed.rs +++ b/tests/ui/lint-group-denied-lint-allowed.rs @@ -1,4 +1,3 @@ -// aux-build:lint-group-plugin-test.rs // check-pass // compile-flags: -D unused -A unused-variables diff --git a/tests/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs b/tests/ui/lint-group-forbid-always-trumps-cli.rs index fc19bc039..77b792f98 100644 --- a/tests/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs +++ b/tests/ui/lint-group-forbid-always-trumps-cli.rs @@ -1,4 +1,3 @@ -// aux-build:lint-group-plugin-test.rs // compile-flags: -F unused -A unused fn main() { diff --git a/tests/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr b/tests/ui/lint-group-forbid-always-trumps-cli.stderr index 6bab367b0..8910af87c 100644 --- a/tests/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr +++ b/tests/ui/lint-group-forbid-always-trumps-cli.stderr @@ -1,5 +1,5 @@ error: unused variable: `x` - --> $DIR/lint-group-forbid-always-trumps-cli.rs:5:9 + --> $DIR/lint-group-forbid-always-trumps-cli.rs:4:9 | LL | let x = 1; | ^ help: if this is intentional, prefix it with an underscore: `_x` diff --git a/tests/ui/lint/auxiliary/missing_docs.rs b/tests/ui/lint/auxiliary/missing_docs.rs new file mode 100644 index 000000000..4a835673a --- /dev/null +++ b/tests/ui/lint/auxiliary/missing_docs.rs @@ -0,0 +1 @@ +pub struct Foo; diff --git a/tests/ui/lint/dead-code/closure-bang.rs b/tests/ui/lint/dead-code/closure-bang.rs index 8e8636b11..bca131a15 100644 --- a/tests/ui/lint/dead-code/closure-bang.rs +++ b/tests/ui/lint/dead-code/closure-bang.rs @@ -1,9 +1,7 @@ -// ignore-test FIXME(#20574) - #![deny(unreachable_code)] fn main() { - let x = || panic!(); + let x = || -> ! { panic!() }; x(); println!("Foo bar"); //~ ERROR: unreachable statement } diff --git a/tests/ui/lint/dead-code/closure-bang.stderr b/tests/ui/lint/dead-code/closure-bang.stderr new file mode 100644 index 000000000..119ce11e3 --- /dev/null +++ b/tests/ui/lint/dead-code/closure-bang.stderr @@ -0,0 +1,17 @@ +error: unreachable statement + --> $DIR/closure-bang.rs:6:5 + | +LL | x(); + | --- any code following this expression is unreachable +LL | println!("Foo bar"); + | ^^^^^^^^^^^^^^^^^^^ unreachable statement + | +note: the lint level is defined here + --> $DIR/closure-bang.rs:1:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/lint/dead-code/offset-of-correct-param-env.rs b/tests/ui/lint/dead-code/offset-of-correct-param-env.rs new file mode 100644 index 000000000..2c6fcef25 --- /dev/null +++ b/tests/ui/lint/dead-code/offset-of-correct-param-env.rs @@ -0,0 +1,42 @@ +// check-pass + +#![feature(offset_of)] +#![deny(dead_code)] + +// This struct contains a projection that can only be normalized after getting the field type. +struct A<T: Project> { + a: <T as Project>::EquateParamTo, +} + +// This is the inner struct that we want to get. +struct MyFieldIsNotDead { + not_dead: u8, +} + +// These are some helpers. +// Inside the param env of `test`, we want to make it so that it considers T=MyFieldIsNotDead. +struct GenericIsEqual<T>(T); +trait Project { + type EquateParamTo; +} +impl<T> Project for GenericIsEqual<T> { + type EquateParamTo = T; +} + +fn test<T>() -> usize +where + GenericIsEqual<T>: Project<EquateParamTo = MyFieldIsNotDead>, +{ + // The first field of the A that we construct here is + // `<GenericIsEqual<T>> as Project>::EquateParamTo`. + // Typeck normalizes this and figures that the not_dead field is totally fine and accessible. + // But importantly, the normalization ends up with T, which, as we've declared in our param + // env is MyFieldDead. When we're in the param env of the `a` field, the where bound above + // is not in scope, so we don't know what T is - it's generic. + // If we use the wrong param env, the lint will ICE. + std::mem::offset_of!(A<GenericIsEqual<T>>, a.not_dead) +} + +fn main() { + test::<MyFieldIsNotDead>(); +} diff --git a/tests/ui/lint/dead-code/offset-of.rs b/tests/ui/lint/dead-code/offset-of.rs new file mode 100644 index 000000000..da91de386 --- /dev/null +++ b/tests/ui/lint/dead-code/offset-of.rs @@ -0,0 +1,44 @@ +#![feature(offset_of)] +#![deny(dead_code)] + +use std::mem::offset_of; + +struct Alpha { + a: (), + b: (), //~ ERROR field `b` is never read + c: Beta, +} + +struct Beta { + a: (), //~ ERROR field `a` is never read + b: (), +} + +struct Gamma { + a: (), //~ ERROR field `a` is never read + b: (), +} + +struct Delta { + a: (), + b: (), //~ ERROR field `b` is never read +} + +trait Trait { + type Assoc; +} +impl Trait for () { + type Assoc = Delta; +} + +struct Project<T: Trait> { + a: u8, //~ ERROR field `a` is never read + b: <T as Trait>::Assoc, +} + +fn main() { + offset_of!(Alpha, a); + offset_of!(Alpha, c.b); + offset_of!((Gamma,), 0.b); + offset_of!(Project::<()>, b.a); +} diff --git a/tests/ui/lint/dead-code/offset-of.stderr b/tests/ui/lint/dead-code/offset-of.stderr new file mode 100644 index 000000000..ed2916461 --- /dev/null +++ b/tests/ui/lint/dead-code/offset-of.stderr @@ -0,0 +1,50 @@ +error: field `b` is never read + --> $DIR/offset-of.rs:8:5 + | +LL | struct Alpha { + | ----- field in this struct +LL | a: (), +LL | b: (), + | ^ + | +note: the lint level is defined here + --> $DIR/offset-of.rs:2:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: field `a` is never read + --> $DIR/offset-of.rs:13:5 + | +LL | struct Beta { + | ---- field in this struct +LL | a: (), + | ^ + +error: field `a` is never read + --> $DIR/offset-of.rs:18:5 + | +LL | struct Gamma { + | ----- field in this struct +LL | a: (), + | ^ + +error: field `b` is never read + --> $DIR/offset-of.rs:24:5 + | +LL | struct Delta { + | ----- field in this struct +LL | a: (), +LL | b: (), + | ^ + +error: field `a` is never read + --> $DIR/offset-of.rs:35:5 + | +LL | struct Project<T: Trait> { + | ------- field in this struct +LL | a: u8, + | ^ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/lint/dropping_copy_types.rs b/tests/ui/lint/dropping_copy_types.rs new file mode 100644 index 000000000..2412222d6 --- /dev/null +++ b/tests/ui/lint/dropping_copy_types.rs @@ -0,0 +1,98 @@ +// check-pass + +#![warn(dropping_copy_types)] + +use std::mem::drop; +use std::vec::Vec; + +#[derive(Copy, Clone)] +struct SomeStruct; + +struct AnotherStruct { + x: u8, + y: u8, + z: Vec<u8>, +} + +impl Clone for AnotherStruct { + fn clone(&self) -> AnotherStruct { + AnotherStruct { + x: self.x, + y: self.y, + z: self.z.clone(), + } + } +} + +fn main() { + let s1 = SomeStruct {}; + let s2 = s1; + let s3 = &s1; + let mut s4 = s1; + let ref s5 = s1; + + drop(s1); //~ WARN calls to `std::mem::drop` + drop(s2); //~ WARN calls to `std::mem::drop` + drop(s3); //~ WARN calls to `std::mem::drop` + drop(s4); //~ WARN calls to `std::mem::drop` + drop(s5); //~ WARN calls to `std::mem::drop` + + let a1 = AnotherStruct { + x: 255, + y: 0, + z: vec![1, 2, 3], + }; + let a2 = &a1; + let mut a3 = a1.clone(); + let ref a4 = a1; + let a5 = a1.clone(); + + drop(a2); //~ WARN calls to `std::mem::drop` + drop(a3); + drop(a4); //~ WARN calls to `std::mem::drop` + drop(a5); +} + +#[allow(unused)] +#[allow(clippy::unit_cmp)] +fn issue9482(x: u8) { + fn println_and<T>(t: T) -> T { + println!("foo"); + t + } + + match x { + // Don't lint (copy type), we only care about side-effects + 0 => drop(println_and(12)), + // Don't lint (no copy type), we only care about side-effects + 1 => drop(println_and(String::new())), + 2 => { + // Lint, even if we only care about the side-effect, it's already in a block + drop(println_and(13)); //~ WARN calls to `std::mem::drop` + }, + // Lint, idiomatic use is only in body of `Arm` + 3 if drop(println_and(14)) == () => (), //~ WARN calls to `std::mem::drop` + // Lint, not a fn/method call + 4 => drop(2),//~ WARN calls to `std::mem::drop` + _ => (), + } +} + +fn issue112653() { + fn foo() -> Result<u8, ()> { + println!("doing foo"); + Ok(0) // result is not always useful, the side-effect matters + } + fn bar() { + println!("doing bar"); + } + + fn stuff() -> Result<(), ()> { + match 42 { + 0 => drop(foo()?), // drop is needed because we only care about side-effects + 1 => bar(), + _ => (), // doing nothing (no side-effects needed here) + } + Ok(()) + } +} diff --git a/tests/ui/lint/dropping_copy_types.stderr b/tests/ui/lint/dropping_copy_types.stderr new file mode 100644 index 000000000..b6291aa5e --- /dev/null +++ b/tests/ui/lint/dropping_copy_types.stderr @@ -0,0 +1,108 @@ +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:34:5 + | +LL | drop(s1); + | ^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result +note: the lint level is defined here + --> $DIR/dropping_copy_types.rs:3:9 + | +LL | #![warn(dropping_copy_types)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:35:5 + | +LL | drop(s2); + | ^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_copy_types.rs:36:5 + | +LL | drop(s3); + | ^^^^^--^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + = note: `#[warn(dropping_references)]` on by default + +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:37:5 + | +LL | drop(s4); + | ^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_copy_types.rs:38:5 + | +LL | drop(s5); + | ^^^^^--^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_copy_types.rs:50:5 + | +LL | drop(a2); + | ^^^^^--^ + | | + | argument has type `&AnotherStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_copy_types.rs:52:5 + | +LL | drop(a4); + | ^^^^^--^ + | | + | argument has type `&AnotherStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:71:13 + | +LL | drop(println_and(13)); + | ^^^^^---------------^ + | | + | argument has type `i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:74:14 + | +LL | 3 if drop(println_and(14)) == () => (), + | ^^^^^---------------^ + | | + | argument has type `i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing + --> $DIR/dropping_copy_types.rs:76:14 + | +LL | 4 => drop(2), + | ^^^^^-^ + | | + | argument has type `i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: 10 warnings emitted + diff --git a/tests/ui/lint/dropping_references.rs b/tests/ui/lint/dropping_references.rs new file mode 100644 index 000000000..bb02cb75a --- /dev/null +++ b/tests/ui/lint/dropping_references.rs @@ -0,0 +1,118 @@ +// check-pass + +#![warn(dropping_references)] + +struct SomeStruct; + +fn main() { + drop(&SomeStruct); //~ WARN calls to `std::mem::drop` + + let mut owned1 = SomeStruct; + drop(&owned1); //~ WARN calls to `std::mem::drop` + drop(&&owned1); //~ WARN calls to `std::mem::drop` + drop(&mut owned1); //~ WARN calls to `std::mem::drop` + drop(owned1); + + let reference1 = &SomeStruct; + drop(reference1); //~ WARN calls to `std::mem::drop` + + let reference2 = &mut SomeStruct; + drop(reference2); //~ WARN calls to `std::mem::drop` + + let ref reference3 = SomeStruct; + drop(reference3); //~ WARN calls to `std::mem::drop` +} + +#[allow(dead_code)] +fn test_generic_fn_drop<T>(val: T) { + drop(&val); //~ WARN calls to `std::mem::drop` + drop(val); +} + +#[allow(dead_code)] +fn test_similarly_named_function() { + fn drop<T>(_val: T) {} + drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name + std::mem::drop(&SomeStruct); //~ WARN calls to `std::mem::drop` +} + +#[derive(Copy, Clone)] +pub struct Error; +fn produce_half_owl_error() -> Result<(), Error> { + Ok(()) +} + +fn produce_half_owl_ok() -> Result<bool, ()> { + Ok(true) +} + +#[allow(dead_code)] +fn test_owl_result() -> Result<(), ()> { + produce_half_owl_error().map_err(|_| ())?; + produce_half_owl_ok().map(|_| ())?; + // the following should not be linted, + // we should not force users to use toilet closures + // to produce owl results when drop is more convenient + produce_half_owl_error().map_err(drop)?; + produce_half_owl_ok().map_err(drop)?; + Ok(()) +} + +#[allow(dead_code)] +fn test_owl_result_2() -> Result<u8, ()> { + produce_half_owl_error().map_err(|_| ())?; + produce_half_owl_ok().map(|_| ())?; + // the following should not be linted, + // we should not force users to use toilet closures + // to produce owl results when drop is more convenient + produce_half_owl_error().map_err(drop)?; + produce_half_owl_ok().map(drop)?; + Ok(1) +} + +#[allow(unused)] +#[allow(clippy::unit_cmp)] +fn issue10122(x: u8) { + // This is a function which returns a reference and has a side-effect, which means + // that calling drop() on the function is considered an idiomatic way of achieving + // the side-effect in a match arm. + fn println_and<T>(t: &T) -> &T { + println!("foo"); + t + } + + match x { + // Don't lint (copy type), we only care about side-effects + 0 => drop(println_and(&12)), + // Don't lint (no copy type), we only care about side-effects + 1 => drop(println_and(&String::new())), + 2 => { + // Lint, even if we only care about the side-effect, it's already in a block + drop(println_and(&13)); //~ WARN calls to `std::mem::drop` + }, + // Lint, idiomatic use is only in body of `Arm` + 3 if drop(println_and(&14)) == () => (), //~ WARN calls to `std::mem::drop` + // Lint, not a fn/method call + 4 => drop(&2), //~ WARN calls to `std::mem::drop` + _ => (), + } +} + +fn issue112653() { + fn foo() -> Result<&'static u8, ()> { + println!("doing foo"); + Ok(&0) // result is not always useful, the side-effect matters + } + fn bar() { + println!("doing bar"); + } + + fn stuff() -> Result<(), ()> { + match 42 { + 0 => drop(foo()?), // drop is needed because we only care about side-effects + 1 => bar(), + _ => (), // doing nothing (no side-effects needed here) + } + Ok(()) + } +} diff --git a/tests/ui/lint/dropping_references.stderr b/tests/ui/lint/dropping_references.stderr new file mode 100644 index 000000000..7e25a4621 --- /dev/null +++ b/tests/ui/lint/dropping_references.stderr @@ -0,0 +1,127 @@ +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:8:5 + | +LL | drop(&SomeStruct); + | ^^^^^-----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result +note: the lint level is defined here + --> $DIR/dropping_references.rs:3:9 + | +LL | #![warn(dropping_references)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:11:5 + | +LL | drop(&owned1); + | ^^^^^-------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:12:5 + | +LL | drop(&&owned1); + | ^^^^^--------^ + | | + | argument has type `&&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:13:5 + | +LL | drop(&mut owned1); + | ^^^^^-----------^ + | | + | argument has type `&mut SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:17:5 + | +LL | drop(reference1); + | ^^^^^----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:20:5 + | +LL | drop(reference2); + | ^^^^^----------^ + | | + | argument has type `&mut SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:23:5 + | +LL | drop(reference3); + | ^^^^^----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:28:5 + | +LL | drop(&val); + | ^^^^^----^ + | | + | argument has type `&T` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:36:5 + | +LL | std::mem::drop(&SomeStruct); + | ^^^^^^^^^^^^^^^-----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:91:13 + | +LL | drop(println_and(&13)); + | ^^^^^----------------^ + | | + | argument has type `&i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:94:14 + | +LL | 3 if drop(println_and(&14)) == () => (), + | ^^^^^----------------^ + | | + | argument has type `&i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing + --> $DIR/dropping_references.rs:96:14 + | +LL | 4 => drop(&2), + | ^^^^^--^ + | | + | argument has type `&i32` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: 12 warnings emitted + diff --git a/tests/ui/lint/forgetting_copy_types.rs b/tests/ui/lint/forgetting_copy_types.rs new file mode 100644 index 000000000..224c7bcd5 --- /dev/null +++ b/tests/ui/lint/forgetting_copy_types.rs @@ -0,0 +1,56 @@ +// check-pass + +#![warn(forgetting_copy_types)] + +use std::mem::forget; +use std::vec::Vec; + +#[derive(Copy, Clone)] +struct SomeStruct; + +struct AnotherStruct { + x: u8, + y: u8, + z: Vec<u8>, +} + +impl Clone for AnotherStruct { + fn clone(&self) -> AnotherStruct { + AnotherStruct { + x: self.x, + y: self.y, + z: self.z.clone(), + } + } +} + +fn main() { + let s1 = SomeStruct {}; + let s2 = s1; + let s3 = &s1; + let mut s4 = s1; + let ref s5 = s1; + + forget(s1); //~ WARN calls to `std::mem::forget` + forget(s2); //~ WARN calls to `std::mem::forget` + forget(s3); //~ WARN calls to `std::mem::forget` + forget(s4); //~ WARN calls to `std::mem::forget` + forget(s5); //~ WARN calls to `std::mem::forget` + + let a1 = AnotherStruct { + x: 255, + y: 0, + z: vec![1, 2, 3], + }; + let a2 = &a1; + let mut a3 = a1.clone(); + let ref a4 = a1; + let a5 = a1.clone(); + + forget(a2); //~ WARN calls to `std::mem::forget` + let a3 = &a1; + forget(a3); //~ WARN calls to `std::mem::forget` + forget(a4); //~ WARN calls to `std::mem::forget` + let a5 = a1.clone(); + forget(a5); +} diff --git a/tests/ui/lint/forgetting_copy_types.stderr b/tests/ui/lint/forgetting_copy_types.stderr new file mode 100644 index 000000000..36d1ef5c5 --- /dev/null +++ b/tests/ui/lint/forgetting_copy_types.stderr @@ -0,0 +1,88 @@ +warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing + --> $DIR/forgetting_copy_types.rs:34:5 + | +LL | forget(s1); + | ^^^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result +note: the lint level is defined here + --> $DIR/forgetting_copy_types.rs:3:9 + | +LL | #![warn(forgetting_copy_types)] + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing + --> $DIR/forgetting_copy_types.rs:35:5 + | +LL | forget(s2); + | ^^^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_copy_types.rs:36:5 + | +LL | forget(s3); + | ^^^^^^^--^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + = note: `#[warn(forgetting_references)]` on by default + +warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing + --> $DIR/forgetting_copy_types.rs:37:5 + | +LL | forget(s4); + | ^^^^^^^--^ + | | + | argument has type `SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_copy_types.rs:38:5 + | +LL | forget(s5); + | ^^^^^^^--^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_copy_types.rs:50:5 + | +LL | forget(a2); + | ^^^^^^^--^ + | | + | argument has type `&AnotherStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_copy_types.rs:52:5 + | +LL | forget(a3); + | ^^^^^^^--^ + | | + | argument has type `&AnotherStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_copy_types.rs:53:5 + | +LL | forget(a4); + | ^^^^^^^--^ + | | + | argument has type `&AnotherStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: 8 warnings emitted + diff --git a/tests/ui/lint/forgetting_references.rs b/tests/ui/lint/forgetting_references.rs new file mode 100644 index 000000000..bd51e9800 --- /dev/null +++ b/tests/ui/lint/forgetting_references.rs @@ -0,0 +1,39 @@ +// check-pass + +#![warn(forgetting_references)] + +use std::mem::forget; + +struct SomeStruct; + +fn main() { + forget(&SomeStruct); //~ WARN calls to `std::mem::forget` + + let mut owned = SomeStruct; + forget(&owned); //~ WARN calls to `std::mem::forget` + forget(&&owned); //~ WARN calls to `std::mem::forget` + forget(&mut owned); //~ WARN calls to `std::mem::forget` + forget(owned); + + let reference1 = &SomeStruct; + forget(&*reference1); //~ WARN calls to `std::mem::forget` + + let reference2 = &mut SomeStruct; + forget(reference2); //~ WARN calls to `std::mem::forget` + + let ref reference3 = SomeStruct; + forget(reference3); //~ WARN calls to `std::mem::forget` +} + +#[allow(dead_code)] +fn test_generic_fn_forget<T>(val: T) { + forget(&val); //~ WARN calls to `std::mem::forget` + forget(val); +} + +#[allow(dead_code)] +fn test_similarly_named_function() { + fn forget<T>(_val: T) {} + forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name + std::mem::forget(&SomeStruct); //~ WARN calls to `std::mem::forget` +} diff --git a/tests/ui/lint/forgetting_references.stderr b/tests/ui/lint/forgetting_references.stderr new file mode 100644 index 000000000..5624b6907 --- /dev/null +++ b/tests/ui/lint/forgetting_references.stderr @@ -0,0 +1,97 @@ +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:10:5 + | +LL | forget(&SomeStruct); + | ^^^^^^^-----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result +note: the lint level is defined here + --> $DIR/forgetting_references.rs:3:9 + | +LL | #![warn(forgetting_references)] + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:13:5 + | +LL | forget(&owned); + | ^^^^^^^------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:14:5 + | +LL | forget(&&owned); + | ^^^^^^^-------^ + | | + | argument has type `&&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:15:5 + | +LL | forget(&mut owned); + | ^^^^^^^----------^ + | | + | argument has type `&mut SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:19:5 + | +LL | forget(&*reference1); + | ^^^^^^^------------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:22:5 + | +LL | forget(reference2); + | ^^^^^^^----------^ + | | + | argument has type `&mut SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:25:5 + | +LL | forget(reference3); + | ^^^^^^^----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:30:5 + | +LL | forget(&val); + | ^^^^^^^----^ + | | + | argument has type `&T` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing + --> $DIR/forgetting_references.rs:38:5 + | +LL | std::mem::forget(&SomeStruct); + | ^^^^^^^^^^^^^^^^^-----------^ + | | + | argument has type `&SomeStruct` + | + = note: use `let _ = ...` to ignore the expression or result + +warning: 9 warnings emitted + diff --git a/tests/ui/lint/internal/trivial-diagnostics.rs b/tests/ui/lint/internal/trivial-diagnostics.rs new file mode 100644 index 000000000..e536e1164 --- /dev/null +++ b/tests/ui/lint/internal/trivial-diagnostics.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunstable-options + +pub fn issue_111280() { + struct_span_err(msg).emit(); //~ ERROR cannot find value `msg` + //~^ ERROR cannot find function `struct_span_err` +} + +fn main() {} diff --git a/tests/ui/lint/internal/trivial-diagnostics.stderr b/tests/ui/lint/internal/trivial-diagnostics.stderr new file mode 100644 index 000000000..d47a7dae0 --- /dev/null +++ b/tests/ui/lint/internal/trivial-diagnostics.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find value `msg` in this scope + --> $DIR/trivial-diagnostics.rs:4:21 + | +LL | struct_span_err(msg).emit(); + | ^^^ not found in this scope + +error[E0425]: cannot find function `struct_span_err` in this scope + --> $DIR/trivial-diagnostics.rs:4:5 + | +LL | struct_span_err(msg).emit(); + | ^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/lint/invalid_value-polymorphic.rs b/tests/ui/lint/invalid_value-polymorphic.rs index 055173e98..98f82b792 100644 --- a/tests/ui/lint/invalid_value-polymorphic.rs +++ b/tests/ui/lint/invalid_value-polymorphic.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-type=lib -Zmir-enable-passes=+InstCombine +// compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify // build-pass #![feature(core_intrinsics)] diff --git a/tests/ui/lint/issue-110573.rs b/tests/ui/lint/issue-110573.rs new file mode 100644 index 000000000..d9f0868b7 --- /dev/null +++ b/tests/ui/lint/issue-110573.rs @@ -0,0 +1,12 @@ +// check-pass + +#![deny(warnings)] + +pub struct Struct; + +impl Struct { + #[allow(non_upper_case_globals)] + pub const Const: () = (); +} + +fn main() {} diff --git a/tests/ui/lint/issue-111359.rs b/tests/ui/lint/issue-111359.rs new file mode 100644 index 000000000..e390c3fc5 --- /dev/null +++ b/tests/ui/lint/issue-111359.rs @@ -0,0 +1,27 @@ +#[deny(missing_debug_implementations)] +#[deny(missing_copy_implementations)] + +mod priv_mod { + use std::convert::TryFrom; + + pub struct BarPub; + //~^ ERROR type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation + //~| ERROR type could implement `Copy`; consider adding `impl Copy` + struct BarPriv; + + impl<'a> TryFrom<BarPriv> for u8 { + type Error = (); + fn try_from(o: BarPriv) -> Result<Self, ()> { + unimplemented!() + } + } + + impl<'a> TryFrom<BarPub> for u8 { + type Error = (); + fn try_from(o: BarPub) -> Result<Self, ()> { + unimplemented!() + } + } +} + +fn main() {} diff --git a/tests/ui/lint/issue-111359.stderr b/tests/ui/lint/issue-111359.stderr new file mode 100644 index 000000000..2296d8413 --- /dev/null +++ b/tests/ui/lint/issue-111359.stderr @@ -0,0 +1,26 @@ +error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation + --> $DIR/issue-111359.rs:7:5 + | +LL | pub struct BarPub; + | ^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-111359.rs:1:8 + | +LL | #[deny(missing_debug_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type could implement `Copy`; consider adding `impl Copy` + --> $DIR/issue-111359.rs:7:5 + | +LL | pub struct BarPub; + | ^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-111359.rs:2:8 + | +LL | #[deny(missing_copy_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/issue-112489.rs b/tests/ui/lint/issue-112489.rs new file mode 100644 index 000000000..559edf0e4 --- /dev/null +++ b/tests/ui/lint/issue-112489.rs @@ -0,0 +1,17 @@ +// check-pass +use std::borrow::Borrow; + +struct S; + +trait T: Sized { + fn foo(self) {} +} + +impl T for S {} +impl T for &S {} + +fn main() { + let s = S; + s.borrow().foo(); + s.foo(); +} diff --git a/tests/ui/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs b/tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs index f30d7e2ed..f30d7e2ed 100644 --- a/tests/ui/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs +++ b/tests/ui/lint/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs diff --git a/tests/ui/lint/lint-attr-everywhere-early.rs b/tests/ui/lint/lint-attr-everywhere-early.rs index fd0c4b43e..0c820ef9a 100644 --- a/tests/ui/lint/lint-attr-everywhere-early.rs +++ b/tests/ui/lint/lint-attr-everywhere-early.rs @@ -134,6 +134,14 @@ fn expressions() { } } + match f { + #[deny(ellipsis_inclusive_range_patterns)] + Match{f1: 0...100} => {} + //~^ ERROR range patterns are deprecated + //~| WARNING this is accepted in the current edition + _ => {} + } + // Statement Block { #![deny(unsafe_code)] diff --git a/tests/ui/lint/lint-attr-everywhere-early.stderr b/tests/ui/lint/lint-attr-everywhere-early.stderr index d6c6d5fae..fac0eb4fa 100644 --- a/tests/ui/lint/lint-attr-everywhere-early.stderr +++ b/tests/ui/lint/lint-attr-everywhere-early.stderr @@ -384,92 +384,106 @@ note: the lint level is defined here LL | #[deny(while_true)] | ^^^^^^^^^^ +error: `...` range patterns are deprecated + --> $DIR/lint-attr-everywhere-early.rs:139:20 + | +LL | Match{f1: 0...100} => {} + | ^^^ help: use `..=` for an inclusive range + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +note: the lint level is defined here + --> $DIR/lint-attr-everywhere-early.rs:138:16 + | +LL | #[deny(ellipsis_inclusive_range_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:140:9 + --> $DIR/lint-attr-everywhere-early.rs:148:9 | LL | unsafe {} | ^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:139:17 + --> $DIR/lint-attr-everywhere-early.rs:147:17 | LL | #![deny(unsafe_code)] | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:144:9 + --> $DIR/lint-attr-everywhere-early.rs:152:9 | LL | unsafe {} | ^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:143:16 + --> $DIR/lint-attr-everywhere-early.rs:151:16 | LL | #[deny(unsafe_code)] | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:149:5 + --> $DIR/lint-attr-everywhere-early.rs:157:5 | LL | unsafe {}; | ^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:148:12 + --> $DIR/lint-attr-everywhere-early.rs:156:12 | LL | #[deny(unsafe_code)] | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:151:27 + --> $DIR/lint-attr-everywhere-early.rs:159:27 | LL | [#[deny(unsafe_code)] unsafe {123}]; | ^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:151:13 + --> $DIR/lint-attr-everywhere-early.rs:159:13 | LL | [#[deny(unsafe_code)] unsafe {123}]; | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:152:27 + --> $DIR/lint-attr-everywhere-early.rs:160:27 | LL | (#[deny(unsafe_code)] unsafe {123},); | ^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:152:13 + --> $DIR/lint-attr-everywhere-early.rs:160:13 | LL | (#[deny(unsafe_code)] unsafe {123},); | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:154:31 + --> $DIR/lint-attr-everywhere-early.rs:162:31 | LL | call(#[deny(unsafe_code)] unsafe {123}); | ^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:154:17 + --> $DIR/lint-attr-everywhere-early.rs:162:17 | LL | call(#[deny(unsafe_code)] unsafe {123}); | ^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-attr-everywhere-early.rs:156:38 + --> $DIR/lint-attr-everywhere-early.rs:164:38 | LL | TupleStruct(#[deny(unsafe_code)] unsafe {123}); | ^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:156:24 + --> $DIR/lint-attr-everywhere-early.rs:164:24 | LL | TupleStruct(#[deny(unsafe_code)] unsafe {123}); | ^^^^^^^^^^^ error: `...` range patterns are deprecated - --> $DIR/lint-attr-everywhere-early.rs:167:18 + --> $DIR/lint-attr-everywhere-early.rs:175:18 | LL | f1: 0...100, | ^^^ help: use `..=` for an inclusive range @@ -477,10 +491,10 @@ LL | f1: 0...100, = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> note: the lint level is defined here - --> $DIR/lint-attr-everywhere-early.rs:166:20 + --> $DIR/lint-attr-everywhere-early.rs:174:20 | LL | #[deny(ellipsis_inclusive_range_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 36 previous errors +error: aborting due to 37 previous errors diff --git a/tests/ui/lint/lint-attr-everywhere-late.rs b/tests/ui/lint/lint-attr-everywhere-late.rs index 1055157d6..a24355bab 100644 --- a/tests/ui/lint/lint-attr-everywhere-late.rs +++ b/tests/ui/lint/lint-attr-everywhere-late.rs @@ -162,6 +162,11 @@ fn expressions() { } } + match 123 { + #[deny(non_snake_case)] + ARM_VAR => {} //~ ERROR variable `ARM_VAR` should have a snake case name + } + // Statement Block { #![deny(enum_intrinsics_non_enums)] diff --git a/tests/ui/lint/lint-attr-everywhere-late.stderr b/tests/ui/lint/lint-attr-everywhere-late.stderr index a69c2e0ef..9587556b0 100644 --- a/tests/ui/lint/lint-attr-everywhere-late.stderr +++ b/tests/ui/lint/lint-attr-everywhere-late.stderr @@ -305,124 +305,136 @@ note: the lint level is defined here LL | #[deny(enum_intrinsics_non_enums)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ +error: variable `ARM_VAR` should have a snake case name + --> $DIR/lint-attr-everywhere-late.rs:167:9 + | +LL | ARM_VAR => {} + | ^^^^^^^ help: convert the identifier to snake case: `arm_var` + | +note: the lint level is defined here + --> $DIR/lint-attr-everywhere-late.rs:166:16 + | +LL | #[deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:168:9 + --> $DIR/lint-attr-everywhere-late.rs:173:9 | LL | discriminant::<i32>(&123); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:168:29 + --> $DIR/lint-attr-everywhere-late.rs:173:29 | LL | discriminant::<i32>(&123); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:167:17 + --> $DIR/lint-attr-everywhere-late.rs:172:17 | LL | #![deny(enum_intrinsics_non_enums)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:172:9 + --> $DIR/lint-attr-everywhere-late.rs:177:9 | LL | discriminant::<i32>(&123); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:172:29 + --> $DIR/lint-attr-everywhere-late.rs:177:29 | LL | discriminant::<i32>(&123); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:171:16 + --> $DIR/lint-attr-everywhere-late.rs:176:16 | LL | #[deny(enum_intrinsics_non_enums)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:177:5 + --> $DIR/lint-attr-everywhere-late.rs:182:5 | LL | discriminant::<i32>(&123); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:177:25 + --> $DIR/lint-attr-everywhere-late.rs:182:25 | LL | discriminant::<i32>(&123); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:176:12 + --> $DIR/lint-attr-everywhere-late.rs:181:12 | LL | #[deny(enum_intrinsics_non_enums)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:179:41 + --> $DIR/lint-attr-everywhere-late.rs:184:41 | LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:179:61 + --> $DIR/lint-attr-everywhere-late.rs:184:61 | LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)]; | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:179:13 + --> $DIR/lint-attr-everywhere-late.rs:184:13 | LL | [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:180:41 + --> $DIR/lint-attr-everywhere-late.rs:185:41 | LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:180:61 + --> $DIR/lint-attr-everywhere-late.rs:185:61 | LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:180:13 + --> $DIR/lint-attr-everywhere-late.rs:185:13 | LL | (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:182:45 + --> $DIR/lint-attr-everywhere-late.rs:187:45 | LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:182:65 + --> $DIR/lint-attr-everywhere-late.rs:187:65 | LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:182:17 + --> $DIR/lint-attr-everywhere-late.rs:187:17 | LL | call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type - --> $DIR/lint-attr-everywhere-late.rs:184:52 + --> $DIR/lint-attr-everywhere-late.rs:189:52 | LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `i32`, which is not an enum. - --> $DIR/lint-attr-everywhere-late.rs:184:72 + --> $DIR/lint-attr-everywhere-late.rs:189:72 | LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^ note: the lint level is defined here - --> $DIR/lint-attr-everywhere-late.rs:184:24 + --> $DIR/lint-attr-everywhere-late.rs:189:24 | LL | TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 31 previous errors +error: aborting due to 32 previous errors diff --git a/tests/ui/lint/lint-match-arms-2.rs b/tests/ui/lint/lint-match-arms-2.rs new file mode 100644 index 000000000..0c1146339 --- /dev/null +++ b/tests/ui/lint/lint-match-arms-2.rs @@ -0,0 +1,24 @@ +#![feature(if_let_guard)] +#![allow(unused, non_snake_case)] + +enum E { + A, +} + +#[allow(bindings_with_variant_name, irrefutable_let_patterns)] +fn foo() { + match E::A { + #[deny(bindings_with_variant_name)] + A => {} + //~^ ERROR pattern binding `A` is named the same as one of the variants of the type `E` + } + + match &E::A { + #[deny(irrefutable_let_patterns)] + a if let b = a => {} + //~^ ERROR irrefutable `if let` guard pattern + _ => {} + } +} + +fn main() { } diff --git a/tests/ui/lint/lint-match-arms-2.stderr b/tests/ui/lint/lint-match-arms-2.stderr new file mode 100644 index 000000000..062d5c12e --- /dev/null +++ b/tests/ui/lint/lint-match-arms-2.stderr @@ -0,0 +1,29 @@ +error[E0170]: pattern binding `A` is named the same as one of the variants of the type `E` + --> $DIR/lint-match-arms-2.rs:12:9 + | +LL | A => {} + | ^ help: to match on the variant, qualify the path: `E::A` + | +note: the lint level is defined here + --> $DIR/lint-match-arms-2.rs:11:16 + | +LL | #[deny(bindings_with_variant_name)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: irrefutable `if let` guard pattern + --> $DIR/lint-match-arms-2.rs:18:18 + | +LL | a if let b = a => {} + | ^ + | + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm +note: the lint level is defined here + --> $DIR/lint-match-arms-2.rs:17:16 + | +LL | #[deny(irrefutable_let_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0170`. diff --git a/tests/ui/lint/lint-missing-doc.rs b/tests/ui/lint/lint-missing-doc.rs index 4a234d265..b59f2212f 100644 --- a/tests/ui/lint/lint-missing-doc.rs +++ b/tests/ui/lint/lint-missing-doc.rs @@ -1,12 +1,17 @@ // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. +// aux-build:missing_docs.rs #![deny(missing_docs)] #![allow(dead_code)] #![feature(associated_type_defaults, extern_types)] +#![feature(trait_alias)] //! Some garbage docs for the crate here #![doc="More garbage"] +// There should be not "missing_docs" warning on "pub extern crate". +pub extern crate missing_docs; + type Typedef = String; pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias @@ -202,4 +207,6 @@ extern "C" { //~^ ERROR: missing documentation for a foreign type } +pub trait T = Sync; //~ ERROR: missing documentation for a trait alias + fn main() {} diff --git a/tests/ui/lint/lint-missing-doc.stderr b/tests/ui/lint/lint-missing-doc.stderr index 733d062a0..adcc21c44 100644 --- a/tests/ui/lint/lint-missing-doc.stderr +++ b/tests/ui/lint/lint-missing-doc.stderr @@ -1,152 +1,158 @@ error: missing documentation for a type alias - --> $DIR/lint-missing-doc.rs:11:1 + --> $DIR/lint-missing-doc.rs:16:1 | LL | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-missing-doc.rs:3:9 + --> $DIR/lint-missing-doc.rs:4:9 | LL | #![deny(missing_docs)] | ^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/lint-missing-doc.rs:18:1 + --> $DIR/lint-missing-doc.rs:23:1 | LL | pub struct PubFoo { | ^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/lint-missing-doc.rs:19:5 + --> $DIR/lint-missing-doc.rs:24:5 | LL | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/lint-missing-doc.rs:30:1 + --> $DIR/lint-missing-doc.rs:35:1 | LL | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:34:1 + --> $DIR/lint-missing-doc.rs:39:1 | LL | pub fn foo2() {} | ^^^^^^^^^^^^^ error: missing documentation for a trait - --> $DIR/lint-missing-doc.rs:52:1 + --> $DIR/lint-missing-doc.rs:57:1 | LL | pub trait C { | ^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/lint-missing-doc.rs:53:5 + --> $DIR/lint-missing-doc.rs:58:5 | LL | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/lint-missing-doc.rs:54:5 + --> $DIR/lint-missing-doc.rs:59:5 | LL | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated function - --> $DIR/lint-missing-doc.rs:55:5 + --> $DIR/lint-missing-doc.rs:60:5 | LL | fn foo_no_self(); | ^^^^^^^^^^^^^^^^^ error: missing documentation for an associated function - --> $DIR/lint-missing-doc.rs:56:5 + --> $DIR/lint-missing-doc.rs:61:5 | LL | fn foo_no_self_with_impl() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/lint-missing-doc.rs:66:5 + --> $DIR/lint-missing-doc.rs:71:5 | LL | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/lint-missing-doc.rs:67:5 + --> $DIR/lint-missing-doc.rs:72:5 | LL | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated function - --> $DIR/lint-missing-doc.rs:83:5 + --> $DIR/lint-missing-doc.rs:88:5 | LL | pub fn foo() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/lint-missing-doc.rs:120:1 + --> $DIR/lint-missing-doc.rs:125:1 | LL | pub enum PubBaz { | ^^^^^^^^^^^^^^^ error: missing documentation for a variant - --> $DIR/lint-missing-doc.rs:121:5 + --> $DIR/lint-missing-doc.rs:126:5 | LL | PubBazA { | ^^^^^^^ error: missing documentation for a struct field - --> $DIR/lint-missing-doc.rs:122:9 + --> $DIR/lint-missing-doc.rs:127:9 | LL | a: isize, | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/lint-missing-doc.rs:153:1 + --> $DIR/lint-missing-doc.rs:158:1 | LL | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/lint-missing-doc.rs:163:1 + --> $DIR/lint-missing-doc.rs:168:1 | LL | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:169:5 + --> $DIR/lint-missing-doc.rs:174:5 | LL | pub fn undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:170:5 + --> $DIR/lint-missing-doc.rs:175:5 | LL | pub fn undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:176:9 + --> $DIR/lint-missing-doc.rs:181:9 | LL | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/lint-missing-doc.rs:191:5 + --> $DIR/lint-missing-doc.rs:196:5 | LL | pub fn extern_fn_undocumented(f: f32) -> f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/lint-missing-doc.rs:196:5 + --> $DIR/lint-missing-doc.rs:201:5 | LL | pub static EXTERN_STATIC_UNDOCUMENTED: u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a foreign type - --> $DIR/lint-missing-doc.rs:201:5 + --> $DIR/lint-missing-doc.rs:206:5 | LL | pub type ExternTyUndocumented; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 24 previous errors +error: missing documentation for a trait alias + --> $DIR/lint-missing-doc.rs:210:1 + | +LL | pub trait T = Sync; + | ^^^^^^^^^^^ + +error: aborting due to 25 previous errors diff --git a/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs new file mode 100644 index 000000000..4409611c2 --- /dev/null +++ b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.rs @@ -0,0 +1,15 @@ +#![deny(non_upper_case_globals)] + +trait Trait { + const item: usize; + //~^ ERROR associated constant `item` should have an upper case name [non_upper_case_globals] +} + +struct Foo; + +impl Trait for Foo { + const item: usize = 5; + // ^^^ there should be no error here (in the trait `impl`) +} + +fn main() {} diff --git a/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr new file mode 100644 index 000000000..98d8d1dd2 --- /dev/null +++ b/tests/ui/lint/lint-non-uppercase-trait-assoc-const.stderr @@ -0,0 +1,14 @@ +error: associated constant `item` should have an upper case name + --> $DIR/lint-non-uppercase-trait-assoc-const.rs:4:11 + | +LL | const item: usize; + | ^^^^ help: convert the identifier to upper case: `ITEM` + | +note: the lint level is defined here + --> $DIR/lint-non-uppercase-trait-assoc-const.rs:1:9 + | +LL | #![deny(non_upper_case_globals)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/lint/lint-uppercase-variables.stderr b/tests/ui/lint/lint-uppercase-variables.stderr index 42ec9364b..922082801 100644 --- a/tests/ui/lint/lint-uppercase-variables.stderr +++ b/tests/ui/lint/lint-uppercase-variables.stderr @@ -12,12 +12,6 @@ error[E0170]: pattern binding `Foo` is named the same as one of the variants of LL | let Foo = foo::Foo::Foo; | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` -error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` - --> $DIR/lint-uppercase-variables.rs:33:17 - | -LL | fn in_param(Foo: foo::Foo) {} - | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` - warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:22:9 | @@ -37,6 +31,12 @@ warning: unused variable: `Foo` LL | let Foo = foo::Foo::Foo; | ^^^ help: if this is intentional, prefix it with an underscore: `_Foo` +error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` + --> $DIR/lint-uppercase-variables.rs:33:17 + | +LL | fn in_param(Foo: foo::Foo) {} + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:33:17 | diff --git a/tests/ui/lint/must_not_suspend/boxed.stderr b/tests/ui/lint/must_not_suspend/boxed.stderr index 9efc7b069..a2abfffc1 100644 --- a/tests/ui/lint/must_not_suspend/boxed.stderr +++ b/tests/ui/lint/must_not_suspend/boxed.stderr @@ -4,7 +4,7 @@ error: boxed `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/boxed.rs:20:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr index 262657da5..cd3baa857 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr index 262657da5..cd3baa857 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr index 7ed43d257..aff2f7c32 100644 --- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 @@ -21,7 +21,7 @@ error: `No` held across a suspend point, but should not be --> $DIR/dedup.rs:20:13 | LL | wheeee(&no).await; - | ^^ ------ the value is held across this suspend point + | ^^ ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:20:13 diff --git a/tests/ui/lint/must_not_suspend/dedup.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr deleted file mode 100644 index 18880f5a7..000000000 --- a/tests/ui/lint/must_not_suspend/dedup.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:13 - | -LL | wheeee(&No {}).await; - | ^^^^^ ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:13 - | -LL | wheeee(&No {}).await; - | ^^^^^ -note: the lint level is defined here - --> $DIR/dedup.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/mutex.stderr b/tests/ui/lint/must_not_suspend/mutex.stderr index c251cb845..9b5fc37a3 100644 --- a/tests/ui/lint/must_not_suspend/mutex.stderr +++ b/tests/ui/lint/must_not_suspend/mutex.stderr @@ -4,7 +4,7 @@ error: `MutexGuard` held across a suspend point, but should not be LL | let _guard = m.lock().unwrap(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send` --> $DIR/mutex.rs:8:9 diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr index 180e187c1..348880b9c 100644 --- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref-drop-tracking.rs:19:13 diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr index e3628ca5e..fb18c2be9 100644 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:13 diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr index e3628ca5e..fb18c2be9 100644 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:13 diff --git a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr index e9bfa08b5..6976dd349 100644 --- a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:26 diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr index 6e62a228a..8c8ad1f37 100644 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr index 6e62a228a..8c8ad1f37 100644 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr index 6e62a228a..8c8ad1f37 100644 --- a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.stderr b/tests/ui/lint/must_not_suspend/trait.stderr deleted file mode 100644 index 6e62a228a..000000000 --- a/tests/ui/lint/must_not_suspend/trait.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: implementer of `Wow` held across a suspend point, but should not be - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -... -LL | other().await; - | ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -note: the lint level is defined here - --> $DIR/trait.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: boxed `Wow` trait object held across a suspend point, but should not be - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ -LL | -LL | other().await; - | ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr index f89b3e341..e24cffdd0 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr index f89b3e341..e24cffdd0 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr index f89b3e341..e24cffdd0 100644 --- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.stderr b/tests/ui/lint/must_not_suspend/unit.stderr deleted file mode 100644 index 50ca292c2..000000000 --- a/tests/ui/lint/must_not_suspend/unit.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ------ the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/unit.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr index 7a422891a..4f7b40a5e 100644 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr index 7a422891a..4f7b40a5e 100644 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr index 7a422891a..4f7b40a5e 100644 --- a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.stderr b/tests/ui/lint/must_not_suspend/warn.stderr deleted file mode 100644 index 7a422891a..000000000 --- a/tests/ui/lint/must_not_suspend/warn.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: `Umm` held across a suspend point, but should not be - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ------ the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/warn.rs:7:9 - | -LL | #![warn(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs index 89b296635..dbcf2a513 100644 --- a/tests/ui/lint/noop-method-call.rs +++ b/tests/ui/lint/noop-method-call.rs @@ -19,18 +19,17 @@ fn main() { let clone_type_ref = &CloneType(1u32); let clone_type_ref_clone: CloneType<u32> = clone_type_ref.clone(); - // Calling clone on a double reference doesn't warn since the method call itself - // peels the outer reference off let clone_type_ref = &&CloneType(1u32); let clone_type_ref_clone: &CloneType<u32> = clone_type_ref.clone(); + //~^ WARNING using `.clone()` on a double reference, which returns `&CloneType<u32>` let non_deref_type = &PlainType(1u32); let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); //~^ WARNING call to `.deref()` on a reference in this situation does nothing - // Dereferencing a &&T does not warn since it has collapsed the double reference let non_deref_type = &&PlainType(1u32); let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); + //~^ WARNING using `.deref()` on a double reference, which returns `&PlainType<u32>` let non_borrow_type = &PlainType(1u32); let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); @@ -41,7 +40,8 @@ fn main() { let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); let xs = ["a", "b", "c"]; - let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // ok, but could use `*x` instead + let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + //~^ WARNING using `.clone()` on a double reference, which returns `&str` } fn generic<T>(non_clone_type: &PlainType<T>) { diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index 6a904d01a..37cd1a0fc 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -11,22 +11,42 @@ note: the lint level is defined here LL | #![warn(noop_method_call)] | ^^^^^^^^^^^^^^^^ +warning: using `.clone()` on a double reference, which returns `&CloneType<u32>` instead of cloning the inner type + --> $DIR/noop-method-call.rs:23:63 + | +LL | let clone_type_ref_clone: &CloneType<u32> = clone_type_ref.clone(); + | ^^^^^^^^ + | + = note: `#[warn(suspicious_double_ref_op)]` on by default + warning: call to `.deref()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:28:63 + --> $DIR/noop-method-call.rs:27:63 | LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); | ^^^^^^^^ unnecessary method call | = note: the type `&PlainType<u32>` which `deref` is being called on is the same as the type returned from `deref`, so the method call does not do anything and can be removed +warning: using `.deref()` on a double reference, which returns `&PlainType<u32>` instead of dereferencing the inner type + --> $DIR/noop-method-call.rs:31:63 + | +LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); + | ^^^^^^^^ + warning: call to `.borrow()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:36:66 + --> $DIR/noop-method-call.rs:35:66 | LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); | ^^^^^^^^^ unnecessary method call | = note: the type `&PlainType<u32>` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed +warning: using `.clone()` on a double reference, which returns `&str` instead of cloning the inner type + --> $DIR/noop-method-call.rs:43:44 + | +LL | let _v: Vec<&str> = xs.iter().map(|x| x.clone()).collect(); // could use `*x` instead + | ^^^^^^^^ + warning: call to `.clone()` on a reference in this situation does nothing --> $DIR/noop-method-call.rs:48:19 | @@ -43,5 +63,5 @@ LL | non_clone_type.clone(); | = note: the type `&PlainType<u32>` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed -warning: 5 warnings emitted +warning: 8 warnings emitted diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr b/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr index 2c35647b8..4852c3313 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.stderr @@ -1,15 +1,3 @@ -error: unused variable: `this_is_my_function` - --> $DIR/expect_nested_lint_levels.rs:48:9 - | -LL | let this_is_my_function = 3; - | ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function` - | -note: the lint level is defined here - --> $DIR/expect_nested_lint_levels.rs:45:10 - | -LL | #[forbid(unused_variables)] - | ^^^^^^^^^^^^^^^^ - warning: variable does not need to be mutable --> $DIR/expect_nested_lint_levels.rs:36:13 | @@ -25,6 +13,18 @@ note: the lint level is defined here LL | unused_mut, | ^^^^^^^^^^ +error: unused variable: `this_is_my_function` + --> $DIR/expect_nested_lint_levels.rs:48:9 + | +LL | let this_is_my_function = 3; + | ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function` + | +note: the lint level is defined here + --> $DIR/expect_nested_lint_levels.rs:45:10 + | +LL | #[forbid(unused_variables)] + | ^^^^^^^^^^^^^^^^ + warning: this lint expectation is unfulfilled --> $DIR/expect_nested_lint_levels.rs:7:5 | diff --git a/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr b/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr index 5942fa8ae..169f03aed 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr +++ b/tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.stderr @@ -12,12 +12,6 @@ warning: unused variable: `fox_name` LL | let fox_name = "Sir Nibbles"; | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_fox_name` -warning: unused variable: `this_should_fulfill_the_expectation` - --> $DIR/force_warn_expected_lints_fulfilled.rs:43:9 - | -LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation` - warning: variable does not need to be mutable --> $DIR/force_warn_expected_lints_fulfilled.rs:32:9 | @@ -28,6 +22,12 @@ LL | let mut what_does_the_fox_say = "*ding* *deng* *dung*"; | = note: requested on the command line with `--force-warn unused-mut` +warning: unused variable: `this_should_fulfill_the_expectation` + --> $DIR/force_warn_expected_lints_fulfilled.rs:43:9 + | +LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation` + warning: denote infinite loops with `loop { ... }` --> $DIR/force_warn_expected_lints_fulfilled.rs:10:5 | diff --git a/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs b/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs new file mode 100644 index 000000000..0cade7fef --- /dev/null +++ b/tests/ui/lint/rfc-2383-lint-reason/root-attribute-confusion.rs @@ -0,0 +1,7 @@ +// check-pass +// compile-flags: -Dunused_attributes + +#![deny(unused_crate_dependencies)] +#![feature(lint_reasons)] + +fn main() {} diff --git a/tests/ui/lint/suspicious-double-ref-op.rs b/tests/ui/lint/suspicious-double-ref-op.rs new file mode 100644 index 000000000..b9bcd31c2 --- /dev/null +++ b/tests/ui/lint/suspicious-double-ref-op.rs @@ -0,0 +1,30 @@ +#![feature(lazy_cell)] +#![deny(suspicious_double_ref_op, noop_method_call)] + +pub fn clone_on_double_ref() { + let x = vec![1]; + let y = &&x; + let z: &Vec<_> = y.clone(); + //~^ ERROR using `.clone()` on a double reference, which returns `&Vec<i32>` + + println!("{:p} {:p}", *y, z); +} + +use std::sync::LazyLock; + +pub static STRS: LazyLock<&str> = LazyLock::new(|| "First"); + +// https://github.com/rust-lang/rust-clippy/issues/9272 +fn rust_clippy_issue_9272() { + let str = STRS.clone(); + println!("{str}") +} + +fn check(mut encoded: &[u8]) { + let _ = &mut encoded.clone(); + //~^ ERROR call to `.clone()` on a reference in this situation does nothing + let _ = &encoded.clone(); + //~^ ERROR call to `.clone()` on a reference in this situation does nothing +} + +fn main() {} diff --git a/tests/ui/lint/suspicious-double-ref-op.stderr b/tests/ui/lint/suspicious-double-ref-op.stderr new file mode 100644 index 000000000..d15487ca2 --- /dev/null +++ b/tests/ui/lint/suspicious-double-ref-op.stderr @@ -0,0 +1,35 @@ +error: using `.clone()` on a double reference, which returns `&Vec<i32>` instead of cloning the inner type + --> $DIR/suspicious-double-ref-op.rs:7:23 + | +LL | let z: &Vec<_> = y.clone(); + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/suspicious-double-ref-op.rs:2:9 + | +LL | #![deny(suspicious_double_ref_op, noop_method_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: call to `.clone()` on a reference in this situation does nothing + --> $DIR/suspicious-double-ref-op.rs:24:25 + | +LL | let _ = &mut encoded.clone(); + | ^^^^^^^^ unnecessary method call + | + = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed +note: the lint level is defined here + --> $DIR/suspicious-double-ref-op.rs:2:35 + | +LL | #![deny(suspicious_double_ref_op, noop_method_call)] + | ^^^^^^^^^^^^^^^^ + +error: call to `.clone()` on a reference in this situation does nothing + --> $DIR/suspicious-double-ref-op.rs:26:21 + | +LL | let _ = &encoded.clone(); + | ^^^^^^^^ unnecessary method call + | + = note: the type `&[u8]` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + +error: aborting due to 3 previous errors + diff --git a/tests/ui/lint/unaligned_references.stderr b/tests/ui/lint/unaligned_references.stderr index 775dcac67..5f9cecadb 100644 --- a/tests/ui/lint/unaligned_references.stderr +++ b/tests/ui/lint/unaligned_references.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | &self.x; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.ptr; | ^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data as *const _; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -40,7 +44,8 @@ error[E0793]: reference to packed field is unaligned LL | let _: *const _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -49,7 +54,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = good.data.clone(); | ^^^^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -58,7 +64,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -67,7 +74,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &packed2.x; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -76,7 +84,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ref = &m1.1.a; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -85,7 +94,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ref = &m2.1.a; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 10 previous errors diff --git a/tests/ui/lint/unaligned_references_external_macro.stderr b/tests/ui/lint/unaligned_references_external_macro.stderr index 5b08f433e..94a95c1d8 100644 --- a/tests/ui/lint/unaligned_references_external_macro.stderr +++ b/tests/ui/lint/unaligned_references_external_macro.stderr @@ -9,7 +9,8 @@ LL | | } LL | | } | |_^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed b/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed index 71ebaea8e..9c52ca557 100644 --- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed +++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.fixed @@ -21,17 +21,32 @@ fn lint_on_top_level() { let _ = |a: u8| 0; //~ ERROR unnecessary parentheses around pattern } -fn _no_lint_attr() { +fn no_lint_attr() { let _x = #[allow(dead_code)] (1 + 2); } -fn _no_lint_yeet() -> Result<(), ()> { +fn no_lint_yeet() -> Result<(), ()> { #[allow(unreachable_code)] if (do yeet) {} Ok(()) } +fn no_lint_ops() { + #![allow(unreachable_code, irrefutable_let_patterns)] + if ((..{}) == ..{}) {} + if (!return) {} + loop { match (() = () = () = break {}) {} } + while let () = (*&mut false |= true && return) {} +} + +fn lint_break_if_not_followed_by_block() { + #![allow(unreachable_code)] + loop { if break {} } //~ ERROR unnecessary parentheses + loop { if break ({ println!("hello") }) {} } //~ ERROR unnecessary parentheses + loop { if (break { println!("hello") }) {} } +} + // Don't lint in these cases (#64106). fn or_patterns_no_lint() { match Box::new(0) { diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs b/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs index 28b662dd0..196ecf0c1 100644 --- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs +++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.rs @@ -21,17 +21,32 @@ fn lint_on_top_level() { let _ = |(a): u8| 0; //~ ERROR unnecessary parentheses around pattern } -fn _no_lint_attr() { +fn no_lint_attr() { let _x = #[allow(dead_code)] (1 + 2); } -fn _no_lint_yeet() -> Result<(), ()> { +fn no_lint_yeet() -> Result<(), ()> { #[allow(unreachable_code)] if (do yeet) {} Ok(()) } +fn no_lint_ops() { + #![allow(unreachable_code, irrefutable_let_patterns)] + if ((..{}) == ..{}) {} + if (!return) {} + loop { match (() = () = () = break {}) {} } + while let () = (*&mut false |= true && return) {} +} + +fn lint_break_if_not_followed_by_block() { + #![allow(unreachable_code)] + loop { if (break) {} } //~ ERROR unnecessary parentheses + loop { if (break ({ println!("hello") })) {} } //~ ERROR unnecessary parentheses + loop { if (break { println!("hello") }) {} } +} + // Don't lint in these cases (#64106). fn or_patterns_no_lint() { match Box::new(0) { diff --git a/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr b/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr index a5e69e6d9..f916bba81 100644 --- a/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr +++ b/tests/ui/lint/unused/issue-54538-unused-parens-lint.stderr @@ -75,8 +75,32 @@ LL - let _ = |(a): u8| 0; LL + let _ = |a: u8| 0; | +error: unnecessary parentheses around `if` condition + --> $DIR/issue-54538-unused-parens-lint.rs:45:15 + | +LL | loop { if (break) {} } + | ^ ^ + | +help: remove these parentheses + | +LL - loop { if (break) {} } +LL + loop { if break {} } + | + +error: unnecessary parentheses around `if` condition + --> $DIR/issue-54538-unused-parens-lint.rs:46:15 + | +LL | loop { if (break ({ println!("hello") })) {} } + | ^ ^ + | +help: remove these parentheses + | +LL - loop { if (break ({ println!("hello") })) {} } +LL + loop { if break ({ println!("hello") }) {} } + | + error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:56:12 + --> $DIR/issue-54538-unused-parens-lint.rs:71:12 | LL | if let (0 | 1) = 0 {} | ^ ^ @@ -88,7 +112,7 @@ LL + if let 0 | 1 = 0 {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:57:13 + --> $DIR/issue-54538-unused-parens-lint.rs:72:13 | LL | if let ((0 | 1),) = (0,) {} | ^ ^ @@ -100,7 +124,7 @@ LL + if let (0 | 1,) = (0,) {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:58:13 + --> $DIR/issue-54538-unused-parens-lint.rs:73:13 | LL | if let [(0 | 1)] = [0] {} | ^ ^ @@ -112,7 +136,7 @@ LL + if let [0 | 1] = [0] {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:59:16 + --> $DIR/issue-54538-unused-parens-lint.rs:74:16 | LL | if let 0 | (1 | 2) = 0 {} | ^ ^ @@ -124,7 +148,7 @@ LL + if let 0 | 1 | 2 = 0 {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:61:15 + --> $DIR/issue-54538-unused-parens-lint.rs:76:15 | LL | if let TS((0 | 1)) = TS(0) {} | ^ ^ @@ -136,7 +160,7 @@ LL + if let TS(0 | 1) = TS(0) {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:63:20 + --> $DIR/issue-54538-unused-parens-lint.rs:78:20 | LL | if let NS { f: (0 | 1) } = (NS { f: 0 }) {} | ^ ^ @@ -148,7 +172,7 @@ LL + if let NS { f: 0 | 1 } = (NS { f: 0 }) {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:73:9 + --> $DIR/issue-54538-unused-parens-lint.rs:88:9 | LL | (_) => {} | ^ ^ @@ -160,7 +184,7 @@ LL + _ => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:74:9 + --> $DIR/issue-54538-unused-parens-lint.rs:89:9 | LL | (y) => {} | ^ ^ @@ -172,7 +196,7 @@ LL + y => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:75:9 + --> $DIR/issue-54538-unused-parens-lint.rs:90:9 | LL | (ref r) => {} | ^ ^ @@ -184,7 +208,7 @@ LL + ref r => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:76:9 + --> $DIR/issue-54538-unused-parens-lint.rs:91:9 | LL | (e @ 1...2) => {} | ^ ^ @@ -196,7 +220,7 @@ LL + e @ 1...2 => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:82:9 + --> $DIR/issue-54538-unused-parens-lint.rs:97:9 | LL | (e @ &(1...2)) => {} | ^ ^ @@ -208,7 +232,7 @@ LL + e @ &(1...2) => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:83:10 + --> $DIR/issue-54538-unused-parens-lint.rs:98:10 | LL | &(_) => {} | ^ ^ @@ -220,7 +244,7 @@ LL + &_ => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:94:9 + --> $DIR/issue-54538-unused-parens-lint.rs:109:9 | LL | (_) => {} | ^ ^ @@ -232,7 +256,7 @@ LL + _ => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:95:9 + --> $DIR/issue-54538-unused-parens-lint.rs:110:9 | LL | (y) => {} | ^ ^ @@ -244,7 +268,7 @@ LL + y => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:96:9 + --> $DIR/issue-54538-unused-parens-lint.rs:111:9 | LL | (ref r) => {} | ^ ^ @@ -256,7 +280,7 @@ LL + ref r => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:97:9 + --> $DIR/issue-54538-unused-parens-lint.rs:112:9 | LL | (e @ 1..=2) => {} | ^ ^ @@ -268,7 +292,7 @@ LL + e @ 1..=2 => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:103:9 + --> $DIR/issue-54538-unused-parens-lint.rs:118:9 | LL | (e @ &(1..=2)) => {} | ^ ^ @@ -280,7 +304,7 @@ LL + e @ &(1..=2) => {} | error: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:104:10 + --> $DIR/issue-54538-unused-parens-lint.rs:119:10 | LL | &(_) => {} | ^ ^ @@ -291,5 +315,5 @@ LL - &(_) => {} LL + &_ => {} | -error: aborting due to 24 previous errors +error: aborting due to 26 previous errors diff --git a/tests/ui/lint/unused/lint-unused-mut-variables.rs b/tests/ui/lint/unused/lint-unused-mut-variables.rs index 67ec7facf..5334ab582 100644 --- a/tests/ui/lint/unused/lint-unused-mut-variables.rs +++ b/tests/ui/lint/unused/lint-unused-mut-variables.rs @@ -205,3 +205,11 @@ fn bar() { let mut b = vec![2]; //~ ERROR: variable does not need to be mutable } + +struct Arg(i32); + +// Regression test for https://github.com/rust-lang/rust/issues/110849 +fn write_through_reference(mut arg: &mut Arg) { + //~^ WARN: variable does not need to be mutable + arg.0 = 1 +} diff --git a/tests/ui/lint/unused/lint-unused-mut-variables.stderr b/tests/ui/lint/unused/lint-unused-mut-variables.stderr index 805ed2b40..5f66c0315 100644 --- a/tests/ui/lint/unused/lint-unused-mut-variables.stderr +++ b/tests/ui/lint/unused/lint-unused-mut-variables.stderr @@ -218,5 +218,13 @@ note: the lint level is defined here LL | #[deny(unused_mut)] | ^^^^^^^^^^ -error: aborting due to previous error; 25 warnings emitted +warning: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:212:28 + | +LL | fn write_through_reference(mut arg: &mut Arg) { + | ----^^^ + | | + | help: remove this `mut` + +error: aborting due to previous error; 26 warnings emitted diff --git a/tests/ui/lint/unused/lint-unused-variables.stderr b/tests/ui/lint/unused/lint-unused-variables.stderr index fd9a5bcbf..09729eeba 100644 --- a/tests/ui/lint/unused/lint-unused-variables.stderr +++ b/tests/ui/lint/unused/lint-unused-variables.stderr @@ -10,12 +10,6 @@ note: the lint level is defined here LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ -error: unused variable: `b` - --> $DIR/lint-unused-variables.rs:14:5 - | -LL | b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - error: unused variable: `a` --> $DIR/lint-unused-variables.rs:22:9 | @@ -23,6 +17,12 @@ LL | a: i32, | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` + --> $DIR/lint-unused-variables.rs:14:5 + | +LL | b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `b` --> $DIR/lint-unused-variables.rs:29:9 | LL | b: i32, diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs index 293fdca1c..c9b16e439 100644 --- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs +++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs @@ -5,7 +5,6 @@ fn test() { drop(b); b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable - //~| NOTE in this expansion of desugaring of drop and replace drop(b); } diff --git a/tests/ui/liveness/liveness-consts.stderr b/tests/ui/liveness/liveness-consts.stderr index 6199ea96c..016debdd3 100644 --- a/tests/ui/liveness/liveness-consts.stderr +++ b/tests/ui/liveness/liveness-consts.stderr @@ -1,10 +1,9 @@ -warning: variable `a` is assigned to, but never used - --> $DIR/liveness-consts.rs:7:13 +warning: unused variable: `e` + --> $DIR/liveness-consts.rs:24:13 | -LL | let mut a = 0; - | ^ +LL | let e = 1; + | ^ help: if this is intentional, prefix it with an underscore: `_e` | - = note: consider using `_a` instead note: the lint level is defined here --> $DIR/liveness-consts.rs:2:9 | @@ -12,21 +11,6 @@ LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` -warning: value assigned to `b` is never read - --> $DIR/liveness-consts.rs:17:5 - | -LL | b += 1; - | ^ - | - = help: maybe it is overwritten before being read? - = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` - -warning: unused variable: `e` - --> $DIR/liveness-consts.rs:24:13 - | -LL | let e = 1; - | ^ help: if this is intentional, prefix it with an underscore: `_e` - warning: unused variable: `s` --> $DIR/liveness-consts.rs:33:24 | @@ -39,6 +23,29 @@ warning: unused variable: `z` LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { | ^ help: if this is intentional, prefix it with an underscore: `_z` +warning: unused variable: `z` + --> $DIR/liveness-consts.rs:60:13 + | +LL | let z = 42; + | ^ help: if this is intentional, prefix it with an underscore: `_z` + +warning: variable `a` is assigned to, but never used + --> $DIR/liveness-consts.rs:7:13 + | +LL | let mut a = 0; + | ^ + | + = note: consider using `_a` instead + +warning: value assigned to `b` is never read + --> $DIR/liveness-consts.rs:17:5 + | +LL | b += 1; + | ^ + | + = help: maybe it is overwritten before being read? + = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` + warning: value assigned to `t` is never read --> $DIR/liveness-consts.rs:42:9 | @@ -53,11 +60,5 @@ warning: unused variable: `w` LL | let w = 10; | ^ help: if this is intentional, prefix it with an underscore: `_w` -warning: unused variable: `z` - --> $DIR/liveness-consts.rs:60:13 - | -LL | let z = 42; - | ^ help: if this is intentional, prefix it with an underscore: `_z` - warning: 8 warnings emitted diff --git a/tests/ui/liveness/liveness-unused.rs b/tests/ui/liveness/liveness-unused.rs index 9c7be15fc..ba635e663 100644 --- a/tests/ui/liveness/liveness-unused.rs +++ b/tests/ui/liveness/liveness-unused.rs @@ -1,7 +1,7 @@ #![warn(unused)] #![deny(unused_variables)] #![deny(unused_assignments)] -#![allow(dead_code, non_camel_case_types, trivial_numeric_casts)] +#![allow(dead_code, non_camel_case_types, trivial_numeric_casts, dropping_copy_types)] use std::ops::AddAssign; diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 56af618d4..8cd9a63b8 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -4,18 +4,21 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env` LL | env::current_dir; | ^^^ use of undeclared crate or module `env` +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/builtin-prelude-no-accidents.rs:7:14 + | +LL | type B = vec::Vec<u8>; + | ^^^ + | | + | use of undeclared crate or module `vec` + | help: a struct with a similar name exists (notice the capitalization): `Vec` + error[E0433]: failed to resolve: use of undeclared crate or module `panic` --> $DIR/builtin-prelude-no-accidents.rs:6:14 | LL | type A = panic::PanicInfo; | ^^^^^ use of undeclared crate or module `panic` -error[E0433]: failed to resolve: use of undeclared crate or module `vec` - --> $DIR/builtin-prelude-no-accidents.rs:7:14 - | -LL | type B = vec::Vec<u8>; - | ^^^ use of undeclared crate or module `vec` - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/macros/issue-111749.rs b/tests/ui/macros/issue-111749.rs new file mode 100644 index 000000000..6c45e4e8c --- /dev/null +++ b/tests/ui/macros/issue-111749.rs @@ -0,0 +1,12 @@ +macro_rules! cbor_map { + ($key:expr) => { + $key.signum(); + }; +} + +fn main() { + cbor_map! { #[test(test)] 4}; + //~^ ERROR removing an expression is not supported in this position + //~| ERROR attribute must be of the form `#[test]` + //~| WARNING this was previously accepted by the compiler but is being phased out +} diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr new file mode 100644 index 000000000..7db2b8e6a --- /dev/null +++ b/tests/ui/macros/issue-111749.stderr @@ -0,0 +1,18 @@ +error: removing an expression is not supported in this position + --> $DIR/issue-111749.rs:8:17 + | +LL | cbor_map! { #[test(test)] 4}; + | ^^^^^^^^^^^^^ + +error: attribute must be of the form `#[test]` + --> $DIR/issue-111749.rs:8:17 + | +LL | cbor_map! { #[test(test)] 4}; + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +error: aborting due to 2 previous errors + diff --git a/tests/ui/issues/issue-26094.rs b/tests/ui/macros/issue-26094.rs index 2742529ed..2742529ed 100644 --- a/tests/ui/issues/issue-26094.rs +++ b/tests/ui/macros/issue-26094.rs diff --git a/tests/ui/issues/issue-26094.stderr b/tests/ui/macros/issue-26094.stderr index ecdf48470..ecdf48470 100644 --- a/tests/ui/issues/issue-26094.stderr +++ b/tests/ui/macros/issue-26094.stderr diff --git a/tests/ui/issues/issue-2804-2.rs b/tests/ui/macros/issue-2804-2.rs index d02725505..d02725505 100644 --- a/tests/ui/issues/issue-2804-2.rs +++ b/tests/ui/macros/issue-2804-2.rs diff --git a/tests/ui/issues/issue-69396-const-no-type-in-macro.rs b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs index 45a308574..45a308574 100644 --- a/tests/ui/issues/issue-69396-const-no-type-in-macro.rs +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs diff --git a/tests/ui/issues/issue-69396-const-no-type-in-macro.stderr b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr index 89aeafeba..89aeafeba 100644 --- a/tests/ui/issues/issue-69396-const-no-type-in-macro.stderr +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr diff --git a/tests/ui/macros/macro-expanded-include/foo/mod.rs b/tests/ui/macros/macro-expanded-include/foo/mod.rs index cff110470..2e4c4c7f8 100644 --- a/tests/ui/macros/macro-expanded-include/foo/mod.rs +++ b/tests/ui/macros/macro-expanded-include/foo/mod.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) macro_rules! m { () => { include!("file.txt"); } diff --git a/tests/ui/macros/macro-local-data-key-priv.stderr b/tests/ui/macros/macro-local-data-key-priv.stderr index fb8cab279..0f412bc86 100644 --- a/tests/ui/macros/macro-local-data-key-priv.stderr +++ b/tests/ui/macros/macro-local-data-key-priv.stderr @@ -9,7 +9,7 @@ note: the constant `baz` is defined here | LL | thread_local!(static baz: f64 = 0.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::__thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/macros/missing-bang-in-decl.stderr b/tests/ui/macros/missing-bang-in-decl.stderr index dfabafb0a..aa78c9a69 100644 --- a/tests/ui/macros/missing-bang-in-decl.stderr +++ b/tests/ui/macros/missing-bang-in-decl.stderr @@ -2,13 +2,23 @@ error: expected `!` after `macro_rules` --> $DIR/missing-bang-in-decl.rs:5:1 | LL | macro_rules foo { - | ^^^^^^^^^^^ help: add a `!`: `macro_rules!` + | ^^^^^^^^^^^ + | +help: add a `!` + | +LL | macro_rules! foo { + | + error: expected `!` after `macro_rules` --> $DIR/missing-bang-in-decl.rs:10:1 | LL | macro_rules bar! { - | ^^^^^^^^^^^ help: add a `!`: `macro_rules!` + | ^^^^^^^^^^^ + | +help: add a `!` + | +LL | macro_rules! bar! { + | + error: macro names aren't followed by a `!` --> $DIR/missing-bang-in-decl.rs:10:16 diff --git a/tests/ui/macros/panic-temporaries-2018.rs b/tests/ui/macros/panic-temporaries-2018.rs new file mode 100644 index 000000000..d914df380 --- /dev/null +++ b/tests/ui/macros/panic-temporaries-2018.rs @@ -0,0 +1,55 @@ +// check-pass +// edition:2018 + +#![allow(non_fmt_panics, unreachable_code)] + +use std::fmt::{self, Display}; +use std::marker::PhantomData; + +struct NotSend { + marker: PhantomData<*const u8>, +} + +const NOT_SEND: NotSend = NotSend { marker: PhantomData }; + +impl Display for NotSend { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("this value does not implement Send") + } +} + +async fn f(_: u8) {} + +// Exercises this matcher in panic_2015: +// ($fmt:expr, $($arg:tt)+) => $crate::panicking::panic_fmt(...) +async fn panic_fmt() { + // Panic returns `!`, so the await is never reached, and in particular the + // temporaries inside the formatting machinery are not still alive at the + // await point. + let todo = "..."; + f(panic!("not yet implemented: {}", todo)).await; +} + +// Exercises ("{}", $arg:expr) => $crate::panicking::panic_display(&$arg) +async fn panic_display() { + f(panic!("{}", NOT_SEND)).await; +} + +// Exercises ($msg:expr) => $crate::panicking::panic_str($msg) +async fn panic_str() { + f(panic!((NOT_SEND, "...").1)).await; +} + +// Exercises ($msg:expr) => $crate::panicking::unreachable_display(&$msg) +async fn unreachable_display() { + f(unreachable!(NOT_SEND)).await; +} + +fn require_send(_: impl Send) {} + +fn main() { + require_send(panic_fmt()); + require_send(panic_display()); + require_send(panic_str()); + require_send(unreachable_display()); +} diff --git a/tests/ui/macros/panic-temporaries.rs b/tests/ui/macros/panic-temporaries.rs new file mode 100644 index 000000000..db65601fb --- /dev/null +++ b/tests/ui/macros/panic-temporaries.rs @@ -0,0 +1,43 @@ +// check-pass +// edition:2021 + +#![allow(unreachable_code)] + +use std::fmt::{self, Display}; +use std::marker::PhantomData; + +struct NotSend { + marker: PhantomData<*const u8>, +} + +const NOT_SEND: NotSend = NotSend { marker: PhantomData }; + +impl Display for NotSend { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("this value does not implement Send") + } +} + +async fn f(_: u8) {} + +// Exercises this matcher in panic_2021: +// ($($t:tt)+) => $crate::panicking::panic_fmt(...) +async fn panic_fmt() { + // Panic returns `!`, so the await is never reached, and in particular the + // temporaries inside the formatting machinery are not still alive at the + // await point. + let todo = "..."; + f(panic!("not yet implemented: {}", todo)).await; +} + +// Exercises ("{}", $arg:expr) => $crate::panicking::panic_display(&$arg) +async fn panic_display() { + f(panic!("{}", NOT_SEND)).await; +} + +fn require_send(_: impl Send) {} + +fn main() { + require_send(panic_fmt()); + require_send(panic_display()); +} diff --git a/tests/ui/macros/parse-complex-macro-invoc-op.rs b/tests/ui/macros/parse-complex-macro-invoc-op.rs index 8fef9b0ed..10810388d 100644 --- a/tests/ui/macros/parse-complex-macro-invoc-op.rs +++ b/tests/ui/macros/parse-complex-macro-invoc-op.rs @@ -4,6 +4,7 @@ #![allow(unused_assignments)] #![allow(unused_variables)] #![allow(stable_features)] +#![allow(dropping_copy_types)] // Test parsing binary operators after macro invocations. diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs index e88e24482..b1db05afd 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs @@ -5,7 +5,7 @@ // needs-unwind Asserting on contents of error message #![allow(path_statements, unused_allocation)] -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] macro_rules! test { ( @@ -51,6 +51,7 @@ macro_rules! tests { const FOO: Foo = Foo { bar: 1 }; + #[derive(Clone, Copy, Debug, PartialEq)] struct Foo { bar: i32 @@ -83,9 +84,18 @@ fn main() { // cast [ elem as i32 == 3 ] => "Assertion failed: elem as i32 == 3\nWith captures:\n elem = 1\n" + // if + [ if elem == 3 { true } else { false } ] => "Assertion failed: if elem == 3 { true } else { false }\nWith captures:\n elem = 1\n" + // index [ [1i32, 1][elem as usize] == 3 ] => "Assertion failed: [1i32, 1][elem as usize] == 3\nWith captures:\n elem = 1\n" + // let + [ if let 3 = elem { true } else { false } ] => "Assertion failed: if let 3 = elem { true } else { false }\nWith captures:\n elem = 1\n" + + // match + [ match elem { 3 => true, _ => false, } ] => "Assertion failed: match elem { 3 => true, _ => false, }\nWith captures:\n elem = 1\n" + // method call [ FOO.add(elem, elem) == 3 ] => "Assertion failed: FOO.add(elem, elem) == 3\nWith captures:\n elem = 1\n" @@ -107,77 +117,4 @@ fn main() { // unary [ -elem == -3 ] => "Assertion failed: -elem == -3\nWith captures:\n elem = 1\n" ); - - // ***** Disallowed ***** - - tests!( - let mut elem = 1i32; - - // assign - [ { let local = elem; local } == 3 ] => "Assertion failed: { let local = elem; local } == 3" - - // assign op - [ { elem += 1; elem } == 3 ] => "Assertion failed: { elem += 1; elem } == 3" - - // async - [ { let _ = async { elem }; elem } == 3 ] => "Assertion failed: { let _ = async { elem }; elem } == 3" - - // await - - // block - [ { elem } == 3 ] => "Assertion failed: { elem } == 3" - - // break - [ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3" - - // closure - [(|| elem)() == 3 ] => "Assertion failed: (|| elem)() == 3" - - // const block - - // continue - - // err - - // field - [ FOO.bar == 3 ] => "Assertion failed: FOO.bar == 3" - - // for loop - [ { for _ in 0..elem { elem; } elem } == 3 ] => "Assertion failed: { for _ in 0..elem { elem; } elem } == 3" - - // if - [ if true { elem } else { elem } == 3 ] => "Assertion failed: if true { elem } else { elem } == 3" - - // inline asm - - // let - [ if let true = true { elem } else { elem } == 3 ] => "Assertion failed: if let true = true { elem } else { elem } == 3" - - // lit - - // loop - [ loop { elem; break elem; } == 3 ] => "Assertion failed: loop { elem; break elem; } == 3" - - // mac call - - // match - [ match elem { _ => elem } == 3 ] => "Assertion failed: (match elem { _ => elem, }) == 3" - - // ret - [ (|| { return elem; })() == 3 ] => "Assertion failed: (|| { return elem; })() == 3" - - // try - [ (|| { Some(Some(elem)?) })() == Some(3) ] => "Assertion failed: (|| { Some(Some(elem)?) })() == Some(3)" - - // try block - - // underscore - - // while - [ { while false { elem; break; } elem } == 3 ] => "Assertion failed: { while false { elem; break; } elem } == 3" - - // yeet - - // yield - ); } diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs index d46f396ee..fcf4f367d 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs @@ -4,7 +4,7 @@ // run-pass // needs-unwind Asserting on contents of error message -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] extern crate common; diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs index 6a1435f79..c8408d16f 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs @@ -1,7 +1,7 @@ // compile-flags: --test // run-pass -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] #[should_panic(expected = "Custom user message")] #[test] diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs index 1f5a29ab5..0e3c14a57 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs @@ -3,7 +3,7 @@ // run-pass // needs-unwind Asserting on contents of error message -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] extern crate common; diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs index 01860adaa..0d2518dc2 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs @@ -2,7 +2,7 @@ // ignore-tidy-linelength // run-pass -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] use std::fmt::{Debug, Formatter}; diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs index 5ec84b08f..57b79a56b 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags: -Z unpretty=expanded -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] fn arbitrary_consuming_method_for_demonstration_purposes() { let elem = 1i32; diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout index ad97f7a4a..66321bc35 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout @@ -3,7 +3,7 @@ // check-pass // compile-flags: -Z unpretty=expanded -#![feature(core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] @@ -26,7 +26,7 @@ fn arbitrary_consuming_method_for_demonstration_purposes() { { ::std::rt::panic_fmt(format_args!("Assertion failed: elem as usize\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -42,7 +42,7 @@ fn addr_of() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: &elem\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -58,7 +58,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem == 1\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -71,7 +71,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem >= 1\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -84,7 +84,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem > 0\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -97,7 +97,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem < 3\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -110,7 +110,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem <= 3\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -123,7 +123,7 @@ fn binary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: elem != 3\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; @@ -139,7 +139,7 @@ fn unary() { (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); { ::std::rt::panic_fmt(format_args!("Assertion failed: *elem\nWith captures:\n elem = {0:?}\n", - __capture0)) + __capture0)); } } }; diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 79d8cd757..816f99baa 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -134,8 +134,7 @@ fn test_expr() { assert_eq!(stringify_expr!(expr as T<u8>), "expr as T<u8>"); // ExprKind::Type - assert_eq!(stringify_expr!(expr: T), "expr: T"); - assert_eq!(stringify_expr!(expr: T<u8>), "expr: T<u8>"); + // There is no syntax for type ascription. // ExprKind::If assert_eq!(stringify_expr!(if true {}), "if true {}"); diff --git a/tests/ui/user-defined-macro-rules.rs b/tests/ui/macros/user-defined-macro-rules.rs index 09e071ec4..09e071ec4 100644 --- a/tests/ui/user-defined-macro-rules.rs +++ b/tests/ui/macros/user-defined-macro-rules.rs diff --git a/tests/ui/match/issue-26996.rs b/tests/ui/match/issue-26996.rs index 84037b72a..9ea454526 100644 --- a/tests/ui/match/issue-26996.rs +++ b/tests/ui/match/issue-26996.rs @@ -4,7 +4,7 @@ // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // -// ignore-test +// ignore-test (#54987) // This test is checking that the write to `c.0` (which has been moved out of) // won't overwrite the state in `c2`. diff --git a/tests/ui/match/issue-27021.rs b/tests/ui/match/issue-27021.rs index ef3b114a5..9630e9a03 100644 --- a/tests/ui/match/issue-27021.rs +++ b/tests/ui/match/issue-27021.rs @@ -4,7 +4,7 @@ // where #54986 is implemented and #54987 is *not* implemented. For // now: just ignore it // -// ignore-test +// ignore-test (#54987) // These are variants of issue-26996.rs. In all cases we are writing // into a record field that has been moved out of, and ensuring that diff --git a/tests/ui/meta/no_std-extern-libc.rs b/tests/ui/meta/no_std-extern-libc.rs new file mode 100644 index 000000000..763ea740a --- /dev/null +++ b/tests/ui/meta/no_std-extern-libc.rs @@ -0,0 +1,7 @@ +// Test that `download-rustc` doesn't put duplicate copies of libc in the sysroot. +// check-pass +#![crate_type = "lib"] +#![no_std] +#![feature(rustc_private)] + +extern crate libc; diff --git a/tests/ui/methods/call_method_unknown_pointee.rs b/tests/ui/methods/call_method_unknown_pointee.rs new file mode 100644 index 000000000..fe4275f53 --- /dev/null +++ b/tests/ui/methods/call_method_unknown_pointee.rs @@ -0,0 +1,28 @@ +// edition: 2018 + +// tests that the pointee type of a raw pointer must be known to call methods on it +// see also: `tests/ui/editions/edition-raw-pointer-method-2018.rs` + +fn main() { + let val = 1_u32; + let ptr = &val as *const u32; + unsafe { + let _a: i32 = (ptr as *const _).read(); + //~^ ERROR cannot call a method on a raw pointer with an unknown pointee type [E0699] + let b = ptr as *const _; + let _b: u8 = b.read(); + //~^ ERROR cannot call a method on a raw pointer with an unknown pointee type [E0699] + let _c = (ptr as *const u8).read(); // we know the type here + } + + let mut val = 2_u32; + let ptr = &mut val as *mut u32; + unsafe { + let _a: i32 = (ptr as *mut _).read(); + //~^ ERROR cannot call a method on a raw pointer with an unknown pointee type [E0699] + let b = ptr as *mut _; + b.write(10); + //~^ ERROR cannot call a method on a raw pointer with an unknown pointee type [E0699] + (ptr as *mut i32).write(1000); // we know the type here + } +} diff --git a/tests/ui/methods/call_method_unknown_pointee.stderr b/tests/ui/methods/call_method_unknown_pointee.stderr new file mode 100644 index 000000000..84ecf046e --- /dev/null +++ b/tests/ui/methods/call_method_unknown_pointee.stderr @@ -0,0 +1,27 @@ +error[E0699]: cannot call a method on a raw pointer with an unknown pointee type + --> $DIR/call_method_unknown_pointee.rs:10:41 + | +LL | let _a: i32 = (ptr as *const _).read(); + | ^^^^ + +error[E0699]: cannot call a method on a raw pointer with an unknown pointee type + --> $DIR/call_method_unknown_pointee.rs:13:24 + | +LL | let _b: u8 = b.read(); + | ^^^^ + +error[E0699]: cannot call a method on a raw pointer with an unknown pointee type + --> $DIR/call_method_unknown_pointee.rs:21:39 + | +LL | let _a: i32 = (ptr as *mut _).read(); + | ^^^^ + +error[E0699]: cannot call a method on a raw pointer with an unknown pointee type + --> $DIR/call_method_unknown_pointee.rs:24:11 + | +LL | b.write(10); + | ^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0699`. diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.rs b/tests/ui/methods/method-not-found-generic-arg-elision.rs index 799ced5e9..538eeadae 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.rs +++ b/tests/ui/methods/method-not-found-generic-arg-elision.rs @@ -83,8 +83,8 @@ fn main() { //~^ ERROR no method named `distance` found for struct `Point<i32> let d = point_i32.other(); //~^ ERROR no method named `other` found for struct `Point - let v = vec![1_i32, 2, 3]; - v.iter().map(|x| x * x).extend(std::iter::once(100)); + let v = vec![1, 2, 3]; + v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100)); //~^ ERROR no method named `extend` found for struct `Map let wrapper = Wrapper(true); wrapper.method(); diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index f3db56d1d..b97688d38 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -20,10 +20,10 @@ LL | let d = point_i32.other(); | ^^^^^ method not found in `Point<i32>` error[E0599]: no method named `extend` found for struct `Map` in the current scope - --> $DIR/method-not-found-generic-arg-elision.rs:87:29 + --> $DIR/method-not-found-generic-arg-elision.rs:87:67 | -LL | v.iter().map(|x| x * x).extend(std::iter::once(100)); - | ^^^^^^ method not found in `Map<Iter<'_, i32>, [closure@method-not-found-generic-arg-elision.rs:87:18]>` +LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100)); + | ^^^^^^ method not found in `Map<Iter<'_, i32>, Box<dyn Fn(&i32) -> i32>>` error[E0599]: no method named `method` found for struct `Wrapper<bool>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:90:13 diff --git a/tests/ui/methods/method-self-arg-1.stderr b/tests/ui/methods/method-self-arg-1.stderr index 9241a8be5..dcc21acc5 100644 --- a/tests/ui/methods/method-self-arg-1.stderr +++ b/tests/ui/methods/method-self-arg-1.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/method-self-arg-1.rs:11:14 | LL | Foo::bar(x); - | -------- ^ - | | | - | | expected `&Foo`, found `Foo` - | | help: consider borrowing here: `&x` + | -------- ^ expected `&Foo`, found `Foo` + | | | arguments to this function are incorrect | note: method defined here @@ -13,6 +11,10 @@ note: method defined here | LL | fn bar(&self) {} | ^^^ ----- +help: consider borrowing here + | +LL | Foo::bar(&x); + | + error[E0308]: mismatched types --> $DIR/method-self-arg-1.rs:13:14 diff --git a/tests/ui/mir/mir_alignment_check.rs b/tests/ui/mir/mir_alignment_check.rs index 68a5384b3..d1bf3d46a 100644 --- a/tests/ui/mir/mir_alignment_check.rs +++ b/tests/ui/mir/mir_alignment_check.rs @@ -1,5 +1,6 @@ // run-fail // ignore-wasm32-bare: No panic messages +// ignore-i686-pc-windows-msvc: #112480 // compile-flags: -C debug-assertions // error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is diff --git a/tests/ui/mir/mir_alignment_check_i686-pc-windows-msvc.rs b/tests/ui/mir/mir_alignment_check_i686-pc-windows-msvc.rs new file mode 100644 index 000000000..56388c104 --- /dev/null +++ b/tests/ui/mir/mir_alignment_check_i686-pc-windows-msvc.rs @@ -0,0 +1,21 @@ +// run-pass +// only-i686-pc-windows-msvc +// compile-flags: -Copt-level=0 -Cdebug-assertions=yes + +// MSVC isn't sure if on 32-bit Windows its u64 type is 8-byte-aligned or 4-byte-aligned. +// So this test ensures that on i686-pc-windows-msvc, we do not insert a runtime check +// that will fail on dereferencing of a pointer to u64 which is not 8-byte-aligned but is +// 4-byte-aligned. + +#![feature(strict_provenance)] + +fn main() { + let mut x = [0u64; 2]; + let ptr: *mut u8 = x.as_mut_ptr().cast::<u8>(); + unsafe { + let misaligned = ptr.add(4).cast::<u64>(); + assert!(misaligned.addr() % 8 != 0); + assert!(misaligned.addr() % 4 == 0); + *misaligned = 42; + } +} diff --git a/tests/ui/mir/validate/storage-live.stderr b/tests/ui/mir/validate/storage-live.stderr index b586a8658..720fb0a90 100644 --- a/tests/ui/mir/validate/storage-live.stderr +++ b/tests/ui/mir/validate/storage-live.stderr @@ -1,4 +1,4 @@ -error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:8 ~ storage_live[HASH]::multiple_storage), const_param_did: None }) (before pass CheckPackedRef) at bb0[1]: +error: internal compiler error: broken MIR in Item(DefId(0:8 ~ storage_live[HASH]::multiple_storage)) (before pass CheckPackedRef) at bb0[1]: StorageLive(_1) which already has storage here --> $DIR/storage-live.rs:22:13 | @@ -9,5 +9,5 @@ error: the compiler unexpectedly panicked. this is a bug. query stack during panic: #0 [mir_const] preparing `multiple_storage` for borrow checking -#1 [mir_promoted] processing MIR for `multiple_storage` +#1 [mir_promoted] promoting constants in MIR for `multiple_storage` end of query stack diff --git a/tests/ui/mismatched_types/assignment-operator-unimplemented.stderr b/tests/ui/mismatched_types/assignment-operator-unimplemented.stderr index 2393791a9..66a85c465 100644 --- a/tests/ui/mismatched_types/assignment-operator-unimplemented.stderr +++ b/tests/ui/mismatched_types/assignment-operator-unimplemented.stderr @@ -6,11 +6,11 @@ LL | a += *b; | | | cannot use `+=` on type `Foo` | -note: an implementation of `AddAssign<_>` might be missing for `Foo` +note: an implementation of `AddAssign` might be missing for `Foo` --> $DIR/assignment-operator-unimplemented.rs:1:1 | LL | struct Foo; - | ^^^^^^^^^^ must implement `AddAssign<_>` + | ^^^^^^^^^^ must implement `AddAssign` note: the trait `AddAssign` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/mismatched_types/cast-rfc0401.stderr index 2a36a352c..6b9ac3c58 100644 --- a/tests/ui/mismatched_types/cast-rfc0401.stderr +++ b/tests/ui/mismatched_types/cast-rfc0401.stderr @@ -220,11 +220,7 @@ LL | let _ = fat_v as *const dyn Foo; | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: required for the cast from `[u8]` to the object type `dyn Foo` -help: consider borrowing the value, since `&[u8]` can be coerced into `dyn Foo` - | -LL | let _ = &fat_v as *const dyn Foo; - | + + = note: required for the cast from `*const [u8]` to `*const dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/cast-rfc0401.rs:62:13 @@ -233,11 +229,7 @@ LL | let _ = a as *const dyn Foo; | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn Foo` -help: consider borrowing the value, since `&str` can be coerced into `dyn Foo` - | -LL | let _ = &a as *const dyn Foo; - | + + = note: required for the cast from `*const str` to `*const dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid --> $DIR/cast-rfc0401.rs:71:30 diff --git a/tests/ui/mismatched_types/closure-mismatch.rs b/tests/ui/mismatched_types/closure-mismatch.rs index b0644e796..4eb33497c 100644 --- a/tests/ui/mismatched_types/closure-mismatch.rs +++ b/tests/ui/mismatched_types/closure-mismatch.rs @@ -8,4 +8,7 @@ fn main() { baz(|_| ()); //~^ ERROR implementation of `FnOnce` is not general enough //~| ERROR mismatched types + baz(|x| ()); + //~^ ERROR implementation of `FnOnce` is not general enough + //~| ERROR mismatched types } diff --git a/tests/ui/mismatched_types/closure-mismatch.stderr b/tests/ui/mismatched_types/closure-mismatch.stderr index a7ef8fa08..c5b8270ba 100644 --- a/tests/ui/mismatched_types/closure-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-mismatch.stderr @@ -25,7 +25,43 @@ note: the lifetime requirement is introduced here | LL | fn baz<T: Foo>(_: T) {} | ^^^ +help: consider specifying the type of the closure parameters + | +LL | baz(|_: &_| ()); + | ~~~~~~~ + +error: implementation of `FnOnce` is not general enough + --> $DIR/closure-mismatch.rs:11:5 + | +LL | baz(|x| ()); + | ^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + +error[E0308]: mismatched types + --> $DIR/closure-mismatch.rs:11:5 + | +LL | baz(|x| ()); + | ^^^^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a> Fn<(&'a (),)>` + found trait `Fn<(&(),)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/closure-mismatch.rs:11:9 + | +LL | baz(|x| ()); + | ^^^ +note: the lifetime requirement is introduced here + --> $DIR/closure-mismatch.rs:5:11 + | +LL | fn baz<T: Foo>(_: T) {} + | ^^^ +help: consider specifying the type of the closure parameters + | +LL | baz(|x: &_| ()); + | ~~~~~~~ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/mismatched_types/dont-point-return-on-E0308.stderr b/tests/ui/mismatched_types/dont-point-return-on-E0308.stderr index 13942682d..7be94ef4a 100644 --- a/tests/ui/mismatched_types/dont-point-return-on-E0308.stderr +++ b/tests/ui/mismatched_types/dont-point-return-on-E0308.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/dont-point-return-on-E0308.rs:11:11 | LL | f(()); - | - ^^ - | | | - | | expected `&()`, found `()` - | | help: consider borrowing here: `&()` + | - ^^ expected `&()`, found `()` + | | | arguments to this function are incorrect | note: function defined here @@ -13,6 +11,10 @@ note: function defined here | LL | async fn f(_: &()) {} | ^ ------ +help: consider borrowing here + | +LL | f(&()); + | + error: aborting due to previous error diff --git a/tests/ui/missing/missing-items/m2.stderr b/tests/ui/missing/missing-items/m2.stderr index d18fb443a..835c9b2aa 100644 --- a/tests/ui/missing/missing-items/m2.stderr +++ b/tests/ui/missing/missing-items/m2.stderr @@ -5,7 +5,7 @@ LL | impl m1::X for X { | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation | = help: implement the missing item: `const CONSTANT: u32 = 42;` - = help: implement the missing item: `type Type = Type;` + = help: implement the missing item: `type Type = /* Type */;` = help: implement the missing item: `fn method(&self, _: String) -> <Self as m1::X>::Type { todo!() }` = help: implement the missing item: `fn method2(self: Box<Self>, _: String) -> <Self as m1::X>::Type { todo!() }` = help: implement the missing item: `fn method3(_: &Self, _: String) -> <Self as m1::X>::Type { todo!() }` diff --git a/tests/ui/mut/mut-cross-borrowing.stderr b/tests/ui/mut/mut-cross-borrowing.stderr index 8401827e5..8a3076db9 100644 --- a/tests/ui/mut/mut-cross-borrowing.stderr +++ b/tests/ui/mut/mut-cross-borrowing.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/mut-cross-borrowing.rs:7:7 | LL | f(x) - | - ^ - | | | - | | expected `&mut isize`, found `Box<{integer}>` - | | help: consider mutably borrowing here: `&mut x` + | - ^ expected `&mut isize`, found `Box<{integer}>` + | | | arguments to this function are incorrect | = note: expected mutable reference `&mut isize` @@ -15,6 +13,10 @@ note: function defined here | LL | fn f(_: &mut isize) {} | ^ ------------- +help: consider mutably borrowing here + | +LL | f(&mut x) + | ++++ error: aborting due to previous error diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs b/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs new file mode 100644 index 000000000..19b9a1770 --- /dev/null +++ b/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs @@ -0,0 +1,5 @@ +// build-fail +// compile-flags:-C link-arg=⦺ⅈ⽯â⽽◃⡽⚞ +// only-msvc +// normalize-stderr-test "(?:.|\n)*(⦺ⅈ⽯â⽽◃⡽⚞)(?:.|\n)*" -> "$1" +pub fn main() {} diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr b/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr new file mode 100644 index 000000000..7f3ef3764 --- /dev/null +++ b/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr @@ -0,0 +1 @@ +⦺ⅈ⽯â⽽◃⡽⚞
\ No newline at end of file diff --git a/tests/ui/never_type/exhaustive_patterns.stderr b/tests/ui/never_type/exhaustive_patterns.stderr index 5fed903eb..f7bf85815 100644 --- a/tests/ui/never_type/exhaustive_patterns.stderr +++ b/tests/ui/never_type/exhaustive_patterns.stderr @@ -14,6 +14,7 @@ LL | enum Either<A, B> { LL | A(A), LL | B(inner::Wrapper<B>), | - not covered + = note: pattern `Either::B(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future = note: the matched value is of type `Either<(), !>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/tests/ui/never_type/fallback-closure-wrap.fallback.stderr b/tests/ui/never_type/fallback-closure-wrap.fallback.stderr index a0f790dba..5b6f02351 100644 --- a/tests/ui/never_type/fallback-closure-wrap.fallback.stderr +++ b/tests/ui/never_type/fallback-closure-wrap.fallback.stderr @@ -10,7 +10,7 @@ LL | | }) as Box<dyn FnMut()>); | = note: expected unit type `()` found type `!` - = note: required for the cast from `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to the object type `dyn FnMut()` + = note: required for the cast from `Box<[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]>` to `Box<dyn FnMut()>` error: aborting due to previous error diff --git a/tests/ui/never_type/issue-52443.rs b/tests/ui/never_type/issue-52443.rs index 4669d7c1a..0498a8a16 100644 --- a/tests/ui/never_type/issue-52443.rs +++ b/tests/ui/never_type/issue-52443.rs @@ -11,5 +11,4 @@ fn main() { //~| ERROR cannot convert //~| ERROR mutable references //~| ERROR cannot call - //~| ERROR the trait bound } diff --git a/tests/ui/never_type/issue-52443.stderr b/tests/ui/never_type/issue-52443.stderr index 1233bdc5d..99dfce869 100644 --- a/tests/ui/never_type/issue-52443.stderr +++ b/tests/ui/never_type/issue-52443.stderr @@ -58,19 +58,6 @@ LL | [(); { for _ in 0usize.. {}; 0}]; = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0277]: the trait bound `RangeFrom<usize>: Iterator` is not satisfied - --> $DIR/issue-52443.rs:9:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; - | ^^^^^^^^ `RangeFrom<usize>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `RangeFrom<usize>` -note: the trait `Iterator` is implemented for `RangeFrom<usize>`, but that implementation is not `const` - --> $DIR/issue-52443.rs:9:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; - | ^^^^^^^^ - error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants --> $DIR/issue-52443.rs:9:21 | @@ -80,7 +67,7 @@ LL | [(); { for _ in 0usize.. {}; 0}]; = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 7 previous errors; 1 warning emitted +error: aborting due to 6 previous errors; 1 warning emitted -Some errors have detailed explanations: E0015, E0277, E0308, E0658. +Some errors have detailed explanations: E0015, E0308, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/never_type/never-assign-dead-code.rs b/tests/ui/never_type/never-assign-dead-code.rs index 7bb7c8709..39df7de5a 100644 --- a/tests/ui/never_type/never-assign-dead-code.rs +++ b/tests/ui/never_type/never-assign-dead-code.rs @@ -3,6 +3,7 @@ // check-pass #![feature(never_type)] +#![allow(dropping_copy_types)] #![warn(unused)] fn main() { diff --git a/tests/ui/never_type/never-assign-dead-code.stderr b/tests/ui/never_type/never-assign-dead-code.stderr index 521b82023..5660bde5c 100644 --- a/tests/ui/never_type/never-assign-dead-code.stderr +++ b/tests/ui/never_type/never-assign-dead-code.stderr @@ -1,5 +1,5 @@ warning: unreachable statement - --> $DIR/never-assign-dead-code.rs:10:5 + --> $DIR/never-assign-dead-code.rs:11:5 | LL | let x: ! = panic!("aah"); | ------------- any code following this expression is unreachable @@ -7,14 +7,14 @@ LL | drop(x); | ^^^^^^^^ unreachable statement | note: the lint level is defined here - --> $DIR/never-assign-dead-code.rs:6:9 + --> $DIR/never-assign-dead-code.rs:7:9 | LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]` warning: unreachable call - --> $DIR/never-assign-dead-code.rs:10:5 + --> $DIR/never-assign-dead-code.rs:11:5 | LL | drop(x); | ^^^^ - any code following this expression is unreachable @@ -22,7 +22,7 @@ LL | drop(x); | unreachable call warning: unused variable: `x` - --> $DIR/never-assign-dead-code.rs:9:9 + --> $DIR/never-assign-dead-code.rs:10:9 | LL | let x: ! = panic!("aah"); | ^ help: if this is intentional, prefix it with an underscore: `_x` diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index c0d95ddaa..61233fd84 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -17,7 +17,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | - - ^^^^^^ assignment requires that `'1` must outlive `'2` | | | | | has type `&'1 i32` - | has type `&'_#2r mut &'2 i32` + | has type `&'?2 mut &'2 i32` note: no external requirements --> $DIR/escape-argument-callee.rs:20:1 diff --git a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr index 4fbd5eb19..c00a31ef8 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -7,10 +7,10 @@ LL | let mut closure1 = || p = &y; = note: defining type: test::{closure#0}::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'?1 mut &'?2 i32, &'?3 i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '?3: '?2 note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 @@ -21,10 +21,10 @@ LL | let mut closure = || { = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'?1 mut &'?2 i32, &'?3 i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '?3: '?2 note: no external requirements --> $DIR/escape-upvar-nested.rs:13:1 diff --git a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr index bc1ceac5b..2d67e6e7d 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/tests/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -7,10 +7,10 @@ LL | let mut closure = || p = &y; = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'?1 mut &'?2 i32, &'?3 i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '?3: '?2 note: no external requirements --> $DIR/escape-upvar-ref.rs:17:1 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 5a7b12732..ba42576d4 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -6,20 +6,20 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?3 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#4r - = note: late-bound region is '_#5r - = note: late-bound region is '_#6r + = note: late-bound region is '?4 + = note: late-bound region is '?5 + = note: late-bound region is '?6 error: lifetime may not live long enough --> $DIR/propagate-approximated-fail-no-postdom.rs:46:13 | LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ---------- ---------- has type `Cell<&'2 &'_#3r u32>` + | ---------- ---------- has type `Cell<&'2 &'?3 u32>` | | - | has type `Cell<&'_#1r &'1 u32>` + | has type `Cell<&'?1 &'1 u32>` ... LL | demand_y(x, y, p) | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr index db2ecc779..9dd6e0208 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -6,13 +6,13 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r + = note: late-bound region is '?3 + = note: late-bound region is '?4 = note: number of external vids: 5 - = note: where '_#1r: '_#2r + = note: where '?1: '?2 note: no external requirements --> $DIR/propagate-approximated-ref.rs:42:1 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 1d9dafbe5..e2f5576d3 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case1::{closure#0} with closure substs [ i32, - for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), ] @@ -36,11 +36,11 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case2::{closure#0} with closure substs [ i32, - for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), ] = note: number of external vids: 2 - = note: where '_#1r: '_#0r + = note: where '?1: '?0 note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 85f7fe35c..383fb471a 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -6,13 +6,13 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#2r - = note: late-bound region is '_#3r + = note: late-bound region is '?2 + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where '_#1r: '_#0r + = note: where '?1: '?0 note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1 @@ -40,7 +40,7 @@ LL | | }); | |______`cell_a` escapes the function body here | argument requires that `'a` must outlive `'static` | - = note: requirement occurs because of the type `Cell<&'_#9r u32>`, which makes the generic argument `&'_#9r u32` invariant + = note: requirement occurs because of the type `Cell<&'?9 u32>`, which makes the generic argument `&'?9 u32` invariant = note: the struct `Cell<T>` is invariant over the parameter `T` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 7194843e2..ac346c0b1 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -6,13 +6,13 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r + = note: late-bound region is '?3 + = note: late-bound region is '?4 = note: number of external vids: 5 - = note: where '_#1r: '_#0r + = note: where '?1: '?0 note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1 @@ -40,7 +40,7 @@ LL | | }); | |______`cell_a` escapes the function body here | argument requires that `'a` must outlive `'static` | - = note: requirement occurs because of the type `Cell<&'_#10r u32>`, which makes the generic argument `&'_#10r u32` invariant + = note: requirement occurs because of the type `Cell<&'?10 u32>`, which makes the generic argument `&'?10 u32` invariant = note: the struct `Cell<T>` is invariant over the parameter `T` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr index 71f8a1c67..b217ae197 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -6,13 +6,13 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | = note: defining type: test::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r + = note: late-bound region is '?3 + = note: late-bound region is '?4 = note: number of external vids: 5 - = note: where '_#1r: '_#2r + = note: where '?1: '?2 note: no external requirements --> $DIR/propagate-approximated-val.rs:35:1 diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index e1cb97b1c..f31478b6d 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -6,12 +6,12 @@ LL | |_outlives1, _outlives2, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where '_#1r: '_#2r + = note: where '?1: '?2 note: no external requirements --> $DIR/propagate-despite-same-free-region.rs:39:1 diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index b66e8391c..1509ade87 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -6,19 +6,19 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#2r - = note: late-bound region is '_#3r + = note: late-bound region is '?2 + = note: late-bound region is '?3 error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:37:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | --------- - has type `&'_#7r Cell<&'1 u32>` + | --------- - has type `&'?7 Cell<&'1 u32>` | | - | has type `&'_#5r Cell<&'2 &'_#1r u32>` + | has type `&'?5 Cell<&'2 &'?1 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 49641fd06..c85a9872e 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -6,19 +6,19 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r + = note: late-bound region is '?3 + = note: late-bound region is '?4 error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:41:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ---------- ---------- has type `&'_#8r Cell<&'2 &'_#2r u32>` + | ---------- ---------- has type `&'?8 Cell<&'2 &'?2 u32>` | | - | has type `&'_#6r Cell<&'1 &'_#1r u32>` + | has type `&'?6 Cell<&'1 &'?1 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 038a5e11f..05e274ab2 100644 --- a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -4,13 +4,13 @@ note: external requirements LL | establish_relationships(value, |value| { | ^^^^^^^ | - = note: defining type: supply::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: supply::<'?1, T>::{closure#0} with closure substs [ i32, extern "rust-call" fn((T,)), (), ] = note: number of external vids: 2 - = note: where T: '_#1r + = note: where T: '?1 note: no external requirements --> $DIR/propagate-from-trait-match.rs:28:1 @@ -20,7 +20,7 @@ LL | | where LL | | T: Trait<'a>, | |_________________^ | - = note: defining type: supply::<'_#1r, T> + = note: defining type: supply::<'?1, T> error[E0309]: the parameter type `T` may not live long enough --> $DIR/propagate-from-trait-match.rs:43:9 diff --git a/tests/ui/issues/issue-30438-a.rs b/tests/ui/nll/issue-30438-a.rs index 0d4eb796a..0d4eb796a 100644 --- a/tests/ui/issues/issue-30438-a.rs +++ b/tests/ui/nll/issue-30438-a.rs diff --git a/tests/ui/issues/issue-30438-a.stderr b/tests/ui/nll/issue-30438-a.stderr index 53845af82..53845af82 100644 --- a/tests/ui/issues/issue-30438-a.stderr +++ b/tests/ui/nll/issue-30438-a.stderr diff --git a/tests/ui/issues/issue-30438-b.rs b/tests/ui/nll/issue-30438-b.rs index 79510cdb6..79510cdb6 100644 --- a/tests/ui/issues/issue-30438-b.rs +++ b/tests/ui/nll/issue-30438-b.rs diff --git a/tests/ui/issues/issue-30438-b.stderr b/tests/ui/nll/issue-30438-b.stderr index fd6bd25b1..fd6bd25b1 100644 --- a/tests/ui/issues/issue-30438-b.stderr +++ b/tests/ui/nll/issue-30438-b.stderr diff --git a/tests/ui/issues/issue-30438-c.rs b/tests/ui/nll/issue-30438-c.rs index 813c1d3e2..813c1d3e2 100644 --- a/tests/ui/issues/issue-30438-c.rs +++ b/tests/ui/nll/issue-30438-c.rs diff --git a/tests/ui/issues/issue-30438-c.stderr b/tests/ui/nll/issue-30438-c.stderr index 7c0010880..7c0010880 100644 --- a/tests/ui/issues/issue-30438-c.stderr +++ b/tests/ui/nll/issue-30438-c.stderr diff --git a/tests/ui/nll/issue-47388.stderr b/tests/ui/nll/issue-47388.stderr index c780451df..09b9d638a 100644 --- a/tests/ui/nll/issue-47388.stderr +++ b/tests/ui/nll/issue-47388.stderr @@ -7,7 +7,7 @@ LL | fancy_ref.num = 6; help: consider changing this to be a mutable reference | LL | let fancy_ref = &mut (&mut fancy); - | ~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/nll/issue-51244.stderr b/tests/ui/nll/issue-51244.stderr index 03d8acc81..8ccb5809e 100644 --- a/tests/ui/nll/issue-51244.stderr +++ b/tests/ui/nll/issue-51244.stderr @@ -7,7 +7,7 @@ LL | *my_ref = 0; help: consider changing this to be a mutable reference | LL | let ref mut my_ref @ _ = 0; - | ~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-54302-cases.rs b/tests/ui/nll/issue-54302-cases.rs index faa116269..faa116269 100644 --- a/tests/ui/issues/issue-54302-cases.rs +++ b/tests/ui/nll/issue-54302-cases.rs diff --git a/tests/ui/issues/issue-54302-cases.stderr b/tests/ui/nll/issue-54302-cases.stderr index 6e8b69c4b..6e8b69c4b 100644 --- a/tests/ui/issues/issue-54302-cases.stderr +++ b/tests/ui/nll/issue-54302-cases.stderr diff --git a/tests/ui/issues/issue-54302.rs b/tests/ui/nll/issue-54302.rs index 1bfaebc38..1bfaebc38 100644 --- a/tests/ui/issues/issue-54302.rs +++ b/tests/ui/nll/issue-54302.rs diff --git a/tests/ui/issues/issue-54302.stderr b/tests/ui/nll/issue-54302.stderr index 26c46571f..26c46571f 100644 --- a/tests/ui/issues/issue-54302.stderr +++ b/tests/ui/nll/issue-54302.stderr diff --git a/tests/ui/nll/issue-57989.stderr b/tests/ui/nll/issue-57989.stderr index d5effd6f3..6062b31d6 100644 --- a/tests/ui/nll/issue-57989.stderr +++ b/tests/ui/nll/issue-57989.stderr @@ -7,7 +7,7 @@ LL | *x = 0; help: consider changing this to be a mutable reference | LL | fn f(x: &mut i32) { - | ~~~~~~~~ + | +++ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-57989.rs:5:5 diff --git a/tests/ui/nll/member-constraints/min-choice.rs b/tests/ui/nll/member-constraints/min-choice.rs index 14b4dae7a..f4aca69e1 100644 --- a/tests/ui/nll/member-constraints/min-choice.rs +++ b/tests/ui/nll/member-constraints/min-choice.rs @@ -1,5 +1,5 @@ -// Assuming that the hidden type in these tests is `&'_#15r u8`, -// we have a member constraint: `'_#15r member ['static, 'a, 'b, 'c]`. +// Assuming that the hidden type in these tests is `&'?15 u8`, +// we have a member constraint: `'?15 member ['static, 'a, 'b, 'c]`. // // Make sure we pick up the minimum non-ambiguous region among them. // We will have to exclude `['b, 'c]` because they're incomparable, diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs b/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs index 66ff828a8..ceb417f84 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs +++ b/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs @@ -5,9 +5,9 @@ trait Cap<'a> {} impl<T> Cap<'_> for T {} -// Assuming the hidden type is `[&'_#15r u8; 1]`, we have two distinct member constraints: -// - '_#15r member ['static, 'a, 'b] // from outer impl-trait -// - '_#15r member ['static, 'a, 'b] // from inner impl-trait +// Assuming the hidden type is `[&'?15 u8; 1]`, we have two distinct member constraints: +// - '?15 member ['static, 'a, 'b] // from outer impl-trait +// - '?15 member ['static, 'a, 'b] // from inner impl-trait // To satisfy both we can choose 'a or 'b, so it's a failure due to ambiguity. fn fail_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a> + Cap<'b>> where diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs b/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs index 15540cb46..4be0f02ac 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs +++ b/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs @@ -5,9 +5,9 @@ trait Cap<'a> {} impl<T> Cap<'_> for T {} -// Assuming the hidden type is `[&'_#15r u8; 1]`, we have two distinct member constraints: -// - '_#15r member ['static, 'a, 'b] // from outer impl-trait -// - '_#15r member ['static, 'a] // from inner impl-trait +// Assuming the hidden type is `[&'?15 u8; 1]`, we have two distinct member constraints: +// - '?15 member ['static, 'a, 'b] // from outer impl-trait +// - '?15 member ['static, 'a] // from inner impl-trait // To satisfy both we can only choose 'a. fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> where diff --git a/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs b/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs index 7cc0acf45..2e9eff593 100644 --- a/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs +++ b/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs @@ -5,6 +5,8 @@ // check-pass // compile-flags:-Zno-leak-check +#![allow(dropping_copy_types)] + fn make_it() -> for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 { panic!() } diff --git a/tests/ui/nll/ty-outlives/projection-body.rs b/tests/ui/nll/ty-outlives/projection-body.rs index b03a539eb..722d67471 100644 --- a/tests/ui/nll/ty-outlives/projection-body.rs +++ b/tests/ui/nll/ty-outlives/projection-body.rs @@ -3,6 +3,8 @@ // // check-pass +#![allow(dropping_references)] + trait MyTrait<'a> { type Output; } diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 4933b9348..4eefb180e 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -4,13 +4,13 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>, + extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '?2)>, (), ] = note: number of external vids: 3 - = note: where <T as std::iter::Iterator>::Item: '_#2r + = note: where <T as std::iter::Iterator>::Item: '?2 note: no external requirements --> $DIR/projection-no-regions-closure.rs:21:1 @@ -20,7 +20,7 @@ LL | | where LL | | T: Iterator, | |________________^ | - = note: defining type: no_region::<'_#1r, T> + = note: defining type: no_region::<'?1, T> error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:25:31 @@ -37,13 +37,13 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: correct_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>, + extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '?2)>, (), ] = note: number of external vids: 3 - = note: where <T as std::iter::Iterator>::Item: '_#2r + = note: where <T as std::iter::Iterator>::Item: '?2 note: no external requirements --> $DIR/projection-no-regions-closure.rs:30:1 @@ -53,7 +53,7 @@ LL | | where LL | | T: 'a + Iterator, | |_____________________^ | - = note: defining type: correct_region::<'_#1r, T> + = note: defining type: correct_region::<'?1, T> note: external requirements --> $DIR/projection-no-regions-closure.rs:42:23 @@ -61,13 +61,13 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: wrong_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: wrong_region::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>, + extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '?3)>, (), ] = note: number of external vids: 4 - = note: where <T as std::iter::Iterator>::Item: '_#3r + = note: where <T as std::iter::Iterator>::Item: '?3 note: no external requirements --> $DIR/projection-no-regions-closure.rs:38:1 @@ -77,7 +77,7 @@ LL | | where LL | | T: 'b + Iterator, | |_____________________^ | - = note: defining type: wrong_region::<'_#1r, '_#2r, T> + = note: defining type: wrong_region::<'?1, '?2, T> error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:42:31 @@ -94,13 +94,13 @@ note: external requirements LL | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^ | - = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>, + extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '?3)>, (), ] = note: number of external vids: 4 - = note: where <T as std::iter::Iterator>::Item: '_#3r + = note: where <T as std::iter::Iterator>::Item: '?3 note: no external requirements --> $DIR/projection-no-regions-closure.rs:47:1 @@ -111,7 +111,7 @@ LL | | T: 'b + Iterator, LL | | 'b: 'a, | |___________^ | - = note: defining type: outlives_region::<'_#1r, '_#2r, T> + = note: defining type: outlives_region::<'?1, '?2, T> error: aborting due to 2 previous errors diff --git a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr index 11ada59c0..986c2bd21 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -4,15 +4,15 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where T: '_#2r - = note: where '_#1r: '_#2r + = note: where T: '?2 + = note: where '?1: '?2 note: no external requirements --> $DIR/projection-one-region-closure.rs:41:1 @@ -22,7 +22,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'?1, T> error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:45:39 @@ -54,14 +54,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where T: '_#3r - = note: where '_#2r: '_#3r + = note: where T: '?3 + = note: where '?2: '?3 note: no external requirements --> $DIR/projection-one-region-closure.rs:51:1 @@ -72,7 +72,7 @@ LL | | T: Anything<'b>, LL | | 'a: 'a, | |___________^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> + = note: defining type: no_relationships_early::<'?1, '?2, T> error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:56:39 @@ -104,13 +104,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where <T as Anything<'_#2r>>::AssocType: '_#3r + = note: where <T as Anything<'?2>>::AssocType: '?3 note: no external requirements --> $DIR/projection-one-region-closure.rs:62:1 @@ -121,7 +121,7 @@ LL | | T: Anything<'b>, LL | | T::AssocType: 'a, | |_____________________^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T> + = note: defining type: projection_outlives::<'?1, '?2, T> note: external requirements --> $DIR/projection-one-region-closure.rs:80:29 @@ -129,14 +129,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where T: '_#3r - = note: where '_#2r: '_#3r + = note: where T: '?3 + = note: where '?2: '?3 note: no external requirements --> $DIR/projection-one-region-closure.rs:74:1 @@ -148,7 +148,7 @@ LL | | T: 'a, LL | | 'b: 'a, | |___________^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T> + = note: defining type: elements_outlive::<'?1, '?2, T> error: aborting due to 4 previous errors diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 47d4f2e46..25cc60d81 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -4,14 +4,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where '_#1r: '_#2r + = note: where '?1: '?2 note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:33:1 @@ -21,7 +21,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'?1, T> error: lifetime may not live long enough --> $DIR/projection-one-region-trait-bound-closure.rs:37:39 @@ -42,13 +42,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where '_#2r: '_#3r + = note: where '?2: '?3 note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:42:1 @@ -59,7 +59,7 @@ LL | | T: Anything<'b>, LL | | 'a: 'a, | |___________^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> + = note: defining type: no_relationships_early::<'?1, '?2, T> error: lifetime may not live long enough --> $DIR/projection-one-region-trait-bound-closure.rs:47:39 @@ -80,13 +80,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where <T as Anything<'_#2r>>::AssocType: '_#3r + = note: where <T as Anything<'?2>>::AssocType: '?3 note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:52:1 @@ -97,7 +97,7 @@ LL | | T: Anything<'b>, LL | | T::AssocType: 'a, | |_____________________^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T> + = note: defining type: projection_outlives::<'?1, '?2, T> note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:69:29 @@ -105,13 +105,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where '_#2r: '_#3r + = note: where '?2: '?3 note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:64:1 @@ -122,7 +122,7 @@ LL | | T: Anything<'b>, LL | | 'b: 'a, | |___________^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T> + = note: defining type: elements_outlive::<'?1, '?2, T> note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:81:29 @@ -130,13 +130,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] = note: number of external vids: 3 - = note: where '_#1r: '_#2r + = note: where '?1: '?2 note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:73:1 @@ -146,7 +146,7 @@ LL | | where LL | | T: Anything<'a>, | |____________________^ | - = note: defining type: one_region::<'_#1r, T> + = note: defining type: one_region::<'?1, T> error: aborting due to 2 previous errors diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index b27186b05..5a092d7b8 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -4,12 +4,12 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:32:1 @@ -19,7 +19,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'?1, T> note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 @@ -27,9 +27,9 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] @@ -42,7 +42,7 @@ LL | | T: Anything<'b>, LL | | 'a: 'a, | |___________^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> + = note: defining type: no_relationships_early::<'?1, '?2, T> note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29 @@ -50,9 +50,9 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] @@ -65,7 +65,7 @@ LL | | T: Anything<'b>, LL | | T::AssocType: 'a, | |_____________________^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, T> + = note: defining type: projection_outlives::<'?1, '?2, T> note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29 @@ -73,9 +73,9 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] @@ -88,7 +88,7 @@ LL | | T: Anything<'b>, LL | | 'b: 'a, | |___________^ | - = note: defining type: elements_outlive::<'_#1r, '_#2r, T> + = note: defining type: elements_outlive::<'?1, '?2, T> note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29 @@ -96,9 +96,9 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] @@ -110,5 +110,5 @@ LL | | where LL | | T: Anything<'a>, | |____________________^ | - = note: defining type: one_region::<'_#1r, T> + = note: defining type: one_region::<'?1, T> diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 530dd8681..51283aa88 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -4,14 +4,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] - = note: late-bound region is '_#4r + = note: late-bound region is '?4 = note: number of external vids: 5 - = note: where <T as Anything<'_#1r, '_#2r>>::AssocType: '_#3r + = note: where <T as Anything<'?1, '?2>>::AssocType: '?3 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:34:1 @@ -21,16 +21,16 @@ LL | | where LL | | T: Anything<'b, 'c>, | |________________________^ | - = note: defining type: no_relationships_late::<'_#1r, '_#2r, T> + = note: defining type: no_relationships_late::<'?1, '?2, T> -error[E0309]: the associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough +error[E0309]: the associated type `<T as Anything<'?5, '?6>>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:38:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ | - = help: consider adding an explicit lifetime bound `<T as Anything<'_#5r, '_#6r>>::AssocType: 'a`... - = note: ...so that the type `<T as Anything<'_#5r, '_#6r>>::AssocType` will meet its required lifetime bounds + = help: consider adding an explicit lifetime bound `<T as Anything<'?5, '?6>>::AssocType: 'a`... + = note: ...so that the type `<T as Anything<'?5, '?6>>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 @@ -38,13 +38,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_early::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), ] = note: number of external vids: 5 - = note: where <T as Anything<'_#2r, '_#3r>>::AssocType: '_#4r + = note: where <T as Anything<'?2, '?3>>::AssocType: '?4 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:43:1 @@ -55,16 +55,16 @@ LL | | T: Anything<'b, 'c>, LL | | 'a: 'a, | |___________^ | - = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T> + = note: defining type: no_relationships_early::<'?1, '?2, '?3, T> -error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough +error[E0309]: the associated type `<T as Anything<'?6, '?7>>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:48:39 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ | - = help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: 'a`... - = note: ...so that the type `<T as Anything<'_#6r, '_#7r>>::AssocType` will meet its required lifetime bounds + = help: consider adding an explicit lifetime bound `<T as Anything<'?6, '?7>>::AssocType: 'a`... + = note: ...so that the type `<T as Anything<'?6, '?7>>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 @@ -72,13 +72,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ + = note: defining type: projection_outlives::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), ] = note: number of external vids: 5 - = note: where <T as Anything<'_#2r, '_#3r>>::AssocType: '_#4r + = note: where <T as Anything<'?2, '?3>>::AssocType: '?4 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:53:1 @@ -89,7 +89,7 @@ LL | | T: Anything<'b, 'c>, LL | | T::AssocType: 'a, | |_____________________^ | - = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T> + = note: defining type: projection_outlives::<'?1, '?2, '?3, T> note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:70:29 @@ -97,13 +97,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive1::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), ] = note: number of external vids: 5 - = note: where <T as Anything<'_#2r, '_#3r>>::AssocType: '_#4r + = note: where <T as Anything<'?2, '?3>>::AssocType: '?4 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:65:1 @@ -114,7 +114,7 @@ LL | | T: Anything<'b, 'c>, LL | | 'b: 'a, | |___________^ | - = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T> + = note: defining type: elements_outlive1::<'?1, '?2, '?3, T> note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:79:29 @@ -122,13 +122,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [ + = note: defining type: elements_outlive2::<'?1, '?2, '?3, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?4 ()>, T)), (), ] = note: number of external vids: 5 - = note: where <T as Anything<'_#2r, '_#3r>>::AssocType: '_#4r + = note: where <T as Anything<'?2, '?3>>::AssocType: '?4 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:74:1 @@ -139,7 +139,7 @@ LL | | T: Anything<'b, 'c>, LL | | 'c: 'a, | |___________^ | - = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T> + = note: defining type: elements_outlive2::<'?1, '?2, '?3, T> note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 @@ -147,14 +147,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: two_regions::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: two_regions::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where <T as Anything<'_#1r, '_#1r>>::AssocType: '_#2r + = note: where <T as Anything<'?1, '?1>>::AssocType: '?2 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:83:1 @@ -164,7 +164,7 @@ LL | | where LL | | T: Anything<'b, 'b>, | |________________________^ | - = note: defining type: two_regions::<'_#1r, T> + = note: defining type: two_regions::<'?1, T> error: lifetime may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:87:5 @@ -178,7 +178,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` | = help: consider adding the following bound: `'b: 'a` - = note: requirement occurs because of the type `Cell<&'_#8r ()>`, which makes the generic argument `&'_#8r ()` invariant + = note: requirement occurs because of the type `Cell<&'?8 ()>`, which makes the generic argument `&'?8 ()` invariant = note: the struct `Cell<T>` is invariant over the parameter `T` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance @@ -188,13 +188,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: two_regions_outlive::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where <T as Anything<'_#2r, '_#2r>>::AssocType: '_#3r + = note: where <T as Anything<'?2, '?2>>::AssocType: '?3 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:92:1 @@ -205,7 +205,7 @@ LL | | T: Anything<'b, 'b>, LL | | 'b: 'a, | |___________^ | - = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T> + = note: defining type: two_regions_outlive::<'?1, '?2, T> note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:109:29 @@ -213,13 +213,13 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: one_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] = note: number of external vids: 3 - = note: where <T as Anything<'_#1r, '_#1r>>::AssocType: '_#2r + = note: where <T as Anything<'?1, '?1>>::AssocType: '?2 note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:101:1 @@ -229,7 +229,7 @@ LL | | where LL | | T: Anything<'a, 'a>, | |________________________^ | - = note: defining type: one_region::<'_#1r, T> + = note: defining type: one_region::<'?1, T> error: aborting due to 3 previous errors diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 2c4a05975..04616f9b7 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -6,11 +6,11 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic::<T>::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), ] = note: number of external vids: 2 - = note: where T: '_#1r + = note: where T: '?1 note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:22:1 @@ -28,12 +28,12 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic_fail::<T>::{closure#0} with closure substs [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), ] - = note: late-bound region is '_#2r + = note: late-bound region is '?2 = note: number of external vids: 3 - = note: where T: '_#1r + = note: where T: '?1 note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:28:1 diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs index 4343c3aee..72b18c167 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs @@ -19,8 +19,8 @@ where // Here, the closure winds up being required to prove that `T: // 'a`. In principle, it could know that, except that it is // type-checked in a fully generic way, and hence it winds up with - // a propagated requirement that `T: '_#2`, where `'_#2` appears - // in the return type. The caller makes the mapping from `'_#2` to + // a propagated requirement that `T: '?2`, where `'?2` appears + // in the return type. The caller makes the mapping from `'?2` to // `'a` (and subsequently reports an error). with_signature(x, |y| y) diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 35979c8bf..d580774ff 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -4,13 +4,13 @@ note: external requirements LL | with_signature(x, |y| y) | ^^^ | - = note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r)>, + extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn std::fmt::Debug + '?2)>, (), ] = note: number of external vids: 3 - = note: where T: '_#2r + = note: where T: '?2 note: no external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:15:1 @@ -20,7 +20,7 @@ LL | | where LL | | T: Debug, | |_____________^ | - = note: defining type: no_region::<'_#1r, T> + = note: defining type: no_region::<'?1, T> error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:27 diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 4c97db58c..3d4c11a3c 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -6,12 +6,12 @@ LL | with_signature(a, b, |x, y| { | = note: defining type: no_region::<T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#1r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?1 ()>, T)), (), ] - = note: late-bound region is '_#2r + = note: late-bound region is '?2 = note: number of external vids: 3 - = note: where T: '_#1r + = note: where T: '?1 note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:26:1 @@ -38,13 +38,13 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: correct_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] = note: number of external vids: 3 - = note: where T: '_#2r + = note: where T: '?2 note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:38:1 @@ -54,7 +54,7 @@ LL | | where LL | | T: 'a, | |__________^ | - = note: defining type: correct_region::<'_#1r, T> + = note: defining type: correct_region::<'?1, T> note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:63:26 @@ -62,14 +62,14 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: wrong_region::<'?1, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?2 ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '?3 = note: number of external vids: 4 - = note: where T: '_#2r + = note: where T: '?2 note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:59:1 @@ -79,7 +79,7 @@ LL | | where LL | | T: 'b, | |__________^ | - = note: defining type: wrong_region::<'_#1r, T> + = note: defining type: wrong_region::<'?1, T> error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:65:9 @@ -98,13 +98,13 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: outlives_region::<'?1, '?2, T>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'?3 ()>, T)), (), ] = note: number of external vids: 4 - = note: where T: '_#3r + = note: where T: '?3 note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:71:1 @@ -115,7 +115,7 @@ LL | | T: 'b, LL | | 'b: 'a, | |___________^ | - = note: defining type: outlives_region::<'_#1r, '_#2r, T> + = note: defining type: outlives_region::<'?1, '?2, T> error: aborting due to 2 previous errors diff --git a/tests/ui/nll/user-annotations/adt-brace-enums.stderr b/tests/ui/nll/user-annotations/adt-brace-enums.stderr index 9e94fd5a7..900e7e253 100644 --- a/tests/ui/nll/user-annotations/adt-brace-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-brace-enums.stderr @@ -31,7 +31,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-brace-structs.stderr b/tests/ui/nll/user-annotations/adt-brace-structs.stderr index cbb7f6a55..d61643dc6 100644 --- a/tests/ui/nll/user-annotations/adt-brace-structs.stderr +++ b/tests/ui/nll/user-annotations/adt-brace-structs.stderr @@ -31,7 +31,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'a u32> { t: &c }; | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-nullary-enums.stderr b/tests/ui/nll/user-annotations/adt-nullary-enums.stderr index bca85a90d..5b385feee 100644 --- a/tests/ui/nll/user-annotations/adt-nullary-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-nullary-enums.stderr @@ -34,7 +34,10 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here +LL | combine( LL | SomeEnum::SomeVariant(Cell::new(&c)), | ----------^^- | | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-enums.stderr b/tests/ui/nll/user-annotations/adt-tuple-enums.stderr index d2d85ec2b..766da9ec0 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-enums.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-enums.stderr @@ -31,7 +31,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | SomeEnum::SomeVariant::<&'a u32>(&c); | ^^ | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr b/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr index b7bc2a10b..2084697e7 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-struct-calls.stderr @@ -33,7 +33,10 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here +LL | let f = SomeStruct::<&'a u32>; LL | f(&c); | --^^- | | | @@ -47,7 +50,9 @@ error[E0597]: `c` does not live long enough | LL | let f = SomeStruct::<&'a u32>; | - lifetime `'1` appears in the type of `f` -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | f(&c); | --^^- | | | diff --git a/tests/ui/nll/user-annotations/adt-tuple-struct.stderr b/tests/ui/nll/user-annotations/adt-tuple-struct.stderr index 97d39da26..c7480f529 100644 --- a/tests/ui/nll/user-annotations/adt-tuple-struct.stderr +++ b/tests/ui/nll/user-annotations/adt-tuple-struct.stderr @@ -31,7 +31,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | SomeStruct::<&'a u32>(&c); | ^^ | | diff --git a/tests/ui/nll/user-annotations/fns.stderr b/tests/ui/nll/user-annotations/fns.stderr index 8b53e138d..abaa35e95 100644 --- a/tests/ui/nll/user-annotations/fns.stderr +++ b/tests/ui/nll/user-annotations/fns.stderr @@ -31,7 +31,9 @@ error[E0597]: `c` does not live long enough | LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here -... +LL | let _closure = || { +LL | let c = 66; + | - binding `c` declared here LL | some_fn::<&'a u32>(&c); | -------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-call.stderr b/tests/ui/nll/user-annotations/method-call.stderr index 3803cbf77..b4d1ac042 100644 --- a/tests/ui/nll/user-annotations/method-call.stderr +++ b/tests/ui/nll/user-annotations/method-call.stderr @@ -33,6 +33,8 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here ... +LL | let c = 66; + | - binding `c` declared here LL | a.method::<&'a u32>(b, &c); | ------------------------^^- | | | diff --git a/tests/ui/nll/user-annotations/method-ufcs-3.stderr b/tests/ui/nll/user-annotations/method-ufcs-3.stderr index 8cb995a03..4dd39e108 100644 --- a/tests/ui/nll/user-annotations/method-ufcs-3.stderr +++ b/tests/ui/nll/user-annotations/method-ufcs-3.stderr @@ -33,6 +33,8 @@ error[E0597]: `c` does not live long enough LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { | -- lifetime `'a` defined here ... +LL | let c = 66; + | - binding `c` declared here LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); | -------------------------------------------^^- | | | diff --git a/tests/ui/not-panic/not-panic-safe-2.stderr b/tests/ui/not-panic/not-panic-safe-2.stderr index 3b0f83b3b..0c399f15a 100644 --- a/tests/ui/not-panic/not-panic-safe-2.stderr +++ b/tests/ui/not-panic/not-panic-safe-2.stderr @@ -5,7 +5,8 @@ LL | assert::<Rc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `Rc<RefCell<i32>>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-2.rs:7:14 @@ -20,8 +21,10 @@ LL | assert::<Rc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>` - = note: required because it appears within the type `Cell<isize>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `Cell<isize>` + --> $SRC_DIR/core/src/cell.rs:LL:COL +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `Rc<RefCell<i32>>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-2.rs:7:14 diff --git a/tests/ui/not-panic/not-panic-safe-3.stderr b/tests/ui/not-panic/not-panic-safe-3.stderr index 9e9a12764..53028d6a3 100644 --- a/tests/ui/not-panic/not-panic-safe-3.stderr +++ b/tests/ui/not-panic/not-panic-safe-3.stderr @@ -5,7 +5,8 @@ LL | assert::<Arc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `Arc<RefCell<i32>>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-3.rs:7:14 @@ -20,8 +21,10 @@ LL | assert::<Arc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>` - = note: required because it appears within the type `Cell<isize>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `Cell<isize>` + --> $SRC_DIR/core/src/cell.rs:LL:COL +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `Arc<RefCell<i32>>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-3.rs:7:14 diff --git a/tests/ui/not-panic/not-panic-safe-4.stderr b/tests/ui/not-panic/not-panic-safe-4.stderr index 9428c1256..b1361cfd8 100644 --- a/tests/ui/not-panic/not-panic-safe-4.stderr +++ b/tests/ui/not-panic/not-panic-safe-4.stderr @@ -5,7 +5,8 @@ LL | assert::<&RefCell<i32>>(); | ^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&RefCell<i32>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-4.rs:6:14 @@ -25,8 +26,10 @@ LL | assert::<&RefCell<i32>>(); | ^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>` - = note: required because it appears within the type `Cell<isize>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `Cell<isize>` + --> $SRC_DIR/core/src/cell.rs:LL:COL +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&RefCell<i32>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-4.rs:6:14 diff --git a/tests/ui/not-panic/not-panic-safe-6.stderr b/tests/ui/not-panic/not-panic-safe-6.stderr index 7986e341e..47f282574 100644 --- a/tests/ui/not-panic/not-panic-safe-6.stderr +++ b/tests/ui/not-panic/not-panic-safe-6.stderr @@ -5,7 +5,8 @@ LL | assert::<*mut RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<i32>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `*mut RefCell<i32>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-6.rs:6:14 @@ -20,8 +21,10 @@ LL | assert::<*mut RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^ `UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | = help: within `RefCell<i32>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<isize>` - = note: required because it appears within the type `Cell<isize>` - = note: required because it appears within the type `RefCell<i32>` +note: required because it appears within the type `Cell<isize>` + --> $SRC_DIR/core/src/cell.rs:LL:COL +note: required because it appears within the type `RefCell<i32>` + --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `*mut RefCell<i32>` to implement `UnwindSafe` note: required by a bound in `assert` --> $DIR/not-panic-safe-6.rs:6:14 diff --git a/tests/ui/numbers-arithmetic/overflow-attribute-works-1.rs b/tests/ui/numbers-arithmetic/overflow-attribute-works-1.rs new file mode 100644 index 000000000..318be2a64 --- /dev/null +++ b/tests/ui/numbers-arithmetic/overflow-attribute-works-1.rs @@ -0,0 +1,19 @@ +// run-pass +// compile-flags: -C overflow_checks=true + +#![feature(cfg_overflow_checks)] + +fn main() { + assert!(cfg!(overflow_checks)); + assert!(compiles_differently()); +} + +#[cfg(overflow_checks)] +fn compiles_differently()->bool { + true +} + +#[cfg(not(overflow_checks))] +fn compiles_differently()->bool { + false +} diff --git a/tests/ui/numbers-arithmetic/overflow-attribute-works-2.rs b/tests/ui/numbers-arithmetic/overflow-attribute-works-2.rs new file mode 100644 index 000000000..0367d980a --- /dev/null +++ b/tests/ui/numbers-arithmetic/overflow-attribute-works-2.rs @@ -0,0 +1,19 @@ +// run-pass +// compile-flags: -C overflow_checks=false + +#![feature(cfg_overflow_checks)] + +fn main() { + assert!(!cfg!(overflow_checks)); + assert!(!compiles_differently()); +} + +#[cfg(overflow_checks)] +fn compiles_differently()->bool { + true +} + +#[cfg(not(overflow_checks))] +fn compiles_differently()->bool { + false +} diff --git a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs new file mode 100644 index 000000000..565b7e86f --- /dev/null +++ b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to negate with overflow' +// ignore-emscripten no processes +// compile-flags: -C debug-assertions + +#![allow(arithmetic_overflow)] + +use std::num::NonZeroI8; + +fn main() { + let _x = -NonZeroI8::new(i8::MIN).unwrap(); +} diff --git a/tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs b/tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs index 4c6929d66..088b2fcdd 100644 --- a/tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs +++ b/tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) // Tests saturating float->int casts. See u128-as-f32.rs for the opposite direction. // diff --git a/tests/ui/object-safety/assoc_const_bounds.rs b/tests/ui/object-safety/assoc_const_bounds.rs new file mode 100644 index 000000000..94b1f6316 --- /dev/null +++ b/tests/ui/object-safety/assoc_const_bounds.rs @@ -0,0 +1,13 @@ +trait Foo<T> { + const BAR: bool + where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` + Self: Sized; +} + +trait Cake {} +impl Cake for () {} + +fn foo(_: &dyn Foo<()>) {} +fn bar(_: &dyn Foo<i32>) {} + +fn main() {} diff --git a/tests/ui/object-safety/assoc_const_bounds.stderr b/tests/ui/object-safety/assoc_const_bounds.stderr new file mode 100644 index 000000000..09bc11e17 --- /dev/null +++ b/tests/ui/object-safety/assoc_const_bounds.stderr @@ -0,0 +1,15 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` + --> $DIR/assoc_const_bounds.rs:3:9 + | +LL | trait Foo<T> { + | - while parsing this item list starting here +LL | const BAR: bool + | - expected one of 7 possible tokens +LL | where + | ^^^^^ unexpected token +LL | Self: Sized; +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.rs b/tests/ui/object-safety/assoc_const_bounds_sized.rs new file mode 100644 index 000000000..2a76e5dce --- /dev/null +++ b/tests/ui/object-safety/assoc_const_bounds_sized.rs @@ -0,0 +1,9 @@ +trait Foo { + const BAR: bool + where //~ ERROR: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` + Self: Sized; +} + +fn foo(_: &dyn Foo) {} + +fn main() {} diff --git a/tests/ui/object-safety/assoc_const_bounds_sized.stderr b/tests/ui/object-safety/assoc_const_bounds_sized.stderr new file mode 100644 index 000000000..e1f57f677 --- /dev/null +++ b/tests/ui/object-safety/assoc_const_bounds_sized.stderr @@ -0,0 +1,15 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found keyword `where` + --> $DIR/assoc_const_bounds_sized.rs:3:9 + | +LL | trait Foo { + | - while parsing this item list starting here +LL | const BAR: bool + | - expected one of 7 possible tokens +LL | where + | ^^^^^ unexpected token +LL | Self: Sized; +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/object-safety/assoc_type_bounds.rs b/tests/ui/object-safety/assoc_type_bounds.rs new file mode 100644 index 000000000..9abf7939c --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds.rs @@ -0,0 +1,13 @@ +trait Foo<T> { + type Bar + where + T: Cake; +} + +trait Cake {} +impl Cake for () {} + +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified + +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds.stderr b/tests/ui/object-safety/assoc_type_bounds.stderr new file mode 100644 index 000000000..a1396dc3a --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds.stderr @@ -0,0 +1,21 @@ +error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds.rs:10:16 + | +LL | type Bar + | -------- `Bar` defined here +... +LL | fn foo(_: &dyn Foo<()>) {} + | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` + +error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds.rs:11:16 + | +LL | type Bar + | -------- `Bar` defined here +... +LL | fn bar(_: &dyn Foo<i32>) {} + | ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/object-safety/assoc_type_bounds2.rs b/tests/ui/object-safety/assoc_type_bounds2.rs new file mode 100644 index 000000000..0112123fd --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds2.rs @@ -0,0 +1,13 @@ +trait Foo<T> { + type Bar + where + Self: Foo<()>; +} + +trait Cake {} +impl Cake for () {} + +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified + +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds2.stderr b/tests/ui/object-safety/assoc_type_bounds2.stderr new file mode 100644 index 000000000..7a3c0e02d --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds2.stderr @@ -0,0 +1,21 @@ +error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds2.rs:10:16 + | +LL | type Bar + | -------- `Bar` defined here +... +LL | fn foo(_: &dyn Foo<()>) {} + | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` + +error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds2.rs:11:16 + | +LL | type Bar + | -------- `Bar` defined here +... +LL | fn bar(_: &dyn Foo<i32>) {} + | ^^^^^^^^ help: specify the associated type: `Foo<i32, Bar = Type>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.rs b/tests/ui/object-safety/assoc_type_bounds_sized.rs new file mode 100644 index 000000000..61ad3cf9d --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized.rs @@ -0,0 +1,9 @@ +trait Foo { + type Bar + where + Self: Sized; +} + +fn foo(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified + +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_sized.stderr new file mode 100644 index 000000000..49d624f9b --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized.stderr @@ -0,0 +1,12 @@ +error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds_sized.rs:7:16 + | +LL | type Bar + | -------- `Bar` defined here +... +LL | fn foo(_: &dyn Foo) {} + | ^^^ help: specify the associated type: `Foo<Bar = Type>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/object-safety/issue-19538.stderr b/tests/ui/object-safety/issue-19538.stderr index 8420637b3..183245b23 100644 --- a/tests/ui/object-safety/issue-19538.stderr +++ b/tests/ui/object-safety/issue-19538.stderr @@ -29,8 +29,7 @@ LL | fn foo<T>(&self, val: T); LL | trait Bar: Foo { } | --- this trait cannot be made into an object... = help: consider moving `foo` to another trait - = note: required for `&mut Thing` to implement `CoerceUnsized<&mut dyn Bar>` - = note: required by cast to type `&mut dyn Bar` + = note: required for the cast from `&mut Thing` to `&mut dyn Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr index f44de07d5..db3e0885a 100644 --- a/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr @@ -12,8 +12,7 @@ LL | trait Bar { LL | const X: usize; | ^ ...because it contains this associated `const` = help: consider moving `X` to another trait - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to previous error diff --git a/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr index 9a2d472d5..b200b64a1 100644 --- a/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr @@ -12,8 +12,7 @@ LL | trait Bar { LL | fn bar<T>(&self, t: T); | ^^^ ...because method `bar` has generic type parameters = help: consider moving `bar` to another trait - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-generics.rs:26:5 @@ -29,8 +28,7 @@ LL | trait Bar { LL | fn bar<T>(&self, t: T); | ^^^ ...because method `bar` has generic type parameters = help: consider moving `bar` to another trait - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr index 40a298bd1..414614d8d 100644 --- a/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr @@ -12,8 +12,7 @@ LL | trait Bar { LL | fn bar(&self, x: &Self); | ^^^^^ ...because method `bar` references the `Self` type in this parameter = help: consider moving `bar` to another trait - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error[E0038]: the trait `Baz` cannot be made into an object --> $DIR/object-safety-mentions-Self.rs:30:5 @@ -29,8 +28,7 @@ LL | trait Baz { LL | fn baz(&self) -> Self; | ^^^^ ...because method `baz` references the `Self` type in its return type = help: consider moving `baz` to another trait - = note: required for `&T` to implement `CoerceUnsized<&dyn Baz>` - = note: required by cast to type `&dyn Baz` + = note: required for the cast from `&T` to `&dyn Baz` error: aborting due to 2 previous errors diff --git a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr index da87b58c9..befcef952 100644 --- a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr @@ -11,8 +11,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo() {} | ^^^ ...because associated function `foo` has no `self` parameter - = note: required for `Box<Bar>` to implement `CoerceUnsized<Box<dyn Foo>>` - = note: required by cast to type `Box<dyn Foo>` + = note: required for the cast from `Box<Bar>` to `Box<dyn Foo>` help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) {} diff --git a/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr index 6c29c8d5f..90e5c59dd 100644 --- a/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr @@ -11,8 +11,7 @@ LL | trait Bar | --- this trait cannot be made into an object... LL | where Self : Sized | ^^^^^ ...because it requires `Self: Sized` - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to previous error diff --git a/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr index 70a44ed61..a6c22b874 100644 --- a/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr @@ -11,8 +11,7 @@ LL | trait Bar : Sized { | --- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&T` to implement `CoerceUnsized<&dyn Bar>` - = note: required by cast to type `&dyn Bar` + = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to previous error diff --git a/tests/ui/offset-of/auxiliary/offset-of-staged-api.rs b/tests/ui/offset-of/auxiliary/offset-of-staged-api.rs new file mode 100644 index 000000000..088086cc5 --- /dev/null +++ b/tests/ui/offset-of/auxiliary/offset-of-staged-api.rs @@ -0,0 +1,33 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.0")] + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct Unstable { + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable: u8, +} + +#[stable(feature = "stable_test_feature", since = "1.0")] +pub struct Stable { + #[stable(feature = "stable_test_feature", since = "1.0")] + pub stable: u8, +} + +#[stable(feature = "stable_test_feature", since = "1.0")] +pub struct StableWithUnstableField { + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable: u8, +} + +#[stable(feature = "stable_test_feature", since = "1.0")] +pub struct StableWithUnstableFieldType { + #[stable(feature = "stable_test_feature", since = "1.0")] + pub stable: Unstable, +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct UnstableWithStableFieldType { + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable: Stable, +} diff --git a/tests/ui/offset-of/offset-of-arg-count.rs b/tests/ui/offset-of/offset-of-arg-count.rs new file mode 100644 index 000000000..31de45bc7 --- /dev/null +++ b/tests/ui/offset-of/offset-of-arg-count.rs @@ -0,0 +1,22 @@ +#![feature(offset_of)] + +use std::mem::offset_of; + +fn main() { + offset_of!(NotEnoughArguments); //~ ERROR unexpected end of macro invocation + offset_of!(NotEnoughArgumentsWithAComma, ); //~ ERROR unexpected end of macro invocation + offset_of!(Container, field, too many arguments); //~ ERROR no rules expected the token `too` + offset_of!(S, f); // compiles fine + offset_of!(S, f,); // also compiles fine + offset_of!(S, f.); //~ ERROR unexpected end of macro invocation + offset_of!(S, f.,); //~ ERROR expected identifier + offset_of!(S, f..); //~ ERROR no rules expected the token + offset_of!(S, f..,); //~ ERROR no rules expected the token + offset_of!(Lt<'static>, bar); // issue #111657 + offset_of!(Lt<'_>, bar); // issue #111678 +} + +struct S { f: u8, } +struct Lt<'a> { + bar: &'a (), +} diff --git a/tests/ui/offset-of/offset-of-arg-count.stderr b/tests/ui/offset-of/offset-of-arg-count.stderr new file mode 100644 index 000000000..4275a8954 --- /dev/null +++ b/tests/ui/offset-of/offset-of-arg-count.stderr @@ -0,0 +1,59 @@ +error: unexpected end of macro invocation + --> $DIR/offset-of-arg-count.rs:6:34 + | +LL | offset_of!(NotEnoughArguments); + | ^ missing tokens in macro arguments + | +note: while trying to match `,` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: unexpected end of macro invocation + --> $DIR/offset-of-arg-count.rs:7:45 + | +LL | offset_of!(NotEnoughArgumentsWithAComma, ); + | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fields:tt` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: no rules expected the token `too` + --> $DIR/offset-of-arg-count.rs:8:34 + | +LL | offset_of!(Container, field, too many arguments); + | ^^^ no rules expected this token in macro call + | + = note: while trying to match sequence end + +error: unexpected end of macro invocation + --> $DIR/offset-of-arg-count.rs:11:21 + | +LL | offset_of!(S, f.); + | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fields:tt` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: expected identifier, found `,` + --> $DIR/offset-of-arg-count.rs:12:21 + | +LL | offset_of!(S, f.,); + | ^ expected identifier + +error: no rules expected the token `..` + --> $DIR/offset-of-arg-count.rs:13:20 + | +LL | offset_of!(S, f..); + | ^^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: no rules expected the token `..` + --> $DIR/offset-of-arg-count.rs:14:20 + | +LL | offset_of!(S, f..,); + | ^^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: aborting due to 7 previous errors + diff --git a/tests/ui/offset-of/offset-of-builtin.rs b/tests/ui/offset-of/offset-of-builtin.rs new file mode 100644 index 000000000..1be989988 --- /dev/null +++ b/tests/ui/offset-of/offset-of-builtin.rs @@ -0,0 +1,44 @@ +#![feature(builtin_syntax)] + +// For the exposed macro we already test these errors in the other files, +// but this test helps to make sure the builtin construct also errors. +// This has the same examples as offset-of-arg-count.rs + +fn main() { + builtin # offset_of(NotEnoughArguments); //~ ERROR expected one of +} +fn t1() { + // Already errored upon at the macro level. Yielding an error would require + // extra effort. + builtin # offset_of(NotEnoughArgumentsWithAComma, ); +} +fn t2() { + builtin # offset_of(Container, field, too many arguments); //~ ERROR expected identifier, found + //~| ERROR found `,` + //~| ERROR found `many` + //~| ERROR found `arguments` +} +fn t3() { + builtin # offset_of(S, f); // compiles fine +} +fn t4() { + // Already errored upon at the macro level. Yielding an error would require + // extra effort. + builtin # offset_of(S, f); +} +fn t5() { + builtin # offset_of(S, f.); //~ ERROR expected identifier +} +fn t6() { + builtin # offset_of(S, f.,); //~ ERROR expected identifier +} +fn t7() { + builtin # offset_of(S, f..); //~ ERROR expected one of +} +fn t8() { + // Already errored upon at the macro level. Yielding an error would require + // extra effort. + builtin # offset_of(S, f..,); +} + +struct S { f: u8, } diff --git a/tests/ui/offset-of/offset-of-builtin.stderr b/tests/ui/offset-of/offset-of-builtin.stderr new file mode 100644 index 000000000..1a1f33cc6 --- /dev/null +++ b/tests/ui/offset-of/offset-of-builtin.stderr @@ -0,0 +1,65 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, or `<`, found `)` + --> $DIR/offset-of-builtin.rs:8:43 + | +LL | builtin # offset_of(NotEnoughArguments); + | ^ expected one of `!`, `(`, `+`, `,`, `::`, or `<` + +error: expected identifier, found `,` + --> $DIR/offset-of-builtin.rs:16:41 + | +LL | builtin # offset_of(Container, field, too many arguments); + | ^ + | | + | expected identifier + | help: remove this comma + +error: expected one of `)` or `.`, found `,` + --> $DIR/offset-of-builtin.rs:16:41 + | +LL | builtin # offset_of(Container, field, too many arguments); + | ^ + | | + | expected one of `)` or `.` + | help: missing `.` + +error: expected one of `)` or `.`, found `many` + --> $DIR/offset-of-builtin.rs:16:47 + | +LL | builtin # offset_of(Container, field, too many arguments); + | -^^^^ expected one of `)` or `.` + | | + | help: missing `.` + +error: expected one of `)` or `.`, found `arguments` + --> $DIR/offset-of-builtin.rs:16:52 + | +LL | builtin # offset_of(Container, field, too many arguments); + | -^^^^^^^^^ expected one of `)` or `.` + | | + | help: missing `.` + +error: expected identifier, found `)` + --> $DIR/offset-of-builtin.rs:30:30 + | +LL | builtin # offset_of(S, f.); + | ^ expected identifier + +error: expected identifier, found `,` + --> $DIR/offset-of-builtin.rs:33:30 + | +LL | builtin # offset_of(S, f.,); + | ^ expected identifier + +error: expected one of `)` or `.`, found `..` + --> $DIR/offset-of-builtin.rs:36:29 + | +LL | builtin # offset_of(S, f..); + | ^^ expected one of `)` or `.` + | +help: if you meant to bind the contents of the rest of the array pattern into `f`, use `@` + | +LL | builtin # offset_of(S, f @ ..); + | + + +error: aborting due to 8 previous errors + diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs new file mode 100644 index 000000000..3b8dc0b84 --- /dev/null +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -0,0 +1,49 @@ +#![feature(offset_of, extern_types)] + +use std::mem::offset_of; + +struct Alpha { + x: u8, + y: u16, + z: [u8], +} + +trait Trait {} + +struct Beta { + x: u8, + y: u16, + z: dyn Trait, +} + +extern { + type Extern; +} + +struct Gamma { + x: u8, + y: u16, + z: Extern, +} + +struct Delta<T: ?Sized> { + x: u8, + y: u16, + z: T, +} + +fn main() { + offset_of!(Alpha, z); //~ ERROR the size for values of type + offset_of!(Beta, z); //~ ERROR the size for values of type + offset_of!(Gamma, z); //~ ERROR the size for values of type +} + +fn delta() { + offset_of!(Delta<Alpha>, z); //~ ERROR the size for values of type + offset_of!(Delta<Extern>, z); //~ ERROR the size for values of type + offset_of!(Delta<dyn Trait>, z); //~ ERROR the size for values of type +} + +fn generic_with_maybe_sized<T: ?Sized>() -> usize { + offset_of!(Delta<T>, z) //~ ERROR the size for values of type +} diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr new file mode 100644 index 000000000..128c783d5 --- /dev/null +++ b/tests/ui/offset-of/offset-of-dst-field.stderr @@ -0,0 +1,77 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:36:5 + | +LL | offset_of!(Alpha, z); + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:37:5 + | +LL | offset_of!(Beta, z); + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `Extern` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:38:5 + | +LL | offset_of!(Gamma, z); + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Extern` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `Extern` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:43:5 + | +LL | offset_of!(Delta<Extern>, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Extern` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:44:5 + | +LL | offset_of!(Delta<dyn Trait>, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Trait` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:42:5 + | +LL | offset_of!(Delta<Alpha>, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Alpha`, the trait `Sized` is not implemented for `[u8]` +note: required because it appears within the type `Alpha` + --> $DIR/offset-of-dst-field.rs:5:8 + | +LL | struct Alpha { + | ^^^^^ + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:48:5 + | +LL | fn generic_with_maybe_sized<T: ?Sized>() -> usize { + | - this type parameter needs to be `std::marker::Sized` +LL | offset_of!(Delta<T>, z) + | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn generic_with_maybe_sized<T: ?Sized>() -> usize { +LL + fn generic_with_maybe_sized<T>() -> usize { + | + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/offset-of/offset-of-enum.rs b/tests/ui/offset-of/offset-of-enum.rs new file mode 100644 index 000000000..d73505821 --- /dev/null +++ b/tests/ui/offset-of/offset-of-enum.rs @@ -0,0 +1,13 @@ +#![feature(offset_of)] + +use std::mem::offset_of; + +enum Alpha { + One(u8), + Two(u8), +} + +fn main() { + offset_of!(Alpha::One, 0); //~ ERROR expected type, found variant `Alpha::One` + offset_of!(Alpha, Two.0); //~ ERROR no field `Two` on type `Alpha` +} diff --git a/tests/ui/offset-of/offset-of-enum.stderr b/tests/ui/offset-of/offset-of-enum.stderr new file mode 100644 index 000000000..6958d199f --- /dev/null +++ b/tests/ui/offset-of/offset-of-enum.stderr @@ -0,0 +1,19 @@ +error[E0573]: expected type, found variant `Alpha::One` + --> $DIR/offset-of-enum.rs:11:16 + | +LL | offset_of!(Alpha::One, 0); + | ^^^^^^^^^^ + | | + | not a type + | help: try using the variant's enum: `Alpha` + +error[E0609]: no field `Two` on type `Alpha` + --> $DIR/offset-of-enum.rs:12:23 + | +LL | offset_of!(Alpha, Two.0); + | ^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0573, E0609. +For more information about an error, try `rustc --explain E0573`. diff --git a/tests/ui/offset-of/offset-of-inference.rs b/tests/ui/offset-of/offset-of-inference.rs new file mode 100644 index 000000000..ba87574ea --- /dev/null +++ b/tests/ui/offset-of/offset-of-inference.rs @@ -0,0 +1,11 @@ +// Test that inference types in `offset_of!` don't ICE. + +#![feature(offset_of)] + +struct Foo<T> { + x: T, +} + +fn main() { + let _ = core::mem::offset_of!(Foo<_>, x); //~ ERROR: type annotations needed +} diff --git a/tests/ui/offset-of/offset-of-inference.stderr b/tests/ui/offset-of/offset-of-inference.stderr new file mode 100644 index 000000000..2a520f6f9 --- /dev/null +++ b/tests/ui/offset-of/offset-of-inference.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/offset-of-inference.rs:10:35 + | +LL | let _ = core::mem::offset_of!(Foo<_>, x); + | ^^^^^^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/offset-of/offset-of-output-type.rs b/tests/ui/offset-of/offset-of-output-type.rs new file mode 100644 index 000000000..50c2e9384 --- /dev/null +++ b/tests/ui/offset-of/offset-of-output-type.rs @@ -0,0 +1,20 @@ +#![feature(offset_of)] + +use std::mem::offset_of; + +struct S { + v: u8, + w: u16, +} + + +fn main() { + let _: u8 = offset_of!(S, v); //~ ERROR mismatched types + let _: u16 = offset_of!(S, v); //~ ERROR mismatched types + let _: u32 = offset_of!(S, v); //~ ERROR mismatched types + let _: u64 = offset_of!(S, v); //~ ERROR mismatched types + let _: isize = offset_of!(S, v); //~ ERROR mismatched types + let _: usize = offset_of!(S, v); + + offset_of!(S, v) //~ ERROR mismatched types +} diff --git a/tests/ui/offset-of/offset-of-output-type.stderr b/tests/ui/offset-of/offset-of-output-type.stderr new file mode 100644 index 000000000..6f8c94750 --- /dev/null +++ b/tests/ui/offset-of/offset-of-output-type.stderr @@ -0,0 +1,64 @@ +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:12:17 + | +LL | let _: u8 = offset_of!(S, v); + | -- ^^^^^^^^^^^^^^^^ expected `u8`, found `usize` + | | + | expected due to this + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:13:18 + | +LL | let _: u16 = offset_of!(S, v); + | --- ^^^^^^^^^^^^^^^^ expected `u16`, found `usize` + | | + | expected due to this + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:14:18 + | +LL | let _: u32 = offset_of!(S, v); + | --- ^^^^^^^^^^^^^^^^ expected `u32`, found `usize` + | | + | expected due to this + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:15:18 + | +LL | let _: u64 = offset_of!(S, v); + | --- ^^^^^^^^^^^^^^^^ expected `u64`, found `usize` + | | + | expected due to this + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:16:20 + | +LL | let _: isize = offset_of!(S, v); + | ----- ^^^^^^^^^^^^^^^^ expected `isize`, found `usize` + | | + | expected due to this + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/offset-of-output-type.rs:19:5 + | +LL | fn main() { + | - expected `()` because of default return type +... +LL | offset_of!(S, v) + | ^^^^^^^^^^^^^^^^ expected `()`, found `usize` + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/offset-of/offset-of-private.rs b/tests/ui/offset-of/offset-of-private.rs new file mode 100644 index 000000000..6b1a16ba6 --- /dev/null +++ b/tests/ui/offset-of/offset-of-private.rs @@ -0,0 +1,28 @@ +#![feature(offset_of)] + +use std::mem::offset_of; + +mod m { + #[repr(C)] + pub struct Foo { + pub public: u8, + private: u8, + } + #[repr(C)] + pub struct FooTuple(pub u8, u8); + #[repr(C)] + struct Bar { + pub public: u8, + private: u8, + } +} + +fn main() { + offset_of!(m::Foo, public); + offset_of!(m::Foo, private); //~ ERROR field `private` of struct `Foo` is private + offset_of!(m::FooTuple, 0); + offset_of!(m::FooTuple, 1); //~ ERROR field `1` of struct `FooTuple` is private + offset_of!(m::Bar, public); //~ ERROR struct `Bar` is private + offset_of!(m::Bar, private); //~ ERROR struct `Bar` is private + //~| ERROR field `private` of struct `Bar` is private +} diff --git a/tests/ui/offset-of/offset-of-private.stderr b/tests/ui/offset-of/offset-of-private.stderr new file mode 100644 index 000000000..0674b58f8 --- /dev/null +++ b/tests/ui/offset-of/offset-of-private.stderr @@ -0,0 +1,46 @@ +error[E0603]: struct `Bar` is private + --> $DIR/offset-of-private.rs:25:19 + | +LL | offset_of!(m::Bar, public); + | ^^^ private struct + | +note: the struct `Bar` is defined here + --> $DIR/offset-of-private.rs:14:5 + | +LL | struct Bar { + | ^^^^^^^^^^ + +error[E0603]: struct `Bar` is private + --> $DIR/offset-of-private.rs:26:19 + | +LL | offset_of!(m::Bar, private); + | ^^^ private struct + | +note: the struct `Bar` is defined here + --> $DIR/offset-of-private.rs:14:5 + | +LL | struct Bar { + | ^^^^^^^^^^ + +error[E0616]: field `private` of struct `Foo` is private + --> $DIR/offset-of-private.rs:22:24 + | +LL | offset_of!(m::Foo, private); + | ^^^^^^^ private field + +error[E0616]: field `1` of struct `FooTuple` is private + --> $DIR/offset-of-private.rs:24:29 + | +LL | offset_of!(m::FooTuple, 1); + | ^ private field + +error[E0616]: field `private` of struct `Bar` is private + --> $DIR/offset-of-private.rs:26:24 + | +LL | offset_of!(m::Bar, private); + | ^^^^^^^ private field + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0603, E0616. +For more information about an error, try `rustc --explain E0603`. diff --git a/tests/ui/offset-of/offset-of-self.rs b/tests/ui/offset-of/offset-of-self.rs new file mode 100644 index 000000000..dbeef0e74 --- /dev/null +++ b/tests/ui/offset-of/offset-of-self.rs @@ -0,0 +1,58 @@ +#![feature(offset_of)] + +use std::mem::offset_of; + +struct C<T> { + v: T, + w: T, +} + +struct S { + v: u8, + w: u16, +} + +impl S { + fn v_offs() -> usize { + offset_of!(Self, v) + } + fn v_offs_wrong_syntax() { + offset_of!(Self, Self::v); //~ ERROR no rules expected the token `::` + offset_of!(S, Self); //~ ERROR expected identifier, found keyword `Self` + //~| no field `Self` on type `S` + } + fn offs_in_c() -> usize { + offset_of!(C<Self>, w) + } + fn offs_in_c_colon() -> usize { + offset_of!(C::<Self>, w) + } +} + +mod m { + use std::mem::offset_of; + fn off() { + offset_of!(self::S, v); //~ ERROR cannot find type `S` in module + offset_of!(super::S, v); + offset_of!(crate::S, v); + } + impl super::n::T { + fn v_offs_self() -> usize { + offset_of!(Self, v) //~ ERROR field `v` of struct `T` is private + } + } +} + +mod n { + pub struct T { v: u8, } +} + +fn main() { + offset_of!(self::S, v); + offset_of!(Self, v); //~ ERROR cannot find type `Self` in this scope + + offset_of!(S, self); //~ ERROR expected identifier, found keyword `self` + //~| no field `self` on type `S` + offset_of!(S, v.self); //~ ERROR expected identifier, found keyword `self` + //~| no field `self` on type `u8` +} diff --git a/tests/ui/offset-of/offset-of-self.stderr b/tests/ui/offset-of/offset-of-self.stderr new file mode 100644 index 000000000..df555463f --- /dev/null +++ b/tests/ui/offset-of/offset-of-self.stderr @@ -0,0 +1,79 @@ +error: no rules expected the token `::` + --> $DIR/offset-of-self.rs:20:30 + | +LL | offset_of!(Self, Self::v); + | ^^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: expected identifier, found keyword `Self` + --> $DIR/offset-of-self.rs:21:23 + | +LL | offset_of!(S, Self); + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `self` + --> $DIR/offset-of-self.rs:54:19 + | +LL | offset_of!(S, self); + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `self` + --> $DIR/offset-of-self.rs:56:21 + | +LL | offset_of!(S, v.self); + | ^^^^ expected identifier, found keyword + +error[E0412]: cannot find type `S` in module `self` + --> $DIR/offset-of-self.rs:35:26 + | +LL | offset_of!(self::S, v); + | ^ not found in `self` + | +help: consider importing this struct + | +LL + use S; + | +help: if you import `S`, refer to it directly + | +LL - offset_of!(self::S, v); +LL + offset_of!(S, v); + | + +error[E0411]: cannot find type `Self` in this scope + --> $DIR/offset-of-self.rs:52:16 + | +LL | fn main() { + | ---- `Self` not allowed in a function +LL | offset_of!(self::S, v); +LL | offset_of!(Self, v); + | ^^^^ `Self` is only available in impls, traits, and type definitions + +error[E0609]: no field `Self` on type `S` + --> $DIR/offset-of-self.rs:21:23 + | +LL | offset_of!(S, Self); + | ^^^^ + +error[E0616]: field `v` of struct `T` is private + --> $DIR/offset-of-self.rs:41:30 + | +LL | offset_of!(Self, v) + | ^ private field + +error[E0609]: no field `self` on type `S` + --> $DIR/offset-of-self.rs:54:19 + | +LL | offset_of!(S, self); + | ^^^^ + +error[E0609]: no field `self` on type `u8` + --> $DIR/offset-of-self.rs:56:21 + | +LL | offset_of!(S, v.self); + | ^^^^ + +error: aborting due to 10 previous errors + +Some errors have detailed explanations: E0411, E0412, E0609, E0616. +For more information about an error, try `rustc --explain E0411`. diff --git a/tests/ui/offset-of/offset-of-unstable-with-feature.rs b/tests/ui/offset-of/offset-of-unstable-with-feature.rs new file mode 100644 index 000000000..7d2eb46c0 --- /dev/null +++ b/tests/ui/offset-of/offset-of-unstable-with-feature.rs @@ -0,0 +1,20 @@ +// check-pass +// aux-build:offset-of-staged-api.rs + +#![feature(offset_of, unstable_test_feature)] + +use std::mem::offset_of; + +extern crate offset_of_staged_api; + +use offset_of_staged_api::*; + +fn main() { + offset_of!(Unstable, unstable); + offset_of!(Stable, stable); + offset_of!(StableWithUnstableField, unstable); + offset_of!(StableWithUnstableFieldType, stable); + offset_of!(StableWithUnstableFieldType, stable.unstable); + offset_of!(UnstableWithStableFieldType, unstable); + offset_of!(UnstableWithStableFieldType, unstable.stable); +} diff --git a/tests/ui/offset-of/offset-of-unstable.rs b/tests/ui/offset-of/offset-of-unstable.rs new file mode 100644 index 000000000..1e19f2091 --- /dev/null +++ b/tests/ui/offset-of/offset-of-unstable.rs @@ -0,0 +1,31 @@ +// aux-build:offset-of-staged-api.rs + +#![feature(offset_of)] + +use std::mem::offset_of; + +extern crate offset_of_staged_api; + +use offset_of_staged_api::*; + +fn main() { + offset_of!( + //~^ ERROR use of unstable library feature + Unstable, //~ ERROR use of unstable library feature + unstable + ); + offset_of!(Stable, stable); + offset_of!(StableWithUnstableField, unstable); //~ ERROR use of unstable library feature + offset_of!(StableWithUnstableFieldType, stable); + offset_of!(StableWithUnstableFieldType, stable.unstable); //~ ERROR use of unstable library feature + offset_of!( + //~^ ERROR use of unstable library feature + UnstableWithStableFieldType, //~ ERROR use of unstable library feature + unstable + ); + offset_of!( + //~^ ERROR use of unstable library feature + UnstableWithStableFieldType, //~ ERROR use of unstable library feature + unstable.stable + ); +} diff --git a/tests/ui/offset-of/offset-of-unstable.stderr b/tests/ui/offset-of/offset-of-unstable.stderr new file mode 100644 index 000000000..c39882519 --- /dev/null +++ b/tests/ui/offset-of/offset-of-unstable.stderr @@ -0,0 +1,84 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:14:9 + | +LL | Unstable, + | ^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:23:9 + | +LL | UnstableWithStableFieldType, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:28:9 + | +LL | UnstableWithStableFieldType, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:12:5 + | +LL | / offset_of!( +LL | | +LL | | Unstable, +LL | | unstable +LL | | ); + | |_____^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:18:5 + | +LL | offset_of!(StableWithUnstableField, unstable); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:20:5 + | +LL | offset_of!(StableWithUnstableFieldType, stable.unstable); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:21:5 + | +LL | / offset_of!( +LL | | +LL | | UnstableWithStableFieldType, +LL | | unstable +LL | | ); + | |_____^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/offset-of-unstable.rs:26:5 + | +LL | / offset_of!( +LL | | +LL | | UnstableWithStableFieldType, +LL | | unstable.stable +LL | | ); + | |_____^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/optimization-remark.rs b/tests/ui/optimization-remark.rs index 4f651b1dc..8fd30466f 100644 --- a/tests/ui/optimization-remark.rs +++ b/tests/ui/optimization-remark.rs @@ -13,7 +13,7 @@ // [merge1] compile-flags: -Cremark=all -Cremark=giraffe // [merge2] compile-flags: -Cremark=inline -Cremark=giraffe // -// error-pattern: inline: 'f' not inlined into 'g' +// error-pattern: inline (missed): 'f' not inlined into 'g' // dont-check-compiler-stderr #[no_mangle] diff --git a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs index e56f9ffe2..df6aab0e6 100644 --- a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs +++ b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs @@ -3,6 +3,8 @@ // check-pass #![allow(irrefutable_let_patterns)] +#![allow(dropping_copy_types)] +#![allow(dropping_references)] fn main() { // A regression test for a mistake we made at one point: diff --git a/tests/ui/or-patterns/or-patterns-syntactic-fail.rs b/tests/ui/or-patterns/or-patterns-syntactic-fail.rs index 358e9d034..23dbb57cb 100644 --- a/tests/ui/or-patterns/or-patterns-syntactic-fail.rs +++ b/tests/ui/or-patterns/or-patterns-syntactic-fail.rs @@ -8,9 +8,12 @@ use E::*; fn no_top_level_or_patterns() { // We do *not* allow or-patterns at the top level of lambdas... - let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()` + let _ = |A | B: E| (); + //~^ ERROR expected identifier, found // -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`. +} +fn no_top_level_or_patterns_2() { // ...and for now neither do we allow or-patterns at the top level of functions. fn fun1(A | B: E) {} //~^ ERROR top-level or-patterns are not allowed diff --git a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr index 10d42b7e3..c16a90368 100644 --- a/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr +++ b/tests/ui/or-patterns/or-patterns-syntactic-fail.stderr @@ -1,43 +1,34 @@ +error: expected identifier, found `:` + --> $DIR/or-patterns-syntactic-fail.rs:11:19 + | +LL | let _ = |A | B: E| (); + | ^ expected identifier + | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> + error: top-level or-patterns are not allowed in function parameters - --> $DIR/or-patterns-syntactic-fail.rs:15:13 + --> $DIR/or-patterns-syntactic-fail.rs:18:13 | LL | fn fun1(A | B: E) {} | ^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in function parameters - --> $DIR/or-patterns-syntactic-fail.rs:18:13 + --> $DIR/or-patterns-syntactic-fail.rs:21:13 | LL | fn fun2(| A | B: E) {} | ^^^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in `let` bindings - --> $DIR/or-patterns-syntactic-fail.rs:23:9 + --> $DIR/or-patterns-syntactic-fail.rs:26:9 | LL | let A | B: E = A; | ^^^^^ help: wrap the pattern in parentheses: `(A | B)` error: top-level or-patterns are not allowed in `let` bindings - --> $DIR/or-patterns-syntactic-fail.rs:26:9 + --> $DIR/or-patterns-syntactic-fail.rs:29:9 | LL | let | A | B: E = A; | ^^^^^^^ help: wrap the pattern in parentheses: `(A | B)` -error[E0369]: no implementation for `E | ()` - --> $DIR/or-patterns-syntactic-fail.rs:11:22 - | -LL | let _ = |A | B: E| (); - | ----^ -- () - | | - | E - | -note: an implementation of `BitOr<_>` might be missing for `E` - --> $DIR/or-patterns-syntactic-fail.rs:6:1 - | -LL | enum E { A, B } - | ^^^^^^ must implement `BitOr<_>` -note: the trait `BitOr` must be implemented - --> $SRC_DIR/core/src/ops/bit.rs:LL:COL - error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/packed/issue-27060.stderr b/tests/ui/packed/issue-27060.stderr index b4753284f..4dc31a283 100644 --- a/tests/ui/packed/issue-27060.stderr +++ b/tests/ui/packed/issue-27060.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 4 previous errors diff --git a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr index 32943b0f0..57630a4b4 100644 --- a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr +++ b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to previous error diff --git a/tests/ui/packed/packed-struct-borrow-element.stderr b/tests/ui/packed/packed-struct-borrow-element.stderr index 29d867fc5..c1f749d6f 100644 --- a/tests/ui/packed/packed-struct-borrow-element.stderr +++ b/tests/ui/packed/packed-struct-borrow-element.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 2 previous errors diff --git a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs index d555b5319..ba917b52d 100644 --- a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs +++ b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs @@ -3,7 +3,6 @@ #![crate_type = "rlib"] #![no_std] -#![feature(c_unwind)] extern "C-unwind" fn foo() {} diff --git a/tests/ui/panics/default-backtrace-ice.rs b/tests/ui/panics/default-backtrace-ice.rs index fd86a3f9d..b40203c33 100644 --- a/tests/ui/panics/default-backtrace-ice.rs +++ b/tests/ui/panics/default-backtrace-ice.rs @@ -2,8 +2,20 @@ // compile-flags:-Z treat-err-as-bug=1 // error-pattern:stack backtrace: // failure-status:101 +// ignore-msvc // normalize-stderr-test "note: .*" -> "" // normalize-stderr-test "thread 'rustc' .*" -> "" -// normalize-stderr-test " .*\n" -> "" +// normalize-stderr-test " +\d+:.*__rust_begin_short_backtrace.*" -> "(begin_short_backtrace)" +// normalize-stderr-test " +\d+:.*__rust_end_short_backtrace.*" -> "(end_short_backtrace)" +// normalize-stderr-test " +\d+:.*\n" -> "" +// normalize-stderr-test " +at .*\n" -> "" +// +// This test makes sure that full backtraces are used for ICEs when +// RUST_BACKTRACE is not set. It does this by checking for the presence of +// `__rust_{begin,end}_short_backtrace` markers, which only appear in full +// backtraces. The rest of the backtrace is filtered out. +// +// Ignored on msvc becaue the `__rust_{begin,end}_short_backtrace` symbols +// aren't reliable. fn main() { missing_ident; } diff --git a/tests/ui/panics/default-backtrace-ice.stderr b/tests/ui/panics/default-backtrace-ice.stderr index 4bd4780e2..815ce4dd0 100644 --- a/tests/ui/panics/default-backtrace-ice.stderr +++ b/tests/ui/panics/default-backtrace-ice.stderr @@ -1,8 +1,15 @@ error[E0425]: cannot find value `missing_ident` in this scope + --> $DIR/default-backtrace-ice.rs:21:13 + | LL | fn main() { missing_ident; } + | ^^^^^^^^^^^^^ not found in this scope stack backtrace: +(end_short_backtrace) +(begin_short_backtrace) +(end_short_backtrace) +(begin_short_backtrace) error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/ui/panics/fmt-only-once.rs b/tests/ui/panics/fmt-only-once.rs new file mode 100644 index 000000000..6211bf961 --- /dev/null +++ b/tests/ui/panics/fmt-only-once.rs @@ -0,0 +1,21 @@ +// run-fail +// check-run-results +// exec-env:RUST_BACKTRACE=0 + +// Test that we format the panic message only once. +// Regression test for https://github.com/rust-lang/rust/issues/110717 + +use std::fmt; + +struct PrintOnFmt; + +impl fmt::Display for PrintOnFmt { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + eprintln!("fmt"); + f.write_str("PrintOnFmt") + } +} + +fn main() { + panic!("{}", PrintOnFmt) +} diff --git a/tests/ui/panics/fmt-only-once.run.stderr b/tests/ui/panics/fmt-only-once.run.stderr new file mode 100644 index 000000000..39bd06881 --- /dev/null +++ b/tests/ui/panics/fmt-only-once.run.stderr @@ -0,0 +1,3 @@ +fmt +thread 'main' panicked at 'PrintOnFmt', $DIR/fmt-only-once.rs:20:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/nested_panic_caught.rs b/tests/ui/panics/nested_panic_caught.rs new file mode 100644 index 000000000..d43886e80 --- /dev/null +++ b/tests/ui/panics/nested_panic_caught.rs @@ -0,0 +1,24 @@ +// run-pass +// needs-unwind + +// Checks that nested panics work correctly. + +use std::panic::catch_unwind; + +fn double() { + struct Double; + + impl Drop for Double { + fn drop(&mut self) { + let _ = catch_unwind(|| panic!("twice")); + } + } + + let _d = Double; + + panic!("once"); +} + +fn main() { + assert!(catch_unwind(|| double()).is_err()); +} diff --git a/tests/ui/panics/panic-short-backtrace-windows-x86_64.rs b/tests/ui/panics/panic-short-backtrace-windows-x86_64.rs index 39ffe86dd..be83eb748 100644 --- a/tests/ui/panics/panic-short-backtrace-windows-x86_64.rs +++ b/tests/ui/panics/panic-short-backtrace-windows-x86_64.rs @@ -1,6 +1,6 @@ // This test has been spuriously failing a lot recently (#92000). // Ignore it until the underlying issue is fixed. -// ignore-test +// ignore-test (#92000) // Regression test for #87481: short backtrace formatting cut off the entire stack trace. diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.rs b/tests/ui/panics/short-ice-remove-middle-frames-2.rs new file mode 100644 index 000000000..38a80f8b6 --- /dev/null +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.rs @@ -0,0 +1,61 @@ +// compile-flags:-Cstrip=none +// run-fail +// check-run-results +// exec-env:RUST_BACKTRACE=1 +// ignore-android FIXME #17520 +// ignore-wasm no panic support +// 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. + +/// This test case make sure that we can have multiple pairs of `__rust_{begin,end}_short_backtrace` + +#[inline(never)] +fn __rust_begin_short_backtrace<T, F: FnOnce() -> T>(f: F) -> T { + let result = f(); + std::hint::black_box(result) +} + +#[inline(never)] +fn __rust_end_short_backtrace<T, F: FnOnce() -> T>(f: F) -> T { + let result = f(); + std::hint::black_box(result) +} + +fn first() { + __rust_end_short_backtrace(|| second()); +} + +fn second() { + third(); // won't show up +} + +fn third() { + fourth(); // won't show up +} + +fn fourth() { + __rust_begin_short_backtrace(|| fifth()); +} + +fn fifth() { + __rust_end_short_backtrace(|| sixth()); +} + +fn sixth() { + seven(); // won't show up +} + +fn seven() { + __rust_begin_short_backtrace(|| eight()); +} + +fn eight() { + panic!("debug!!!"); +} + +fn main() { + first(); +} 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 new file mode 100644 index 000000000..2592b7479 --- /dev/null +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -0,0 +1,11 @@ +thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames-2.rs:56:5 +stack backtrace: + 0: std::panicking::begin_panic + 1: short_ice_remove_middle_frames_2::eight + 2: short_ice_remove_middle_frames_2::seven::{{closure}} + 3: short_ice_remove_middle_frames_2::fifth + 4: short_ice_remove_middle_frames_2::fourth::{{closure}} + 5: short_ice_remove_middle_frames_2::first + 6: short_ice_remove_middle_frames_2::main + 7: core::ops::function::FnOnce::call_once +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/panics/short-ice-remove-middle-frames.rs b/tests/ui/panics/short-ice-remove-middle-frames.rs new file mode 100644 index 000000000..c872084f0 --- /dev/null +++ b/tests/ui/panics/short-ice-remove-middle-frames.rs @@ -0,0 +1,57 @@ +// compile-flags:-Cstrip=none +// run-fail +// check-run-results +// exec-env:RUST_BACKTRACE=1 +// ignore-android FIXME #17520 +// ignore-wasm no panic support +// 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. + + +#[inline(never)] +fn __rust_begin_short_backtrace<T, F: FnOnce() -> T>(f: F) -> T { + let result = f(); + std::hint::black_box(result) +} + +#[inline(never)] +fn __rust_end_short_backtrace<T, F: FnOnce() -> T>(f: F) -> T { + let result = f(); + std::hint::black_box(result) +} + +fn first() { + __rust_end_short_backtrace(|| second()); + // do not take effect since we already has a inner call of __rust_end_short_backtrace +} + +fn second() { + __rust_end_short_backtrace(|| third()); +} + +fn third() { + fourth(); // won't show up in backtrace +} + +fn fourth() { + fifth(); // won't show up in backtrace +} + +fn fifth() { + __rust_begin_short_backtrace(|| sixth()); +} + +fn sixth() { + seven(); +} + +fn seven() { + panic!("debug!!!"); +} + +fn main() { + first(); +} diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr new file mode 100644 index 000000000..9c15f2e08 --- /dev/null +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -0,0 +1,12 @@ +thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames.rs:52:5 +stack backtrace: + 0: std::panicking::begin_panic + 1: short_ice_remove_middle_frames::seven + 2: short_ice_remove_middle_frames::sixth + 3: short_ice_remove_middle_frames::fifth::{{closure}} + 4: short_ice_remove_middle_frames::second + 5: short_ice_remove_middle_frames::first::{{closure}} + 6: short_ice_remove_middle_frames::first + 7: short_ice_remove_middle_frames::main + 8: core::ops::function::FnOnce::call_once +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.rs b/tests/ui/parser/attr-stmt-expr-attr-bad.rs index c94a32146..d1950087c 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.rs +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.rs @@ -6,6 +6,7 @@ fn main() {} //~^ ERROR expected one of #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } //~^ ERROR an inner attribute is not permitted in this context +//~| ERROR an inner attribute is not permitted in this context //~| ERROR expected expression, found `)` #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } //~^ ERROR an inner attribute is not permitted in this context diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr index a857f11fd..96899fd3f 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -19,6 +19,15 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files = note: outer attributes, like `#[test]`, annotate the item following them +error: an inner attribute is not permitted in this context + --> $DIR/attr-stmt-expr-attr-bad.rs:7:36 + | +LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } + | ^^^^^^^^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files + = note: outer attributes, like `#[test]`, annotate the item following them + error: expected expression, found `)` --> $DIR/attr-stmt-expr-attr-bad.rs:7:44 | @@ -26,7 +35,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:10:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:11:38 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^^^^^^^^ @@ -35,13 +44,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `)` - --> $DIR/attr-stmt-expr-attr-bad.rs:10:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:11:46 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:13:36 + --> $DIR/attr-stmt-expr-attr-bad.rs:14:36 | LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } | ^^^^^^^^ @@ -50,7 +59,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:15:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:16:33 | LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } | ^^^^^^^^ @@ -59,7 +68,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:17:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:18:33 | LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } | ^^^^^^^^ @@ -68,13 +77,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:19:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:20:34 | LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; } | ^ expected one of 8 possible tokens error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:21:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:22:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } | ^^^^^^^^ @@ -83,7 +92,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:23:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:24:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } | ^^^^^^^^ @@ -92,7 +101,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:25:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:26:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } | ^^^^^^^^ @@ -101,7 +110,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:27:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:28:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } | ^^^^^^^^ @@ -110,19 +119,19 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:29:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:30:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; } | ^^ expected expression error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:31:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:32:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..; } | ^^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:33:41 + --> $DIR/attr-stmt-expr-attr-bad.rs:34:41 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } | ^^^^^^^^ @@ -131,7 +140,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:35:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:36:45 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } | ^^^^^^^^ @@ -140,7 +149,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:37:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:38:37 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -149,7 +158,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:39:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:40:38 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } | ^^^^^^^^ @@ -158,13 +167,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:41:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:42:40 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:43:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:44:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -173,7 +182,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:45:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:46:46 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -182,7 +191,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:47:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:48:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | ---- ^^^^^^^ ------- the attributes are attached to this branch @@ -191,7 +200,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:49:50 + --> $DIR/attr-stmt-expr-attr-bad.rs:50:50 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -200,7 +209,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:51:51 + --> $DIR/attr-stmt-expr-attr-bad.rs:52:51 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } | ^^^^^^^^ @@ -209,7 +218,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:53:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:54:45 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -218,7 +227,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:55:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:56:46 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -227,13 +236,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:57:48 + --> $DIR/attr-stmt-expr-attr-bad.rs:58:48 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:59:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:60:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -242,7 +251,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:61:54 + --> $DIR/attr-stmt-expr-attr-bad.rs:62:54 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -251,7 +260,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:63:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:64:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; } | ---- ^^^^^^^ --------------- the attributes are attached to this branch @@ -260,7 +269,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {} | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:65:66 + --> $DIR/attr-stmt-expr-attr-bad.rs:66:66 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -269,7 +278,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {} | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:67:67 + --> $DIR/attr-stmt-expr-attr-bad.rs:68:67 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -278,7 +287,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]} = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:70:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:71:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -289,7 +298,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:72:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:73:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -300,7 +309,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:74:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:75:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -316,7 +325,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!(); } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:76:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:77:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -332,7 +341,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo![]; } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:78:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:79:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; } | ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation @@ -348,7 +357,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!{}; } | error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:84:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:85:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^^^ help: use `..` instead @@ -356,13 +365,13 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:84:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:85:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^ expected one of `=>`, `if`, or `|` error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:87:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:88:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^^^ help: use `..` instead @@ -370,19 +379,19 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:87:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:88:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:90:39 + --> $DIR/attr-stmt-expr-attr-bad.rs:91:39 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } } | ^ error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:92:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:93:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^^^ help: use `..` instead @@ -390,47 +399,47 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:92:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:93:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:96:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:97:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:96:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:97:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:100:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:100:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:104:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:105:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } } | ^^^^^^^ error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:106:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:107:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } } | ^^^^^^^ -error: aborting due to 52 previous errors +error: aborting due to 53 previous errors For more information about this error, try `rustc --explain E0586`. diff --git a/tests/ui/parser/builtin-syntax.rs b/tests/ui/parser/builtin-syntax.rs new file mode 100644 index 000000000..897dab8ec --- /dev/null +++ b/tests/ui/parser/builtin-syntax.rs @@ -0,0 +1,9 @@ +#![feature(builtin_syntax)] + +fn main() { + builtin # foobar(); //~ ERROR unknown `builtin #` construct +} + +fn not_identifier() { + builtin # {}(); //~ ERROR expected identifier after +} diff --git a/tests/ui/parser/builtin-syntax.stderr b/tests/ui/parser/builtin-syntax.stderr new file mode 100644 index 000000000..ee3764a62 --- /dev/null +++ b/tests/ui/parser/builtin-syntax.stderr @@ -0,0 +1,14 @@ +error: unknown `builtin #` construct `foobar` + --> $DIR/builtin-syntax.rs:4:5 + | +LL | builtin # foobar(); + | ^^^^^^^^^^^^^^^^ + +error: expected identifier after `builtin #` + --> $DIR/builtin-syntax.rs:8:15 + | +LL | builtin # {}(); + | ^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 653be5b3b..e34d855a9 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `dyn` - --> $DIR/dyn-trait-compatibility.rs:3:11 - | -LL | type A1 = dyn::dyn; - | ^^^ use of undeclared crate or module `dyn` - error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:1:11 | @@ -46,6 +40,12 @@ error[E0412]: cannot find type `dyn` in this scope LL | type A3 = dyn<<dyn as dyn>::dyn>; | ^^^ not found in this scope +error[E0433]: failed to resolve: use of undeclared crate or module `dyn` + --> $DIR/dyn-trait-compatibility.rs:3:11 + | +LL | type A1 = dyn::dyn; + | ^^^ use of undeclared crate or module `dyn` + error: aborting due to 8 previous errors Some errors have detailed explanations: E0405, E0412, E0433. diff --git a/tests/ui/parser/eq-less-to-less-eq.rs b/tests/ui/parser/eq-less-to-less-eq.rs new file mode 100644 index 000000000..23c6c59d7 --- /dev/null +++ b/tests/ui/parser/eq-less-to-less-eq.rs @@ -0,0 +1,33 @@ +fn foo() { + let a = 0; + let b = 4; + if a =< b { //~ERROR + println!("yay!"); + } +} + +fn bar() { + let a = 0; + let b = 4; + if a = <b { //~ERROR + println!("yay!"); + } +} + +fn baz() { + let a = 0; + let b = 4; + if a = < b { //~ERROR + println!("yay!"); + } +} + +fn qux() { + let a = 0; + let b = 4; + if a =< i32>::abs(-4) { //~ERROR: mismatched types + println!("yay!"); + } +} + +fn main() {} diff --git a/tests/ui/parser/eq-less-to-less-eq.stderr b/tests/ui/parser/eq-less-to-less-eq.stderr new file mode 100644 index 000000000..4717d8287 --- /dev/null +++ b/tests/ui/parser/eq-less-to-less-eq.stderr @@ -0,0 +1,34 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `{` + --> $DIR/eq-less-to-less-eq.rs:4:15 + | +LL | if a =< b { + | -- ^ expected one of 7 possible tokens + | | + | help: did you mean: `<=` + +error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `{` + --> $DIR/eq-less-to-less-eq.rs:12:15 + | +LL | if a = <b { + | ^ expected one of 7 possible tokens + +error: expected one of `!`, `(`, `+`, `::`, `<`, `>`, or `as`, found `{` + --> $DIR/eq-less-to-less-eq.rs:20:16 + | +LL | if a = < b { + | ^ expected one of 7 possible tokens + +error[E0308]: mismatched types + --> $DIR/eq-less-to-less-eq.rs:28:8 + | +LL | if a =< i32>::abs(-4) { + | ^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to compare for equality + | +LL | if a ==< i32>::abs(-4) { + | + + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/impl-on-unsized-typo.rs b/tests/ui/parser/impl-on-unsized-typo.rs new file mode 100644 index 000000000..e09c04630 --- /dev/null +++ b/tests/ui/parser/impl-on-unsized-typo.rs @@ -0,0 +1,6 @@ +trait Tr {} + +impl<T ?Sized> Tr for T {} +//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `?` + +fn main() {} diff --git a/tests/ui/parser/impl-on-unsized-typo.stderr b/tests/ui/parser/impl-on-unsized-typo.stderr new file mode 100644 index 000000000..23dcc1efd --- /dev/null +++ b/tests/ui/parser/impl-on-unsized-typo.stderr @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, `=`, or `>`, found `?` + --> $DIR/impl-on-unsized-typo.rs:3:8 + | +LL | impl<T ?Sized> Tr for T {} + | ^ expected one of `,`, `:`, `=`, or `>` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-111148.rs b/tests/ui/parser/issues/issue-111148.rs new file mode 100644 index 000000000..2502beab4 --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.rs @@ -0,0 +1,2 @@ +fn a<<i<Y<w<># +//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` diff --git a/tests/ui/parser/issues/issue-111148.stderr b/tests/ui/parser/issues/issue-111148.stderr new file mode 100644 index 000000000..e6595a5cb --- /dev/null +++ b/tests/ui/parser/issues/issue-111148.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `<` + --> $DIR/issue-111148.rs:1:6 + | +LL | fn a<<i<Y<w<># + | ^ expected one of `#`, `>`, `const`, identifier, or lifetime + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-111416.rs b/tests/ui/parser/issues/issue-111416.rs new file mode 100644 index 000000000..cfd1b6b99 --- /dev/null +++ b/tests/ui/parser/issues/issue-111416.rs @@ -0,0 +1,3 @@ +fn main() { + let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments +} diff --git a/tests/ui/parser/issues/issue-111416.stderr b/tests/ui/parser/issues/issue-111416.stderr new file mode 100644 index 000000000..ddacf4d6d --- /dev/null +++ b/tests/ui/parser/issues/issue-111416.stderr @@ -0,0 +1,18 @@ +error: invalid `struct` delimiters or `fn` call arguments + --> $DIR/issue-111416.rs:2:14 + | +LL | let my = monad_bind(mx, T: Try); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: if `monad_bind` is a struct, use braces as delimiters + | +LL | let my = monad_bind { mx, T: Try }; + | ~ ~ +help: if `monad_bind` is a function, use the arguments directly + | +LL - let my = monad_bind(mx, T: Try); +LL + let my = monad_bind(mx, Try); + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-33418.fixed b/tests/ui/parser/issues/issue-33418.fixed deleted file mode 100644 index ed885ae14..000000000 --- a/tests/ui/parser/issues/issue-33418.fixed +++ /dev/null @@ -1,19 +0,0 @@ -// run-rustfix - -trait Tr {} -//~^ ERROR negative bounds are not supported -trait Tr2: SuperA {} -//~^ ERROR negative bounds are not supported -trait Tr3: SuperB {} -//~^ ERROR negative bounds are not supported -trait Tr4: SuperB + SuperD {} -//~^ ERROR negative bounds are not supported -trait Tr5 {} -//~^ ERROR negative bounds are not supported - -trait SuperA {} -trait SuperB {} -trait SuperC {} -trait SuperD {} - -fn main() {} diff --git a/tests/ui/parser/issues/issue-33418.rs b/tests/ui/parser/issues/issue-33418.rs index 9934284ab..4ebd5871e 100644 --- a/tests/ui/parser/issues/issue-33418.rs +++ b/tests/ui/parser/issues/issue-33418.rs @@ -1,5 +1,3 @@ -// run-rustfix - trait Tr: !SuperA {} //~^ ERROR negative bounds are not supported trait Tr2: SuperA + !SuperB {} @@ -7,10 +5,12 @@ trait Tr2: SuperA + !SuperB {} trait Tr3: !SuperA + SuperB {} //~^ ERROR negative bounds are not supported trait Tr4: !SuperA + SuperB - + !SuperC + SuperD {} +//~^ ERROR negative bounds are not supported ++ !SuperC + SuperD {} //~^ ERROR negative bounds are not supported trait Tr5: !SuperA - + !SuperB {} +//~^ ERROR negative bounds are not supported ++ !SuperB {} //~^ ERROR negative bounds are not supported trait SuperA {} diff --git a/tests/ui/parser/issues/issue-33418.stderr b/tests/ui/parser/issues/issue-33418.stderr index 9a8733e89..b111bcfd2 100644 --- a/tests/ui/parser/issues/issue-33418.stderr +++ b/tests/ui/parser/issues/issue-33418.stderr @@ -1,36 +1,44 @@ error: negative bounds are not supported - --> $DIR/issue-33418.rs:3:9 + --> $DIR/issue-33418.rs:1:11 | LL | trait Tr: !SuperA {} - | ^^^^^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-33418.rs:5:19 + --> $DIR/issue-33418.rs:3:21 | LL | trait Tr2: SuperA + !SuperB {} - | ^^^^^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-33418.rs:7:10 + --> $DIR/issue-33418.rs:5:12 | LL | trait Tr3: !SuperA + SuperB {} - | ^^^^^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-33418.rs:9:10 + --> $DIR/issue-33418.rs:7:12 | LL | trait Tr4: !SuperA + SuperB - | ^^^^^^^^^ -LL | + !SuperC + SuperD {} - | ^^^^^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-33418.rs:12:10 + --> $DIR/issue-33418.rs:9:3 + | +LL | + !SuperC + SuperD {} + | ^ + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:11:12 | LL | trait Tr5: !SuperA - | ^^^^^^^^^ -LL | + !SuperB {} - | ^^^^^^^^^ negative bounds are not supported + | ^ + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:13:3 + | +LL | + !SuperB {} + | ^ -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs index 7bd4b3a16..3d110adef 100644 --- a/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs +++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs @@ -10,14 +10,14 @@ pub fn index_after_as_cast() { vec![1, 2, 3] as Vec<i32>[0]; //~^ ERROR: cast cannot be followed by indexing vec![1, 2, 3]: Vec<i32>[0]; - //~^ ERROR: type ascription cannot be followed by indexing + //~^ ERROR: expected one of } pub fn index_after_cast_to_index() { (&[0]) as &[i32][0]; //~^ ERROR: cast cannot be followed by indexing (&[0i32]): &[i32; 1][0]; - //~^ ERROR: type ascription cannot be followed by indexing + //~^ ERROR: expected one of } pub fn cast_after_cast() { @@ -25,7 +25,7 @@ pub fn cast_after_cast() { } if 5u64: u64: u64 == 0u64 { - + //~^ ERROR expected `{`, found `:` } let _ = 5u64: u64: u64 as u8 as i8 == 9i8; let _ = 0i32: i32: i32; @@ -36,26 +36,46 @@ pub fn cast_after_cast() { } pub fn cast_cast_method_call() { - let _ = 0i32: i32: i32.count_ones(); - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0 as i32: i32.count_ones(); - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0i32: i32 as i32.count_ones(); - //~^ ERROR: cast cannot be followed by a method call + let _ = 0i32: i32: i32.count_ones(); //~ ERROR expected one of +} + +pub fn cast_cast_method_call_2() { + let _ = 0 as i32: i32.count_ones(); //~ ERROR expected one of +} + +pub fn cast_cast_method_call_3() { + let _ = 0i32: i32 as i32.count_ones(); //~ ERROR expected one of +} + +pub fn cast_cast_method_call_4() { let _ = 0 as i32 as i32.count_ones(); //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32: i32 as u32 as i32.count_ones(); - //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32.count_ones(): u32; - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0 as i32.count_ones(): u32; +} + +pub fn cast_cast_method_call_5() { + let _ = 0i32: i32: i32 as u32 as i32.count_ones(); //~ ERROR expected one of +} + +pub fn cast_cast_method_call_6() { + let _ = 0i32: i32.count_ones(): u32; //~ ERROR expected one of +} + +pub fn cast_cast_method_call_7() { + let _ = 0 as i32.count_ones(): u32; //~ ERROR expected one of //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32.count_ones() as u32; - //~^ ERROR: type ascription cannot be followed by a method call +} + +pub fn cast_cast_method_call_8() { + let _ = 0i32: i32.count_ones() as u32; //~ ERROR expected one of +} + +pub fn cast_cast_method_call_9() { let _ = 0 as i32.count_ones() as u32; //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32: i32.count_ones() as u32 as i32; - //~^ ERROR: type ascription cannot be followed by a method call +} + +pub fn cast_cast_method_call_10() { + let _ = 0i32: i32: i32.count_ones() as u32 as i32; //~ ERROR expected one of } pub fn multiline_error() { @@ -74,8 +94,7 @@ pub fn precedence() { pub fn method_calls() { 0 as i32.max(0); //~^ ERROR: cast cannot be followed by a method call - 0: i32.max(0); - //~^ ERROR: type ascription cannot be followed by a method call + 0: i32.max(0); //~ ERROR expected one of } pub fn complex() { @@ -84,7 +103,7 @@ pub fn complex() { if true { 33 } else { 44 } as i32.max(0), //~^ ERROR: cast cannot be followed by a method call if true { 33 } else { 44 }: i32.max(0) - //~^ ERROR: type ascription cannot be followed by a method call + //~^ ERROR: expected one of ); } @@ -93,7 +112,7 @@ pub fn in_condition() { //~^ ERROR: cast cannot be followed by a method call } if 5u64: u64.max(0) == 0 { - //~^ ERROR: type ascription cannot be followed by a method call + //~^ ERROR: expected `{`, found `:` } } @@ -104,7 +123,7 @@ pub fn inside_block() { } else { false }; let _ = if true { 5u64: u64.max(0) == 0 - //~^ ERROR: type ascription cannot be followed by a method call + //~^ ERROR: expected one of } else { false }; } @@ -112,14 +131,14 @@ static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]); //~^ ERROR: cast cannot be followed by indexing static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); -//~^ ERROR: type ascription cannot be followed by indexing +//~^ ERROR: expected one of pub fn cast_then_try() -> Result<u64,u64> { Err(0u64) as Result<u64,u64>?; //~^ ERROR: cast cannot be followed by `?` Err(0u64): Result<u64,u64>?; - //~^ ERROR: type ascription cannot be followed by `?` + //~^ ERROR: expected one of Ok(1) } @@ -131,13 +150,14 @@ pub fn cast_then_call() { drop as F(); //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] drop_ptr: F(); - //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] + //~^ ERROR: expected identifier, found `:` } pub fn cast_to_fn_should_work() { let drop_ptr = drop as fn(u8); drop as fn(u8); drop_ptr: fn(u8); + //~^ ERROR expected one of } pub fn parens_after_cast_error() { @@ -145,7 +165,7 @@ pub fn parens_after_cast_error() { drop as fn(u8)(0); //~^ ERROR: cast cannot be followed by a function call drop_ptr: fn(u8)(0); - //~^ ERROR: type ascription cannot be followed by a function call + //~^ ERROR: expected one of } pub async fn cast_then_await() { @@ -153,7 +173,7 @@ pub async fn cast_then_await() { //~^ ERROR: cast cannot be followed by `.await` Box::pin(noop()): Pin<Box<_>>.await; - //~^ ERROR: type ascription cannot be followed by `.await` + //~^ ERROR: expected one of } pub async fn noop() {} @@ -167,5 +187,5 @@ pub fn struct_field() { Foo::default() as Foo.bar; //~^ ERROR: cannot be followed by a field access Foo::default(): Foo.bar; - //~^ ERROR: type ascription cannot be followed by a field access + //~^ ERROR expected one of } diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr index 0c328bde2..d313c888e 100644 --- a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr +++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr @@ -9,21 +9,11 @@ help: try surrounding the expression in parentheses LL | (vec![1, 2, 3] as Vec<i32>)[0]; | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:12:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:12:18 | LL | vec![1, 2, 3]: Vec<i32>[0]; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (vec![1, 2, 3]: Vec<i32>)[0]; - | + + -help: alternatively, remove the type ascription - | -LL - vec![1, 2, 3]: Vec<i32>[0]; -LL + vec![1, 2, 3][0]; - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by indexing --> $DIR/issue-35813-postfix-after-cast.rs:17:5 @@ -36,67 +26,50 @@ help: try surrounding the expression in parentheses LL | ((&[0]) as &[i32])[0]; | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:19:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:19:14 | LL | (&[0i32]): &[i32; 1][0]; - | ^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses + | ^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: expected `{`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:27:12 | -LL | ((&[0i32]): &[i32; 1])[0]; - | + + -help: alternatively, remove the type ascription +LL | if 5u64: u64: u64 == 0u64 { + | ^ expected `{` | -LL - (&[0i32]): &[i32; 1][0]; -LL + (&[0i32])[0]; +note: the `if` expression is missing a block after this condition + --> $DIR/issue-35813-postfix-after-cast.rs:27:8 | +LL | if 5u64: u64: u64 == 0u64 { + | ^^^^ -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:39:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:39:17 | LL | let _ = 0i32: i32: i32.count_ones(); - | ^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32: i32).count_ones(); - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32: i32.count_ones(); -LL + let _ = 0i32: i32.count_ones(); + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:41:13 +error: expected one of `!`, `(`, `.`, `::`, `;`, `<`, `?`, or `else`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:43:21 | LL | let _ = 0 as i32: i32.count_ones(); - | ^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0 as i32: i32).count_ones(); - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0 as i32: i32.count_ones(); -LL + let _ = 0 as i32.count_ones(); + | ^ expected one of 8 possible tokens | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:43:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:47:17 | LL | let _ = 0i32: i32 as i32.count_ones(); - | ^^^^^^^^^^^^^^^^ + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32 as i32).count_ones(); - | + + + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:45:13 + --> $DIR/issue-35813-postfix-after-cast.rs:51:13 | LL | let _ = 0 as i32 as i32.count_ones(); | ^^^^^^^^^^^^^^^ @@ -106,35 +79,24 @@ help: try surrounding the expression in parentheses LL | let _ = (0 as i32 as i32).count_ones(); | + + -error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:47:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:56:17 | LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | -LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones(); - | + + + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:49:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:60:17 | LL | let _ = 0i32: i32.count_ones(): u32; - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32).count_ones(): u32; - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32.count_ones(): u32; -LL + let _ = 0i32.count_ones(): u32; + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:51:13 + --> $DIR/issue-35813-postfix-after-cast.rs:64:13 | LL | let _ = 0 as i32.count_ones(): u32; | ^^^^^^^^ @@ -144,24 +106,24 @@ help: try surrounding the expression in parentheses LL | let _ = (0 as i32).count_ones(): u32; | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:53:13 +error: expected one of `.`, `;`, `?`, or `else`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:64:34 | -LL | let _ = 0i32: i32.count_ones() as u32; - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses +LL | let _ = 0 as i32.count_ones(): u32; + | ^ expected one of `.`, `;`, `?`, or `else` | -LL | let _ = (0i32: i32).count_ones() as u32; - | + + -help: alternatively, remove the type ascription + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:69:17 | -LL - let _ = 0i32: i32.count_ones() as u32; -LL + let _ = 0i32.count_ones() as u32; +LL | let _ = 0i32: i32.count_ones() as u32; + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:55:13 + --> $DIR/issue-35813-postfix-after-cast.rs:73:13 | LL | let _ = 0 as i32.count_ones() as u32; | ^^^^^^^^ @@ -171,24 +133,16 @@ help: try surrounding the expression in parentheses LL | let _ = (0 as i32).count_ones() as u32; | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:57:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:78:17 | LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32; - | ^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | let _ = (0i32: i32: i32).count_ones() as u32 as i32; - | + + -help: alternatively, remove the type ascription - | -LL - let _ = 0i32: i32: i32.count_ones() as u32 as i32; -LL + let _ = 0i32: i32.count_ones() as u32 as i32; + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:62:13 + --> $DIR/issue-35813-postfix-after-cast.rs:82:13 | LL | let _ = 0 | _____________^ @@ -202,7 +156,7 @@ LL ~ as i32) | error: cast cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:70:18 + --> $DIR/issue-35813-postfix-after-cast.rs:90:18 | LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -213,7 +167,7 @@ LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0]; | + + error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:75:5 + --> $DIR/issue-35813-postfix-after-cast.rs:95:5 | LL | 0 as i32.max(0); | ^^^^^^^^ @@ -223,24 +177,14 @@ help: try surrounding the expression in parentheses LL | (0 as i32).max(0); | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:77:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:97:6 | LL | 0: i32.max(0); - | ^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (0: i32).max(0); - | + + -help: alternatively, remove the type ascription - | -LL - 0: i32.max(0); -LL + 0.max(0); - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:92:8 + --> $DIR/issue-35813-postfix-after-cast.rs:111:8 | LL | if 5u64 as i32.max(0) == 0 { | ^^^^^^^^^^^ @@ -250,24 +194,20 @@ help: try surrounding the expression in parentheses LL | if (5u64 as i32).max(0) == 0 { | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:95:8 +error: expected `{`, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:114:12 | LL | if 5u64: u64.max(0) == 0 { - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | if (5u64: u64).max(0) == 0 { - | + + -help: alternatively, remove the type ascription + | ^ expected `{` | -LL - if 5u64: u64.max(0) == 0 { -LL + if 5u64.max(0) == 0 { +note: the `if` expression is missing a block after this condition + --> $DIR/issue-35813-postfix-after-cast.rs:114:8 | +LL | if 5u64: u64.max(0) == 0 { + | ^^^^ error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:102:9 + --> $DIR/issue-35813-postfix-after-cast.rs:121:9 | LL | 5u64 as u32.max(0) == 0 | ^^^^^^^^^^^ @@ -277,24 +217,14 @@ help: try surrounding the expression in parentheses LL | (5u64 as u32).max(0) == 0 | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:106:9 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:125:13 | LL | 5u64: u64.max(0) == 0 - | ^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (5u64: u64).max(0) == 0 - | + + -help: alternatively, remove the type ascription - | -LL - 5u64: u64.max(0) == 0 -LL + 5u64.max(0) == 0 - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:111:24 + --> $DIR/issue-35813-postfix-after-cast.rs:130:24 | LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]); | ^^^^^^^^^^^^^^^^^^ @@ -304,24 +234,14 @@ help: try surrounding the expression in parentheses LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]); | + + -error: type ascription cannot be followed by indexing - --> $DIR/issue-35813-postfix-after-cast.rs:114:25 +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:133:36 | LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]); - | + + -help: alternatively, remove the type ascription - | -LL - static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); -LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]); - | + | ^ expected one of `)`, `,`, `.`, `?`, or an operator error: cast cannot be followed by `?` - --> $DIR/issue-35813-postfix-after-cast.rs:119:5 + --> $DIR/issue-35813-postfix-after-cast.rs:138:5 | LL | Err(0u64) as Result<u64,u64>?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -331,24 +251,28 @@ help: try surrounding the expression in parentheses LL | (Err(0u64) as Result<u64,u64>)?; | + + -error: type ascription cannot be followed by `?` - --> $DIR/issue-35813-postfix-after-cast.rs:121:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:140:14 | LL | Err(0u64): Result<u64,u64>?; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses + | ^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: expected identifier, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:152:13 | -LL | (Err(0u64): Result<u64,u64>)?; - | + + -help: alternatively, remove the type ascription +LL | drop_ptr: F(); + | ^ expected identifier | -LL - Err(0u64): Result<u64,u64>?; -LL + Err(0u64)?; + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:159:13 | +LL | drop_ptr: fn(u8); + | ^ expected one of 8 possible tokens error: cast cannot be followed by a function call - --> $DIR/issue-35813-postfix-after-cast.rs:145:5 + --> $DIR/issue-35813-postfix-after-cast.rs:165:5 | LL | drop as fn(u8)(0); | ^^^^^^^^^^^^^^ @@ -358,24 +282,14 @@ help: try surrounding the expression in parentheses LL | (drop as fn(u8))(0); | + + -error: type ascription cannot be followed by a function call - --> $DIR/issue-35813-postfix-after-cast.rs:147:5 +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:167:13 | LL | drop_ptr: fn(u8)(0); - | ^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (drop_ptr: fn(u8))(0); - | + + -help: alternatively, remove the type ascription - | -LL - drop_ptr: fn(u8)(0); -LL + drop_ptr(0); - | + | ^ expected one of 8 possible tokens error: cast cannot be followed by `.await` - --> $DIR/issue-35813-postfix-after-cast.rs:152:5 + --> $DIR/issue-35813-postfix-after-cast.rs:172:5 | LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -385,24 +299,14 @@ help: try surrounding the expression in parentheses LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await; | + + -error: type ascription cannot be followed by `.await` - --> $DIR/issue-35813-postfix-after-cast.rs:155:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:175:21 | LL | Box::pin(noop()): Pin<Box<_>>.await; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Box::pin(noop()): Pin<Box<_>>).await; - | + + -help: alternatively, remove the type ascription - | -LL - Box::pin(noop()): Pin<Box<_>>.await; -LL + Box::pin(noop()).await; - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by a field access - --> $DIR/issue-35813-postfix-after-cast.rs:167:5 + --> $DIR/issue-35813-postfix-after-cast.rs:187:5 | LL | Foo::default() as Foo.bar; | ^^^^^^^^^^^^^^^^^^^^^ @@ -412,24 +316,14 @@ help: try surrounding the expression in parentheses LL | (Foo::default() as Foo).bar; | + + -error: type ascription cannot be followed by a field access - --> $DIR/issue-35813-postfix-after-cast.rs:169:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:189:19 | LL | Foo::default(): Foo.bar; - | ^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (Foo::default(): Foo).bar; - | + + -help: alternatively, remove the type ascription - | -LL - Foo::default(): Foo.bar; -LL + Foo::default().bar; - | + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: cast cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:84:9 + --> $DIR/issue-35813-postfix-after-cast.rs:103:9 | LL | if true { 33 } else { 44 } as i32.max(0), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -439,34 +333,18 @@ help: try surrounding the expression in parentheses LL | (if true { 33 } else { 44 } as i32).max(0), | + + -error: type ascription cannot be followed by a method call - --> $DIR/issue-35813-postfix-after-cast.rs:86:9 +error: expected one of `,`, `.`, `?`, or an operator, found `:` + --> $DIR/issue-35813-postfix-after-cast.rs:105:35 | LL | if true { 33 } else { 44 }: i32.max(0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try surrounding the expression in parentheses - | -LL | (if true { 33 } else { 44 }: i32).max(0) - | + + -help: alternatively, remove the type ascription - | -LL - if true { 33 } else { 44 }: i32.max(0) -LL + if true { 33 } else { 44 }.max(0) - | + | ^ expected one of `,`, `.`, `?`, or an operator error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-35813-postfix-after-cast.rs:131:13 + --> $DIR/issue-35813-postfix-after-cast.rs:150:13 | LL | drop as F(); | ^^^ only `Fn` traits may use parentheses -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-35813-postfix-after-cast.rs:133:15 - | -LL | drop_ptr: F(); - | ^^^ only `Fn` traits may use parentheses - -error: aborting due to 36 previous errors +error: aborting due to 39 previous errors For more information about this error, try `rustc --explain E0214`. diff --git a/tests/ui/parser/issues/issue-44406.rs b/tests/ui/parser/issues/issue-44406.rs index a5b7e83a0..6719e5828 100644 --- a/tests/ui/parser/issues/issue-44406.rs +++ b/tests/ui/parser/issues/issue-44406.rs @@ -6,5 +6,4 @@ macro_rules! foo { fn main() { foo!(true); - //~^ ERROR expected identifier, found keyword } diff --git a/tests/ui/parser/issues/issue-44406.stderr b/tests/ui/parser/issues/issue-44406.stderr index de02ea85b..69ff64c27 100644 --- a/tests/ui/parser/issues/issue-44406.stderr +++ b/tests/ui/parser/issues/issue-44406.stderr @@ -1,14 +1,3 @@ -error: expected identifier, found keyword `true` - --> $DIR/issue-44406.rs:8:10 - | -LL | foo!(true); - | ^^^^ expected identifier, found keyword - | -help: escape `true` to use it as an identifier - | -LL | foo!(r#true); - | ++ - error: invalid `struct` delimiters or `fn` call arguments --> $DIR/issue-44406.rs:3:9 | @@ -29,5 +18,5 @@ LL - bar(baz: $rest) LL + bar(: $rest) | -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-62913.rs b/tests/ui/parser/issues/issue-62913.rs index 0db06f636..a55ef5ac7 100644 --- a/tests/ui/parser/issues/issue-62913.rs +++ b/tests/ui/parser/issues/issue-62913.rs @@ -1,4 +1,4 @@ "\u\\" //~^ ERROR incorrect unicode escape sequence //~| ERROR invalid trailing slash in literal -//~| ERROR expected item, found `"\u\\"` +//~| ERROR expected item, found `"\u\"` diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed index 95019b278..2c42f9731 100644 --- a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed @@ -6,9 +6,12 @@ fn main() {} -pub fn f1<T>() {} +pub fn f1<T: 'static>() {} //~^ ERROR negative bounds are not supported -pub fn f2<'a, T: Ord>() {} +//~| ERROR `!` may only modify trait bounds, not lifetime bound +pub fn f2<'a, T: Ord + 'a>() {} //~^ ERROR negative bounds are not supported -pub fn f3<'a, T: Ord>() {} +//~| ERROR `!` may only modify trait bounds, not lifetime bound +pub fn f3<'a, T: 'a + Ord>() {} //~^ ERROR negative bounds are not supported +//~| ERROR `!` may only modify trait bounds, not lifetime bound diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs index 82f54f8fa..e510efaae 100644 --- a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs @@ -8,7 +8,10 @@ fn main() {} pub fn f1<T: !'static>() {} //~^ ERROR negative bounds are not supported +//~| ERROR `!` may only modify trait bounds, not lifetime bound pub fn f2<'a, T: Ord + !'a>() {} //~^ ERROR negative bounds are not supported +//~| ERROR `!` may only modify trait bounds, not lifetime bound pub fn f3<'a, T: !'a + Ord>() {} //~^ ERROR negative bounds are not supported +//~| ERROR `!` may only modify trait bounds, not lifetime bound diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr index a4a422948..91fe02db3 100644 --- a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr @@ -1,20 +1,38 @@ +error: `!` may only modify trait bounds, not lifetime bounds + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:14 + | +LL | pub fn f1<T: !'static>() {} + | ^ + +error: `!` may only modify trait bounds, not lifetime bounds + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:12:24 + | +LL | pub fn f2<'a, T: Ord + !'a>() {} + | ^ + +error: `!` may only modify trait bounds, not lifetime bounds + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:15:18 + | +LL | pub fn f3<'a, T: !'a + Ord>() {} + | ^ + error: negative bounds are not supported - --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:12 + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:14 | LL | pub fn f1<T: !'static>() {} - | ^^^^^^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:22 + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:12:24 | LL | pub fn f2<'a, T: Ord + !'a>() {} - | ^^^^^ negative bounds are not supported + | ^ error: negative bounds are not supported - --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:13:16 + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:15:18 | LL | pub fn f3<'a, T: !'a + Ord>() {} - | ^^^^^ negative bounds are not supported + | ^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/parser/issues/issue-91461.rs b/tests/ui/parser/issues/issue-91461.rs index 3e3c411c4..80e0940ad 100644 --- a/tests/ui/parser/issues/issue-91461.rs +++ b/tests/ui/parser/issues/issue-91461.rs @@ -1,6 +1,5 @@ fn main() { a(_:b:,) - //~^ ERROR: expected identifier, found reserved identifier `_` - //~| ERROR: expected type, found `,` - //~| ERROR: expected type, found `,` + //~^ ERROR expected identifier, found reserved identifier + //~| ERROR: expected one of } diff --git a/tests/ui/parser/issues/issue-91461.stderr b/tests/ui/parser/issues/issue-91461.stderr index 94fcf1721..27e1b5cdc 100644 --- a/tests/ui/parser/issues/issue-91461.stderr +++ b/tests/ui/parser/issues/issue-91461.stderr @@ -4,28 +4,11 @@ error: expected identifier, found reserved identifier `_` LL | a(_:b:,) | ^ expected identifier, found reserved identifier -error: expected type, found `,` - --> $DIR/issue-91461.rs:2:11 +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` + --> $DIR/issue-91461.rs:2:8 | LL | a(_:b:,) - | - -^ expected type - | | | - | | tried to parse a type due to this type ascription - | while parsing this struct - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information - -error: expected type, found `,` - --> $DIR/issue-91461.rs:2:11 - | -LL | a(_:b:,) - | -^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + | ^ expected one of `)`, `,`, `.`, `?`, or an operator -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/item-kw-case-mismatch.fixed b/tests/ui/parser/item-kw-case-mismatch.fixed index 1794268f2..4b99537fb 100644 --- a/tests/ui/parser/item-kw-case-mismatch.fixed +++ b/tests/ui/parser/item-kw-case-mismatch.fixed @@ -4,31 +4,31 @@ fn main() {} -use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case -use std::ptr::write; //~ ERROR keyword `use` is written in a wrong case +use std::ptr::read; //~ ERROR keyword `use` is written in the wrong case +use std::ptr::write; //~ ERROR keyword `use` is written in the wrong case async fn _a() {} -//~^ ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `fn` is written in the wrong case fn _b() {} -//~^ ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `fn` is written in the wrong case async fn _c() {} -//~^ ERROR keyword `async` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `async` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case async fn _d() {} -//~^ ERROR keyword `async` is written in a wrong case +//~^ ERROR keyword `async` is written in the wrong case const unsafe fn _e() {} -//~^ ERROR keyword `const` is written in a wrong case -//~| ERROR keyword `unsafe` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `const` is written in the wrong case +//~| ERROR keyword `unsafe` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case unsafe extern fn _f() {} -//~^ ERROR keyword `unsafe` is written in a wrong case -//~| ERROR keyword `extern` is written in a wrong case +//~^ ERROR keyword `unsafe` is written in the wrong case +//~| ERROR keyword `extern` is written in the wrong case extern "C" fn _g() {} -//~^ ERROR keyword `extern` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `extern` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.rs b/tests/ui/parser/item-kw-case-mismatch.rs index ac8390efd..b11ec9375 100644 --- a/tests/ui/parser/item-kw-case-mismatch.rs +++ b/tests/ui/parser/item-kw-case-mismatch.rs @@ -4,31 +4,31 @@ fn main() {} -Use std::ptr::read; //~ ERROR keyword `use` is written in a wrong case -USE std::ptr::write; //~ ERROR keyword `use` is written in a wrong case +Use std::ptr::read; //~ ERROR keyword `use` is written in the wrong case +USE std::ptr::write; //~ ERROR keyword `use` is written in the wrong case async Fn _a() {} -//~^ ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `fn` is written in the wrong case Fn _b() {} -//~^ ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `fn` is written in the wrong case aSYNC fN _c() {} -//~^ ERROR keyword `async` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `async` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case Async fn _d() {} -//~^ ERROR keyword `async` is written in a wrong case +//~^ ERROR keyword `async` is written in the wrong case CONST UNSAFE FN _e() {} -//~^ ERROR keyword `const` is written in a wrong case -//~| ERROR keyword `unsafe` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `const` is written in the wrong case +//~| ERROR keyword `unsafe` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case unSAFE EXTern fn _f() {} -//~^ ERROR keyword `unsafe` is written in a wrong case -//~| ERROR keyword `extern` is written in a wrong case +//~^ ERROR keyword `unsafe` is written in the wrong case +//~| ERROR keyword `extern` is written in the wrong case EXTERN "C" FN _g() {} -//~^ ERROR keyword `extern` is written in a wrong case -//~| ERROR keyword `fn` is written in a wrong case +//~^ ERROR keyword `extern` is written in the wrong case +//~| ERROR keyword `fn` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.stderr b/tests/ui/parser/item-kw-case-mismatch.stderr index e66dae825..ba59ea853 100644 --- a/tests/ui/parser/item-kw-case-mismatch.stderr +++ b/tests/ui/parser/item-kw-case-mismatch.stderr @@ -1,82 +1,82 @@ -error: keyword `use` is written in a wrong case +error: keyword `use` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:7:1 | LL | Use std::ptr::read; | ^^^ help: write it in the correct case (notice the capitalization): `use` -error: keyword `use` is written in a wrong case +error: keyword `use` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:8:1 | LL | USE std::ptr::write; | ^^^ help: write it in the correct case: `use` -error: keyword `fn` is written in a wrong case +error: keyword `fn` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:10:7 | LL | async Fn _a() {} | ^^ help: write it in the correct case (notice the capitalization): `fn` -error: keyword `fn` is written in a wrong case +error: keyword `fn` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:13:1 | LL | Fn _b() {} | ^^ help: write it in the correct case (notice the capitalization): `fn` -error: keyword `async` is written in a wrong case +error: keyword `async` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:16:1 | LL | aSYNC fN _c() {} | ^^^^^ help: write it in the correct case: `async` -error: keyword `fn` is written in a wrong case +error: keyword `fn` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:16:7 | LL | aSYNC fN _c() {} | ^^ help: write it in the correct case: `fn` -error: keyword `async` is written in a wrong case +error: keyword `async` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:20:1 | LL | Async fn _d() {} | ^^^^^ help: write it in the correct case: `async` -error: keyword `const` is written in a wrong case +error: keyword `const` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:23:1 | LL | CONST UNSAFE FN _e() {} | ^^^^^ help: write it in the correct case: `const` -error: keyword `unsafe` is written in a wrong case +error: keyword `unsafe` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:23:7 | LL | CONST UNSAFE FN _e() {} | ^^^^^^ help: write it in the correct case: `unsafe` -error: keyword `fn` is written in a wrong case +error: keyword `fn` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:23:14 | LL | CONST UNSAFE FN _e() {} | ^^ help: write it in the correct case: `fn` -error: keyword `unsafe` is written in a wrong case +error: keyword `unsafe` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:1 | LL | unSAFE EXTern fn _f() {} | ^^^^^^ help: write it in the correct case: `unsafe` -error: keyword `extern` is written in a wrong case +error: keyword `extern` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:8 | LL | unSAFE EXTern fn _f() {} | ^^^^^^ help: write it in the correct case: `extern` -error: keyword `extern` is written in a wrong case +error: keyword `extern` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:32:1 | LL | EXTERN "C" FN _g() {} | ^^^^^^ help: write it in the correct case: `extern` -error: keyword `fn` is written in a wrong case +error: keyword `fn` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:32:12 | LL | EXTERN "C" FN _g() {} diff --git a/tests/ui/parser/recover-unticked-labels.stderr b/tests/ui/parser/recover-unticked-labels.stderr index c115dffb1..fbd108ca6 100644 --- a/tests/ui/parser/recover-unticked-labels.stderr +++ b/tests/ui/parser/recover-unticked-labels.stderr @@ -2,13 +2,17 @@ error: expected a label, found an identifier --> $DIR/recover-unticked-labels.rs:5:26 | LL | 'label: loop { break label 0 }; - | ^^^^^ help: labels start with a tick: `'label` + | -^^^^ + | | + | help: labels start with a tick error: expected a label, found an identifier --> $DIR/recover-unticked-labels.rs:6:29 | LL | 'label: loop { continue label }; - | ^^^^^ help: labels start with a tick: `'label` + | -^^^^ + | | + | help: labels start with a tick error[E0425]: cannot find value `label` in this scope --> $DIR/recover-unticked-labels.rs:4:26 diff --git a/tests/ui/parser/use-colon-as-mod-sep.stderr b/tests/ui/parser/use-colon-as-mod-sep.stderr index e825dfed1..bfc5374ef 100644 --- a/tests/ui/parser/use-colon-as-mod-sep.stderr +++ b/tests/ui/parser/use-colon-as-mod-sep.stderr @@ -11,18 +11,24 @@ error: expected `::`, found `:` | LL | use std:fs::File; | ^ help: use double colon + | + = note: import paths are delimited using `::` error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:7:8 | LL | use std:collections:HashMap; | ^ help: use double colon + | + = note: import paths are delimited using `::` error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:7:20 | LL | use std:collections:HashMap; | ^ help: use double colon + | + = note: import paths are delimited using `::` error: aborting due to 4 previous errors diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs index fbdefd9d3..43b53b7cf 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs @@ -2,6 +2,9 @@ // Test `@` patterns combined with `box` patterns. +#![allow(dropping_references)] +#![allow(dropping_copy_types)] + #![feature(box_patterns)] #[derive(Copy, Clone)] diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index 9305facc4..3ce48b1a7 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -54,14 +54,6 @@ LL | ref mut a @ box ref b => { | | | value is mutably borrowed by `a` here -error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-at-and-box.rs:54:11 - | -LL | fn f5(ref mut a @ box ref b: Box<NC>) { - | ^^^^^^^^^ ----- value is borrowed by `b` here - | | - | value is mutably borrowed by `a` here - error[E0382]: borrow of moved value --> $DIR/borrowck-pat-at-and-box.rs:31:9 | @@ -120,6 +112,14 @@ LL | ref mut a @ box ref b => { LL | drop(b); | - immutable borrow later used here +error: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-at-and-box.rs:54:11 + | +LL | fn f5(ref mut a @ box ref b: Box<NC>) { + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | + | value is mutably borrowed by `a` here + error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-at-and-box.rs:54:11 | diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs index 0108861cf..1df51c0ed 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs @@ -2,6 +2,8 @@ // Test `Copy` bindings in the rhs of `@` patterns. +#![allow(dropping_copy_types)] + #[derive(Copy, Clone)] struct C; diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index 13989ebad..1ed019f0a 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -286,78 +286,6 @@ help: borrow this binding in the pattern to avoid moving the value LL | ref mut a @ Some([ref b, ref mut c]) => {} | +++ -error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11 - | -LL | fn f1(a @ ref b: U) {} - | ^ ----- value borrowed here after move - | | - | value moved into `a` here - | move occurs because `a` has type `U` which does not implement the `Copy` trait - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | fn f1(ref a @ ref b: U) {} - | +++ - -error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 - | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ^^^^^ ----- ----- value borrowed here after move - | | | - | | value borrowed here after move - | value moved into `a` here - | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | +++ - -error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20 - | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ^ ----- value borrowed here after move - | | - | value moved into `b` here - | move occurs because `b` has type `U` which does not implement the `Copy` trait - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {} - | +++ - -error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31 - | -LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | ^^^^^ ----- value borrowed here after move - | | - | value moved into `d` here - | move occurs because `d` has type `U` which does not implement the `Copy` trait - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {} - | +++ - -error: borrow of moved value - --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11 - | -LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} - | ^ --------- ----- value borrowed here after move - | | | - | | value borrowed here after move - | value moved into `a` here - | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {} - | +++ - error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 | @@ -447,6 +375,63 @@ LL | mut a @ Some([ref b, ref mut c]) => {} | | | value moved here +error: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11 + | +LL | fn f1(a @ ref b: U) {} + | ^ ----- value borrowed here after move + | | + | value moved into `a` here + | move occurs because `a` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f1(ref a @ ref b: U) {} + | +++ + +error: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 + | +LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | ^^^^^ ----- ----- value borrowed here after move + | | | + | | value borrowed here after move + | value moved into `a` here + | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | +++ + +error: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20 + | +LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | ^ ----- value borrowed here after move + | | + | value moved into `b` here + | move occurs because `b` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {} + | +++ + +error: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31 + | +LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} + | ^^^^^ ----- value borrowed here after move + | | + | value moved into `d` here + | move occurs because `d` has type `U` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {} + | +++ + error[E0382]: use of partially moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 | @@ -457,6 +442,21 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} | = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait +error: borrow of moved value + --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11 + | +LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} + | ^ --------- ----- value borrowed here after move + | | | + | | value borrowed here after move + | value moved into `a` here + | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {} + | +++ + error: aborting due to 33 previous errors For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index 00593b2a9..c8c4d9b8f 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -166,48 +166,6 @@ LL | ref mut a @ Some([b, mut c]) => {} | | value is moved into `b` here | value is mutably borrowed by `a` here -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:11:11 - | -LL | fn f1(ref a @ b: U) {} - | ^^^^^ - value is moved into `b` here - | | - | value is borrowed by `a` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:14:11 - | -LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | ^^^^^ ----- - value is moved into `e` here - | | | - | | value is moved into `c` here - | value is borrowed by `a` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:14:20 - | -LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | ^^^^^ ----- value is moved into `c` here - | | - | value is borrowed by `b` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:14:35 - | -LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | ^^^^^ - value is moved into `e` here - | | - | value is borrowed by `d` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-by-move-and-ref.rs:20:11 - | -LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} - | ^^^^^^^^^ - ----- value is moved into `c` here - | | | - | | value is moved into `b` here - | value is mutably borrowed by `a` here - error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:30:9 | @@ -306,6 +264,14 @@ help: borrow this binding in the pattern to avoid moving the value LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {} | +++ +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-by-move-and-ref.rs:11:11 + | +LL | fn f1(ref a @ b: U) {} + | ^^^^^ - value is moved into `b` here + | | + | value is borrowed by `a` here + error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:11:11 | @@ -315,6 +281,31 @@ LL | fn f1(ref a @ b: U) {} | value borrowed here after move | move occurs because value has type `U`, which does not implement the `Copy` trait +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-by-move-and-ref.rs:14:11 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^ ----- - value is moved into `e` here + | | | + | | value is moved into `c` here + | value is borrowed by `a` here + +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-by-move-and-ref.rs:14:20 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^ ----- value is moved into `c` here + | | + | value is borrowed by `b` here + +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-by-move-and-ref.rs:14:35 + | +LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} + | ^^^^^ - value is moved into `e` here + | | + | value is borrowed by `d` here + error[E0382]: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:14:20 | @@ -335,6 +326,15 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} | = note: move occurs because value has type `U`, which does not implement the `Copy` trait +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-by-move-and-ref.rs:20:11 + | +LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | + | | value is moved into `b` here + | value is mutably borrowed by `a` here + error[E0382]: borrow of partially moved value --> $DIR/borrowck-pat-by-move-and-ref.rs:20:11 | diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index d6409d1b6..c0a6558a1 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -221,47 +221,6 @@ LL | let ref mut a @ (ref b, ref c) = (U, U); | | value is borrowed by `b` here | value is mutably borrowed by `a` here -error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:22:11 - | -LL | fn f1(ref a @ ref mut b: U) {} - | ^^^^^ --------- value is mutably borrowed by `b` here - | | - | value is borrowed by `a` here - -error: cannot borrow value as immutable because it is also borrowed as mutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11 - | -LL | fn f2(ref mut a @ ref b: U) {} - | ^^^^^^^^^ ----- value is borrowed by `b` here - | | - | value is mutably borrowed by `a` here - -error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11 - | -LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {} - | ^^^^^ ----------- value is mutably borrowed by `mid` here - | | - | value is borrowed by `a` here - -error: cannot borrow value as mutable because it is also borrowed as immutable - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:22 - | -LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} - | ^^^^^ --------- - value is moved into `c` here - | | | - | | value is mutably borrowed by `b` here - | value is borrowed by `a` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30 - | -LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} - | ^^^^^^^^^ - value is moved into `c` here - | | - | value is mutably borrowed by `b` here - error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:8:31 | @@ -398,6 +357,47 @@ LL | LL | *b = U; | ------ mutable borrow later used here +error: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:22:11 + | +LL | fn f1(ref a @ ref mut b: U) {} + | ^^^^^ --------- value is mutably borrowed by `b` here + | | + | value is borrowed by `a` here + +error: cannot borrow value as immutable because it is also borrowed as mutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11 + | +LL | fn f2(ref mut a @ ref b: U) {} + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | + | value is mutably borrowed by `a` here + +error: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11 + | +LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {} + | ^^^^^ ----------- value is mutably borrowed by `mid` here + | | + | value is borrowed by `a` here + +error: cannot borrow value as mutable because it is also borrowed as immutable + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:22 + | +LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} + | ^^^^^ --------- - value is moved into `c` here + | | | + | | value is mutably borrowed by `b` here + | value is borrowed by `a` here + +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30 + | +LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} + | ^^^^^^^^^ - value is moved into `c` here + | | + | value is mutably borrowed by `b` here + error[E0382]: borrow of moved value --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30 | diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index 24189d061..c634ea470 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -194,50 +194,6 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { | | | value is mutably borrowed by `a` here -error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:8:11 - | -LL | fn f1(ref mut a @ ref mut b: U) {} - | ^^^^^^^^^ --------- value is mutably borrowed by `b` here - | | - | value is mutably borrowed by `a` here - -error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:10:11 - | -LL | fn f2(ref mut a @ ref mut b: U) {} - | ^^^^^^^^^ --------- value is mutably borrowed by `b` here - | | - | value is mutably borrowed by `a` here - -error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:13:9 - | -LL | ref mut a @ [ - | ^^^^^^^^^ value is mutably borrowed by `a` here -LL | -LL | [ref b @ .., _], - | ----- value is borrowed by `b` here -LL | [_, ref mut mid @ ..], - | ----------- value is mutably borrowed by `mid` here - -error: cannot borrow value as mutable more than once at a time - --> $DIR/borrowck-pat-ref-mut-twice.rs:21:22 - | -LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} - | ^^^^^^^^^ --------- - value is moved into `c` here - | | | - | | value is mutably borrowed by `b` here - | value is mutably borrowed by `a` here - -error: cannot move out of value because it is borrowed - --> $DIR/borrowck-pat-ref-mut-twice.rs:21:34 - | -LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} - | ^^^^^^^^^ - value is moved into `c` here - | | - | value is mutably borrowed by `b` here - error[E0499]: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:29:9 | @@ -304,6 +260,50 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { LL | drop(a); | - first borrow later used here +error: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:8:11 + | +LL | fn f1(ref mut a @ ref mut b: U) {} + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | + | value is mutably borrowed by `a` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:10:11 + | +LL | fn f2(ref mut a @ ref mut b: U) {} + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | + | value is mutably borrowed by `a` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:13:9 + | +LL | ref mut a @ [ + | ^^^^^^^^^ value is mutably borrowed by `a` here +LL | +LL | [ref b @ .., _], + | ----- value is borrowed by `b` here +LL | [_, ref mut mid @ ..], + | ----------- value is mutably borrowed by `mid` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/borrowck-pat-ref-mut-twice.rs:21:22 + | +LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} + | ^^^^^^^^^ --------- - value is moved into `c` here + | | | + | | value is mutably borrowed by `b` here + | value is mutably borrowed by `a` here + +error: cannot move out of value because it is borrowed + --> $DIR/borrowck-pat-ref-mut-twice.rs:21:34 + | +LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} + | ^^^^^^^^^ - value is moved into `c` here + | | + | value is mutably borrowed by `b` here + error[E0382]: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:21:34 | diff --git a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs index a709e34b5..01a978d55 100644 --- a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs +++ b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs @@ -22,8 +22,7 @@ fn case_1() { #[cfg(FALSE)] fn case_2() { let a @ (b: u8); - //~^ ERROR expected one of `!` - //~| ERROR expected one of `)` + //~^ ERROR expected one of `)` } #[cfg(FALSE)] diff --git a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr index 27660ae40..0c109ff6b 100644 --- a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr +++ b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr @@ -9,18 +9,14 @@ error: expected one of `)`, `,`, `@`, or `|`, found `:` | LL | let a @ (b: u8); | ^ expected one of `)`, `,`, `@`, or `|` - -error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `)` - --> $DIR/nested-type-ascription-syntactically-invalid.rs:24:19 | -LL | let a @ (b: u8); - | ^ expected one of 7 possible tokens + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@` - --> $DIR/nested-type-ascription-syntactically-invalid.rs:31:15 + --> $DIR/nested-type-ascription-syntactically-invalid.rs:30:15 | LL | let a: T1 @ Outer(b: T2); | ^ expected one of 7 possible tokens -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs index 5445696fd..204cd3e66 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs @@ -1,5 +1,7 @@ // check-pass +#![allow(dropping_references)] + fn main() {} struct U; diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr index c7c7c074f..a033cc065 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr @@ -112,7 +112,7 @@ LL | *_x0 = U; help: consider changing this to be a mutable reference | LL | let (ref mut _x0, _x1, ref _x2, ..) = tup; - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference --> $DIR/borrowck-move-ref-pattern.rs:27:5 @@ -123,7 +123,7 @@ LL | *_x2 = U; help: consider changing this to be a mutable reference | LL | let (ref _x0, _x1, ref mut _x2, ..) = tup; - | ~~~~~~~~~~~ + | +++ error[E0382]: use of moved value: `tup.1` --> $DIR/borrowck-move-ref-pattern.rs:28:10 diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs index 583f70f41..4de1f653d 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs @@ -1,5 +1,7 @@ // check-pass +#![allow(dropping_references)] + fn main() { struct U; fn accept_fn_once(_: impl FnOnce()) {} diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr index e1349fb02..10fcccb03 100644 --- a/tests/ui/pattern/pattern-error-continue.stderr +++ b/tests/ui/pattern/pattern-error-continue.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `E` - --> $DIR/pattern-error-continue.rs:33:9 - | -LL | E::V => {} - | ^ use of undeclared type `E` - error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D` --> $DIR/pattern-error-continue.rs:18:9 | @@ -56,6 +50,15 @@ note: function defined here LL | fn f(_c: char) {} | ^ -------- +error[E0433]: failed to resolve: use of undeclared type `E` + --> $DIR/pattern-error-continue.rs:33:9 + | +LL | E::V => {} + | ^ + | | + | use of undeclared type `E` + | help: an enum with a similar name exists: `A` + error: aborting due to 5 previous errors Some errors have detailed explanations: E0023, E0308, E0433, E0532. diff --git a/tests/ui/pattern/usefulness/consts-opaque.rs b/tests/ui/pattern/usefulness/consts-opaque.rs index ca4fcd85b..c10c6205a 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.rs +++ b/tests/ui/pattern/usefulness/consts-opaque.rs @@ -20,11 +20,12 @@ const BAR: Bar = Bar; #[derive(PartialEq)] enum Baz { Baz1, - Baz2 + Baz2, } impl Eq for Baz {} const BAZ: Baz = Baz::Baz1; +#[rustfmt::skip] fn main() { match FOO { FOO => {} @@ -124,8 +125,16 @@ fn main() { match WRAPQUUX { Wrap(_) => {} - WRAPQUUX => {} // detected unreachable because we do inspect the `Wrap` layer - //~^ ERROR unreachable pattern + WRAPQUUX => {} + } + + match WRAPQUUX { + Wrap(_) => {} + } + + match WRAPQUUX { + //~^ ERROR: non-exhaustive patterns: `Wrap(_)` not covered + WRAPQUUX => {} } #[derive(PartialEq, Eq)] @@ -138,8 +147,7 @@ fn main() { match WHOKNOWSQUUX { WHOKNOWSQUUX => {} WhoKnows::Yay(_) => {} - WHOKNOWSQUUX => {} // detected unreachable because we do inspect the `WhoKnows` layer - //~^ ERROR unreachable pattern + WHOKNOWSQUUX => {} WhoKnows::Nope => {} } } diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index 3f0b4a9f2..e01b06ccc 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -1,5 +1,5 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:30:9 + --> $DIR/consts-opaque.rs:31:9 | LL | FOO => {} | ^^^ @@ -8,7 +8,7 @@ LL | FOO => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:37:9 + --> $DIR/consts-opaque.rs:38:9 | LL | FOO_REF => {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | FOO_REF => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:45:9 + --> $DIR/consts-opaque.rs:46:9 | LL | FOO_REF_REF => {} | ^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | FOO_REF_REF => {} = note: `#[warn(indirect_structural_match)]` on by default error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:53:9 + --> $DIR/consts-opaque.rs:54:9 | LL | BAR => {} // should not be emitting unreachable warning | ^^^ @@ -38,7 +38,7 @@ LL | BAR => {} // should not be emitting unreachable warning = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:61:9 + --> $DIR/consts-opaque.rs:62:9 | LL | BAR => {} | ^^^ @@ -47,7 +47,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:70:9 + --> $DIR/consts-opaque.rs:71:9 | LL | BAR => {} | ^^^ @@ -56,7 +56,7 @@ LL | BAR => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:72:9 + --> $DIR/consts-opaque.rs:73:9 | LL | BAR => {} // should not be emitting unreachable warning | ^^^ @@ -65,7 +65,7 @@ LL | BAR => {} // should not be emitting unreachable warning = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:80:9 + --> $DIR/consts-opaque.rs:81:9 | LL | BAZ => {} | ^^^ @@ -74,7 +74,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:90:9 + --> $DIR/consts-opaque.rs:91:9 | LL | BAZ => {} | ^^^ @@ -83,7 +83,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:97:9 + --> $DIR/consts-opaque.rs:98:9 | LL | BAZ => {} | ^^^ @@ -92,7 +92,7 @@ LL | BAZ => {} = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: unreachable pattern - --> $DIR/consts-opaque.rs:32:9 + --> $DIR/consts-opaque.rs:33:9 | LL | FOO => {} | --- matches any value @@ -107,7 +107,7 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/consts-opaque.rs:39:9 + --> $DIR/consts-opaque.rs:40:9 | LL | FOO_REF => {} | ------- matches any value @@ -116,7 +116,7 @@ LL | Foo(_) => {} // should not be emitting unreachable warning | ^^^^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:53:9 + --> $DIR/consts-opaque.rs:54:9 | LL | Bar => {} | --- matches any value @@ -124,7 +124,7 @@ LL | BAR => {} // should not be emitting unreachable warning | ^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:56:9 + --> $DIR/consts-opaque.rs:57:9 | LL | Bar => {} | --- matches any value @@ -133,7 +133,7 @@ LL | _ => {} | ^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:63:9 + --> $DIR/consts-opaque.rs:64:9 | LL | BAR => {} | --- matches any value @@ -142,7 +142,7 @@ LL | Bar => {} // should not be emitting unreachable warning | ^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:65:9 + --> $DIR/consts-opaque.rs:66:9 | LL | BAR => {} | --- matches any value @@ -151,7 +151,7 @@ LL | _ => {} | ^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:72:9 + --> $DIR/consts-opaque.rs:73:9 | LL | BAR => {} | --- matches any value @@ -160,7 +160,7 @@ LL | BAR => {} // should not be emitting unreachable warning | ^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:75:9 + --> $DIR/consts-opaque.rs:76:9 | LL | BAR => {} | --- matches any value @@ -169,7 +169,7 @@ LL | _ => {} // should not be emitting unreachable warning | ^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:82:9 + --> $DIR/consts-opaque.rs:83:9 | LL | BAZ => {} | --- matches any value @@ -178,7 +178,7 @@ LL | Baz::Baz1 => {} // should not be emitting unreachable warning | ^^^^^^^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:84:9 + --> $DIR/consts-opaque.rs:85:9 | LL | BAZ => {} | --- matches any value @@ -187,7 +187,7 @@ LL | _ => {} | ^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:92:9 + --> $DIR/consts-opaque.rs:93:9 | LL | BAZ => {} | --- matches any value @@ -196,7 +196,7 @@ LL | _ => {} | ^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:99:9 + --> $DIR/consts-opaque.rs:100:9 | LL | BAZ => {} | --- matches any value @@ -205,7 +205,7 @@ LL | Baz::Baz2 => {} // should not be emitting unreachable warning | ^^^^^^^^^ unreachable pattern error: unreachable pattern - --> $DIR/consts-opaque.rs:101:9 + --> $DIR/consts-opaque.rs:102:9 | LL | BAZ => {} | --- matches any value @@ -213,19 +213,24 @@ LL | BAZ => {} LL | _ => {} // should not be emitting unreachable warning | ^ unreachable pattern -error: unreachable pattern - --> $DIR/consts-opaque.rs:127:9 +error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered + --> $DIR/consts-opaque.rs:135:11 | -LL | Wrap(_) => {} - | ------- matches any value -LL | WRAPQUUX => {} // detected unreachable because we do inspect the `Wrap` layer - | ^^^^^^^^ unreachable pattern - -error: unreachable pattern - --> $DIR/consts-opaque.rs:141:9 +LL | match WRAPQUUX { + | ^^^^^^^^ pattern `Wrap(_)` not covered + | +note: `Wrap<fn(usize, usize) -> usize>` defined here + --> $DIR/consts-opaque.rs:117:12 + | +LL | struct Wrap<T>(T); + | ^^^^ + = note: the matched value is of type `Wrap<fn(usize, usize) -> usize>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ WRAPQUUX => {}, +LL + Wrap(_) => todo!() | -LL | WHOKNOWSQUUX => {} // detected unreachable because we do inspect the `WhoKnows` layer - | ^^^^^^^^^^^^ -error: aborting due to 24 previous errors; 1 warning emitted +error: aborting due to 23 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr index 5a145efce..49b6dfca6 100644 --- a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-match.rs:37:9 + --> $DIR/empty-match.rs:58:9 | LL | _ => {}, | ^ @@ -11,37 +11,52 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-match.rs:40:9 + --> $DIR/empty-match.rs:61:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:47:9 + --> $DIR/empty-match.rs:68:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:50:9 + --> $DIR/empty-match.rs:71:9 | LL | _ if false => {}, | ^ +error[E0005]: refutable pattern in local binding + --> $DIR/empty-match.rs:76:9 + | +LL | let None = x; + | ^^^^ pattern `Some(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: pattern `Some(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future + = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let None = x { todo!() }; + | ++ +++++++++++ + error: unreachable pattern - --> $DIR/empty-match.rs:57:9 + --> $DIR/empty-match.rs:88:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:60:9 + --> $DIR/empty-match.rs:91:9 | LL | _ if false => {}, | ^ error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/empty-match.rs:78:20 + --> $DIR/empty-match.rs:109:20 | LL | match_no_arms!(0u8); | ^^^ @@ -50,13 +65,13 @@ LL | match_no_arms!(0u8); = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty - --> $DIR/empty-match.rs:79:20 + --> $DIR/empty-match.rs:111:20 | LL | match_no_arms!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ | note: `NonEmptyStruct1` defined here - --> $DIR/empty-match.rs:14:8 + --> $DIR/empty-match.rs:15:8 | LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ @@ -64,13 +79,13 @@ LL | struct NonEmptyStruct1; = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty - --> $DIR/empty-match.rs:80:20 + --> $DIR/empty-match.rs:113:20 | LL | match_no_arms!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyStruct2` defined here - --> $DIR/empty-match.rs:15:8 + --> $DIR/empty-match.rs:18:8 | LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ @@ -78,13 +93,13 @@ LL | struct NonEmptyStruct2(bool); = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty - --> $DIR/empty-match.rs:81:20 + --> $DIR/empty-match.rs:115:20 | LL | match_no_arms!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyUnion1` defined here - --> $DIR/empty-match.rs:16:7 + --> $DIR/empty-match.rs:21:7 | LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ @@ -92,13 +107,13 @@ LL | union NonEmptyUnion1 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty - --> $DIR/empty-match.rs:82:20 + --> $DIR/empty-match.rs:117:20 | LL | match_no_arms!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyUnion2` defined here - --> $DIR/empty-match.rs:19:7 + --> $DIR/empty-match.rs:26:7 | LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ @@ -106,13 +121,13 @@ LL | union NonEmptyUnion2 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:83:20 + --> $DIR/empty-match.rs:119:20 | LL | match_no_arms!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered | note: `NonEmptyEnum1` defined here - --> $DIR/empty-match.rs:24:5 + --> $DIR/empty-match.rs:33:5 | LL | enum NonEmptyEnum1 { | ------------- @@ -122,31 +137,32 @@ LL | Foo(bool), = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:84:20 + --> $DIR/empty-match.rs:122:20 | LL | match_no_arms!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered | note: `NonEmptyEnum2` defined here - --> $DIR/empty-match.rs:27:5 + --> $DIR/empty-match.rs:40:5 | LL | enum NonEmptyEnum2 { | ------------- LL | Foo(bool), | ^^^ not covered +... LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:85:20 + --> $DIR/empty-match.rs:125:20 | LL | match_no_arms!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered | note: `NonEmptyEnum5` defined here - --> $DIR/empty-match.rs:30:6 + --> $DIR/empty-match.rs:49:6 | LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ @@ -154,7 +170,7 @@ LL | enum NonEmptyEnum5 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/empty-match.rs:87:24 + --> $DIR/empty-match.rs:129:24 | LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered @@ -167,13 +183,13 @@ LL + _ => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered - --> $DIR/empty-match.rs:88:24 + --> $DIR/empty-match.rs:133:24 | LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered | note: `NonEmptyStruct1` defined here - --> $DIR/empty-match.rs:14:8 + --> $DIR/empty-match.rs:15:8 | LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ @@ -185,13 +201,13 @@ LL + NonEmptyStruct1 => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered - --> $DIR/empty-match.rs:89:24 + --> $DIR/empty-match.rs:137:24 | LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered | note: `NonEmptyStruct2` defined here - --> $DIR/empty-match.rs:15:8 + --> $DIR/empty-match.rs:18:8 | LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ @@ -203,13 +219,13 @@ LL + NonEmptyStruct2(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/empty-match.rs:90:24 + --> $DIR/empty-match.rs:141:24 | LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered | note: `NonEmptyUnion1` defined here - --> $DIR/empty-match.rs:16:7 + --> $DIR/empty-match.rs:21:7 | LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ @@ -221,13 +237,13 @@ LL + NonEmptyUnion1 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/empty-match.rs:91:24 + --> $DIR/empty-match.rs:145:24 | LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered | note: `NonEmptyUnion2` defined here - --> $DIR/empty-match.rs:19:7 + --> $DIR/empty-match.rs:26:7 | LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ @@ -239,13 +255,13 @@ LL + NonEmptyUnion2 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:92:24 + --> $DIR/empty-match.rs:149:24 | LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered | note: `NonEmptyEnum1` defined here - --> $DIR/empty-match.rs:24:5 + --> $DIR/empty-match.rs:33:5 | LL | enum NonEmptyEnum1 { | ------------- @@ -259,18 +275,19 @@ LL + NonEmptyEnum1::Foo(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:93:24 + --> $DIR/empty-match.rs:153:24 | LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered | note: `NonEmptyEnum2` defined here - --> $DIR/empty-match.rs:27:5 + --> $DIR/empty-match.rs:40:5 | LL | enum NonEmptyEnum2 { | ------------- LL | Foo(bool), | ^^^ not covered +... LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` @@ -281,13 +298,13 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:94:24 + --> $DIR/empty-match.rs:157:24 | LL | match_guarded_arm!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered | note: `NonEmptyEnum5` defined here - --> $DIR/empty-match.rs:30:6 + --> $DIR/empty-match.rs:49:6 | LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ @@ -298,6 +315,7 @@ LL ~ _ if false => {}, LL + _ => todo!() | -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors -For more information about this error, try `rustc --explain E0004`. +Some errors have detailed explanations: E0004, E0005. +For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-match.normal.stderr b/tests/ui/pattern/usefulness/empty-match.normal.stderr index 5a145efce..f54a3f336 100644 --- a/tests/ui/pattern/usefulness/empty-match.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-match.normal.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-match.rs:37:9 + --> $DIR/empty-match.rs:58:9 | LL | _ => {}, | ^ @@ -11,37 +11,51 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-match.rs:40:9 + --> $DIR/empty-match.rs:61:9 | LL | _ if false => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:47:9 + --> $DIR/empty-match.rs:68:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:50:9 + --> $DIR/empty-match.rs:71:9 | LL | _ if false => {}, | ^ +error[E0005]: refutable pattern in local binding + --> $DIR/empty-match.rs:76:9 + | +LL | let None = x; + | ^^^^ pattern `Some(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if let None = x { todo!() }; + | ++ +++++++++++ + error: unreachable pattern - --> $DIR/empty-match.rs:57:9 + --> $DIR/empty-match.rs:88:9 | LL | _ => {}, | ^ error: unreachable pattern - --> $DIR/empty-match.rs:60:9 + --> $DIR/empty-match.rs:91:9 | LL | _ if false => {}, | ^ error[E0004]: non-exhaustive patterns: type `u8` is non-empty - --> $DIR/empty-match.rs:78:20 + --> $DIR/empty-match.rs:109:20 | LL | match_no_arms!(0u8); | ^^^ @@ -50,13 +64,13 @@ LL | match_no_arms!(0u8); = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty - --> $DIR/empty-match.rs:79:20 + --> $DIR/empty-match.rs:111:20 | LL | match_no_arms!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ | note: `NonEmptyStruct1` defined here - --> $DIR/empty-match.rs:14:8 + --> $DIR/empty-match.rs:15:8 | LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ @@ -64,13 +78,13 @@ LL | struct NonEmptyStruct1; = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty - --> $DIR/empty-match.rs:80:20 + --> $DIR/empty-match.rs:113:20 | LL | match_no_arms!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyStruct2` defined here - --> $DIR/empty-match.rs:15:8 + --> $DIR/empty-match.rs:18:8 | LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ @@ -78,13 +92,13 @@ LL | struct NonEmptyStruct2(bool); = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty - --> $DIR/empty-match.rs:81:20 + --> $DIR/empty-match.rs:115:20 | LL | match_no_arms!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyUnion1` defined here - --> $DIR/empty-match.rs:16:7 + --> $DIR/empty-match.rs:21:7 | LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ @@ -92,13 +106,13 @@ LL | union NonEmptyUnion1 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty - --> $DIR/empty-match.rs:82:20 + --> $DIR/empty-match.rs:117:20 | LL | match_no_arms!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `NonEmptyUnion2` defined here - --> $DIR/empty-match.rs:19:7 + --> $DIR/empty-match.rs:26:7 | LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ @@ -106,13 +120,13 @@ LL | union NonEmptyUnion2 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:83:20 + --> $DIR/empty-match.rs:119:20 | LL | match_no_arms!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered | note: `NonEmptyEnum1` defined here - --> $DIR/empty-match.rs:24:5 + --> $DIR/empty-match.rs:33:5 | LL | enum NonEmptyEnum1 { | ------------- @@ -122,31 +136,32 @@ LL | Foo(bool), = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:84:20 + --> $DIR/empty-match.rs:122:20 | LL | match_no_arms!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered | note: `NonEmptyEnum2` defined here - --> $DIR/empty-match.rs:27:5 + --> $DIR/empty-match.rs:40:5 | LL | enum NonEmptyEnum2 { | ------------- LL | Foo(bool), | ^^^ not covered +... LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:85:20 + --> $DIR/empty-match.rs:125:20 | LL | match_no_arms!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered | note: `NonEmptyEnum5` defined here - --> $DIR/empty-match.rs:30:6 + --> $DIR/empty-match.rs:49:6 | LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ @@ -154,7 +169,7 @@ LL | enum NonEmptyEnum5 { = help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/empty-match.rs:87:24 + --> $DIR/empty-match.rs:129:24 | LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered @@ -167,13 +182,13 @@ LL + _ => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered - --> $DIR/empty-match.rs:88:24 + --> $DIR/empty-match.rs:133:24 | LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered | note: `NonEmptyStruct1` defined here - --> $DIR/empty-match.rs:14:8 + --> $DIR/empty-match.rs:15:8 | LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ @@ -185,13 +200,13 @@ LL + NonEmptyStruct1 => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered - --> $DIR/empty-match.rs:89:24 + --> $DIR/empty-match.rs:137:24 | LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered | note: `NonEmptyStruct2` defined here - --> $DIR/empty-match.rs:15:8 + --> $DIR/empty-match.rs:18:8 | LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ @@ -203,13 +218,13 @@ LL + NonEmptyStruct2(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/empty-match.rs:90:24 + --> $DIR/empty-match.rs:141:24 | LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered | note: `NonEmptyUnion1` defined here - --> $DIR/empty-match.rs:16:7 + --> $DIR/empty-match.rs:21:7 | LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ @@ -221,13 +236,13 @@ LL + NonEmptyUnion1 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/empty-match.rs:91:24 + --> $DIR/empty-match.rs:145:24 | LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered | note: `NonEmptyUnion2` defined here - --> $DIR/empty-match.rs:19:7 + --> $DIR/empty-match.rs:26:7 | LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ @@ -239,13 +254,13 @@ LL + NonEmptyUnion2 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:92:24 + --> $DIR/empty-match.rs:149:24 | LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered | note: `NonEmptyEnum1` defined here - --> $DIR/empty-match.rs:24:5 + --> $DIR/empty-match.rs:33:5 | LL | enum NonEmptyEnum1 { | ------------- @@ -259,18 +274,19 @@ LL + NonEmptyEnum1::Foo(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:93:24 + --> $DIR/empty-match.rs:153:24 | LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered | note: `NonEmptyEnum2` defined here - --> $DIR/empty-match.rs:27:5 + --> $DIR/empty-match.rs:40:5 | LL | enum NonEmptyEnum2 { | ------------- LL | Foo(bool), | ^^^ not covered +... LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` @@ -281,13 +297,13 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:94:24 + --> $DIR/empty-match.rs:157:24 | LL | match_guarded_arm!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered | note: `NonEmptyEnum5` defined here - --> $DIR/empty-match.rs:30:6 + --> $DIR/empty-match.rs:49:6 | LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ @@ -298,6 +314,7 @@ LL ~ _ if false => {}, LL + _ => todo!() | -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors -For more information about this error, try `rustc --explain E0004`. +Some errors have detailed explanations: E0004, E0005. +For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-match.rs b/tests/ui/pattern/usefulness/empty-match.rs index 9cdc0413b..062241faa 100644 --- a/tests/ui/pattern/usefulness/empty-match.rs +++ b/tests/ui/pattern/usefulness/empty-match.rs @@ -6,28 +6,49 @@ #![feature(never_type_fallback)] #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![deny(unreachable_patterns)] +//~^ NOTE the lint level is defined here extern crate empty; enum EmptyEnum {} struct NonEmptyStruct1; +//~^ NOTE `NonEmptyStruct1` defined here +//~| NOTE `NonEmptyStruct1` defined here struct NonEmptyStruct2(bool); +//~^ NOTE `NonEmptyStruct2` defined here +//~| NOTE `NonEmptyStruct2` defined here union NonEmptyUnion1 { + //~^ NOTE `NonEmptyUnion1` defined here + //~| NOTE `NonEmptyUnion1` defined here foo: (), } union NonEmptyUnion2 { + //~^ NOTE `NonEmptyUnion2` defined here + //~| NOTE `NonEmptyUnion2` defined here foo: (), bar: (), } enum NonEmptyEnum1 { Foo(bool), + //~^ NOTE `NonEmptyEnum1` defined here + //~| NOTE `NonEmptyEnum1` defined here + //~| NOTE not covered + //~| NOTE not covered } enum NonEmptyEnum2 { Foo(bool), + //~^ NOTE `NonEmptyEnum2` defined here + //~| NOTE `NonEmptyEnum2` defined here + //~| NOTE not covered + //~| NOTE not covered Bar, + //~^ NOTE not covered + //~| NOTE not covered } enum NonEmptyEnum5 { + //~^ NOTE `NonEmptyEnum5` defined here + //~| NOTE `NonEmptyEnum5` defined here V1, V2, V3, V4, V5, } @@ -51,6 +72,16 @@ fn empty_foreign_enum(x: empty::EmptyForeignEnum) { } } +fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>) { + let None = x; + //~^ ERROR refutable pattern in local binding + //~| NOTE `let` bindings require an "irrefutable pattern" + //~| NOTE for more information, visit + //~| NOTE the matched value is of type + //~| NOTE pattern `Some(_)` not covered + //[exhaustive_patterns]~| NOTE currently uninhabited, but this variant contains private fields +} + fn never(x: !) { match x {} // ok match x { @@ -76,20 +107,55 @@ macro_rules! match_guarded_arm { fn main() { match_no_arms!(0u8); //~ ERROR type `u8` is non-empty + //~| NOTE the matched value is of type match_no_arms!(NonEmptyStruct1); //~ ERROR type `NonEmptyStruct1` is non-empty + //~| NOTE the matched value is of type match_no_arms!(NonEmptyStruct2(true)); //~ ERROR type `NonEmptyStruct2` is non-empty + //~| NOTE the matched value is of type match_no_arms!((NonEmptyUnion1 { foo: () })); //~ ERROR type `NonEmptyUnion1` is non-empty + //~| NOTE the matched value is of type match_no_arms!((NonEmptyUnion2 { foo: () })); //~ ERROR type `NonEmptyUnion2` is non-empty + //~| NOTE the matched value is of type match_no_arms!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered + //~| NOTE pattern `NonEmptyEnum1::Foo(_)` not covered + //~| NOTE the matched value is of type match_no_arms!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered + //~| NOTE patterns `NonEmptyEnum2::Foo(_)` and + //~| NOTE the matched value is of type match_no_arms!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered + //~| NOTE patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2` + //~| NOTE the matched value is of type match_guarded_arm!(0u8); //~ ERROR `_` not covered + //~| NOTE the matched value is of type + //~| NOTE pattern `_` not covered + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyStruct1); //~ ERROR `NonEmptyStruct1` not covered + //~| NOTE pattern `NonEmptyStruct1` not covered + //~| NOTE the matched value is of type + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyStruct2(true)); //~ ERROR `NonEmptyStruct2(_)` not covered + //~| NOTE the matched value is of type + //~| NOTE pattern `NonEmptyStruct2(_)` not covered + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!((NonEmptyUnion1 { foo: () })); //~ ERROR `NonEmptyUnion1 { .. }` not covered + //~| NOTE the matched value is of type + //~| NOTE pattern `NonEmptyUnion1 { .. }` not covered + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!((NonEmptyUnion2 { foo: () })); //~ ERROR `NonEmptyUnion2 { .. }` not covered + //~| NOTE the matched value is of type + //~| NOTE pattern `NonEmptyUnion2 { .. }` not covered + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered + //~| NOTE the matched value is of type + //~| NOTE pattern `NonEmptyEnum1::Foo(_)` not covered + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered + //~| NOTE the matched value is of type + //~| NOTE patterns `NonEmptyEnum2::Foo(_)` and + //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered + //~| NOTE the matched value is of type + //~| NOTE patterns `NonEmptyEnum5::V1`, + //~| NOTE in this expansion of match_guarded_arm! } diff --git a/tests/ui/phantom-auto-trait.stderr b/tests/ui/phantom-auto-trait.stderr index 4769d53eb..5af648f6a 100644 --- a/tests/ui/phantom-auto-trait.stderr +++ b/tests/ui/phantom-auto-trait.stderr @@ -11,7 +11,8 @@ note: required for `&T` to implement `Zen` | LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} | ^^^ ^^^^^ ---- unsatisfied trait bound introduced here - = note: required because it appears within the type `PhantomData<&T>` +note: required because it appears within the type `PhantomData<&T>` + --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Guard<'_, T>` --> $DIR/phantom-auto-trait.rs:12:8 | @@ -40,7 +41,8 @@ note: required for `&T` to implement `Zen` | LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} | ^^^ ^^^^^ ---- unsatisfied trait bound introduced here - = note: required because it appears within the type `PhantomData<&T>` +note: required because it appears within the type `PhantomData<&T>` + --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Guard<'_, T>` --> $DIR/phantom-auto-trait.rs:12:8 | diff --git a/tests/ui/polymorphization/generators.stderr b/tests/ui/polymorphization/generators.stderr index 84888f6fb..32d49d25f 100644 --- a/tests/ui/polymorphization/generators.stderr +++ b/tests/ui/polymorphization/generators.stderr @@ -15,12 +15,6 @@ LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + LL | || { | ^^ -note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 35:7], u32, u32>` - --> $DIR/generators.rs:86:5 - | -LL | finish(unused_type::<u32>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: item has unused generic parameters --> $DIR/generators.rs:60:5 | @@ -29,11 +23,5 @@ LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Retu LL | || { | ^^ -note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 60:7], u32, u32>` - --> $DIR/generators.rs:89:5 - | -LL | finish(unused_const::<1u32>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/polymorphization/predicates.stderr b/tests/ui/polymorphization/predicates.stderr index 80bb2af25..a3b2f75b1 100644 --- a/tests/ui/polymorphization/predicates.stderr +++ b/tests/ui/polymorphization/predicates.stderr @@ -1,4 +1,10 @@ error: item has unused generic parameters + --> $DIR/predicates.rs:10:4 + | +LL | fn bar<I>() { + | ^^^ - generic parameter `I` is unused + +error: item has unused generic parameters --> $DIR/predicates.rs:15:4 | LL | fn foo<I, T>(_: I) @@ -35,17 +41,5 @@ error: item has unused generic parameters LL | fn foobar<F, G>() -> usize | ^^^^^^ - generic parameter `F` is unused -error: item has unused generic parameters - --> $DIR/predicates.rs:10:4 - | -LL | fn bar<I>() { - | ^^^ - generic parameter `I` is unused - -note: the above error was encountered while instantiating `fn foo::<std::slice::Iter<'_, u32>, T>` - --> $DIR/predicates.rs:86:5 - | -LL | foo(x.iter()); - | ^^^^^^^^^^^^^ - error: aborting due to 6 previous errors diff --git a/tests/ui/polymorphization/type_parameters/closures.stderr b/tests/ui/polymorphization/type_parameters/closures.stderr index 94a4a08bd..5c3b46c60 100644 --- a/tests/ui/polymorphization/type_parameters/closures.stderr +++ b/tests/ui/polymorphization/type_parameters/closures.stderr @@ -44,21 +44,6 @@ LL | pub fn unused_all<G: Default>() -> u32 { | ^^^^^^^^^^ - generic parameter `G` is unused error: item has unused generic parameters - --> $DIR/closures.rs:128:23 - | -LL | pub fn used_impl<G: Default>() -> u32 { - | - generic parameter `G` is unused -LL | -LL | let add_one = |x: u32| { - | ^^^^^^^^ - -error: item has unused generic parameters - --> $DIR/closures.rs:126:12 - | -LL | pub fn used_impl<G: Default>() -> u32 { - | ^^^^^^^^^ - generic parameter `G` is unused - -error: item has unused generic parameters --> $DIR/closures.rs:115:23 | LL | impl<F: Default> Foo<F> { @@ -76,5 +61,20 @@ LL | impl<F: Default> Foo<F> { LL | pub fn used_fn<G: Default>() -> u32 { | ^^^^^^^ +error: item has unused generic parameters + --> $DIR/closures.rs:128:23 + | +LL | pub fn used_impl<G: Default>() -> u32 { + | - generic parameter `G` is unused +LL | +LL | let add_one = |x: u32| { + | ^^^^^^^^ + +error: item has unused generic parameters + --> $DIR/closures.rs:126:12 + | +LL | pub fn used_impl<G: Default>() -> u32 { + | ^^^^^^^^^ - generic parameter `G` is unused + error: aborting due to 9 previous errors diff --git a/tests/ui/print_type_sizes/async.rs b/tests/ui/print_type_sizes/async.rs index 1598b0696..f38a6e674 100644 --- a/tests/ui/print_type_sizes/async.rs +++ b/tests/ui/print_type_sizes/async.rs @@ -3,6 +3,8 @@ // build-pass // ignore-pass +#![allow(dropping_copy_types)] + async fn wait() {} pub async fn test(arg: [u8; 8192]) { diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout index 8fe936efc..873def903 100644 --- a/tests/ui/print_type_sizes/async.stdout +++ b/tests/ui/print_type_sizes/async.stdout @@ -1,29 +1,29 @@ -print-type-size type: `[async fn body@$DIR/async.rs:8:36: 11:2]`: 16386 bytes, alignment: 1 bytes +print-type-size type: `[async fn body@$DIR/async.rs:10:36: 13:2]`: 16386 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 8192 bytes -print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 8192 bytes print-type-size variant `Suspend0`: 16385 bytes -print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 8192 bytes print-type-size local `.arg`: 8192 bytes print-type-size local `.__awaitee`: 1 bytes print-type-size variant `Returned`: 8192 bytes -print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 8192 bytes print-type-size variant `Panicked`: 8192 bytes -print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.arg`: 8192 bytes print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes print-type-size field `.value`: 8192 bytes print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 8192 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 8192 bytes -print-type-size type: `[async fn body@$DIR/async.rs:6:17: 6:19]`: 1 bytes, alignment: 1 bytes +print-type-size type: `[async fn body@$DIR/async.rs:8:17: 8:19]`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes -print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async.rs:6:17: 6:19]>`: 1 bytes, alignment: 1 bytes +print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async.rs:8:17: 8:19]>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes -print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async.rs:6:17: 6:19]>`: 1 bytes, alignment: 1 bytes +print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async.rs:8:17: 8:19]>`: 1 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 1 bytes diff --git a/tests/ui/print_type_sizes/generator.stdout b/tests/ui/print_type_sizes/generator.stdout index 7c58d6ce5..2dcadde9e 100644 --- a/tests/ui/print_type_sizes/generator.stdout +++ b/tests/ui/print_type_sizes/generator.stdout @@ -1,10 +1,10 @@ print-type-size type: `[generator@$DIR/generator.rs:10:5: 10:14]`: 8193 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 8192 bytes -print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.array`: 8192 bytes print-type-size variant `Suspend0`: 8192 bytes -print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.array`: 8192 bytes print-type-size variant `Returned`: 8192 bytes -print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.array`: 8192 bytes print-type-size variant `Panicked`: 8192 bytes -print-type-size upvar `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes +print-type-size upvar `.array`: 8192 bytes diff --git a/tests/ui/print_type_sizes/generator_discr_placement.rs b/tests/ui/print_type_sizes/generator_discr_placement.rs index 1a85fe95b..6adc14f9b 100644 --- a/tests/ui/print_type_sizes/generator_discr_placement.rs +++ b/tests/ui/print_type_sizes/generator_discr_placement.rs @@ -6,6 +6,7 @@ // Avoid emitting panic handlers, like the rest of these tests... #![feature(generators)] +#![allow(dropping_copy_types)] pub fn foo() { let a = || { diff --git a/tests/ui/print_type_sizes/generator_discr_placement.stdout b/tests/ui/print_type_sizes/generator_discr_placement.stdout index f2a11c7a3..fe0022cf5 100644 --- a/tests/ui/print_type_sizes/generator_discr_placement.stdout +++ b/tests/ui/print_type_sizes/generator_discr_placement.stdout @@ -1,4 +1,4 @@ -print-type-size type: `[generator@$DIR/generator_discr_placement.rs:11:13: 11:15]`: 8 bytes, alignment: 4 bytes +print-type-size type: `[generator@$DIR/generator_discr_placement.rs:12:13: 12:15]`: 8 bytes, alignment: 4 bytes print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Suspend0`: 7 bytes diff --git a/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.rs b/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.rs new file mode 100644 index 000000000..f413b5027 --- /dev/null +++ b/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.rs @@ -0,0 +1,33 @@ +mod b { + pub struct A(u32); +} + +trait Id { + type Assoc; +} +impl Id for b::A { + type Assoc = b::A; +} +impl Id for u32 { + type Assoc = u32; +} + + +trait Trait<T> { + fn method(&self) + where + T: Id<Assoc = b::A>; +} + +impl<T: Id> Trait<T> for <T as Id>::Assoc { + fn method(&self) + where + T: Id<Assoc = b::A>, + { + let Self(a) = self; + //~^ ERROR: tuple struct constructor `A` is private + println!("{a}"); + } +} + +fn main() {} diff --git a/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.stderr b/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.stderr new file mode 100644 index 000000000..231a4da8b --- /dev/null +++ b/tests/ui/privacy/issue-111220-2-tuple-struct-fields-projection.stderr @@ -0,0 +1,9 @@ +error[E0603]: tuple struct constructor `A` is private + --> $DIR/issue-111220-2-tuple-struct-fields-projection.rs:27:13 + | +LL | let Self(a) = self; + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/issue-111220-tuple-struct-fields.rs b/tests/ui/privacy/issue-111220-tuple-struct-fields.rs new file mode 100644 index 000000000..78d35fd96 --- /dev/null +++ b/tests/ui/privacy/issue-111220-tuple-struct-fields.rs @@ -0,0 +1,46 @@ +mod b { + #[derive(Default)] + pub struct A(u32); +} + +impl b::A { + fn inherent_bypass(&self) { + let Self(x) = self; + //~^ ERROR: tuple struct constructor `A` is private + println!("{x}"); + } +} + +pub trait B { + fn f(&self); +} + +impl B for b::A { + fn f(&self) { + let Self(a) = self; + //~^ ERROR: tuple struct constructor `A` is private + println!("{}", a); + } +} + +pub trait Projector { + type P; +} + +impl Projector for () { + type P = b::A; +} + +pub trait Bypass2 { + fn f2(&self); +} + +impl Bypass2 for <() as Projector>::P { + fn f2(&self) { + let Self(a) = self; + //~^ ERROR: tuple struct constructor `A` is private + println!("{}", a); + } +} + +fn main() {} diff --git a/tests/ui/privacy/issue-111220-tuple-struct-fields.stderr b/tests/ui/privacy/issue-111220-tuple-struct-fields.stderr new file mode 100644 index 000000000..17a32379c --- /dev/null +++ b/tests/ui/privacy/issue-111220-tuple-struct-fields.stderr @@ -0,0 +1,21 @@ +error[E0603]: tuple struct constructor `A` is private + --> $DIR/issue-111220-tuple-struct-fields.rs:8:13 + | +LL | let Self(x) = self; + | ^^^^^^^ + +error[E0603]: tuple struct constructor `A` is private + --> $DIR/issue-111220-tuple-struct-fields.rs:20:13 + | +LL | let Self(a) = self; + | ^^^^^^^ + +error[E0603]: tuple struct constructor `A` is private + --> $DIR/issue-111220-tuple-struct-fields.rs:40:13 + | +LL | let Self(a) = self; + | ^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index 882f31465..c2a33ce1f 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -23,13 +23,7 @@ LL | pub fn foo() {} error: requires `sized` lang_item -error: requires `sized` lang_item - -error: requires `sized` lang_item - -error: requires `sized` lang_item - -error: aborting due to 6 previous errors +error: aborting due to 3 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.stderr b/tests/ui/privacy/privacy3.stderr index 42ce456d9..22c1e48b0 100644 --- a/tests/ui/privacy/privacy3.stderr +++ b/tests/ui/privacy/privacy3.stderr @@ -6,12 +6,6 @@ LL | use bar::gpriv; error: requires `sized` lang_item -error: requires `sized` lang_item - -error: requires `sized` lang_item - -error: requires `sized` lang_item - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/proc-macro/module.rs b/tests/ui/proc-macro/module.rs index 5777ed899..a750083c6 100644 --- a/tests/ui/proc-macro/module.rs +++ b/tests/ui/proc-macro/module.rs @@ -1 +1 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) diff --git a/tests/ui/proc-macro/module_with_attrs.rs b/tests/ui/proc-macro/module_with_attrs.rs index 63e66a62a..0b2604f95 100644 --- a/tests/ui/proc-macro/module_with_attrs.rs +++ b/tests/ui/proc-macro/module_with_attrs.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) #![rustfmt::skip] #![print_attr] diff --git a/tests/ui/proc-macro/outer/inner.rs b/tests/ui/proc-macro/outer/inner.rs index 5777ed899..a750083c6 100644 --- a/tests/ui/proc-macro/outer/inner.rs +++ b/tests/ui/proc-macro/outer/inner.rs @@ -1 +1 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) diff --git a/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs index 9501980fa..889f399a7 100644 --- a/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs +++ b/tests/ui/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) #[derive(Print)] enum ProceduralMasqueradeDummyType { diff --git a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs index 9501980fa..889f399a7 100644 --- a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs +++ b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) #[derive(Print)] enum ProceduralMasqueradeDummyType { diff --git a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs index 9501980fa..889f399a7 100644 --- a/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs +++ b/tests/ui/proc-macro/pretty-print-hack/rental-0.5.6/src/lib.rs @@ -1,4 +1,4 @@ -// ignore-test +// ignore-test (auxiliary, used by other tests) #[derive(Print)] enum ProceduralMasqueradeDummyType { diff --git a/tests/ui/proc-macro/test-same-crate.rs b/tests/ui/proc-macro/test-same-crate.rs new file mode 100644 index 000000000..c13f384fa --- /dev/null +++ b/tests/ui/proc-macro/test-same-crate.rs @@ -0,0 +1,16 @@ +// compile-flags: --test +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro] +pub fn mac(input: TokenStream) -> TokenStream { loop {} } + +#[cfg(test)] +mod test { + #[test] + fn t() { crate::mac!(A) } + //~^ ERROR can't use a procedural macro from the same crate that defines it + //~| HELP you can define integration tests in a directory named `tests` +} diff --git a/tests/ui/proc-macro/test-same-crate.stderr b/tests/ui/proc-macro/test-same-crate.stderr new file mode 100644 index 000000000..5d12e149c --- /dev/null +++ b/tests/ui/proc-macro/test-same-crate.stderr @@ -0,0 +1,10 @@ +error: can't use a procedural macro from the same crate that defines it + --> $DIR/test-same-crate.rs:13:14 + | +LL | fn t() { crate::mac!(A) } + | ^^^^^^^^^^ + | + = help: you can define integration tests in a directory named `tests` + +error: aborting due to previous error + diff --git a/tests/ui/process/process-sigpipe.rs b/tests/ui/process/process-sigpipe.rs index 7ae14c6b8..4f4db1191 100644 --- a/tests/ui/process/process-sigpipe.rs +++ b/tests/ui/process/process-sigpipe.rs @@ -8,14 +8,14 @@ // libstd ignores SIGPIPE, and other libraries may set signal masks. // Make sure that these behaviors don't get inherited to children // spawned via std::process, since they're needed for traditional UNIX -// filter behavior. This test checks that `yes | head` terminates +// filter behavior. +// This test checks that `while echo y ; do : ; done | head` terminates // (instead of running forever), and that it does not print an error // message about a broken pipe. // ignore-emscripten no threads support // ignore-vxworks no 'sh' // ignore-fuchsia no 'sh' -// ignore-nto no 'yes' use std::process; use std::thread; @@ -27,7 +27,11 @@ fn main() { thread::sleep_ms(5000); process::exit(1); }); - let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap(); + let output = process::Command::new("sh") + .arg("-c") + .arg("while echo y ; do : ; done | head") + .output() + .unwrap(); assert!(output.status.success()); assert!(output.stderr.len() == 0); } diff --git a/tests/ui/range/issue-54505-no-literals.fixed b/tests/ui/range/issue-54505-no-literals.fixed index 4d8f67182..71c36c741 100644 --- a/tests/ui/range/issue-54505-no-literals.fixed +++ b/tests/ui/range/issue-54505-no-literals.fixed @@ -16,60 +16,60 @@ fn main() { take_range(&std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } + //~| SUGGESTION & take_range(&::std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } + //~| SUGGESTION & take_range(&std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeFrom { start: 1 } + //~| SUGGESTION & take_range(&::std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } + //~| SUGGESTION & take_range(&std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeFull {} + //~| SUGGESTION & take_range(&::std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeFull {} + //~| SUGGESTION & take_range(&std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) + //~| SUGGESTION & take_range(&::std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) + //~| SUGGESTION & take_range(&std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeTo { end: 5 } + //~| SUGGESTION & take_range(&::std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeTo { end: 5 } + //~| SUGGESTION & take_range(&std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } + //~| SUGGESTION & take_range(&::std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } + //~| SUGGESTION & } diff --git a/tests/ui/range/issue-54505-no-literals.rs b/tests/ui/range/issue-54505-no-literals.rs index dc21dcbc2..db125d1a2 100644 --- a/tests/ui/range/issue-54505-no-literals.rs +++ b/tests/ui/range/issue-54505-no-literals.rs @@ -16,60 +16,60 @@ fn main() { take_range(std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } + //~| SUGGESTION & take_range(::std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } + //~| SUGGESTION & take_range(std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeFrom { start: 1 } + //~| SUGGESTION & take_range(::std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } + //~| SUGGESTION & take_range(std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeFull {} + //~| SUGGESTION & take_range(::std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeFull {} + //~| SUGGESTION & take_range(std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) + //~| SUGGESTION & take_range(::std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) + //~| SUGGESTION & take_range(std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeTo { end: 5 } + //~| SUGGESTION & take_range(::std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeTo { end: 5 } + //~| SUGGESTION & take_range(std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } + //~| SUGGESTION & take_range(::std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } + //~| SUGGESTION & } diff --git a/tests/ui/range/issue-54505-no-literals.stderr b/tests/ui/range/issue-54505-no-literals.stderr index d11298384..5894bb6ba 100644 --- a/tests/ui/range/issue-54505-no-literals.stderr +++ b/tests/ui/range/issue-54505-no-literals.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:16:16 | LL | take_range(std::ops::Range { start: 0, end: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `Range<{integer}>` - | | help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -15,15 +13,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::Range { start: 0, end: 1 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:21:16 | LL | take_range(::std::ops::Range { start: 0, end: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `Range<{integer}>` - | | help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `Range<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -33,15 +33,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::Range { start: 0, end: 1 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:26:16 | LL | take_range(std::ops::RangeFrom { start: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeFrom<{integer}>` - | | help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFrom<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -51,15 +53,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::RangeFrom { start: 1 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:31:16 | LL | take_range(::std::ops::RangeFrom { start: 1 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeFrom<{integer}>` - | | help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFrom<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -69,15 +73,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::RangeFrom { start: 1 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:36:16 | LL | take_range(std::ops::RangeFull {}); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeFull` - | | help: consider borrowing here: `&std::ops::RangeFull {}` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFull` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -87,15 +93,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::RangeFull {}); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:41:16 | LL | take_range(::std::ops::RangeFull {}); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeFull` - | | help: consider borrowing here: `&::std::ops::RangeFull {}` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeFull` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -105,15 +113,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::RangeFull {}); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:46:16 | LL | take_range(std::ops::RangeInclusive::new(0, 1)); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeInclusive<{integer}>` - | | help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -123,15 +133,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::RangeInclusive::new(0, 1)); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:51:16 | LL | take_range(::std::ops::RangeInclusive::new(0, 1)); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeInclusive<{integer}>` - | | help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -141,15 +153,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::RangeInclusive::new(0, 1)); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:56:16 | LL | take_range(std::ops::RangeTo { end: 5 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeTo<{integer}>` - | | help: consider borrowing here: `&std::ops::RangeTo { end: 5 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeTo<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -159,15 +173,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::RangeTo { end: 5 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:61:16 | LL | take_range(::std::ops::RangeTo { end: 5 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeTo<{integer}>` - | | help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeTo<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -177,15 +193,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::RangeTo { end: 5 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:66:16 | LL | take_range(std::ops::RangeToInclusive { end: 5 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeToInclusive<{integer}>` - | | help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeToInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -195,15 +213,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&std::ops::RangeToInclusive { end: 5 }); + | + error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:71:16 | LL | take_range(::std::ops::RangeToInclusive { end: 5 }); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | expected `&_`, found `RangeToInclusive<{integer}>` - | | help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }` + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `RangeToInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -213,6 +233,10 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&::std::ops::RangeToInclusive { end: 5 }); + | + error: aborting due to 12 previous errors diff --git a/tests/ui/range/issue-54505-no-std.rs b/tests/ui/range/issue-54505-no-std.rs index 9f378b483..db455fada 100644 --- a/tests/ui/range/issue-54505-no-std.rs +++ b/tests/ui/range/issue-54505-no-std.rs @@ -29,30 +29,30 @@ fn main() { take_range(0..1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..1) + //~| SUGGESTION &( take_range(1..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(1..) + //~| SUGGESTION &( take_range(..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..) + //~| SUGGESTION &( take_range(0..=1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..=1) + //~| SUGGESTION &( take_range(..5); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..5) + //~| SUGGESTION &( take_range(..=42); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..=42) + //~| SUGGESTION &( } diff --git a/tests/ui/range/issue-54505-no-std.stderr b/tests/ui/range/issue-54505-no-std.stderr index a6a9f89da..13563d194 100644 --- a/tests/ui/range/issue-54505-no-std.stderr +++ b/tests/ui/range/issue-54505-no-std.stderr @@ -14,10 +14,8 @@ error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:29:16 | LL | take_range(0..1); - | ---------- ^^^^ - | | | - | | expected `&_`, found `Range<{integer}>` - | | help: consider borrowing here: `&(0..1)` + | ---------- ^^^^ expected `&_`, found `Range<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -27,15 +25,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(0..1)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:34:16 | LL | take_range(1..); - | ---------- ^^^ - | | | - | | expected `&_`, found `RangeFrom<{integer}>` - | | help: consider borrowing here: `&(1..)` + | ---------- ^^^ expected `&_`, found `RangeFrom<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -45,15 +45,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(1..)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:39:16 | LL | take_range(..); - | ---------- ^^ - | | | - | | expected `&_`, found `RangeFull` - | | help: consider borrowing here: `&(..)` + | ---------- ^^ expected `&_`, found `RangeFull` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -63,15 +65,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:44:16 | LL | take_range(0..=1); - | ---------- ^^^^^ - | | | - | | expected `&_`, found `RangeInclusive<{integer}>` - | | help: consider borrowing here: `&(0..=1)` + | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -81,15 +85,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(0..=1)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:49:16 | LL | take_range(..5); - | ---------- ^^^ - | | | - | | expected `&_`, found `RangeTo<{integer}>` - | | help: consider borrowing here: `&(..5)` + | ---------- ^^^ expected `&_`, found `RangeTo<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -99,15 +105,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..5)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:54:16 | LL | take_range(..=42); - | ---------- ^^^^^ - | | | - | | expected `&_`, found `RangeToInclusive<{integer}>` - | | help: consider borrowing here: `&(..=42)` + | ---------- ^^^^^ expected `&_`, found `RangeToInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -117,6 +125,10 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..=42)); + | ++ + error: aborting due to 8 previous errors diff --git a/tests/ui/range/issue-54505.fixed b/tests/ui/range/issue-54505.fixed index f8298c0b5..9d113ba1d 100644 --- a/tests/ui/range/issue-54505.fixed +++ b/tests/ui/range/issue-54505.fixed @@ -14,30 +14,30 @@ fn main() { take_range(&(0..1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..1) + //~| SUGGESTION &( take_range(&(1..)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(1..) + //~| SUGGESTION &( take_range(&(..)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..) + //~| SUGGESTION &( take_range(&(0..=1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..=1) + //~| SUGGESTION &( take_range(&(..5)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..5) + //~| SUGGESTION &( take_range(&(..=42)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..=42) + //~| SUGGESTION &( } diff --git a/tests/ui/range/issue-54505.rs b/tests/ui/range/issue-54505.rs index 03673252d..c9929988f 100644 --- a/tests/ui/range/issue-54505.rs +++ b/tests/ui/range/issue-54505.rs @@ -14,30 +14,30 @@ fn main() { take_range(0..1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..1) + //~| SUGGESTION &( take_range(1..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(1..) + //~| SUGGESTION &( take_range(..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..) + //~| SUGGESTION &( take_range(0..=1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(0..=1) + //~| SUGGESTION &( take_range(..5); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..5) + //~| SUGGESTION &( take_range(..=42); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here - //~| SUGGESTION &(..=42) + //~| SUGGESTION &( } diff --git a/tests/ui/range/issue-54505.stderr b/tests/ui/range/issue-54505.stderr index eda047b50..0e959fc05 100644 --- a/tests/ui/range/issue-54505.stderr +++ b/tests/ui/range/issue-54505.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-54505.rs:14:16 | LL | take_range(0..1); - | ---------- ^^^^ - | | | - | | expected `&_`, found `Range<{integer}>` - | | help: consider borrowing here: `&(0..1)` + | ---------- ^^^^ expected `&_`, found `Range<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -15,15 +13,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(0..1)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505.rs:19:16 | LL | take_range(1..); - | ---------- ^^^ - | | | - | | expected `&_`, found `RangeFrom<{integer}>` - | | help: consider borrowing here: `&(1..)` + | ---------- ^^^ expected `&_`, found `RangeFrom<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -33,15 +33,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(1..)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505.rs:24:16 | LL | take_range(..); - | ---------- ^^ - | | | - | | expected `&_`, found `RangeFull` - | | help: consider borrowing here: `&(..)` + | ---------- ^^ expected `&_`, found `RangeFull` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -51,15 +53,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505.rs:29:16 | LL | take_range(0..=1); - | ---------- ^^^^^ - | | | - | | expected `&_`, found `RangeInclusive<{integer}>` - | | help: consider borrowing here: `&(0..=1)` + | ---------- ^^^^^ expected `&_`, found `RangeInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -69,15 +73,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(0..=1)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505.rs:34:16 | LL | take_range(..5); - | ---------- ^^^ - | | | - | | expected `&_`, found `RangeTo<{integer}>` - | | help: consider borrowing here: `&(..5)` + | ---------- ^^^ expected `&_`, found `RangeTo<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -87,15 +93,17 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..5)); + | ++ + error[E0308]: mismatched types --> $DIR/issue-54505.rs:39:16 | LL | take_range(..=42); - | ---------- ^^^^^ - | | | - | | expected `&_`, found `RangeToInclusive<{integer}>` - | | help: consider borrowing here: `&(..=42)` + | ---------- ^^^^^ expected `&_`, found `RangeToInclusive<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -105,6 +113,10 @@ note: function defined here | LL | fn take_range(_r: &impl RangeBounds<i8>) {} | ^^^^^^^^^^ ------------------------- +help: consider borrowing here + | +LL | take_range(&(..=42)); + | ++ + error: aborting due to 6 previous errors diff --git a/tests/ui/range/issue-73553-misinterp-range-literal.stderr b/tests/ui/range/issue-73553-misinterp-range-literal.stderr index 77595b367..52efa241d 100644 --- a/tests/ui/range/issue-73553-misinterp-range-literal.stderr +++ b/tests/ui/range/issue-73553-misinterp-range-literal.stderr @@ -2,10 +2,8 @@ error[E0308]: mismatched types --> $DIR/issue-73553-misinterp-range-literal.rs:12:10 | LL | demo(tell(1)..tell(10)); - | ---- ^^^^^^^^^^^^^^^^^ - | | | - | | expected `&Range<usize>`, found `Range<usize>` - | | help: consider borrowing here: `&(tell(1)..tell(10))` + | ---- ^^^^^^^^^^^^^^^^^ expected `&Range<usize>`, found `Range<usize>` + | | | arguments to this function are incorrect | = note: expected reference `&std::ops::Range<usize>` @@ -15,15 +13,17 @@ note: function defined here | LL | fn demo(r: &Range) { | ^^^^ --------- +help: consider borrowing here + | +LL | demo(&(tell(1)..tell(10))); + | ++ + error[E0308]: mismatched types --> $DIR/issue-73553-misinterp-range-literal.rs:14:10 | LL | demo(1..10); - | ---- ^^^^^ - | | | - | | expected `&Range<usize>`, found `Range<{integer}>` - | | help: consider borrowing here: `&(1..10)` + | ---- ^^^^^ expected `&Range<usize>`, found `Range<{integer}>` + | | | arguments to this function are incorrect | = note: expected reference `&std::ops::Range<usize>` @@ -33,6 +33,10 @@ note: function defined here | LL | fn demo(r: &Range) { | ^^^^ --------- +help: consider borrowing here + | +LL | demo(&(1..10)); + | ++ + error: aborting due to 2 previous errors diff --git a/tests/ui/reachable/auxiliary/foreign-priv-aux.rs b/tests/ui/reachable/auxiliary/foreign-priv-aux.rs new file mode 100644 index 000000000..10dc08614 --- /dev/null +++ b/tests/ui/reachable/auxiliary/foreign-priv-aux.rs @@ -0,0 +1,21 @@ +trait PrivTrait { + fn priv_fn(&self); +} + +pub struct ImplPrivTrait; + +impl PrivTrait for ImplPrivTrait { + fn priv_fn(&self) {} +} + +pub struct Wrapper<T>(T); + +pub trait PubTrait { + fn pub_fn(&self); +} + +impl<T: PrivTrait> PubTrait for Wrapper<T> { + fn pub_fn(&self) { + self.0.priv_fn() + } +} diff --git a/tests/ui/reachable/foreign-priv.rs b/tests/ui/reachable/foreign-priv.rs new file mode 100644 index 000000000..bf336b6be --- /dev/null +++ b/tests/ui/reachable/foreign-priv.rs @@ -0,0 +1,12 @@ +// aux-build:foreign-priv-aux.rs +// build-pass + +#![crate_type = "lib"] + +extern crate foreign_priv_aux; + +use foreign_priv_aux::{ImplPrivTrait, PubTrait, Wrapper}; + +pub fn foo(x: Wrapper<ImplPrivTrait>) { + x.pub_fn(); +} diff --git a/tests/ui/issues/issue-948.rs b/tests/ui/reachable/issue-948.rs index b9bbeb395..b9bbeb395 100644 --- a/tests/ui/issues/issue-948.rs +++ b/tests/ui/reachable/issue-948.rs diff --git a/tests/ui/recursion/recursive-requirements.stderr b/tests/ui/recursion/recursive-requirements.stderr index 8ee154ce5..bb63f7cd0 100644 --- a/tests/ui/recursion/recursive-requirements.stderr +++ b/tests/ui/recursion/recursive-requirements.stderr @@ -28,7 +28,8 @@ note: required because it appears within the type `Bar` | LL | pub struct Bar { | ^^^ - = note: required because it appears within the type `PhantomData<Bar>` +note: required because it appears within the type `PhantomData<Bar>` + --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Foo` --> $DIR/recursive-requirements.rs:5:12 | diff --git a/tests/ui/regions/type-param-outlives-reempty-issue-74429-2.rs b/tests/ui/regions/type-param-outlives-reempty-issue-74429-2.rs index a65c17e0e..5ae5ebb45 100644 --- a/tests/ui/regions/type-param-outlives-reempty-issue-74429-2.rs +++ b/tests/ui/regions/type-param-outlives-reempty-issue-74429-2.rs @@ -55,11 +55,11 @@ where } pub fn x<T: Copy>(a: Array<T>) { - // drop just avoids a must_use warning - drop((0..1).filter(|_| true)); + // _ just avoids a must_use warning + let _ = (0..1).filter(|_| true); let y = a.index_axis(); a.axis_iter().for_each(|_| { - drop(y); + let _ = y; }); } diff --git a/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs b/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs index d463f311c..0c1e93144 100644 --- a/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs +++ b/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs @@ -3,6 +3,8 @@ // check-pass +#![allow(dropping_copy_types)] + use std::marker::PhantomData; fn apply<T, F: FnOnce(T)>(_: T, _: F) {} diff --git a/tests/ui/repr/invalid_repr_list_help.rs b/tests/ui/repr/invalid_repr_list_help.rs index c32098453..785ffb1e0 100644 --- a/tests/ui/repr/invalid_repr_list_help.rs +++ b/tests/ui/repr/invalid_repr_list_help.rs @@ -15,3 +15,8 @@ pub struct OwO3 { pub enum OwO4 { UwU = 1, } + +#[repr(uwu)] //~ERROR: unrecognized representation hint +#[doc(owo)] //~WARN: unknown `doc` attribute + //~^ WARN: this was previously +pub struct Owo5; diff --git a/tests/ui/repr/invalid_repr_list_help.stderr b/tests/ui/repr/invalid_repr_list_help.stderr index 2acd56d9a..48a6af3dd 100644 --- a/tests/ui/repr/invalid_repr_list_help.stderr +++ b/tests/ui/repr/invalid_repr_list_help.stderr @@ -30,6 +30,24 @@ LL | #[repr(uwu, u8)] | = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` -error: aborting due to 4 previous errors +warning: unknown `doc` attribute `owo` + --> $DIR/invalid_repr_list_help.rs:20:7 + | +LL | #[doc(owo)] + | ^^^ + | + = 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 #82730 <https://github.com/rust-lang/rust/issues/82730> + = note: `#[warn(invalid_doc_attributes)]` on by default + +error[E0552]: unrecognized representation hint + --> $DIR/invalid_repr_list_help.rs:19:8 + | +LL | #[repr(uwu)] + | ^^^ + | + = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + +error: aborting due to 5 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0552`. diff --git a/tests/ui/repr/repr-transparent.stderr b/tests/ui/repr/repr-transparent.stderr index f1c570b95..cb1e23377 100644 --- a/tests/ui/repr/repr-transparent.stderr +++ b/tests/ui/repr/repr-transparent.stderr @@ -58,7 +58,7 @@ error[E0731]: transparent enum needs exactly one variant, but has 2 LL | enum MultipleVariants { | ^^^^^^^^^^^^^^^^^^^^^ needs exactly one variant, but has 2 LL | Foo(String), - | --- + | --- variant here LL | Bar, | --- too many variants in `MultipleVariants` diff --git a/tests/ui/repr/transparent-enum-too-many-variants.stderr b/tests/ui/repr/transparent-enum-too-many-variants.stderr index fb44757ef..1a500257f 100644 --- a/tests/ui/repr/transparent-enum-too-many-variants.stderr +++ b/tests/ui/repr/transparent-enum-too-many-variants.stderr @@ -5,6 +5,8 @@ LL | enum Foo { | ^^^^^^^^ needs exactly one variant, but has 2 LL | A(u8), B(u8), | - - too many variants in `Foo` + | | + | variant here error: aborting due to previous error diff --git a/tests/ui/resolve/explicit-self-lowercase-param.rs b/tests/ui/resolve/explicit-self-lowercase-param.rs new file mode 100644 index 000000000..7171bd8a4 --- /dev/null +++ b/tests/ui/resolve/explicit-self-lowercase-param.rs @@ -0,0 +1,8 @@ +struct Foo; + +impl Foo { + fn do_nothing(self: Box<self>) {} //~ ERROR attempt to use a non-constant value in a constant + //~^ HELP try using `Self` +} + +fn main() {} diff --git a/tests/ui/resolve/explicit-self-lowercase-param.stderr b/tests/ui/resolve/explicit-self-lowercase-param.stderr new file mode 100644 index 000000000..cd64dbb38 --- /dev/null +++ b/tests/ui/resolve/explicit-self-lowercase-param.stderr @@ -0,0 +1,8 @@ +error: attempt to use a non-constant value in a constant + --> $DIR/explicit-self-lowercase-param.rs:4:29 + | +LL | fn do_nothing(self: Box<self>) {} + | ^^^^ help: try using `Self` + +error: aborting due to previous error + diff --git a/tests/ui/resolve/issue-109250.rs b/tests/ui/resolve/issue-109250.rs new file mode 100644 index 000000000..68e33f693 --- /dev/null +++ b/tests/ui/resolve/issue-109250.rs @@ -0,0 +1,3 @@ +fn main() { //~ HELP consider importing + HashMap::new; //~ ERROR failed to resolve: use of undeclared type `HashMap` +} diff --git a/tests/ui/resolve/issue-109250.stderr b/tests/ui/resolve/issue-109250.stderr new file mode 100644 index 000000000..d5b8c08ce --- /dev/null +++ b/tests/ui/resolve/issue-109250.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: use of undeclared type `HashMap` + --> $DIR/issue-109250.rs:2:5 + | +LL | HashMap::new; + | ^^^^^^^ use of undeclared type `HashMap` + | +help: consider importing this struct + | +LL + use std::collections::HashMap; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/issue-111312.rs b/tests/ui/resolve/issue-111312.rs new file mode 100644 index 000000000..acea37b35 --- /dev/null +++ b/tests/ui/resolve/issue-111312.rs @@ -0,0 +1,11 @@ +// edition: 2021 + +trait Has { + fn has() {} +} + +trait HasNot {} + +fn main() { + HasNot::has(); //~ ERROR +} diff --git a/tests/ui/resolve/issue-111312.stderr b/tests/ui/resolve/issue-111312.stderr new file mode 100644 index 000000000..4c864029c --- /dev/null +++ b/tests/ui/resolve/issue-111312.stderr @@ -0,0 +1,15 @@ +error[E0599]: no function or associated item named `has` found for trait `HasNot` + --> $DIR/issue-111312.rs:10:13 + | +LL | HasNot::has(); + | ^^^ function or associated item not found in `HasNot` + | +note: `Has` defines an item `has` + --> $DIR/issue-111312.rs:3:1 + | +LL | trait Has { + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/resolve/issue-111727.rs b/tests/ui/resolve/issue-111727.rs new file mode 100644 index 000000000..36f308121 --- /dev/null +++ b/tests/ui/resolve/issue-111727.rs @@ -0,0 +1,5 @@ +// edition: 2021 + +fn main() { + std::any::Any::create(); //~ ERROR +} diff --git a/tests/ui/resolve/issue-111727.stderr b/tests/ui/resolve/issue-111727.stderr new file mode 100644 index 000000000..bd748211e --- /dev/null +++ b/tests/ui/resolve/issue-111727.stderr @@ -0,0 +1,9 @@ +error[E0599]: no function or associated item named `create` found for trait `Any` + --> $DIR/issue-111727.rs:4:20 + | +LL | std::any::Any::create(); + | ^^^^^^ function or associated item not found in `Any` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-3099-a.rs b/tests/ui/resolve/issue-3099-a.rs index 9c3d8cf5a..9c3d8cf5a 100644 --- a/tests/ui/issues/issue-3099-a.rs +++ b/tests/ui/resolve/issue-3099-a.rs diff --git a/tests/ui/issues/issue-3099-a.stderr b/tests/ui/resolve/issue-3099-a.stderr index e3733cebb..e3733cebb 100644 --- a/tests/ui/issues/issue-3099-a.stderr +++ b/tests/ui/resolve/issue-3099-a.stderr diff --git a/tests/ui/issues/issue-3099-b.rs b/tests/ui/resolve/issue-3099-b.rs index 71952c3b0..71952c3b0 100644 --- a/tests/ui/issues/issue-3099-b.rs +++ b/tests/ui/resolve/issue-3099-b.rs diff --git a/tests/ui/issues/issue-3099-b.stderr b/tests/ui/resolve/issue-3099-b.stderr index c0cfefeb9..c0cfefeb9 100644 --- a/tests/ui/issues/issue-3099-b.stderr +++ b/tests/ui/resolve/issue-3099-b.stderr diff --git a/tests/ui/resolve/issue-50599.rs b/tests/ui/resolve/issue-50599.rs index 72238a591..00588735b 100644 --- a/tests/ui/resolve/issue-50599.rs +++ b/tests/ui/resolve/issue-50599.rs @@ -2,5 +2,4 @@ fn main() { const N: u32 = 1_000; const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value let mut digits = [0u32; M]; - //~^ constant } diff --git a/tests/ui/resolve/issue-50599.stderr b/tests/ui/resolve/issue-50599.stderr index d7419b64f..d58b6ca5b 100644 --- a/tests/ui/resolve/issue-50599.stderr +++ b/tests/ui/resolve/issue-50599.stderr @@ -16,12 +16,6 @@ LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; LL + const M: usize = (f64::from(N) * LOG10_2) as usize; | -note: erroneous constant used - --> $DIR/issue-50599.rs:4:29 - | -LL | let mut digits = [0u32; M]; - | ^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/resolve-variant-assoc-item.stderr b/tests/ui/resolve/resolve-variant-assoc-item.stderr index 4be101996..ed157197d 100644 --- a/tests/ui/resolve/resolve-variant-assoc-item.stderr +++ b/tests/ui/resolve/resolve-variant-assoc-item.stderr @@ -3,12 +3,26 @@ error[E0433]: failed to resolve: `V` is a variant, not a module | LL | E::V::associated_item; | ^ `V` is a variant, not a module + | +help: there is an enum variant `E::V`; try using the variant's enum + | +LL | E; + | ~ error[E0433]: failed to resolve: `V` is a variant, not a module --> $DIR/resolve-variant-assoc-item.rs:6:5 | LL | V::associated_item; | ^ `V` is a variant, not a module + | +help: there is an enum variant `E::V`; try using the variant's enum + | +LL | E; + | ~ +help: an enum with a similar name exists + | +LL | E::associated_item; + | ~ error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs b/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs index be775b37f..b9ff24c76 100644 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs +++ b/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs @@ -3,6 +3,8 @@ // check-pass +#![allow(dropping_references)] + // aux-build:monovariants.rs extern crate monovariants; diff --git a/tests/ui/rfc-2294-if-let-guard/feature-gate.rs b/tests/ui/rfc-2294-if-let-guard/feature-gate.rs index f0105e08e..3beb20f0a 100644 --- a/tests/ui/rfc-2294-if-let-guard/feature-gate.rs +++ b/tests/ui/rfc-2294-if-let-guard/feature-gate.rs @@ -10,10 +10,12 @@ fn _if_let_guard() { () if (let 0 = 1) => {} //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here () if (((let 0 = 1))) => {} //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here () if true && let 0 = 1 => {} //~^ ERROR `if let` guards are experimental @@ -26,16 +28,20 @@ fn _if_let_guard() { () if (let 0 = 1) && true => {} //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here () if true && (let 0 = 1) => {} //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here () if (let 0 = 1) && (let 0 = 1) => {} //~^ ERROR `let` expressions in this position are unstable //~| ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} //~^ ERROR `if let` guards are experimental @@ -47,6 +53,10 @@ fn _if_let_guard() { //~| ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + () if let Range { start: _, end: _ } = (true..true) && false => {} //~^ ERROR `if let` guards are experimental @@ -68,9 +78,11 @@ fn _macros() { use_expr!((let 0 = 1 && 0 == 0)); //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here use_expr!((let 0 = 1)); //~^ ERROR `let` expressions in this position are unstable //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here match () { #[cfg(FALSE)] () if let 0 = 1 => {} diff --git a/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr b/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr index 96fe11911..dc182ce46 100644 --- a/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr +++ b/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr @@ -5,67 +5,67 @@ LL | () if (let 0 = 1) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:14:18 + --> $DIR/feature-gate.rs:15:18 | LL | () if (((let 0 = 1))) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:26:16 + --> $DIR/feature-gate.rs:28:16 | LL | () if (let 0 = 1) && true => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:30:24 + --> $DIR/feature-gate.rs:33:24 | LL | () if true && (let 0 = 1) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:34:16 + --> $DIR/feature-gate.rs:38:16 | LL | () if (let 0 = 1) && (let 0 = 1) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:34:31 + --> $DIR/feature-gate.rs:38:31 | LL | () if (let 0 = 1) && (let 0 = 1) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:40:42 + --> $DIR/feature-gate.rs:46:42 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:40:55 + --> $DIR/feature-gate.rs:46:55 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:40:68 + --> $DIR/feature-gate.rs:46:68 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:68:16 + --> $DIR/feature-gate.rs:78:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:71:16 + --> $DIR/feature-gate.rs:82:16 | LL | use_expr!((let 0 = 1)); | ^^^ error: no rules expected the token `let` - --> $DIR/feature-gate.rs:80:15 + --> $DIR/feature-gate.rs:92:15 | LL | macro_rules! use_expr { | --------------------- when calling this macro @@ -74,11 +74,154 @@ LL | use_expr!(let 0 = 1); | ^^^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr` - --> $DIR/feature-gate.rs:61:10 + --> $DIR/feature-gate.rs:71:10 | LL | ($e:expr) => { | ^^^^^^^ +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:55 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:68 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + error[E0658]: `if let` guards are experimental --> $DIR/feature-gate.rs:7:12 | @@ -90,7 +233,7 @@ LL | () if let 0 = 1 => {} = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:18:12 + --> $DIR/feature-gate.rs:20:12 | LL | () if true && let 0 = 1 => {} | ^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +243,7 @@ LL | () if true && let 0 = 1 => {} = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:22:12 + --> $DIR/feature-gate.rs:24:12 | LL | () if let 0 = 1 && true => {} | ^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +253,7 @@ LL | () if let 0 = 1 && true => {} = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:40:12 + --> $DIR/feature-gate.rs:46:12 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +263,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:51:12 + --> $DIR/feature-gate.rs:61:12 | LL | () if let Range { start: _, end: _ } = (true..true) && false => {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +273,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {} = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>` error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:76:12 + --> $DIR/feature-gate.rs:88:12 | LL | () if let 0 = 1 => {} | ^^^^^^^^^^^^ @@ -149,7 +292,7 @@ LL | () if (let 0 = 1) => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:14:18 + --> $DIR/feature-gate.rs:15:18 | LL | () if (((let 0 = 1))) => {} | ^^^^^^^^^ @@ -158,7 +301,7 @@ LL | () if (((let 0 = 1))) => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:18:23 + --> $DIR/feature-gate.rs:20:23 | LL | () if true && let 0 = 1 => {} | ^^^^^^^^^ @@ -167,7 +310,7 @@ LL | () if true && let 0 = 1 => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:22:15 + --> $DIR/feature-gate.rs:24:15 | LL | () if let 0 = 1 && true => {} | ^^^^^^^^^ @@ -176,7 +319,7 @@ LL | () if let 0 = 1 && true => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:26:16 + --> $DIR/feature-gate.rs:28:16 | LL | () if (let 0 = 1) && true => {} | ^^^^^^^^^ @@ -185,7 +328,7 @@ LL | () if (let 0 = 1) && true => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:30:24 + --> $DIR/feature-gate.rs:33:24 | LL | () if true && (let 0 = 1) => {} | ^^^^^^^^^ @@ -194,7 +337,7 @@ LL | () if true && (let 0 = 1) => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:34:16 + --> $DIR/feature-gate.rs:38:16 | LL | () if (let 0 = 1) && (let 0 = 1) => {} | ^^^^^^^^^ @@ -203,7 +346,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:34:31 + --> $DIR/feature-gate.rs:38:31 | LL | () if (let 0 = 1) && (let 0 = 1) => {} | ^^^^^^^^^ @@ -212,7 +355,7 @@ LL | () if (let 0 = 1) && (let 0 = 1) => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:40:15 + --> $DIR/feature-gate.rs:46:15 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^ @@ -221,7 +364,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:40:28 + --> $DIR/feature-gate.rs:46:28 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^ @@ -230,7 +373,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:40:42 + --> $DIR/feature-gate.rs:46:42 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^ @@ -239,7 +382,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:40:55 + --> $DIR/feature-gate.rs:46:55 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^ @@ -248,7 +391,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:40:68 + --> $DIR/feature-gate.rs:46:68 | LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} | ^^^^^^^^^ @@ -257,7 +400,7 @@ LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:51:15 + --> $DIR/feature-gate.rs:61:15 | LL | () if let Range { start: _, end: _ } = (true..true) && false => {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -266,7 +409,7 @@ LL | () if let Range { start: _, end: _ } = (true..true) && false => {} = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:68:16 + --> $DIR/feature-gate.rs:78:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^^^^^^^ @@ -275,7 +418,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = help: add `#![feature(let_chains)]` to the crate attributes to enable error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:71:16 + --> $DIR/feature-gate.rs:82:16 | LL | use_expr!((let 0 = 1)); | ^^^^^^^^^ @@ -283,6 +426,6 @@ LL | use_expr!((let 0 = 1)); = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information = help: add `#![feature(let_chains)]` to the crate attributes to enable -error: aborting due to 34 previous errors +error: aborting due to 45 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs index 04d924a9a..542be3942 100644 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs +++ b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs @@ -4,6 +4,8 @@ // Tests ensuring that `dbg!(expr)` has the expected run-time behavior. // as well as some compile time properties we expect. +#![allow(dropping_copy_types)] + #[derive(Copy, Clone, Debug)] struct Unit; diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr index 49d72158e..a20a6062c 100644 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr +++ b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr @@ -1,28 +1,28 @@ -[$DIR/dbg-macro-expected-behavior.rs:20] Unit = Unit -[$DIR/dbg-macro-expected-behavior.rs:21] a = Unit -[$DIR/dbg-macro-expected-behavior.rs:27] Point { x: 42, y: 24 } = Point { +[$DIR/dbg-macro-expected-behavior.rs:22] Unit = Unit +[$DIR/dbg-macro-expected-behavior.rs:23] a = Unit +[$DIR/dbg-macro-expected-behavior.rs:29] Point { x: 42, y: 24 } = Point { x: 42, y: 24, } -[$DIR/dbg-macro-expected-behavior.rs:28] b = Point { +[$DIR/dbg-macro-expected-behavior.rs:30] b = Point { x: 42, y: 24, } -[$DIR/dbg-macro-expected-behavior.rs:36] -[$DIR/dbg-macro-expected-behavior.rs:40] &a = NoCopy( +[$DIR/dbg-macro-expected-behavior.rs:38] +[$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( 1337, ) -[$DIR/dbg-macro-expected-behavior.rs:40] dbg!(& a) = NoCopy( +[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(& a) = NoCopy( 1337, ) -[$DIR/dbg-macro-expected-behavior.rs:45] f(&42) = 42 +[$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 before -[$DIR/dbg-macro-expected-behavior.rs:50] { foo += 1; eprintln!("before"); 7331 } = 7331 -[$DIR/dbg-macro-expected-behavior.rs:58] ("Yeah",) = ( +[$DIR/dbg-macro-expected-behavior.rs:52] { foo += 1; eprintln!("before"); 7331 } = 7331 +[$DIR/dbg-macro-expected-behavior.rs:60] ("Yeah",) = ( "Yeah", ) -[$DIR/dbg-macro-expected-behavior.rs:61] 1 = 1 -[$DIR/dbg-macro-expected-behavior.rs:61] 2 = 2 -[$DIR/dbg-macro-expected-behavior.rs:65] 1u8 = 1 -[$DIR/dbg-macro-expected-behavior.rs:65] 2u32 = 2 -[$DIR/dbg-macro-expected-behavior.rs:65] "Yeah" = "Yeah" +[$DIR/dbg-macro-expected-behavior.rs:63] 1 = 1 +[$DIR/dbg-macro-expected-behavior.rs:63] 2 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67] 1u8 = 1 +[$DIR/dbg-macro-expected-behavior.rs:67] 2u32 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67] "Yeah" = "Yeah" diff --git a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs new file mode 100644 index 000000000..e6dee2a1d --- /dev/null +++ b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs @@ -0,0 +1,23 @@ +#![feature(let_chains)] + +fn let_or_guard(x: Result<Option<i32>, ()>) { + match x { + Ok(opt) if let Some(4) = opt || false => {} + //~^ ERROR `let` expressions are not supported here + _ => {} + } +} + +fn hiding_unsafe_mod(x: Result<Option<i32>, ()>) { + match x { + Ok(opt) + if { + unsafe mod a {}; + //~^ ERROR module cannot be declared unsafe + false + } => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr new file mode 100644 index 000000000..26850998c --- /dev/null +++ b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr @@ -0,0 +1,21 @@ +error: `let` expressions are not supported here + --> $DIR/ast-validate-guards.rs:5:20 + | +LL | Ok(opt) if let Some(4) = opt || false => {} + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/ast-validate-guards.rs:5:38 + | +LL | Ok(opt) if let Some(4) = opt || false => {} + | ^^ + +error: module cannot be declared unsafe + --> $DIR/ast-validate-guards.rs:15:17 + | +LL | unsafe mod a {}; + | ^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr b/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr index 6d18d295c..16e1af460 100644 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr +++ b/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr @@ -10,6 +10,12 @@ note: the lint level is defined here LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:41:27 + | +LL | #[cfg(something)] a: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_a` + error: unused variable: `b` --> $DIR/param-attrs-cfg.rs:30:23 | @@ -22,12 +28,6 @@ error: unused variable: `c` LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, | ^ help: if this is intentional, prefix it with an underscore: `_c` -error: unused variable: `a` - --> $DIR/param-attrs-cfg.rs:41:27 - | -LL | #[cfg(something)] a: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_a` - error: unused variable: `b` --> $DIR/param-attrs-cfg.rs:48:27 | diff --git a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs new file mode 100644 index 000000000..d7a418959 --- /dev/null +++ b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs @@ -0,0 +1,19 @@ +// Tests that dlltool failing to generate an import library will raise an error. + +// only-gnu +// only-windows +// needs-dlltool +// compile-flags: --crate-type lib --emit link +// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL" +// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE" +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + // `@1` is an invalid name to export, as it usually indicates that something + // is being exported via ordinal. + #[link_name = "@1"] + fn f(x: i32); +} + +pub fn lib_main() { + unsafe { f(42); } +} diff --git a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr new file mode 100644 index 000000000..020ac6a2b --- /dev/null +++ b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr @@ -0,0 +1,5 @@ +error: Dlltool could not create import library: + $DLLTOOL: Syntax error in def file $DEF_FILE:1 + +error: aborting due to previous error + diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs index 22d57f8be..7bc44d65b 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs @@ -1,7 +1,5 @@ // only-windows // only-x86 -#![feature(raw_dylib)] - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] //~^ ERROR import name type must be of the form `import_name_type = "string"` extern "C" { } diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr index 0e95fec29..fb70b987f 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr @@ -1,5 +1,5 @@ error: import name type must be of the form `import_name_type = "string"` - --> $DIR/import-name-type-invalid-format.rs:5:42 + --> $DIR/import-name-type-invalid-format.rs:3:42 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs index 7ccb0082f..b96f61a26 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs @@ -1,8 +1,6 @@ // ignore-tidy-linelength // only-windows // only-x86 -#![feature(raw_dylib)] - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] //~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute extern "C" { } diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr index 7c0e0be91..953306189 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr @@ -1,5 +1,5 @@ error: multiple `import_name_type` arguments in a single `#[link]` attribute - --> $DIR/import-name-type-multiple.rs:6:74 + --> $DIR/import-name-type-multiple.rs:4:74 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs index f728a578d..067e82a17 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs @@ -1,7 +1,5 @@ // only-windows // only-x86 -#![feature(raw_dylib)] - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] //~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated extern "C" { } diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr index 2b299f2fe..2bce9758e 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr @@ -1,5 +1,5 @@ error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated - --> $DIR/import-name-type-unknown-value.rs:5:42 + --> $DIR/import-name-type-unknown-value.rs:3:42 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs index ae9207864..34e907bde 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs @@ -1,7 +1,5 @@ // only-windows // only-x86 -#![feature(raw_dylib)] - #[link(name = "foo", import_name_type = "decorated")] //~^ ERROR import name type can only be used with link kind `raw-dylib` extern "C" { } diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr index 5898cd875..75cadc471 100644 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr +++ b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr @@ -1,11 +1,11 @@ error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:5:22 + --> $DIR/import-name-type-unsupported-link-kind.rs:3:22 | LL | #[link(name = "foo", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:9:39 + --> $DIR/import-name-type-unsupported-link-kind.rs:7:39 | LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs new file mode 100644 index 000000000..a07be9d92 --- /dev/null +++ b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs @@ -0,0 +1,13 @@ +// Tests that failing to run dlltool will raise an error. + +// only-gnu +// only-windows +// compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + fn f(x: i32); +} + +pub fn lib_main() { + unsafe { f(42); } +} diff --git a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr new file mode 100644 index 000000000..3ae901e0d --- /dev/null +++ b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr @@ -0,0 +1,4 @@ +error: Error calling dlltool 'does_not_exit.exe': program not found + +error: aborting due to previous error + diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs index 1a128c87a..b04c2facb 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name="foo")] extern "C" { #[link_name="foo"] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr index 481a06d27..f1e54d378 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr @@ -1,11 +1,11 @@ error: cannot use `#[link_name]` with `#[link_ordinal]` - --> $DIR/link-ordinal-and-name.rs:6:5 + --> $DIR/link-ordinal-and-name.rs:4:5 | LL | #[link_ordinal(42)] | ^^^^^^^^^^^^^^^^^^^ error: cannot use `#[link_name]` with `#[link_ordinal]` - --> $DIR/link-ordinal-and-name.rs:10:5 + --> $DIR/link-ordinal-and-name.rs:8:5 | LL | #[link_ordinal(5)] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs index 7c8da050c..9b7e8d707 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo")] extern "C" { #[link_ordinal("JustMonika")] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr index 55cdcad75..6341e57a0 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr @@ -1,5 +1,5 @@ error: illegal ordinal format in `link_ordinal` - --> $DIR/link-ordinal-invalid-format.rs:5:5 + --> $DIR/link-ordinal-invalid-format.rs:3:5 | LL | #[link_ordinal("JustMonika")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[link_ordinal("JustMonika")] = note: an unsuffixed integer value, e.g., `1`, is expected error: illegal ordinal format in `link_ordinal` - --> $DIR/link-ordinal-invalid-format.rs:8:5 + --> $DIR/link-ordinal-invalid-format.rs:6:5 | LL | #[link_ordinal("JustMonika")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs index 9feed3941..6b8cd4956 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo")] extern "C" { #[link_ordinal()] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr index 853cdad8c..1b04bb228 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr @@ -1,5 +1,5 @@ error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-missing-argument.rs:5:5 + --> $DIR/link-ordinal-missing-argument.rs:3:5 | LL | #[link_ordinal()] | ^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[link_ordinal()] = note: the attribute requires exactly one argument error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-missing-argument.rs:8:5 + --> $DIR/link-ordinal-missing-argument.rs:6:5 | LL | #[link_ordinal()] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs index 631c363d4..8842cb944 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs @@ -1,6 +1,4 @@ // only-windows -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo", kind = "raw-dylib")] extern "C" { #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr index c0453d2bf..2e6cf3761 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr @@ -1,23 +1,23 @@ error: multiple `link_ordinal` attributes - --> $DIR/link-ordinal-multiple.rs:6:5 + --> $DIR/link-ordinal-multiple.rs:4:5 | LL | #[link_ordinal(1)] | ^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/link-ordinal-multiple.rs:7:5 + --> $DIR/link-ordinal-multiple.rs:5:5 | LL | #[link_ordinal(2)] | ^^^^^^^^^^^^^^^^^^ error: multiple `link_ordinal` attributes - --> $DIR/link-ordinal-multiple.rs:9:5 + --> $DIR/link-ordinal-multiple.rs:7:5 | LL | #[link_ordinal(1)] | ^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/link-ordinal-multiple.rs:10:5 + --> $DIR/link-ordinal-multiple.rs:8:5 | LL | #[link_ordinal(2)] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs index 54e614164..f33a3d62e 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link_ordinal(123)] //~^ ERROR attribute should be applied to a foreign function or static struct Foo {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr index ec4104fbe..8f2795087 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr @@ -1,17 +1,17 @@ error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:3:1 + --> $DIR/link-ordinal-not-foreign-fn.rs:1:1 | LL | #[link_ordinal(123)] | ^^^^^^^^^^^^^^^^^^^^ error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:7:1 + --> $DIR/link-ordinal-not-foreign-fn.rs:5:1 | LL | #[link_ordinal(123)] | ^^^^^^^^^^^^^^^^^^^^ error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:11:1 + --> $DIR/link-ordinal-not-foreign-fn.rs:9:1 | LL | #[link_ordinal(42)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs index 46731581e..9d741630f 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo")] extern "C" { #[link_ordinal(72436)] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr index fef6de6ae..811145e77 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr @@ -1,5 +1,5 @@ error: ordinal value in `link_ordinal` is too large: `72436` - --> $DIR/link-ordinal-too-large.rs:5:5 + --> $DIR/link-ordinal-too-large.rs:3:5 | LL | #[link_ordinal(72436)] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[link_ordinal(72436)] = note: the value may not exceed `u16::MAX` error: ordinal value in `link_ordinal` is too large: `72436` - --> $DIR/link-ordinal-too-large.rs:8:5 + --> $DIR/link-ordinal-too-large.rs:6:5 | LL | #[link_ordinal(72436)] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs index 71e0ac9f3..9988115fd 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo")] extern "C" { #[link_ordinal(3, 4)] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr index 7e0fcd845..d5ce8aff3 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr @@ -1,5 +1,5 @@ error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-too-many-arguments.rs:5:5 + --> $DIR/link-ordinal-too-many-arguments.rs:3:5 | LL | #[link_ordinal(3, 4)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[link_ordinal(3, 4)] = note: the attribute requires exactly one argument error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-too-many-arguments.rs:8:5 + --> $DIR/link-ordinal-too-many-arguments.rs:6:5 | LL | #[link_ordinal(3, 4)] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs index 329c93fc1..14e915d60 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs @@ -1,5 +1,3 @@ -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] - #[link(name = "foo")] extern "C" { #[link_ordinal(3)] diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr index 5fbffbda5..200b8f628 100644 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr +++ b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr @@ -1,11 +1,11 @@ error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` - --> $DIR/link-ordinal-unsupported-link-kind.rs:5:5 + --> $DIR/link-ordinal-unsupported-link-kind.rs:3:5 | LL | #[link_ordinal(3)] | ^^^^^^^^^^^^^^^^^^ error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` - --> $DIR/link-ordinal-unsupported-link-kind.rs:12:5 + --> $DIR/link-ordinal-unsupported-link-kind.rs:10:5 | LL | #[link_ordinal(3)] | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs index 6542faad2..b4173f3b6 100644 --- a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs +++ b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs @@ -2,7 +2,6 @@ // only-windows // compile-flags: --crate-type lib --emit link #![allow(clashing_extern_declarations)] -#![feature(raw_dylib)] #[link(name = "foo", kind = "raw-dylib")] extern "C" { fn f(x: i32); diff --git a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr index c6808bec7..510108405 100644 --- a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr +++ b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr @@ -1,5 +1,5 @@ error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions - --> $DIR/multiple-declarations.rs:14:9 + --> $DIR/multiple-declarations.rs:13:9 | LL | fn f(x: i32); | ^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs index 4efffbd53..d4c6658a3 100644 --- a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs +++ b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs @@ -1,6 +1,5 @@ // ignore-windows // compile-flags: --crate-type lib -#![cfg_attr(target_arch = "x86", feature(raw_dylib))] #[link(name = "foo", kind = "raw-dylib")] //~^ ERROR: link kind `raw-dylib` is only supported on Windows targets extern "C" {} diff --git a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr index 14e791f1f..b635a09af 100644 --- a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr +++ b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr @@ -1,5 +1,5 @@ error[E0455]: link kind `raw-dylib` is only supported on Windows targets - --> $DIR/raw-dylib-windows-only.rs:4:29 + --> $DIR/raw-dylib-windows-only.rs:3:29 | LL | #[link(name = "foo", kind = "raw-dylib")] | ^^^^^^^^^^^ diff --git a/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs b/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs index 7d9dae52c..96790a873 100644 --- a/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs +++ b/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(const_trait_impl)] struct NonConstAdd(i32); @@ -17,7 +19,6 @@ trait Foo { impl const Foo for NonConstAdd { type Bar = NonConstAdd; - //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts } #[const_trait] diff --git a/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr b/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr index 89177b0f1..0cffae1da 100644 --- a/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr @@ -1,21 +1,8 @@ -error[E0277]: cannot add `NonConstAdd` to `NonConstAdd` in const contexts - --> $DIR/assoc-type.rs:19:16 - | -LL | type Bar = NonConstAdd; - | ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd` - | - = help: the trait `~const Add` is not implemented for `NonConstAdd` -note: the trait `Add` is implemented for `NonConstAdd`, but that implementation is not `const` - --> $DIR/assoc-type.rs:19:16 - | -LL | type Bar = NonConstAdd; - | ^^^^^^^^^^^ -note: required by a bound in `Foo::Bar` - --> $DIR/assoc-type.rs:15:15 +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/assoc-type.rs:17:22 | LL | type Bar: ~const std::ops::Add; - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar` + | ^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs index b64161b6a..ae0c2e6bc 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs @@ -1,4 +1,4 @@ -// run-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr new file mode 100644 index 000000000..ff53eea11 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/call-const-trait-method-pass.rs:7:12 + | +LL | impl const std::ops::Add for Int { + | ^^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-const-trait-method-pass.rs:15:12 + | +LL | impl const PartialEq for Int { + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs index 50c465790..5120e6bfb 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(const_trait_impl)] #[const_trait] diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr new file mode 100644 index 000000000..02d53cc78 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-in-impl.rs:9:16 + | +LL | impl<T: ~const PartialEq> const MyPartialEq for T { + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs index b00ff1f2f..3febb328a 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs @@ -1,6 +1,6 @@ //! Basic test for calling methods on generic type parameters in `const fn`. -// check-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr new file mode 100644 index 000000000..529a472e0 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr @@ -0,0 +1,23 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-chain.rs:9:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-chain.rs:18:32 + | +LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-chain.rs:22:40 + | +LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool { + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs index c8ded0fa7..e618160d3 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr new file mode 100644 index 000000000..bdc6ccc8a --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr @@ -0,0 +1,23 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-dup-bound.rs:7:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-dup-bound.rs:18:44 + | +LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-dup-bound.rs:25:37 + | +LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool { + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs index 2bc5ee512..fe1abbf42 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs @@ -1,8 +1,9 @@ +// known-bug: #110395 #![feature(const_trait_impl)] pub const fn equals_self<T: PartialEq>(t: &T) -> bool { *t == *t - //~^ ERROR can't compare + // (remove this) ~^ ERROR can't compare } fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr index 31e6dbdab..3963f64ad 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr @@ -1,15 +1,28 @@ -error[E0277]: can't compare `T` with `_` in const contexts - --> $DIR/call-generic-method-fail.rs:4:8 +error[E0277]: can't compare `T` with `T` in const contexts + --> $DIR/call-generic-method-fail.rs:5:5 | LL | *t == *t - | ^^ no implementation for `T == _` + | ^^^^^^^^ no implementation for `T == T` | -note: the trait `PartialEq<_>` is implemented for `T`, but that implementation is not `const` - --> $DIR/call-generic-method-fail.rs:4:8 +note: the trait `PartialEq` is implemented for `T`, but that implementation is not `const` + --> $DIR/call-generic-method-fail.rs:5:5 | LL | *t == *t - | ^^ + | ^^^^^^^^ -error: aborting due to previous error +error[E0015]: cannot call non-const operator in constant functions + --> $DIR/call-generic-method-fail.rs:5:5 + | +LL | *t == *t + | ^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider further restricting this bound + | +LL | pub const fn equals_self<T: PartialEq + ~const std::cmp::PartialEq>(t: &T) -> bool { + | ++++++++++++++++++++++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs index 40565d1b7..09f35a277 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs @@ -1,6 +1,6 @@ //! Basic test for calling methods on generic type parameters in `const fn`. -// check-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr new file mode 100644 index 000000000..7fbe89dba --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr @@ -0,0 +1,17 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-pass.rs:9:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-pass.rs:18:32 + | +LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs index f66d63da6..9ba19e800 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs @@ -1,9 +1,10 @@ +// known-bug: #110395 + #![feature(const_trait_impl)] pub struct Int(i32); impl const std::ops::Add for i32 { - //~^ ERROR only traits defined in the current crate can be implemented for primitive types type Output = Self; fn add(self, rhs: Self) -> Self { @@ -20,7 +21,6 @@ impl std::ops::Add for Int { } impl const std::ops::Add for Int { - //~^ ERROR conflicting implementations of trait type Output = Self; fn add(self, rhs: Self) -> Self { diff --git a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr index 36a09add4..4f858d61e 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -1,25 +1,20 @@ -error[E0117]: only traits defined in the current crate can be implemented for primitive types - --> $DIR/const-and-non-const-impl.rs:5:1 +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/const-and-non-const-impl.rs:7:12 | LL | impl const std::ops::Add for i32 { - | ^^^^^^^^^^^-------------^^^^^--- - | | | | - | | | `i32` is not defined in the current crate - | | `i32` is not defined in the current crate - | impl doesn't use only types from inside the current crate + | ^^^^^^^^^^^^^ | - = note: define and implement a trait or new type instead + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change -error[E0119]: conflicting implementations of trait `Add` for type `Int` - --> $DIR/const-and-non-const-impl.rs:22:1 +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/const-and-non-const-impl.rs:23:12 | -LL | impl std::ops::Add for Int { - | -------------------------- first implementation here -... LL | impl const std::ops::Add for Int { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` + | ^^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change error: aborting due to 2 previous errors -Some errors have detailed explanations: E0117, E0119. -For more information about an error, try `rustc --explain E0117`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs index b5f19e40c..b4cc7a9e1 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + #![feature(const_trait_impl)] #[const_trait] @@ -14,6 +16,5 @@ const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { } const _: () = assert!(need_const_closure(Tr::a) == 42); -//~^ ERROR: the trait bound fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index ffc24ec6e..112416a35 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}` - --> $DIR/const-closure-trait-method-fail.rs:16:23 + --> $DIR/const-closure-trait-method-fail.rs:18:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` | note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/const-closure-trait-method-fail.rs:16:23 + --> $DIR/const-closure-trait-method-fail.rs:18:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closures.rs b/tests/ui/rfc-2632-const-trait-impl/const-closures.rs index 755d85398..7c55b51c8 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-closures.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-closures.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr index bcdc80f82..13350a6d1 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr @@ -1,50 +1,26 @@ -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:23:25 | -LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` +LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { + | ^^^^ | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:31:23 - | -LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:33:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-fail-2.rs:29:26 | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:33:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` +LL | const fn check<T: ~const Destruct>(_: T) {} + | ^^^^^^^^ -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail-2.rs:39:9 +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:39:25 | LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail-2.rs:37:1 + | ^^^^ | -LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs index 6a252c5d3..3de9d37d4 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs @@ -1,4 +1,4 @@ -// revisions: stock precise +// known-bug: #110395 #![feature(const_trait_impl)] #![feature(const_mut_refs)] #![cfg_attr(precise, feature(const_precise_live_drops))] @@ -29,15 +29,12 @@ impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { const fn check<T: ~const Destruct>(_: T) {} const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( - //~^ ERROR the trait bound ConstDropImplWithBounds(PhantomData) - //~^ ERROR the trait bound ); struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { -//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not fn drop(&mut self) { T::a(); } diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr new file mode 100644 index 000000000..375f5d2c5 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -0,0 +1,50 @@ +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:32:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:32:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail-2.rs:37:9 + | +LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { + | ^^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail-2.rs:35:1 + | +LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr index bcdc80f82..13350a6d1 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr @@ -1,50 +1,26 @@ -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:23:25 | -LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` +LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { + | ^^^^ | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:31:23 - | -LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:33:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-fail-2.rs:29:26 | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail-2.rs:33:5 - | -LL | ConstDropImplWithBounds(PhantomData) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail-2.rs:21:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` +LL | const fn check<T: ~const Destruct>(_: T) {} + | ^^^^^^^^ -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail-2.rs:39:9 +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:39:25 | LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail-2.rs:37:1 + | ^^^^ | -LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index 40caada51..e745cbd24 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,5 +1,5 @@ error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` @@ -11,7 +11,7 @@ LL | | } | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | | } = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` @@ -36,7 +36,7 @@ LL | | } | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | | ConstImplWithDropGlue(NonTrivialDrop), LL | | } | |_- in this macro invocation note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:16:8 + --> $DIR/const-drop-fail.rs:18:8 | LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs index c4bdb9ef5..1c37648ff 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 + // revisions: stock precise #![feature(const_trait_impl)] #![feature(const_mut_refs)] @@ -24,8 +26,6 @@ const fn check<T: ~const Destruct>(_: T) {} macro_rules! check_all { ($($exp:expr),*$(,)?) => {$( const _: () = check($exp); - //~^ ERROR can't drop - //~| ERROR can't drop )*}; } diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index 40caada51..e745cbd24 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,5 +1,5 @@ error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` @@ -11,7 +11,7 @@ LL | | } | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | | } = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` @@ -36,7 +36,7 @@ LL | | } | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:26:23 + --> $DIR/const-drop-fail.rs:28:23 | LL | const _: () = check($exp); | ^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | | ConstImplWithDropGlue(NonTrivialDrop), LL | | } | |_- in this macro invocation note: required because it appears within the type `ConstImplWithDropGlue` - --> $DIR/const-drop-fail.rs:16:8 + --> $DIR/const-drop-fail.rs:18:8 | LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs index 0622f96e7..f396deff4 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![allow(incomplete_features)] #![feature( associated_type_bounds, diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr new file mode 100644 index 000000000..f9078e227 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr @@ -0,0 +1,39 @@ +error[E0635]: unknown feature `const_cmp` + --> $DIR/const-impl-trait.rs:6:5 + | +LL | const_cmp, + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:12:30 + | +LL | const fn cmp(a: &impl ~const PartialEq) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:16:30 + | +LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:17:20 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:24:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:28:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs index 348ca0ab1..dba3ad7f8 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs @@ -1,4 +1,5 @@ #[derive_const(Default)] //~ ERROR use of unstable library feature +//~^ ERROR not marked with `#[const_trait]` pub struct S; fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr index cc9bdd271..6a81f96d8 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr @@ -6,6 +6,16 @@ LL | #[derive_const(Default)] | = help: add `#![feature(derive_const)]` to the crate attributes to enable -error: aborting due to previous error +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/derive-const-gate.rs:1:16 + | +LL | #[derive_const(Default)] + | ^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs index ed6699f37..b575ea8da 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs @@ -1,3 +1,4 @@ +// known-bug: #110395 #![feature(derive_const)] pub struct A; @@ -8,7 +9,5 @@ impl Default for A { #[derive_const(Default)] pub struct S(A); -//~^ cannot call non-const fn -//~| the trait bound fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr index 653037ef3..1c69ad431 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr @@ -1,38 +1,12 @@ -error[E0277]: the trait bound `A: Default` is not satisfied - --> $DIR/derive-const-non-const-type.rs:10:14 +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/derive-const-non-const-type.rs:10:16 | LL | #[derive_const(Default)] - | ------- in this derive macro expansion -LL | pub struct S(A); - | ^ the trait `~const Default` is not implemented for `A` + | ^^^^^^^ | -note: the trait `Default` is implemented for `A`, but that implementation is not `const` - --> $DIR/derive-const-non-const-type.rs:10:14 - | -LL | #[derive_const(Default)] - | ------- in this derive macro expansion -LL | pub struct S(A); - | ^ - = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider annotating `A` with `#[derive(Default)]` - | -LL + #[derive(Default)] -LL | pub struct A; - | - -error[E0015]: cannot call non-const fn `<A as Default>::default` in constant functions - --> $DIR/derive-const-non-const-type.rs:10:14 - | -LL | #[derive_const(Default)] - | ------- in this derive macro expansion -LL | pub struct S(A); - | ^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs index d1fbeac85..69098542b 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] pub struct A; diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr new file mode 100644 index 000000000..88054096e --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr @@ -0,0 +1,53 @@ +error[E0635]: unknown feature `const_cmp` + --> $DIR/derive-const-use.rs:2:30 + | +LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] + | ^^^^^^^^^ + +error[E0635]: unknown feature `const_default_impls` + --> $DIR/derive-const-use.rs:2:41 + | +LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] + | ^^^^^^^^^^^^^^^^^^^ + +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:6:12 + | +LL | impl const Default for A { + | ^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:10:12 + | +LL | impl const PartialEq for A { + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:14:16 + | +LL | #[derive_const(Default, PartialEq)] + | ^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:14:25 + | +LL | #[derive_const(Default, PartialEq)] + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs index 72edfbc97..2a5d0176b 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(derive_const)] #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr new file mode 100644 index 000000000..fa7832658 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-with-params.rs:6:16 + | +LL | #[derive_const(PartialEq)] + | ^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/derive-const-with-params.rs:6:16 + | +LL | #[derive_const(PartialEq)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs b/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs index 5495b531c..d665c4479 100644 --- a/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs +++ b/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs @@ -1,4 +1,4 @@ -// run-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr new file mode 100644 index 000000000..1b21d7c0e --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr @@ -0,0 +1,11 @@ +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/generic-bound.rs:16:15 + | +LL | impl<T> const std::ops::Add for S<T> { + | ^^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: aborting due to previous error + diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs index 1a4509b18..dff8a2444 100644 --- a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs +++ b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr new file mode 100644 index 000000000..cfdda4713 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/non-const-op-in-closure-in-const.rs:10:51 + | +LL | impl<A, B> const Convert<B> for A where B: ~const From<A> { + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs index 3ac909924..f31123f16 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs @@ -12,7 +12,9 @@ trait Specialize {} trait Foo {} #[const_trait] -trait Bar {} +trait Bar { + fn bar(); +} // bgr360: I was only able to exercise the code path that raises the // "missing ~const qualifier" error by making this base impl non-const, even @@ -21,26 +23,36 @@ trait Bar {} impl<T> Bar for T where T: ~const Foo, -{} +{ + default fn bar() {} +} impl<T> Bar for T where T: Foo, //~ ERROR missing `~const` qualifier T: Specialize, -{} +{ + fn bar() {} +} #[const_trait] -trait Baz {} +trait Baz { + fn baz(); +} impl<T> const Baz for T where T: ~const Foo, -{} +{ + default fn baz() {} +} impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz` where T: Foo, T: Specialize, -{} +{ + fn baz() {} +} fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr index 4aea19794..057cf4aea 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -1,11 +1,11 @@ error: missing `~const` qualifier for specialization - --> $DIR/const-default-bound-non-const-specialized-bound.rs:28:8 + --> $DIR/const-default-bound-non-const-specialized-bound.rs:32:8 | LL | T: Foo, | ^^^ error[E0119]: conflicting implementations of trait `Baz` - --> $DIR/const-default-bound-non-const-specialized-bound.rs:40:1 + --> $DIR/const-default-bound-non-const-specialized-bound.rs:50:1 | LL | impl<T> const Baz for T | ----------------------- first implementation here diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs index 9c2c2cf16..92d8be6bb 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs +++ b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs @@ -11,27 +11,39 @@ trait Specialize {} #[const_trait] -trait Foo {} +trait Foo { + fn foo(); +} -impl<T> const Foo for T {} +impl<T> const Foo for T { + default fn foo() {} +} impl<T> const Foo for T where T: ~const Specialize, -{} +{ + fn foo() {} +} #[const_trait] -trait Bar {} +trait Bar { + fn bar() {} +} impl<T> const Bar for T where T: ~const Foo, -{} +{ + default fn bar() {} +} impl<T> const Bar for T where T: ~const Foo, T: ~const Specialize, -{} +{ + fn bar() {} +} fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs index 1e6b1c651..51bfaf73b 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs +++ b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -15,31 +15,43 @@ trait Specialize {} trait Foo {} #[const_trait] -trait Bar {} +trait Bar { + fn bar(); +} impl<T> Bar for T where T: Foo, -{} +{ + default fn bar() {} +} impl<T> const Bar for T where T: ~const Foo, T: Specialize, -{} +{ + fn bar() {} +} #[const_trait] -trait Baz {} +trait Baz { + fn baz(); +} impl<T> const Baz for T where T: Foo, -{} +{ + default fn baz() {} +} impl<T> const Baz for T where T: ~const Foo, T: Specialize, -{} +{ + fn baz() {} +} fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs index 9ab170f09..5c2a3f801 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs +++ b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs @@ -11,13 +11,16 @@ pub trait A { fn a() -> u32; } -impl<T: ~const Default> const A for T { +#[const_trait] +pub trait Spec {} + +impl<T: ~const Spec> const A for T { default fn a() -> u32 { 2 } } -impl<T: Default + Sup> A for T { +impl<T: Spec + Sup> A for T { //~^ ERROR: cannot specialize //~| ERROR: missing `~const` qualifier fn a() -> u32 { diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr index 843fc6ce8..1ffdc50e5 100644 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr @@ -1,14 +1,14 @@ error: cannot specialize on const impl with non-const impl - --> $DIR/specializing-constness.rs:20:1 + --> $DIR/specializing-constness.rs:23:1 | -LL | impl<T: Default + Sup> A for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl<T: Spec + Sup> A for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing `~const` qualifier for specialization - --> $DIR/specializing-constness.rs:20:9 + --> $DIR/specializing-constness.rs:23:9 | -LL | impl<T: Default + Sup> A for T { - | ^^^^^^^ +LL | impl<T: Spec + Sup> A for T { + | ^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr new file mode 100644 index 000000000..78aab9469 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr @@ -0,0 +1,9 @@ +error[E0635]: unknown feature `const_default_impls` + --> $DIR/std-impl-gate.rs:6:46 + | +LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs index 2f54c09e3..e9e5e0235 100644 --- a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs +++ b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs @@ -1,7 +1,7 @@ // This tests feature gates for const impls in the standard library. // revisions: stock gated -//[gated] run-pass +//[gated] known-bug: #110395 #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr index d4f42b787..97f346e8c 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr @@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits LL | trait Bar: ~const Foo {} | ^^^ -error: aborting due to previous error +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr index d4f42b787..97f346e8c 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr @@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits LL | trait Bar: ~const Foo {} | ^^^ -error: aborting due to previous error +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs index d183efde2..ecb06271c 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -10,6 +10,7 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} //[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` const fn foo<T: Bar>(x: &T) { x.a(); diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr index 13fc719f2..c9fa19554 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: ~const Foo` is not satisfied - --> $DIR/super-traits-fail-2.rs:15:7 + --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); | ^ the trait `~const Foo` is not implemented for `T` | note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:15:5 + --> $DIR/super-traits-fail-2.rs:16:5 | LL | x.a(); | ^ diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr index 13fc719f2..c9fa19554 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: ~const Foo` is not satisfied - --> $DIR/super-traits-fail-2.rs:15:7 + --> $DIR/super-traits-fail-2.rs:16:7 | LL | x.a(); | ^ the trait `~const Foo` is not implemented for `T` | note: the trait `Foo` is implemented for `T`, but that implementation is not `const` - --> $DIR/super-traits-fail-2.rs:15:5 + --> $DIR/super-traits-fail-2.rs:16:5 | LL | x.a(); | ^ diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr index d433e1cfa..fdc6b8058 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr @@ -5,10 +5,16 @@ LL | trait Bar: ~const Foo {} | ^^^ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:15:24 + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:16:24 | LL | const fn foo<T: ~const Bar>(x: &T) { | ^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr index 2a7e8e00b..7375b8c81 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr @@ -4,5 +4,11 @@ error: ~const can only be applied to `#[const_trait]` traits LL | trait Bar: ~const Foo {} | ^^^ -error: aborting due to previous error +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs index 70d2936d3..8cf64944a 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs @@ -11,6 +11,7 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} //[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` const fn foo<T: ~const Bar>(x: &T) { //[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr index e5978c12a..7a152914b 100644 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr @@ -1,5 +1,5 @@ error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:15:24 + --> $DIR/super-traits-fail-3.rs:16:24 | LL | const fn foo<T: ~const Bar>(x: &T) { | ^^^ diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs index 334fc4cb8..8d56295e7 100644 --- a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs +++ b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: #110395 #![feature(staged_api)] #![feature(const_trait_impl)] diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr new file mode 100644 index 000000000..35dc1ca12 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `Try` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:18:12 + | +LL | impl const Try for T { + | ^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:33:12 + | +LL | impl const FromResidual for T { + | ^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs b/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs new file mode 100644 index 000000000..7d7cb967c --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs @@ -0,0 +1,23 @@ +// check-pass + +struct LazyLock<T> { + data: (Option<T>, fn() -> T), +} + +impl<T> LazyLock<T> { + pub const fn new(f: fn() -> T) -> LazyLock<T> { + LazyLock { data: (None, f) } + } +} + +struct A<T = i32>(Option<T>); + +impl<T> Default for A<T> { + fn default() -> Self { + A(None) + } +} + +static EMPTY_SET: LazyLock<A<i32>> = LazyLock::new(A::default); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs new file mode 100644 index 000000000..3fc5fd481 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.rs @@ -0,0 +1,9 @@ +// FIXME(c_str_literals): This should be `run-pass` +// known-bug: #113333 +// edition: 2021 + +#![feature(c_str_literals)] + +fn main() { + assert_eq!(b"test\0", c"test".to_bytes_with_nul()); +} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr new file mode 100644 index 000000000..571c319d8 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/basic.stderr @@ -0,0 +1,25 @@ +error: prefix `c` is unknown + --> $DIR/basic.rs:8:27 + | +LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); + | ^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: consider inserting whitespace here + | +LL | assert_eq!(b"test\0", c "test".to_bytes_with_nul()); + | + + +error: no rules expected the token `"test"` + --> $DIR/basic.rs:8:28 + | +LL | assert_eq!(b"test\0", c"test".to_bytes_with_nul()); + | -^^^^^ + | | + | no rules expected this token in macro call + | help: missing comma here + | + = note: while trying to match sequence start + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/edition-2015-2018-lexing.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-2015-2018-lexing.rs new file mode 100644 index 000000000..2a4cd6004 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/edition-2015-2018-lexing.rs @@ -0,0 +1,24 @@ +// Regression test for issue #113235. + +// check-pass +// revisions: edition2015 edition2018 +//[edition2015] edition: 2015 +//[edition2018] edition: 2018 + +// Make sure that in pre-2021 editions we continue to parse the snippet +// `c"hello"` as an identifier followed by a (normal) string literal and +// allow the code below to compile. +// Prefixes including `c` as used by C string literals are only reserved +// in edition 2021 and onward. +// +// Consider checking out rust-2021/reserved-prefixes-migration.rs as well. + +macro_rules! parse { + (c $e:expr) => { + $e + }; +} + +fn main() { + let _: &'static str = parse!(c"hello"); +} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs new file mode 100644 index 000000000..ddd6d9a25 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.rs @@ -0,0 +1,15 @@ +// gate-test-c_str_literals +// known-bug: #113333 +// edition: 2021 + +macro_rules! m { + ($t:tt) => {} +} + +fn main() { + c"foo"; + // FIXME(c_str_literals): This should be ``c".."` literals are experimental` + + m!(c"test"); + // FIXME(c_str_literals): This should be ``c".."` literals are experimental` +} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr new file mode 100644 index 000000000..8de36ca4a --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/gate.stderr @@ -0,0 +1,32 @@ +error: prefix `c` is unknown + --> $DIR/gate.rs:10:5 + | +LL | c"foo"; + | ^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: consider inserting whitespace here + | +LL | c "foo"; + | + + +error: prefix `c` is unknown + --> $DIR/gate.rs:13:8 + | +LL | m!(c"test"); + | ^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: consider inserting whitespace here + | +LL | m!(c "test"); + | + + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"foo"` + --> $DIR/gate.rs:10:6 + | +LL | c"foo"; + | ^^^^^ expected one of 8 possible tokens + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs Binary files differnew file mode 100644 index 000000000..96945f125 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.rs diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr Binary files differnew file mode 100644 index 000000000..2226c7aa6 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/no-nuls.stderr diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs new file mode 100644 index 000000000..066505c23 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.rs @@ -0,0 +1,12 @@ +// FIXME(c_str_literals): This should be `run-pass` +// known-bug: #113333 +// edition: 2021 + +#![feature(c_str_literals)] + +fn main() { + assert_eq!( + c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + &[0xEF, 0x80, 0xF0, 0x9F, 0xA6, 0x80, 0xF0, 0x9F, 0xA6, 0x80, 0x00], + ); +} diff --git a/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr new file mode 100644 index 000000000..47361fb61 --- /dev/null +++ b/tests/ui/rfcs/rfc-3348-c-string-literals/non-ascii.stderr @@ -0,0 +1,38 @@ +error: prefix `c` is unknown + --> $DIR/non-ascii.rs:9:9 + | +LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + | ^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: consider inserting whitespace here + | +LL | c "\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + | + + +error: out of range hex escape + --> $DIR/non-ascii.rs:9:11 + | +LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + | ^^^^ must be a character in the range [\x00-\x7f] + +error: out of range hex escape + --> $DIR/non-ascii.rs:9:15 + | +LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + | ^^^^ must be a character in the range [\x00-\x7f] + +error: no rules expected the token `"\xEF\x80🦀\u{1F980}"` + --> $DIR/non-ascii.rs:9:10 + | +LL | c"\xEF\x80🦀\u{1F980}".to_bytes_with_nul(), + | -^^^^^^^^^^^^^^^^^^^^ + | | + | no rules expected this token in macro call + | help: missing comma here + | +note: while trying to match `,` + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL + +error: aborting due to 4 previous errors + diff --git a/tests/ui/rust-2018/remove-extern-crate.fixed b/tests/ui/rust-2018/remove-extern-crate.fixed index 15e0ccc52..209b91af1 100644 --- a/tests/ui/rust-2018/remove-extern-crate.fixed +++ b/tests/ui/rust-2018/remove-extern-crate.fixed @@ -5,6 +5,7 @@ // compile-flags:--extern remove_extern_crate #![warn(rust_2018_idioms)] +#![allow(dropping_copy_types)] //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/rust-2018/remove-extern-crate.rs b/tests/ui/rust-2018/remove-extern-crate.rs index aec0bc7c3..ef3c2db69 100644 --- a/tests/ui/rust-2018/remove-extern-crate.rs +++ b/tests/ui/rust-2018/remove-extern-crate.rs @@ -5,6 +5,7 @@ // compile-flags:--extern remove_extern_crate #![warn(rust_2018_idioms)] +#![allow(dropping_copy_types)] extern crate core; //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/rust-2018/remove-extern-crate.stderr b/tests/ui/rust-2018/remove-extern-crate.stderr index d07358e47..f752cac8e 100644 --- a/tests/ui/rust-2018/remove-extern-crate.stderr +++ b/tests/ui/rust-2018/remove-extern-crate.stderr @@ -1,5 +1,5 @@ warning: unused extern crate - --> $DIR/remove-extern-crate.rs:9:1 + --> $DIR/remove-extern-crate.rs:10:1 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ help: remove it @@ -12,7 +12,7 @@ LL | #![warn(rust_2018_idioms)] = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:33:5 + --> $DIR/remove-extern-crate.rs:34:5 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | use core; | ~~~ warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:43:5 + --> $DIR/remove-extern-crate.rs:44:5 | LL | pub extern crate core; | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sanitize/cfg.rs b/tests/ui/sanitize/cfg.rs index 79dfe58f0..c0f08a6d1 100644 --- a/tests/ui/sanitize/cfg.rs +++ b/tests/ui/sanitize/cfg.rs @@ -3,12 +3,16 @@ // needs-sanitizer-support // needs-sanitizer-address +// needs-sanitizer-cfi +// needs-sanitizer-kcfi // needs-sanitizer-leak // needs-sanitizer-memory // needs-sanitizer-thread // check-pass // revisions: address leak memory thread //[address]compile-flags: -Zsanitizer=address --cfg address +//[cfi]compile-flags: -Zsanitizer=cfi --cfg cfi +//[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi //[leak]compile-flags: -Zsanitizer=leak --cfg leak //[memory]compile-flags: -Zsanitizer=memory --cfg memory //[thread]compile-flags: -Zsanitizer=thread --cfg thread @@ -18,6 +22,12 @@ #[cfg(all(sanitize = "address", address))] fn main() {} +#[cfg(all(sanitize = "cfi", cfi))] +fn main() {} + +#[cfg(all(sanitize = "kcfi", kcfi))] +fn main() {} + #[cfg(all(sanitize = "leak", leak))] fn main() {} diff --git a/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.rs b/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.rs new file mode 100644 index 000000000..462a3f661 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.rs @@ -0,0 +1,8 @@ +// Verifies that `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`. +// +// needs-sanitizer-cfi +// compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-canonical-jump-tables=false + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.stderr b/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.stderr new file mode 100644 index 000000000..3ee95634b --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-canonical-jump-tables-require-cfi.stderr @@ -0,0 +1,4 @@ +error: `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs new file mode 100644 index 000000000..3a0fc143d --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs @@ -0,0 +1,9 @@ +// Verifies that when compiling with `-Zsanitizer-cfi-generalize-pointers` the +// `#[cfg(sanitizer_cfi_generalize_pointers)]` attribute is configured. +// +// needs-sanitizer-cfi +// check-pass +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers + +#[cfg(sanitizer_cfi_generalize_pointers)] +fn main() {} diff --git a/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.rs b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.rs new file mode 100644 index 000000000..f31b8bde7 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.rs @@ -0,0 +1,9 @@ +// Verifies that `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or +// `-Zsanitizer=kcfi`. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-generalize-pointers + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.stderr b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.stderr new file mode 100644 index 000000000..6eb09a53b --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-require-cfi.stderr @@ -0,0 +1,4 @@ +error: `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.rs b/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.rs new file mode 100644 index 000000000..fe044f50a --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.rs @@ -0,0 +1,11 @@ +// Verifies that invalid user-defined CFI encodings can't be used. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![feature(cfi_encoding, no_core)] +#![no_core] +#![no_main] + +#[cfi_encoding] //~ERROR 10:1: 10:16: malformed `cfi_encoding` attribute input +pub struct Type1(i32); diff --git a/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.stderr b/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.stderr new file mode 100644 index 000000000..e23bafb18 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-invalid-attr-cfi-encoding.stderr @@ -0,0 +1,8 @@ +error: malformed `cfi_encoding` attribute input + --> $DIR/sanitizer-cfi-invalid-attr-cfi-encoding.rs:10:1 + | +LL | #[cfi_encoding] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.aarch64.stderr b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.aarch64.stderr new file mode 100644 index 000000000..8328178e8 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.aarch64.stderr @@ -0,0 +1,8 @@ +error: cfi sanitizer is not supported for this target + +error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` + +error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.rs b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.rs new file mode 100644 index 000000000..9a5b0f389 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.rs @@ -0,0 +1,12 @@ +// Verifies that `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi`. +// +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: x86 +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer=kcfi + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.x86_64.stderr b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.x86_64.stderr new file mode 100644 index 000000000..8328178e8 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-is-incompatible-with-saniziter-kcfi.x86_64.stderr @@ -0,0 +1,8 @@ +error: cfi sanitizer is not supported for this target + +error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` + +error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs new file mode 100644 index 000000000..dafc20162 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs @@ -0,0 +1,9 @@ +// Verifies that when compiling with `-Zsanitizer-cfi-normalize-integers` the +// `#[cfg(sanitizer_cfi_normalize_integers)]` attribute is configured. +// +// needs-sanitizer-cfi +// check-pass +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers + +#[cfg(sanitizer_cfi_normalize_integers)] +fn main() {} diff --git a/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.rs b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.rs new file mode 100644 index 000000000..b25a60d34 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.rs @@ -0,0 +1,9 @@ +// Verifies that `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or +// `-Zsanitizer=kcfi` +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-normalize-integers + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.stderr b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.stderr new file mode 100644 index 000000000..e31642054 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-require-cfi.stderr @@ -0,0 +1,4 @@ +error: `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs b/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs new file mode 100644 index 000000000..29e32889f --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-requires-lto.rs @@ -0,0 +1,8 @@ +// Verifies that `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`. +// +// needs-sanitizer-cfi +// compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr b/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr new file mode 100644 index 000000000..5e706b513 --- /dev/null +++ b/tests/ui/sanitize/sanitizer-cfi-requires-lto.stderr @@ -0,0 +1,4 @@ +error: `-Zsanitizer=cfi` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto` + +error: aborting due to previous error + diff --git a/tests/ui/sanitize/split-lto-unit-requires-lto.rs b/tests/ui/sanitize/split-lto-unit-requires-lto.rs new file mode 100644 index 000000000..3c497260e --- /dev/null +++ b/tests/ui/sanitize/split-lto-unit-requires-lto.rs @@ -0,0 +1,8 @@ +// Verifies that `-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`. +// +// needs-sanitizer-cfi +// compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsplit-lto-unit + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitize/split-lto-unit-requires-lto.stderr b/tests/ui/sanitize/split-lto-unit-requires-lto.stderr new file mode 100644 index 000000000..ab8f4f4f3 --- /dev/null +++ b/tests/ui/sanitize/split-lto-unit-requires-lto.stderr @@ -0,0 +1,4 @@ +error: `-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto` + +error: aborting due to previous error + diff --git a/tests/ui/self/arbitrary-self-from-method-substs.rs b/tests/ui/self/arbitrary-self-from-method-substs.rs new file mode 100644 index 000000000..0f911a208 --- /dev/null +++ b/tests/ui/self/arbitrary-self-from-method-substs.rs @@ -0,0 +1,16 @@ +#![feature(arbitrary_self_types)] + +use std::ops::Deref; + +struct Foo(u32); +impl Foo { + fn get<R: Deref<Target=Self>>(self: R) -> u32 { + self.0 + } +} + +fn main() { + let mut foo = Foo(1); + foo.get::<&Foo>(); + //~^ ERROR mismatched types +} diff --git a/tests/ui/self/arbitrary-self-from-method-substs.stderr b/tests/ui/self/arbitrary-self-from-method-substs.stderr new file mode 100644 index 000000000..6c252fadf --- /dev/null +++ b/tests/ui/self/arbitrary-self-from-method-substs.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/arbitrary-self-from-method-substs.rs:14:5 + | +LL | foo.get::<&Foo>(); + | ^^^ expected `&Foo`, found `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr index 0ec0d4be5..13591f5b6 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr @@ -31,8 +31,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = note: required for `Rc<usize>` to implement `CoerceUnsized<Rc<dyn Foo>>` - = note: required by cast to type `Rc<dyn Foo>` + = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` error: aborting due to 2 previous errors diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr index b494b448e..593f70535 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr @@ -14,8 +14,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = note: required for `Rc<usize>` to implement `CoerceUnsized<Rc<dyn Foo>>` - = note: required by cast to type `Rc<dyn Foo>` + = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` error: aborting due to previous error diff --git a/tests/ui/self/elision/nested-item.rs b/tests/ui/self/elision/nested-item.rs new file mode 100644 index 000000000..4bcb645c6 --- /dev/null +++ b/tests/ui/self/elision/nested-item.rs @@ -0,0 +1,13 @@ +// Regression test for #110899. +// When looking for the elided lifetime for `wrap`, +// we must not consider the lifetimes in `bar` as candidates. + +fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { + //~^ ERROR `self` parameter is only allowed in associated functions + //~| ERROR `self` parameter is only allowed in associated functions + //~| ERROR missing lifetime specifier + //~| ERROR cannot find type `Wrap` in this scope + &() +} + +fn main() {} diff --git a/tests/ui/self/elision/nested-item.stderr b/tests/ui/self/elision/nested-item.stderr new file mode 100644 index 000000000..752fd8233 --- /dev/null +++ b/tests/ui/self/elision/nested-item.stderr @@ -0,0 +1,38 @@ +error: `self` parameter is only allowed in associated functions + --> $DIR/nested-item.rs:5:9 + | +LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { + | ^^^^ not semantically valid as function parameter + | + = note: associated functions are those in `impl` or `trait` definitions + +error: `self` parameter is only allowed in associated functions + --> $DIR/nested-item.rs:5:29 + | +LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { + | ^^^^^ not semantically valid as function parameter + | + = note: associated functions are those in `impl` or `trait` definitions + +error[E0106]: missing lifetime specifier + --> $DIR/nested-item.rs:5:46 + | +LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &'static () { + | +++++++ + +error[E0412]: cannot find type `Wrap` in this scope + --> $DIR/nested-item.rs:5:15 + | +LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { + | ^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0106, E0412. +For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/self/self-ctor-nongeneric.rs b/tests/ui/self/self-ctor-nongeneric.rs new file mode 100644 index 000000000..0ae7f8da4 --- /dev/null +++ b/tests/ui/self/self-ctor-nongeneric.rs @@ -0,0 +1,15 @@ +// `Self` as a constructor is currently allowed when the outer item is not generic. +// check-pass + +struct S0(usize); + +impl S0 { + fn foo() { + const C: S0 = Self(0); + fn bar() -> S0 { + Self(0) + } + } +} + +fn main() {} diff --git a/tests/ui/simd/issue-105439.rs b/tests/ui/simd/issue-105439.rs new file mode 100644 index 000000000..35ca76e98 --- /dev/null +++ b/tests/ui/simd/issue-105439.rs @@ -0,0 +1,25 @@ +// run-pass +// compile-flags: -O -Zverify-llvm-ir + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[allow(non_camel_case_types)] +#[derive(Clone, Copy)] +#[repr(simd)] +struct i32x4([i32; 4]); + +extern "platform-intrinsic" { + pub(crate) fn simd_add<T>(x: T, y: T) -> T; +} + +#[inline(always)] +fn to_array(a: i32x4) -> [i32; 4] { + a.0 +} + +fn main() { + let a = i32x4([1, 2, 3, 4]); + let b = unsafe { simd_add(a, a) }; + assert_eq!(to_array(b), [2, 4, 6, 8]); +} diff --git a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index 570328fc2..80c5f9da4 100644 --- a/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/tests/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -18,7 +18,7 @@ LL | &mut x.y help: consider changing this to be a mutable reference | LL | fn deref_extend_mut_field1(x: &mut Own<Point>) -> &mut isize { - | ~~~~~~~~~~~~~~~ + | +++ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19 @@ -50,7 +50,7 @@ LL | x.y = 3; help: consider changing this to be a mutable reference | LL | fn assign_field2<'a>(x: &'a mut Own<Point>) { - | ~~~~~~~~~~~~~~~~~~ + | +++ error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5 @@ -82,7 +82,7 @@ LL | x.y_mut() help: consider changing this to be a mutable reference | LL | fn deref_extend_mut_method1(x: &mut Own<Point>) -> &mut isize { - | ~~~~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 @@ -104,7 +104,7 @@ LL | *x.y_mut() = 3; help: consider changing this to be a mutable reference | LL | fn assign_method2<'a>(x: &'a mut Own<Point>) { - | ~~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to 10 previous errors diff --git a/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr b/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr index 3fed7b3f4..dbd52dc2d 100644 --- a/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr +++ b/tests/ui/span/borrowck-borrow-overloaded-deref-mut.stderr @@ -18,7 +18,7 @@ LL | &mut **x help: consider changing this to be a mutable reference | LL | fn deref_extend_mut1<'a>(x: &'a mut Own<isize>) -> &'a mut isize { - | ~~~~~~~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6 @@ -40,7 +40,7 @@ LL | **x = 3; help: consider changing this to be a mutable reference | LL | fn assign2<'a>(x: &'a mut Own<isize>) { - | ~~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to 4 previous errors diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 9711dad80..99c8fa1f9 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -19,7 +19,7 @@ LL | (*f)(); help: consider changing this to be a mutable reference | LL | fn test2<F>(f: &mut F) where F: FnMut() { - | ~~~~~~ + | +++ error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 @@ -29,8 +29,8 @@ LL | f.f.call_mut(()) | help: consider changing this to be a mutable reference | -LL | fn test4(f: &mut Test<'_>) { - | ~~~~~~~~~~~~~ +LL | fn test4(f: &mut Test) { + | +++ error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 diff --git a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr index 2a842f5a2..328197ae9 100644 --- a/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/tests/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -7,7 +7,7 @@ LL | x.h(); help: consider changing this to be a mutable reference | LL | fn b(x: &mut Foo) { - | ~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/span/borrowck-fn-in-const-b.stderr b/tests/ui/span/borrowck-fn-in-const-b.stderr index 1df19deb1..17fdcc622 100644 --- a/tests/ui/span/borrowck-fn-in-const-b.stderr +++ b/tests/ui/span/borrowck-fn-in-const-b.stderr @@ -7,7 +7,7 @@ LL | x.push(format!("this is broken")); help: consider changing this to be a mutable reference | LL | fn broken(x: &mut Vec<String>) { - | ~~~~~~~~~~~~~~~~ + | +++ error: aborting due to previous error diff --git a/tests/ui/span/borrowck-object-mutability.stderr b/tests/ui/span/borrowck-object-mutability.stderr index b6517e0b3..805a8034c 100644 --- a/tests/ui/span/borrowck-object-mutability.stderr +++ b/tests/ui/span/borrowck-object-mutability.stderr @@ -7,7 +7,7 @@ LL | x.borrowed_mut(); help: consider changing this to be a mutable reference | LL | fn borrowed_receiver(x: &mut dyn Foo) { - | ~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 diff --git a/tests/ui/span/coerce-suggestions.stderr b/tests/ui/span/coerce-suggestions.stderr index bb30f000e..ff840b781 100644 --- a/tests/ui/span/coerce-suggestions.stderr +++ b/tests/ui/span/coerce-suggestions.stderr @@ -10,11 +10,14 @@ error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:9:19 | LL | let x: &str = String::new(); - | ---- ^^^^^^^^^^^^^ - | | | - | | expected `&str`, found `String` - | | help: consider borrowing here: `&String::new()` + | ---- ^^^^^^^^^^^^^ expected `&str`, found `String` + | | | expected due to this + | +help: consider borrowing here + | +LL | let x: &str = &String::new(); + | + error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:12:10 diff --git a/tests/ui/span/issue-23729.stderr b/tests/ui/span/issue-23729.stderr index f88ce6c88..cd854e61f 100644 --- a/tests/ui/span/issue-23729.stderr +++ b/tests/ui/span/issue-23729.stderr @@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Item` LL | impl Iterator for Recurrence { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation | - = help: implement the missing item: `type Item = Type;` + = help: implement the missing item: `type Item = /* Type */;` error: aborting due to previous error diff --git a/tests/ui/span/issue-23827.stderr b/tests/ui/span/issue-23827.stderr index 46a820f1b..83a9e8c9b 100644 --- a/tests/ui/span/issue-23827.stderr +++ b/tests/ui/span/issue-23827.stderr @@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Output` LL | impl<C: Component> FnOnce<(C,)> for Prototype { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation | - = help: implement the missing item: `type Output = Type;` + = help: implement the missing item: `type Output = /* Type */;` error: aborting due to previous error diff --git a/tests/ui/span/issue-24356.stderr b/tests/ui/span/issue-24356.stderr index a1f9b2550..cf666e8b4 100644 --- a/tests/ui/span/issue-24356.stderr +++ b/tests/ui/span/issue-24356.stderr @@ -4,7 +4,7 @@ error[E0046]: not all trait items implemented, missing: `Target` LL | impl Deref for Thing { | ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation | - = help: implement the missing item: `type Target = Type;` + = help: implement the missing item: `type Target = /* Type */;` error: aborting due to previous error diff --git a/tests/ui/span/issue-39018.stderr b/tests/ui/span/issue-39018.stderr index 771f21c45..c8c4a5139 100644 --- a/tests/ui/span/issue-39018.stderr +++ b/tests/ui/span/issue-39018.stderr @@ -21,11 +21,11 @@ LL | let y = World::Hello + World::Goodbye; | | | World | -note: an implementation of `Add<_>` might be missing for `World` +note: an implementation of `Add` might be missing for `World` --> $DIR/issue-39018.rs:15:1 | LL | enum World { - | ^^^^^^^^^^ must implement `Add<_>` + | ^^^^^^^^^^ must implement `Add` note: the trait `Add` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL @@ -78,10 +78,12 @@ error[E0308]: mismatched types --> $DIR/issue-39018.rs:29:17 | LL | let _ = a + b; - | ^ - | | - | expected `&str`, found `String` - | help: consider borrowing here: `&b` + | ^ expected `&str`, found `String` + | +help: consider borrowing here + | +LL | let _ = a + &b; + | + error[E0369]: cannot add `String` to `&String` --> $DIR/issue-39018.rs:30:15 diff --git a/tests/ui/span/mut-arg-hint.stderr b/tests/ui/span/mut-arg-hint.stderr index 96ce4d5bc..06011eac6 100644 --- a/tests/ui/span/mut-arg-hint.stderr +++ b/tests/ui/span/mut-arg-hint.stderr @@ -7,7 +7,7 @@ LL | a.push_str("bar"); help: consider changing this to be a mutable reference | LL | fn foo(mut a: &mut String) { - | ~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:8:5 @@ -18,7 +18,7 @@ LL | a.push_str("foo"); help: consider changing this to be a mutable reference | LL | pub fn foo<'a>(mut a: &'a mut String) { - | ~~~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:15:9 @@ -29,7 +29,7 @@ LL | a.push_str("foo"); help: consider changing this to be a mutable reference | LL | pub fn foo(mut a: &mut String) { - | ~~~~~~~~~~~ + | +++ error: aborting due to 3 previous errors diff --git a/tests/ui/span/send-is-not-static-std-sync-2.stderr b/tests/ui/span/send-is-not-static-std-sync-2.stderr index b0267fa6f..c825cc8d6 100644 --- a/tests/ui/span/send-is-not-static-std-sync-2.stderr +++ b/tests/ui/span/send-is-not-static-std-sync-2.stderr @@ -25,8 +25,6 @@ LL | }; error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:31:25 | -LL | let (_tx, rx) = { - | --- borrow later used here LL | let x = 1; | - binding `x` declared here LL | let (tx, rx) = mpsc::channel(); diff --git a/tests/ui/specialization/const_trait_impl.rs b/tests/ui/specialization/const_trait_impl.rs index 05ba4c8d4..b1ec58c3d 100644 --- a/tests/ui/specialization/const_trait_impl.rs +++ b/tests/ui/specialization/const_trait_impl.rs @@ -1,4 +1,5 @@ -// check-pass +// known-bug: #110395 + #![feature(const_trait_impl, min_specialization, rustc_attrs)] #[rustc_specialization_trait] diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr new file mode 100644 index 000000000..d13cd8f55 --- /dev/null +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -0,0 +1,20 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const_trait_impl.rs:34:16 + | +LL | impl<T: ~const Default> const A for T { + | ^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const_trait_impl.rs:40:16 + | +LL | impl<T: ~const Default + ~const Sup> const A for T { + | ^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const_trait_impl.rs:46:16 + | +LL | impl<T: ~const Default + ~const Sub> const A for T { + | ^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/specialization/issue-111232.rs b/tests/ui/specialization/issue-111232.rs new file mode 100644 index 000000000..3ed3c580e --- /dev/null +++ b/tests/ui/specialization/issue-111232.rs @@ -0,0 +1,11 @@ +#![feature(min_specialization)] + +struct S; + +impl From<S> for S { + fn from(s: S) -> S { //~ ERROR `from` specializes an item from a parent `impl`, but that item is not marked `default` + s + } +} + +fn main() {} diff --git a/tests/ui/specialization/issue-111232.stderr b/tests/ui/specialization/issue-111232.stderr new file mode 100644 index 000000000..27ee42fc0 --- /dev/null +++ b/tests/ui/specialization/issue-111232.stderr @@ -0,0 +1,11 @@ +error[E0520]: `from` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/issue-111232.rs:6:5 + | +LL | fn from(s: S) -> S { + | ^^^^^^^^^^^^^^^^^^ + | + = note: parent implementation is in crate `core` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0520`. diff --git a/tests/ui/specialization/issue-40582.rs b/tests/ui/specialization/issue-40582.rs new file mode 100644 index 000000000..980593355 --- /dev/null +++ b/tests/ui/specialization/issue-40582.rs @@ -0,0 +1,35 @@ +// check-pass +// known-bug: #40582 + +// Should fail. Should not be possible to implement `make_static`. + +#![feature(specialization)] +#![allow(incomplete_features)] + +trait FromRef<'a, T: ?Sized> { + fn from_ref(r: &'a T) -> Self; +} + +impl<'a, T: ?Sized> FromRef<'a, T> for &'a T { + fn from_ref(r: &'a T) -> Self { + r + } +} + +impl<'a, T: ?Sized, R> FromRef<'a, T> for R { + default fn from_ref(_: &'a T) -> Self { + unimplemented!() + } +} + +fn make_static<T: ?Sized>(data: &T) -> &'static T { + fn helper<T: ?Sized, R>(data: &T) -> R { + R::from_ref(data) + } + helper(data) +} + +fn main() { + let s = "specialization".to_owned(); + println!("{:?}", make_static(s.as_str())); +} diff --git a/tests/ui/specialization/min_specialization/specialize-associated-type.rs b/tests/ui/specialization/min_specialization/specialize-associated-type.rs new file mode 100644 index 000000000..c4960b0c2 --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize-associated-type.rs @@ -0,0 +1,37 @@ +// Another regression test for #109815. + +// check-pass + +#![feature(min_specialization)] +#![feature(rustc_attrs)] + +#[rustc_specialization_trait] +trait X {} +trait Z { + type Assoc: X; +} +struct A<T>(T); + +impl X for () {} + +impl<T: X> Z for A<T> { + type Assoc = (); +} + +trait MyFrom<T> { + fn from(other: T) -> Self; +} + +impl<T> MyFrom<()> for T { + default fn from(other: ()) -> T { + panic!(); + } +} + +impl<T: X> MyFrom<<A<T> as Z>::Assoc> for T { + fn from(other: ()) -> T { + panic!(); + } +} + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/specialize_nothing.rs b/tests/ui/specialization/min_specialization/specialize_nothing.rs new file mode 100644 index 000000000..ef92254d4 --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_nothing.rs @@ -0,0 +1,14 @@ +#![feature(min_specialization)] + +trait Special { + fn be_special(); +} + +impl<T> Special for T { + fn be_special() {} +} + +impl Special for usize {} +//~^ ERROR specialization impl does not specialize any associated items + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/specialize_nothing.stderr b/tests/ui/specialization/min_specialization/specialize_nothing.stderr new file mode 100644 index 000000000..65f73781c --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_nothing.stderr @@ -0,0 +1,14 @@ +error: specialization impl does not specialize any associated items + --> $DIR/specialize_nothing.rs:11:1 + | +LL | impl Special for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl is a specialization of this impl + --> $DIR/specialize_nothing.rs:7:1 + | +LL | impl<T> Special for T { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/specialization/min_specialization/specialize_on_type_error.rs b/tests/ui/specialization/min_specialization/specialize_on_type_error.rs new file mode 100644 index 000000000..24e92a0ab --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_on_type_error.rs @@ -0,0 +1,33 @@ +// A regression test for #109815. + +#![feature(min_specialization)] +#![feature(rustc_attrs)] + +#[rustc_specialization_trait] +trait X {} +trait Y: X {} +trait Z { + type Assoc: Y; +} +struct A<T>(T); + +impl<T: X> Z for A<T> {} +//~^ ERROR not all trait items implemented + +trait MyFrom<T> { + fn from(other: T) -> Self; +} + +impl<T> MyFrom<T> for T { + default fn from(other: T) -> T { + other + } +} + +impl<T: X> MyFrom<<A<T> as Z>::Assoc> for T { + fn from(other: <A<T> as Z>::Assoc) -> T { + other + } +} + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/specialize_on_type_error.stderr b/tests/ui/specialization/min_specialization/specialize_on_type_error.stderr new file mode 100644 index 000000000..cc12302bd --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_on_type_error.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Assoc` + --> $DIR/specialize_on_type_error.rs:14:1 + | +LL | type Assoc: Y; + | ------------- `Assoc` from trait +... +LL | impl<T: X> Z for A<T> {} + | ^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.rs b/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.rs new file mode 100644 index 000000000..d90b81f71 --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.rs @@ -0,0 +1,50 @@ +// Regression test for #79457. + +#![feature(min_specialization)] + +use std::any::Any; + +pub trait Tr { + fn method(self) -> Box<dyn Any + 'static>; + fn other(self); +} + +impl<T: Any + 'static> Tr for T { + default fn method(self) -> Box<dyn Any + 'static> { + Box::new(self) + } + + default fn other(self) {} +} + +impl<'a> Tr for &'a i32 { + //~^ ERROR does not fulfill the required lifetime + fn other(self) {} +} + +fn promote_to_static<'a>(i: &'a i32) -> &'static i32 { + *i.method().downcast().unwrap() +} + +struct Wrapper<'a>(&'a i32); + +impl<'a> Tr for Wrapper<'a> { + //~^ ERROR does not fulfill the required lifetime + fn other(self) {} +} + +fn promote_to_static_2<'a>(w: Wrapper<'a>) -> Wrapper<'static> { + *w.method().downcast().unwrap() +} + +fn main() { + let i = Box::new(100_i32); + let static_i: &'static i32 = promote_to_static(&*i); + drop(i); + println!("{}", *static_i); + + let j = Box::new(200_i32); + let static_w: Wrapper<'static> = promote_to_static_2(Wrapper(&*j)); + drop(j); + println!("{}", *static_w.0); +} diff --git a/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.stderr b/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.stderr new file mode 100644 index 000000000..2af75876d --- /dev/null +++ b/tests/ui/specialization/min_specialization/specialize_with_generalize_lifetimes.stderr @@ -0,0 +1,27 @@ +error[E0477]: the type `&'a i32` does not fulfill the required lifetime + --> $DIR/specialize_with_generalize_lifetimes.rs:20:1 + | +LL | impl<'a> Tr for &'a i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/specialize_with_generalize_lifetimes.rs:12:15 + | +LL | impl<T: Any + 'static> Tr for T { + | ^^^^^^^ + +error[E0477]: the type `Wrapper<'a>` does not fulfill the required lifetime + --> $DIR/specialize_with_generalize_lifetimes.rs:31:1 + | +LL | impl<'a> Tr for Wrapper<'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/specialize_with_generalize_lifetimes.rs:12:15 + | +LL | impl<T: Any + 'static> Tr for T { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0477`. diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.rs b/tests/ui/specialization/specialization-default-items-drop-coherence.rs new file mode 100644 index 000000000..16ad942d5 --- /dev/null +++ b/tests/ui/specialization/specialization-default-items-drop-coherence.rs @@ -0,0 +1,30 @@ +// check-pass +// known-bug: #105782 + +// Should fail. Default items completely drop candidates instead of ambiguity, +// which is unsound during coherence, since coherence requires completeness. + +#![feature(specialization)] +#![allow(incomplete_features)] + +trait Default { + type Id; +} + +impl<T> Default for T { + default type Id = T; +} + +trait Overlap { + type Assoc; +} + +impl Overlap for u32 { + type Assoc = usize; +} + +impl Overlap for <u32 as Default>::Id { + type Assoc = Box<usize>; +} + +fn main() {} diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.rs b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs index 0c771ae87..1d138e264 100644 --- a/tests/ui/stability-attribute/stability-attribute-trait-impl.rs +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs @@ -1,4 +1,4 @@ -#![feature(staged_api, never_type, c_unwind)] +#![feature(staged_api, never_type, rust_cold_cc)] //~^ ERROR module has missing stability attribute #[stable(feature = "a", since = "1")] @@ -25,9 +25,9 @@ impl UnstableTrait for StableType {} #[unstable(feature = "h", issue = "none")] impl StableTrait for ! {} -// Note: If C-unwind is stabilized, switch this to another (unstable) ABI. +// Note: If rust_cold_cc is stabilized, switch this to another (unstable) ABI. #[unstable(feature = "i", issue = "none")] -impl StableTrait for extern "C-unwind" fn() {} +impl StableTrait for extern "rust-cold" fn() {} #[unstable(feature = "j", issue = "none")] //~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr index b91a1d2e1..96322c2c9 100644 --- a/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr @@ -18,7 +18,7 @@ LL | #[unstable(feature = "k", issue = "none")] error: module has missing stability attribute --> $DIR/stability-attribute-trait-impl.rs:1:1 | -LL | / #![feature(staged_api, never_type, c_unwind)] +LL | / #![feature(staged_api, never_type, rust_cold_cc)] LL | | LL | | LL | | #[stable(feature = "a", since = "1")] diff --git a/tests/ui/static/issue-18118.stderr b/tests/ui/static/issue-18118.stderr index 49798a148..035be2b12 100644 --- a/tests/ui/static/issue-18118.stderr +++ b/tests/ui/static/issue-18118.stderr @@ -1,6 +1,8 @@ error[E0597]: `p` does not live long enough --> $DIR/issue-18118.rs:4:9 | +LL | let p = 3; + | - binding `p` declared here LL | &p | ^^ | | diff --git a/tests/ui/statics/issue-91050-1.rs b/tests/ui/statics/issue-91050-1.rs index 403a41462..c6268dba5 100644 --- a/tests/ui/statics/issue-91050-1.rs +++ b/tests/ui/statics/issue-91050-1.rs @@ -12,6 +12,8 @@ // // In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!" +#![allow(dropping_copy_types)] + pub mod before { #[no_mangle] pub static GLOBAL1: [u8; 1] = [1]; diff --git a/tests/ui/str/str-array-assignment.stderr b/tests/ui/str/str-array-assignment.stderr index c23400a1d..515cb9e12 100644 --- a/tests/ui/str/str-array-assignment.stderr +++ b/tests/ui/str/str-array-assignment.stderr @@ -10,10 +10,12 @@ error[E0308]: mismatched types --> $DIR/str-array-assignment.rs:5:27 | LL | let u: &str = if true { s[..2] } else { s }; - | ^^^^^^ - | | - | expected `&str`, found `str` - | help: consider borrowing here: `&s[..2]` + | ^^^^^^ expected `&str`, found `str` + | +help: consider borrowing here + | +LL | let u: &str = if true { &s[..2] } else { s }; + | + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/str-array-assignment.rs:7:7 @@ -33,11 +35,14 @@ error[E0308]: mismatched types --> $DIR/str-array-assignment.rs:9:17 | LL | let w: &str = s[..2]; - | ---- ^^^^^^ - | | | - | | expected `&str`, found `str` - | | help: consider borrowing here: `&s[..2]` + | ---- ^^^^^^ expected `&str`, found `str` + | | | expected due to this + | +help: consider borrowing here + | +LL | let w: &str = &s[..2]; + | + error: aborting due to 4 previous errors diff --git a/tests/ui/structs-enums/issue-103869.fixed b/tests/ui/structs-enums/issue-103869.fixed new file mode 100644 index 000000000..49fe32c71 --- /dev/null +++ b/tests/ui/structs-enums/issue-103869.fixed @@ -0,0 +1,13 @@ +// run-rustfix + +struct VecOrMap { + //~^ HELP: perhaps you meant to use `struct` here + vec: Vec<usize>, + //~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `:` + //~| HELP: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` +} + +fn main() { + let o = VecOrMap { vec: vec![1, 2, 3] }; + println!("{:?}", o.vec); +} diff --git a/tests/ui/parser/issue-103869.rs b/tests/ui/structs-enums/issue-103869.rs index 28c442bdd..729079e05 100644 --- a/tests/ui/parser/issue-103869.rs +++ b/tests/ui/structs-enums/issue-103869.rs @@ -1,9 +1,13 @@ -enum VecOrMap{ +// run-rustfix + +enum VecOrMap { + //~^ HELP: perhaps you meant to use `struct` here vec: Vec<usize>, //~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `:` //~| HELP: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` - //~| ERROR expected item, found `:` - map: HashMap<String,usize> } -fn main() {} +fn main() { + let o = VecOrMap { vec: vec![1, 2, 3] }; + println!("{:?}", o.vec); +} diff --git a/tests/ui/parser/issue-103869.stderr b/tests/ui/structs-enums/issue-103869.stderr index 0b8cd919a..4665ebf89 100644 --- a/tests/ui/parser/issue-103869.stderr +++ b/tests/ui/structs-enums/issue-103869.stderr @@ -1,16 +1,17 @@ error: expected one of `(`, `,`, `=`, `{`, or `}`, found `:` - --> $DIR/issue-103869.rs:2:8 + --> $DIR/issue-103869.rs:5:8 | +LL | enum VecOrMap { + | -------- while parsing this enum +LL | LL | vec: Vec<usize>, | ^ expected one of `(`, `,`, `=`, `{`, or `}` | = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` - -error: expected item, found `:` - --> $DIR/issue-103869.rs:2:8 +help: perhaps you meant to use `struct` here | -LL | vec: Vec<usize>, - | ^ expected item +LL | struct VecOrMap { + | ~~~~~~ -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/structs-enums/type-sizes.rs b/tests/ui/structs-enums/type-sizes.rs index 63e2f3150..406e5c844 100644 --- a/tests/ui/structs-enums/type-sizes.rs +++ b/tests/ui/structs-enums/type-sizes.rs @@ -4,9 +4,14 @@ #![allow(dead_code)] #![feature(never_type)] #![feature(pointer_is_aligned)] +#![feature(ptr_from_ref)] +#![feature(strict_provenance)] use std::mem::size_of; -use std::num::NonZeroU8; +use std::num::{NonZeroU8, NonZeroU16}; +use std::ptr; +use std::ptr::NonNull; +use std::borrow::Cow; struct t {a: u8, b: i8} struct u {a: u8, b: i8, c: u8} @@ -181,6 +186,41 @@ struct Reorder2 { ary: [u8; 6], } +// We want the niche in the front, which means we can't treat the array as quasi-aligned more than +// 4 bytes even though we also want to place it at an 8-aligned offset where possible. +// So the ideal layout would look like: (char, u32, [u8; 8], u8) +// The current layout algorithm does (char, [u8; 8], u32, u8) +#[repr(align(8))] +struct ReorderWithNiche { + a: u32, + b: char, + c: u8, + ary: [u8; 8] +} + +#[repr(C)] +struct EndNiche8([u8; 7], bool); + +#[repr(C)] +struct MiddleNiche4(u8, u8, bool, u8); + +struct ReorderEndNiche { + a: EndNiche8, + b: MiddleNiche4, +} + + +// standins for std types which we want to be laid out in a reasonable way +struct RawVecDummy { + ptr: NonNull<u8>, + cap: usize, +} + +struct VecDummy { + r: RawVecDummy, + len: usize, +} + pub fn main() { assert_eq!(size_of::<u8>(), 1 as usize); assert_eq!(size_of::<u32>(), 4 as usize); @@ -270,4 +310,29 @@ pub fn main() { let v = Reorder2 {a: 0, b: 0, ary: [0; 6]}; assert_eq!(size_of::<Reorder2>(), 10); assert!((&v.ary).as_ptr().is_aligned_to(2), "[u8; 6] should group with align-2 fields"); + + let v = VecDummy { r: RawVecDummy { ptr: NonNull::dangling(), cap: 0 }, len: 1 }; + assert_eq!(ptr::from_ref(&v), ptr::from_ref(&v.r.ptr).cast(), + "sort niches to the front where possible"); + + // Ideal layouts: (bool, u8, NonZeroU16) or (NonZeroU16, u8, bool) + // Currently the layout algorithm will choose the latter because it doesn't attempt + // to aggregate multiple smaller fields to move a niche before a higher-alignment one. + let b = BoolInTheMiddle( NonZeroU16::new(1).unwrap(), true, 0); + assert!(ptr::from_ref(&b.1).addr() > ptr::from_ref(&b.2).addr()); + + assert_eq!(size_of::<Cow<'static, str>>(), size_of::<String>()); + + let v = ReorderWithNiche {a: 0, b: ' ', c: 0, ary: [0; 8]}; + assert!((&v.ary).as_ptr().is_aligned_to(4), + "here [u8; 8] should group with _at least_ align-4 fields"); + assert_eq!(ptr::from_ref(&v), ptr::from_ref(&v.b).cast(), + "sort niches to the front where possible"); + + // Neither field has a niche at the beginning so the layout algorithm should try move niches to + // the end which means the 8-sized field shouldn't be alignment-promoted before the 4-sized one. + let v = ReorderEndNiche { a: EndNiche8([0; 7], false), b: MiddleNiche4(0, 0, false, 0) }; + assert!(ptr::from_ref(&v.a).addr() > ptr::from_ref(&v.b).addr()); + + } diff --git a/tests/ui/suggestions/as-ref.stderr b/tests/ui/suggestions/as-ref.stderr index 0ee343ebf..2147d2d92 100644 --- a/tests/ui/suggestions/as-ref.stderr +++ b/tests/ui/suggestions/as-ref.stderr @@ -2,61 +2,73 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:7:29 | LL | opt.map(|arg| takes_ref(arg)); - | --- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().map` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | opt.as_ref().map(|arg| takes_ref(arg)); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:8:39 | LL | opt.and_then(|arg| Some(takes_ref(arg))); - | -------- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().and_then` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | opt.as_ref().and_then(|arg| Some(takes_ref(arg))); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:10:29 | LL | opt.map(|arg| takes_ref(arg)); - | --- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().map` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | opt.as_ref().map(|arg| takes_ref(arg)); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:11:37 | LL | opt.and_then(|arg| Ok(takes_ref(arg))); - | -------- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().and_then` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | opt.as_ref().and_then(|arg| Ok(takes_ref(arg))); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:13:29 @@ -101,61 +113,73 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:22:42 | LL | multiple_ref_opt.map(|arg| takes_ref(arg)); - | --- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().map` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | multiple_ref_opt.as_ref().map(|arg| takes_ref(arg)); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:23:52 | LL | multiple_ref_opt.and_then(|arg| Some(takes_ref(arg))); - | -------- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().and_then` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | multiple_ref_opt.as_ref().and_then(|arg| Some(takes_ref(arg))); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:25:45 | LL | multiple_ref_result.map(|arg| takes_ref(arg)); - | --- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().map` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | multiple_ref_result.as_ref().map(|arg| takes_ref(arg)); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:26:53 | LL | multiple_ref_result.and_then(|arg| Ok(takes_ref(arg))); - | -------- --------- ^^^ expected `&Foo`, found `Foo` - | | | - | | arguments to this function are incorrect - | help: consider using `as_ref` instead: `as_ref().and_then` + | --------- ^^^ expected `&Foo`, found `Foo` + | | + | arguments to this function are incorrect | note: function defined here --> $DIR/as-ref.rs:3:4 | LL | fn takes_ref(_: &Foo) {} | ^^^^^^^^^ ------- +help: consider using `as_ref` instead + | +LL | multiple_ref_result.as_ref().and_then(|arg| Ok(takes_ref(arg))); + | +++++++++ error: aborting due to 11 previous errors diff --git a/tests/ui/suggestions/auxiliary/missing-assoc-fn-applicable-suggestions.rs b/tests/ui/suggestions/auxiliary/missing-assoc-fn-applicable-suggestions.rs new file mode 100644 index 000000000..b026035a6 --- /dev/null +++ b/tests/ui/suggestions/auxiliary/missing-assoc-fn-applicable-suggestions.rs @@ -0,0 +1,16 @@ +pub trait TraitB { + type Item; +} + +pub trait TraitA<A> { + type Type; + + fn bar<T>(_: T) -> Self; + + fn baz<T>(_: T) -> Self + where + T: TraitB, + <T as TraitB>::Item: Copy; + + const A: usize; +} diff --git a/tests/ui/suggestions/derive-macro-missing-bounds.stderr b/tests/ui/suggestions/derive-macro-missing-bounds.stderr index c3f305c17..bffcb1af4 100644 --- a/tests/ui/suggestions/derive-macro-missing-bounds.stderr +++ b/tests/ui/suggestions/derive-macro-missing-bounds.stderr @@ -36,7 +36,7 @@ LL | impl<T: Debug + Trait> Debug for Inner<T> { | unsatisfied trait bound introduced here = note: 1 redundant requirement hidden = note: required for `&c::Inner<T>` to implement `Debug` - = note: required for the cast from `&c::Inner<T>` to the object type `dyn Debug` + = note: required for the cast from `&&c::Inner<T>` to `&dyn Debug` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -58,7 +58,7 @@ LL | impl<T> Debug for Inner<T> where T: Debug, T: Trait { | ^^^^^ ^^^^^^^^ ----- unsatisfied trait bound introduced here = note: 1 redundant requirement hidden = note: required for `&d::Inner<T>` to implement `Debug` - = note: required for the cast from `&d::Inner<T>` to the object type `dyn Debug` + = note: required for the cast from `&&d::Inner<T>` to `&dyn Debug` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -80,7 +80,7 @@ LL | impl<T> Debug for Inner<T> where T: Debug + Trait { | ^^^^^ ^^^^^^^^ ----- unsatisfied trait bound introduced here = note: 1 redundant requirement hidden = note: required for `&e::Inner<T>` to implement `Debug` - = note: required for the cast from `&e::Inner<T>` to the object type `dyn Debug` + = note: required for the cast from `&&e::Inner<T>` to `&dyn Debug` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -102,7 +102,7 @@ LL | impl<T: Debug> Debug for Inner<T> where T: Trait { | ^^^^^ ^^^^^^^^ ----- unsatisfied trait bound introduced here = note: 1 redundant requirement hidden = note: required for `&f::Inner<T>` to implement `Debug` - = note: required for the cast from `&f::Inner<T>` to the object type `dyn Debug` + = note: required for the cast from `&&f::Inner<T>` to `&dyn Debug` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | diff --git a/tests/ui/suggestions/invalid-bin-op.stderr b/tests/ui/suggestions/invalid-bin-op.stderr index e291cedb8..570afcea6 100644 --- a/tests/ui/suggestions/invalid-bin-op.stderr +++ b/tests/ui/suggestions/invalid-bin-op.stderr @@ -6,11 +6,11 @@ LL | let _ = s == t; | | | S<T> | -note: an implementation of `PartialEq<_>` might be missing for `S<T>` +note: an implementation of `PartialEq` might be missing for `S<T>` --> $DIR/invalid-bin-op.rs:5:1 | LL | struct S<T>(T); - | ^^^^^^^^^^^ must implement `PartialEq<_>` + | ^^^^^^^^^^^ must implement `PartialEq` help: consider annotating `S<T>` with `#[derive(PartialEq)]` | LL + #[derive(PartialEq)] diff --git a/tests/ui/suggestions/issue-109436.stderr b/tests/ui/suggestions/issue-109436.stderr index 48518b33d..c479326f9 100644 --- a/tests/ui/suggestions/issue-109436.stderr +++ b/tests/ui/suggestions/issue-109436.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Foo: Into<_>` is not satisfied --> $DIR/issue-109436.rs:12:22 | LL | let b: Bar = foo.into(); - | ^^^^ the trait `~const Into<_>` is not implemented for `Foo` + | ^^^^ the trait `Into<_>` is not implemented for `Foo` | = note: required for `Foo` to implement `Into<Bar>` help: consider borrowing here diff --git a/tests/ui/suggestions/issue-109854.rs b/tests/ui/suggestions/issue-109854.rs new file mode 100644 index 000000000..dd4542dd7 --- /dev/null +++ b/tests/ui/suggestions/issue-109854.rs @@ -0,0 +1,12 @@ +fn generate_setter() { + String::with_capacity( + //~^ ERROR this function takes 1 argument but 3 arguments were supplied + generate_setter, + r#" +pub(crate) struct Person<T: Clone> {} +"#, + r#""#, + ); +} + +fn main() {} diff --git a/tests/ui/suggestions/issue-109854.stderr b/tests/ui/suggestions/issue-109854.stderr new file mode 100644 index 000000000..621a38971 --- /dev/null +++ b/tests/ui/suggestions/issue-109854.stderr @@ -0,0 +1,31 @@ +error[E0061]: this function takes 1 argument but 3 arguments were supplied + --> $DIR/issue-109854.rs:2:5 + | +LL | String::with_capacity( + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | / r#" +LL | | pub(crate) struct Person<T: Clone> {} +LL | | "#, + | |__- unexpected argument of type `&'static str` +LL | r#""#, + | ----- unexpected argument of type `&'static str` + | +note: expected `usize`, found fn item + --> $DIR/issue-109854.rs:4:5 + | +LL | generate_setter, + | ^^^^^^^^^^^^^^^ + = note: expected type `usize` + found fn item `fn() {generate_setter}` +note: associated function defined here + --> $SRC_DIR/alloc/src/string.rs:LL:COL +help: remove the extra arguments + | +LL - generate_setter, +LL + /* usize */, + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/suggestions/issue-68049-2.stderr b/tests/ui/suggestions/issue-68049-2.stderr index de35aa5b1..6f3c78443 100644 --- a/tests/ui/suggestions/issue-68049-2.stderr +++ b/tests/ui/suggestions/issue-68049-2.stderr @@ -4,10 +4,10 @@ error[E0594]: cannot assign to `*input`, which is behind a `&` reference LL | *input = self.0; | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written | -help: consider changing that to be a mutable reference +help: consider changing this to be a mutable reference | -LL | fn example(&self, input: &mut i32); // should suggest here - | ~~~~~~~~ +LL | fn example(&self, input: &mut i32) { // should not suggest here + | +++ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference --> $DIR/issue-68049-2.rs:17:5 @@ -15,7 +15,7 @@ error[E0594]: cannot assign to `self.0`, which is behind a `&` reference LL | self.0 += *input; | ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written | -help: consider changing that to be a mutable reference +help: consider changing this to be a mutable reference | LL | fn example(&mut self, input: &i32); // should suggest here | ~~~~~~~~~ diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.rs b/tests/ui/suggestions/issue-71394-no-from-impl.rs index 0c35deb51..63f12a912 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.rs +++ b/tests/ui/suggestions/issue-71394-no-from-impl.rs @@ -1,3 +1,8 @@ +// ignore-wasm +// ignore-msvc +// ignore-emscripten +// ignore-uwp + fn main() { let data: &[u8] = &[0; 10]; let _: &[i8] = data.into(); diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index a5e6f5b5f..2cd036d2b 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -1,12 +1,19 @@ error[E0277]: the trait bound `&[i8]: From<&[u8]>` is not satisfied - --> $DIR/issue-71394-no-from-impl.rs:3:25 + --> $DIR/issue-71394-no-from-impl.rs:8:25 | LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | = help: the following other types implement trait `From<T>`: - <[T; LANES] as From<Simd<T, LANES>>> - <[bool; LANES] as From<Mask<T, LANES>>> + <[T; 10] as From<(T, T, T, T, T, T, T, T, T, T)>> + <[T; 11] as From<(T, T, T, T, T, T, T, T, T, T, T)>> + <[T; 12] as From<(T, T, T, T, T, T, T, T, T, T, T, T)>> + <[T; 1] as From<(T,)>> + <[T; 2] as From<(T, T)>> + <[T; 3] as From<(T, T, T)>> + <[T; 4] as From<(T, T, T, T)>> + <[T; 5] as From<(T, T, T, T, T)>> + and 6 others = note: required for `&[u8]` to implement `Into<&[i8]>` error: aborting due to previous error diff --git a/tests/ui/suggestions/issue-94171.rs b/tests/ui/suggestions/issue-94171.rs new file mode 100644 index 000000000..cbb9f9cec --- /dev/null +++ b/tests/ui/suggestions/issue-94171.rs @@ -0,0 +1,5 @@ +fn L(]{match +(; {` +//~^^ ERROR mismatched closing delimiter +//~^^ ERROR unknown start of token +//~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/suggestions/issue-94171.stderr b/tests/ui/suggestions/issue-94171.stderr new file mode 100644 index 000000000..b3440e46e --- /dev/null +++ b/tests/ui/suggestions/issue-94171.stderr @@ -0,0 +1,36 @@ +error: unknown start of token: ` + --> $DIR/issue-94171.rs:2:5 + | +LL | (; {` + | ^ + | +help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not + | +LL | (; {' + | ~ + +error: mismatched closing delimiter: `]` + --> $DIR/issue-94171.rs:1:5 + | +LL | fn L(]{match + | ^^ mismatched closing delimiter + | | + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-94171.rs:5:52 + | +LL | fn L(]{match + | -- unclosed delimiter + | | + | missing open `[` for this delimiter +LL | (; {` + | - - unclosed delimiter + | | + | unclosed delimiter +... +LL | + | ^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/suggestions/issue-96555.stderr b/tests/ui/suggestions/issue-96555.stderr index 9a8a183dc..1a1e069f0 100644 --- a/tests/ui/suggestions/issue-96555.stderr +++ b/tests/ui/suggestions/issue-96555.stderr @@ -1,8 +1,8 @@ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:4:12 + --> $DIR/issue-96555.rs:4:13 | LL | m::f1().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -20,10 +20,10 @@ LL | pub async fn f1() {} | +++++ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:5:12 + --> $DIR/issue-96555.rs:5:13 | LL | m::f2().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -41,10 +41,10 @@ LL | pub(crate) async fn f2() {} | +++++ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:6:12 + --> $DIR/issue-96555.rs:6:13 | LL | m::f3().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | diff --git a/tests/ui/suggestions/issue-99597.rs b/tests/ui/suggestions/issue-99597.rs new file mode 100644 index 000000000..8ba9e1fdd --- /dev/null +++ b/tests/ui/suggestions/issue-99597.rs @@ -0,0 +1,15 @@ +#![allow(dead_code)] + +trait T1 { } + +trait T2 { + fn test(&self) { } +} + +fn go(s: &impl T1) { + //~^ SUGGESTION ( + s.test(); + //~^ ERROR no method named `test` +} + +fn main() { } diff --git a/tests/ui/suggestions/issue-99597.stderr b/tests/ui/suggestions/issue-99597.stderr new file mode 100644 index 000000000..bdf2a07c1 --- /dev/null +++ b/tests/ui/suggestions/issue-99597.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `test` found for reference `&impl T1` in the current scope + --> $DIR/issue-99597.rs:11:7 + | +LL | s.test(); + | ^^^^ method not found in `&impl T1` + | + = help: items from traits can only be used if the type parameter is bounded by the trait +help: the following trait defines an item `test`, perhaps you need to restrict type parameter `impl T1` with it: + | +LL | fn go(s: &(impl T1 + T2)) { + | + +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/suggestions/many-type-ascription.rs b/tests/ui/suggestions/many-type-ascription.rs index 31ac556b9..cc2406d66 100644 --- a/tests/ui/suggestions/many-type-ascription.rs +++ b/tests/ui/suggestions/many-type-ascription.rs @@ -1,4 +1,4 @@ fn main() { - let _ = 0: i32; //~ ERROR: type ascription is experimental + let _ = 0: i32; //~ ERROR: expected one of let _ = 0: i32; // (error only emitted once) } diff --git a/tests/ui/suggestions/many-type-ascription.stderr b/tests/ui/suggestions/many-type-ascription.stderr index 3706bbae9..e36919c82 100644 --- a/tests/ui/suggestions/many-type-ascription.stderr +++ b/tests/ui/suggestions/many-type-ascription.stderr @@ -1,12 +1,10 @@ -error[E0658]: type ascription is experimental - --> $DIR/many-type-ascription.rs:2:13 +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/many-type-ascription.rs:2:14 | LL | let _ = 0: i32; - | ^^^^^^ + | ^ expected one of `.`, `;`, `?`, `else`, or an operator | - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information - = help: add `#![feature(type_ascription)]` to the crate attributes to enable + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.fixed b/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.fixed deleted file mode 100644 index a0cb39a3f..000000000 --- a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.fixed +++ /dev/null @@ -1,21 +0,0 @@ -// run-rustfix -trait TraitB { - type Item; -} - -trait TraitA<A> { - type Type; - fn bar<T>(_: T) -> Self; - fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; -} - -struct S; -struct Type; - -impl TraitA<()> for S { //~ ERROR not all trait items implemented -fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() } -fn bar<T>(_: T) -> Self { todo!() } -type Type = Type; -} - -fn main() {} diff --git a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.rs b/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.rs index c80ede1b2..11e0c9a3a 100644 --- a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.rs +++ b/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.rs @@ -1,18 +1,15 @@ -// run-rustfix -trait TraitB { - type Item; -} +// aux-build:missing-assoc-fn-applicable-suggestions.rs -trait TraitA<A> { - type Type; - fn bar<T>(_: T) -> Self; - fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; -} +extern crate missing_assoc_fn_applicable_suggestions; +use missing_assoc_fn_applicable_suggestions::TraitA; struct S; -struct Type; - -impl TraitA<()> for S { //~ ERROR not all trait items implemented +impl TraitA<()> for S { + //~^ ERROR not all trait items implemented } +//~^ HELP implement the missing item: `type Type = /* Type */;` +//~| HELP implement the missing item: `fn bar<T>(_: T) -> Self { todo!() }` +//~| HELP implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() }` +//~| HELP implement the missing item: `const A: usize = 42;` fn main() {} diff --git a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.stderr b/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.stderr index 4c75fbe4c..4c2d2776d 100644 --- a/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.stderr +++ b/tests/ui/suggestions/missing-assoc-fn-applicable-suggestions.stderr @@ -1,15 +1,13 @@ -error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz` - --> $DIR/missing-assoc-fn-applicable-suggestions.rs:15:1 +error[E0046]: not all trait items implemented, missing: `Type`, `bar`, `baz`, `A` + --> $DIR/missing-assoc-fn-applicable-suggestions.rs:7:1 | -LL | type Type; - | --------- `Type` from trait -LL | fn bar<T>(_: T) -> Self; - | ------------------------ `bar` from trait -LL | fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy; - | ------------------------------------------------------------------- `baz` from trait -... LL | impl TraitA<()> for S { - | ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz` in implementation + | ^^^^^^^^^^^^^^^^^^^^^ missing `Type`, `bar`, `baz`, `A` in implementation + | + = help: implement the missing item: `type Type = /* Type */;` + = help: implement the missing item: `fn bar<T>(_: T) -> Self { todo!() }` + = help: implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: Copy { todo!() }` + = help: implement the missing item: `const A: usize = 42;` error: aborting due to previous error diff --git a/tests/ui/suggestions/missing-assoc-fn.stderr b/tests/ui/suggestions/missing-assoc-fn.stderr index 136ec2152..77fa95628 100644 --- a/tests/ui/suggestions/missing-assoc-fn.stderr +++ b/tests/ui/suggestions/missing-assoc-fn.stderr @@ -28,7 +28,7 @@ error[E0046]: not all trait items implemented, missing: `from_iter` LL | impl FromIterator<()> for X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_iter` in implementation | - = help: implement the missing item: `fn from_iter<T>(_: T) -> Self where T: IntoIterator, std::iter::IntoIterator::Item = A { todo!() }` + = help: implement the missing item: `fn from_iter<T>(_: T) -> Self where T: IntoIterator, std::iter::IntoIterator::Item = () { todo!() }` error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/path-by-value.stderr b/tests/ui/suggestions/path-by-value.stderr index bbeaa26a9..fd3646b8c 100644 --- a/tests/ui/suggestions/path-by-value.stderr +++ b/tests/ui/suggestions/path-by-value.stderr @@ -5,7 +5,8 @@ LL | fn f(p: Path) { } | ^ doesn't have a size known at compile-time | = help: within `Path`, the trait `Sized` is not implemented for `[u8]` - = note: required because it appears within the type `Path` +note: required because it appears within the type `Path` + --> $SRC_DIR/std/src/path.rs:LL:COL = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | diff --git a/tests/ui/suggestions/restrict-type-not-param.stderr b/tests/ui/suggestions/restrict-type-not-param.stderr index 5434472ce..3c7d42888 100644 --- a/tests/ui/suggestions/restrict-type-not-param.stderr +++ b/tests/ui/suggestions/restrict-type-not-param.stderr @@ -6,11 +6,11 @@ LL | a + b | | | Wrapper<T> | -note: an implementation of `Add<_>` might be missing for `Wrapper<T>` +note: an implementation of `Add<T>` might be missing for `Wrapper<T>` --> $DIR/restrict-type-not-param.rs:3:1 | LL | struct Wrapper<T>(T); - | ^^^^^^^^^^^^^^^^^ must implement `Add<_>` + | ^^^^^^^^^^^^^^^^^ must implement `Add<T>` note: the trait `Add` must be implemented --> $SRC_DIR/core/src/ops/arith.rs:LL:COL help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement diff --git a/tests/ui/suggestions/suggest-borrow-to-dyn-object.rs b/tests/ui/suggestions/suggest-borrow-to-dyn-object.rs deleted file mode 100644 index 120fc5383..000000000 --- a/tests/ui/suggestions/suggest-borrow-to-dyn-object.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::ffi::{OsStr, OsString}; -use std::path::Path; - -fn check(p: &dyn AsRef<Path>) { - let m = std::fs::metadata(&p); - println!("{:?}", &m); -} - -fn main() { - let s: OsString = ".".into(); - let s: &OsStr = &s; - check(s); - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| HELP within `OsStr`, the trait `Sized` is not implemented for `[u8]` - //~| HELP consider borrowing the value, since `&OsStr` can be coerced into `dyn AsRef<Path>` -} diff --git a/tests/ui/suggestions/suggest-borrow-to-dyn-object.stderr b/tests/ui/suggestions/suggest-borrow-to-dyn-object.stderr deleted file mode 100644 index 6ce9bfd9d..000000000 --- a/tests/ui/suggestions/suggest-borrow-to-dyn-object.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/suggest-borrow-to-dyn-object.rs:12:11 - | -LL | check(s); - | ^ doesn't have a size known at compile-time - | - = help: within `OsStr`, the trait `Sized` is not implemented for `[u8]` - = note: required because it appears within the type `OsStr` - = note: required for the cast from `OsStr` to the object type `dyn AsRef<Path>` -help: consider borrowing the value, since `&OsStr` can be coerced into `dyn AsRef<Path>` - | -LL | check(&s); - | + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/suggest-boxed-empty-block.fixed b/tests/ui/suggestions/suggest-boxed-empty-block.fixed new file mode 100644 index 000000000..46683aa09 --- /dev/null +++ b/tests/ui/suggestions/suggest-boxed-empty-block.fixed @@ -0,0 +1,12 @@ +#![feature(async_closure)] + +// edition:2021 +// run-rustfix + +fn foo<T>(_: Box<T>) {} +fn bar<T>(_: impl Fn() -> Box<T>) {} + +fn main() { + foo(Box::new(())); //~ ERROR mismatched types + bar(|| Box::new(())); //~ ERROR mismatched types +} diff --git a/tests/ui/suggestions/suggest-boxed-empty-block.rs b/tests/ui/suggestions/suggest-boxed-empty-block.rs new file mode 100644 index 000000000..e19670a50 --- /dev/null +++ b/tests/ui/suggestions/suggest-boxed-empty-block.rs @@ -0,0 +1,12 @@ +#![feature(async_closure)] + +// edition:2021 +// run-rustfix + +fn foo<T>(_: Box<T>) {} +fn bar<T>(_: impl Fn() -> Box<T>) {} + +fn main() { + foo({}); //~ ERROR mismatched types + bar(|| {}); //~ ERROR mismatched types +} diff --git a/tests/ui/suggestions/suggest-boxed-empty-block.stderr b/tests/ui/suggestions/suggest-boxed-empty-block.stderr new file mode 100644 index 000000000..474a37b88 --- /dev/null +++ b/tests/ui/suggestions/suggest-boxed-empty-block.stderr @@ -0,0 +1,33 @@ +error[E0308]: mismatched types + --> $DIR/suggest-boxed-empty-block.rs:10:9 + | +LL | foo({}); + | ^^ expected `Box<_>`, found `()` + | + = note: expected struct `Box<_>` + found unit type `()` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL - foo({}); +LL + foo(Box::new(())); + | + +error[E0308]: mismatched types + --> $DIR/suggest-boxed-empty-block.rs:11:12 + | +LL | bar(|| {}); + | ^^ expected `Box<_>`, found `()` + | + = note: expected struct `Box<_>` + found unit type `()` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL - bar(|| {}); +LL + bar(|| Box::new(())); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed index b69bad988..556c95438 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.fixed @@ -11,7 +11,7 @@ fn main() { let mut map = HashMap::new(); map.insert("a", Test { v: 0 }); - for (_k, mut v) in map.iter_mut() { + for (_k, v) in map.iter_mut() { //~^ HELP use mutable method //~| NOTE this iterator yields `&` references v.v += 1; diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs index 9284410df..b9d49a074 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.rs @@ -11,7 +11,7 @@ fn main() { let mut map = HashMap::new(); map.insert("a", Test { v: 0 }); - for (_k, mut v) in map.iter() { + for (_k, v) in map.iter() { //~^ HELP use mutable method //~| NOTE this iterator yields `&` references v.v += 1; diff --git a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr index 74433daa6..c442ed637 100644 --- a/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr +++ b/tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr @@ -1,11 +1,11 @@ error[E0594]: cannot assign to `v.v`, which is behind a `&` reference --> $DIR/suggest-mut-method-for-loop-hashmap.rs:17:9 | -LL | for (_k, mut v) in map.iter() { - | ---------- - | | | - | | help: use mutable method: `iter_mut()` - | this iterator yields `&` references +LL | for (_k, v) in map.iter() { + | ---------- + | | | + | | help: use mutable method: `iter_mut()` + | this iterator yields `&` references ... LL | v.v += 1; | ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/suggestions/suggest-ref-macro.rs b/tests/ui/suggestions/suggest-ref-macro.rs index 6f780f32a..730f5fa1b 100644 --- a/tests/ui/suggestions/suggest-ref-macro.rs +++ b/tests/ui/suggestions/suggest-ref-macro.rs @@ -14,7 +14,7 @@ macro_rules! bla { () => { x(123); //~^ ERROR mismatched types - //~| SUGGESTION &mut 123 + //~| SUGGESTION &mut }; ($v:expr) => { x($v) @@ -25,5 +25,5 @@ fn main() { bla!(); bla!(456); //~^ ERROR mismatched types - //~| SUGGESTION &mut 456 + //~| SUGGESTION &mut } diff --git a/tests/ui/suggestions/suggest-ref-macro.stderr b/tests/ui/suggestions/suggest-ref-macro.stderr index 17de49fbd..08bc9e86a 100644 --- a/tests/ui/suggestions/suggest-ref-macro.stderr +++ b/tests/ui/suggestions/suggest-ref-macro.stderr @@ -18,10 +18,8 @@ error[E0308]: mismatched types --> $DIR/suggest-ref-macro.rs:15:11 | LL | x(123); - | - ^^^ - | | | - | | expected `&mut i32`, found integer - | | help: consider mutably borrowing here: `&mut 123` + | - ^^^ expected `&mut i32`, found integer + | | | arguments to this function are incorrect ... LL | bla!(); @@ -33,6 +31,10 @@ note: function defined here LL | fn x(_: &mut i32) {} | ^ ----------- = note: this error originates in the macro `bla` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider mutably borrowing here + | +LL | x(&mut 123); + | ++++ error[E0308]: mismatched types --> $DIR/suggest-ref-macro.rs:26:10 @@ -41,16 +43,17 @@ LL | x($v) | - arguments to this function are incorrect ... LL | bla!(456); - | ^^^ - | | - | expected `&mut i32`, found integer - | help: consider mutably borrowing here: `&mut 456` + | ^^^ expected `&mut i32`, found integer | note: function defined here --> $DIR/suggest-ref-macro.rs:11:4 | LL | fn x(_: &mut i32) {} | ^ ----------- +help: consider mutably borrowing here + | +LL | bla!(&mut 456); + | ++++ error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/suggest-ref-mut.rs b/tests/ui/suggestions/suggest-ref-mut.rs index d04113ffc..b40439b8e 100644 --- a/tests/ui/suggestions/suggest-ref-mut.rs +++ b/tests/ui/suggestions/suggest-ref-mut.rs @@ -12,12 +12,10 @@ impl X { fn main() { let ref foo = 16; //~^ HELP - //~| SUGGESTION ref mut foo *foo = 32; //~^ ERROR if let Some(ref bar) = Some(16) { //~^ HELP - //~| SUGGESTION ref mut bar *bar = 32; //~^ ERROR } @@ -25,6 +23,5 @@ fn main() { ref quo => { *quo = 32; }, //~^ ERROR //~| HELP - //~| SUGGESTION ref mut quo } } diff --git a/tests/ui/suggestions/suggest-ref-mut.stderr b/tests/ui/suggestions/suggest-ref-mut.stderr index 7973759bf..cc00022ab 100644 --- a/tests/ui/suggestions/suggest-ref-mut.stderr +++ b/tests/ui/suggestions/suggest-ref-mut.stderr @@ -10,7 +10,7 @@ LL | fn zap(&mut self) { | ~~~~~~~~~ error[E0594]: cannot assign to `*foo`, which is behind a `&` reference - --> $DIR/suggest-ref-mut.rs:16:5 + --> $DIR/suggest-ref-mut.rs:15:5 | LL | *foo = 32; | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written @@ -18,10 +18,10 @@ LL | *foo = 32; help: consider changing this to be a mutable reference | LL | let ref mut foo = 16; - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to `*bar`, which is behind a `&` reference - --> $DIR/suggest-ref-mut.rs:21:9 + --> $DIR/suggest-ref-mut.rs:19:9 | LL | *bar = 32; | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written @@ -29,10 +29,10 @@ LL | *bar = 32; help: consider changing this to be a mutable reference | LL | if let Some(ref mut bar) = Some(16) { - | ~~~~~~~~~~~ + | +++ error[E0594]: cannot assign to `*quo`, which is behind a `&` reference - --> $DIR/suggest-ref-mut.rs:25:22 + --> $DIR/suggest-ref-mut.rs:23:22 | LL | ref quo => { *quo = 32; }, | ^^^^^^^^^ `quo` is a `&` reference, so the data it refers to cannot be written @@ -40,7 +40,7 @@ LL | ref quo => { *quo = 32; }, help: consider changing this to be a mutable reference | LL | ref mut quo => { *quo = 32; }, - | ~~~~~~~~~~~ + | +++ error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.fixed b/tests/ui/suggestions/type-ascription-instead-of-let.fixed new file mode 100644 index 000000000..e3d03b6f2 --- /dev/null +++ b/tests/ui/suggestions/type-ascription-instead-of-let.fixed @@ -0,0 +1,11 @@ +// run-rustfix + +fn fun(x: i32) -> i32 { x } + +fn main() { + let _closure_annotated = |value: i32| -> i32 { + let temp: i32 = fun(5i32); + //~^ ERROR expected identifier, found `:` + temp + value + 1 + }; +} diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.rs b/tests/ui/suggestions/type-ascription-instead-of-let.rs index 0e1c30750..6e1c86f96 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-let.rs +++ b/tests/ui/suggestions/type-ascription-instead-of-let.rs @@ -1,10 +1,11 @@ +// run-rustfix + fn fun(x: i32) -> i32 { x } fn main() { - let closure_annotated = |value: i32| -> i32 { + let _closure_annotated = |value: i32| -> i32 { temp: i32 = fun(5i32); - //~^ ERROR cannot find value `temp` in this scope + //~^ ERROR expected identifier, found `:` temp + value + 1 - //~^ ERROR cannot find value `temp` in this scope }; } diff --git a/tests/ui/suggestions/type-ascription-instead-of-let.stderr b/tests/ui/suggestions/type-ascription-instead-of-let.stderr index 92e4b5798..065b1f4d3 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-let.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-let.stderr @@ -1,18 +1,13 @@ -error[E0425]: cannot find value `temp` in this scope - --> $DIR/type-ascription-instead-of-let.rs:5:9 +error: expected identifier, found `:` + --> $DIR/type-ascription-instead-of-let.rs:7:13 | LL | temp: i32 = fun(5i32); - | ^^^^ - | | - | not found in this scope - | help: maybe you meant to write an assignment here: `let temp` - -error[E0425]: cannot find value `temp` in this scope - --> $DIR/type-ascription-instead-of-let.rs:7:9 + | ^ expected identifier + | +help: you might have meant to introduce a new binding | -LL | temp + value + 1 - | ^^^^ not found in this scope +LL | let temp: i32 = fun(5i32); + | +++ -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/suggestions/type-ascription-instead-of-method.fixed b/tests/ui/suggestions/type-ascription-instead-of-method.fixed index 56b740b0d..02e316b26 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-method.fixed +++ b/tests/ui/suggestions/type-ascription-instead-of-method.fixed @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _ = Box::new("foo".to_string()); - //~^ ERROR expected type, found + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/suggestions/type-ascription-instead-of-method.rs b/tests/ui/suggestions/type-ascription-instead-of-method.rs index a603e09e7..6f893ee89 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-method.rs +++ b/tests/ui/suggestions/type-ascription-instead-of-method.rs @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _ = Box:new("foo".to_string()); - //~^ ERROR expected type, found + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/suggestions/type-ascription-instead-of-method.stderr b/tests/ui/suggestions/type-ascription-instead-of-method.stderr index 83bc33f41..b3799101c 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-method.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-method.stderr @@ -1,12 +1,10 @@ -error: expected type, found `"foo"` - --> $DIR/type-ascription-instead-of-method.rs:3:21 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-method.rs:3:16 | LL | let _ = Box:new("foo".to_string()); - | - ^^^^^ expected type - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed b/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed index 787fcc120..4cec58be8 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed +++ b/tests/ui/suggestions/type-ascription-instead-of-path-2.fixed @@ -1,6 +1,6 @@ // run-rustfix fn main() -> Result<(), ()> { let _ = vec![Ok(2)].into_iter().collect::<Result<Vec<_>,_>>()?; - //~^ ERROR expected `::`, found `(` + //~^ ERROR expected one of Ok(()) } diff --git a/tests/ui/suggestions/type-ascription-instead-of-path-2.rs b/tests/ui/suggestions/type-ascription-instead-of-path-2.rs index 934016b3b..5695d5a7f 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path-2.rs +++ b/tests/ui/suggestions/type-ascription-instead-of-path-2.rs @@ -1,6 +1,6 @@ // run-rustfix fn main() -> Result<(), ()> { let _ = vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?; - //~^ ERROR expected `::`, found `(` + //~^ ERROR expected one of Ok(()) } diff --git a/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr b/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr index 970b220b7..43d00591e 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-path-2.stderr @@ -1,12 +1,14 @@ -error: expected `::`, found `(` - --> $DIR/type-ascription-instead-of-path-2.rs:3:63 +error: expected one of `(`, `.`, `::`, `;`, `?`, `else`, or an operator, found `:` + --> $DIR/type-ascription-instead-of-path-2.rs:3:44 | LL | let _ = vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?; - | - ^ expected `::` - | | - | help: maybe write a path separator here: `::` + | ^ expected one of 7 possible tokens | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: maybe write a path separator here + | +LL | let _ = vec![Ok(2)].into_iter().collect::<Result<Vec<_>,_>>()?; + | ~~ error: aborting due to previous error diff --git a/tests/ui/suggestions/type-ascription-instead-of-path.rs b/tests/ui/suggestions/type-ascription-instead-of-path.rs index ce40b55f1..69647887a 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path.rs +++ b/tests/ui/suggestions/type-ascription-instead-of-path.rs @@ -1,5 +1,4 @@ fn main() { std:io::stdin(); - //~^ ERROR failed to resolve: use of undeclared crate or module `io` - //~| ERROR expected value, found crate + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/suggestions/type-ascription-instead-of-path.stderr b/tests/ui/suggestions/type-ascription-instead-of-path.stderr index 518660cfa..849630218 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-path.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-path.stderr @@ -1,18 +1,10 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `io` - --> $DIR/type-ascription-instead-of-path.rs:2:9 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-path.rs:2:8 | LL | std:io::stdin(); - | ^^ use of undeclared crate or module `io` - -error[E0423]: expected value, found crate `std` - --> $DIR/type-ascription-instead-of-path.rs:2:5 + | ^ help: use a double colon instead: `::` | -LL | std:io::stdin(); - | ^^^- help: maybe you meant to write a path separator here: `::` - | | - | not a value + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0423, E0433. -For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/suggestions/type-ascription-instead-of-variant.fixed b/tests/ui/suggestions/type-ascription-instead-of-variant.fixed index b3247e128..04cb20686 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-variant.fixed +++ b/tests/ui/suggestions/type-ascription-instead-of-variant.fixed @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _ = Option::Some(""); - //~^ ERROR expected type, found + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/suggestions/type-ascription-instead-of-variant.rs b/tests/ui/suggestions/type-ascription-instead-of-variant.rs index 6fd2c1954..2cce69bfe 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-variant.rs +++ b/tests/ui/suggestions/type-ascription-instead-of-variant.rs @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _ = Option:Some(""); - //~^ ERROR expected type, found + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr index f59ba78d4..11d0f5f52 100644 --- a/tests/ui/suggestions/type-ascription-instead-of-variant.stderr +++ b/tests/ui/suggestions/type-ascription-instead-of-variant.stderr @@ -1,12 +1,10 @@ -error: expected type, found `""` - --> $DIR/type-ascription-instead-of-variant.rs:3:25 +error: path separator must be a double colon + --> $DIR/type-ascription-instead-of-variant.rs:3:19 | LL | let _ = Option:Some(""); - | - ^^ expected type - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 2eea087c7..8d1765eb8 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -10,6 +10,7 @@ // ignore-sparc // ignore-sparc64 // ignore-s390x +// ignore-loongarch64 // gate-test-sse4a_target_feature // gate-test-powerpc_target_feature // gate-test-avx512_target_feature diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index 2d6abcc0a..ee542b60a 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/gate.rs:31:18 + --> $DIR/gate.rs:32:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index b59ed076f..77fd8b85f 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -10,6 +10,7 @@ // ignore-s390x // ignore-sparc // ignore-sparc64 +// ignore-loongarch64 #![warn(unused_attributes)] diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index c36392d43..6d37d0917 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -1,11 +1,11 @@ error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:31:1 + --> $DIR/invalid-attribute.rs:32:1 | LL | #[target_feature = "+sse2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:16:1 + --> $DIR/invalid-attribute.rs:17:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | extern crate alloc; | ------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:21:1 + --> $DIR/invalid-attribute.rs:22:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | use alloc::alloc::alloc; | ------------------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:26:1 + --> $DIR/invalid-attribute.rs:27:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | extern "Rust" {} | ---------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:48:1 + --> $DIR/invalid-attribute.rs:49:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | mod another {} | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:53:1 + --> $DIR/invalid-attribute.rs:54:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | const FOO: usize = 7; | --------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:58:1 + --> $DIR/invalid-attribute.rs:59:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | struct Foo; | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:63:1 + --> $DIR/invalid-attribute.rs:64:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | enum Bar {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:68:1 + --> $DIR/invalid-attribute.rs:69:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | | } | |_- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:76:1 + --> $DIR/invalid-attribute.rs:77:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | type Uwu = (); | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:81:1 + --> $DIR/invalid-attribute.rs:82:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | trait Baz {} | ------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:91:1 + --> $DIR/invalid-attribute.rs:92:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | static A: () = (); | ------------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:96:1 + --> $DIR/invalid-attribute.rs:97:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +117,7 @@ LL | impl Quux for u8 {} | ------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:101:1 + --> $DIR/invalid-attribute.rs:102:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | impl Foo {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:119:5 + --> $DIR/invalid-attribute.rs:120:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | | } | |_____- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:127:5 + --> $DIR/invalid-attribute.rs:128:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,25 +147,25 @@ LL | || {}; | ----- not a function definition error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:33:18 + --> $DIR/invalid-attribute.rs:34:18 | LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:36:18 + --> $DIR/invalid-attribute.rs:37:18 | LL | #[target_feature(bar)] | ^^^ help: must be of the form: `enable = ".."` error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:38:18 + --> $DIR/invalid-attribute.rs:39:18 | LL | #[target_feature(disable = "baz")] | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:42:1 + --> $DIR/invalid-attribute.rs:43:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,13 +177,13 @@ LL | fn bar() {} = help: add `#![feature(target_feature_11)]` to the crate attributes to enable error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:86:1 + --> $DIR/invalid-attribute.rs:87:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:111:5 + --> $DIR/invalid-attribute.rs:112:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-12997-1.rs b/tests/ui/test-attrs/issue-12997-1.rs index 9f808dac3..9f808dac3 100644 --- a/tests/ui/issues/issue-12997-1.rs +++ b/tests/ui/test-attrs/issue-12997-1.rs diff --git a/tests/ui/issues/issue-12997-1.stderr b/tests/ui/test-attrs/issue-12997-1.stderr index 00c605174..00c605174 100644 --- a/tests/ui/issues/issue-12997-1.stderr +++ b/tests/ui/test-attrs/issue-12997-1.stderr diff --git a/tests/ui/issues/issue-12997-2.rs b/tests/ui/test-attrs/issue-12997-2.rs index 9df965315..9df965315 100644 --- a/tests/ui/issues/issue-12997-2.rs +++ b/tests/ui/test-attrs/issue-12997-2.rs diff --git a/tests/ui/issues/issue-12997-2.stderr b/tests/ui/test-attrs/issue-12997-2.stderr index 2a3d0e345..2a3d0e345 100644 --- a/tests/ui/issues/issue-12997-2.stderr +++ b/tests/ui/test-attrs/issue-12997-2.stderr diff --git a/tests/ui/issues/issue-34932.rs b/tests/ui/test-attrs/issue-34932.rs index ab568fd01..ab568fd01 100644 --- a/tests/ui/issues/issue-34932.rs +++ b/tests/ui/test-attrs/issue-34932.rs diff --git a/tests/ui/test-attrs/test-type.rs b/tests/ui/test-attrs/test-type.rs index f99e476ea..8416270fd 100644 --- a/tests/ui/test-attrs/test-type.rs +++ b/tests/ui/test-attrs/test-type.rs @@ -3,6 +3,7 @@ // check-run-results // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support +// needs-unwind // run-pass #[test] diff --git a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr index 9f6276300..5d8b37554 100644 --- a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr +++ b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr @@ -1 +1 @@ -error: The "json" format is only accepted on the nightly compiler +error: The "json" format is only accepted on the nightly compiler with -Z unstable-options diff --git a/tests/ui/test-attrs/tests-listing-format-json.run.stdout b/tests/ui/test-attrs/tests-listing-format-json.run.stdout index b4131e97c..33cc939b5 100644 --- a/tests/ui/test-attrs/tests-listing-format-json.run.stdout +++ b/tests/ui/test-attrs/tests-listing-format-json.run.stdout @@ -1,5 +1,5 @@ { "type": "suite", "event": "discovery" } -{ "type": "test", "event": "discovered", "name": "a_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 20, "start_col": 4, "end_line": 20, "end_col": 10 } -{ "type": "test", "event": "discovered", "name": "m_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 13, "start_col": 4, "end_line": 13, "end_col": 10 } -{ "type": "test", "event": "discovered", "name": "z_test", "ignore": true, "ignore_message": "not yet implemented", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 17, "start_col": 4, "end_line": 17, "end_col": 10 } +{ "type": "test", "event": "discovered", "name": "a_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 21, "start_col": 4, "end_line": 21, "end_col": 10 } +{ "type": "test", "event": "discovered", "name": "m_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 14, "start_col": 4, "end_line": 14, "end_col": 10 } +{ "type": "test", "event": "discovered", "name": "z_test", "ignore": true, "ignore_message": "not yet implemented", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 18, "start_col": 4, "end_line": 18, "end_col": 10 } { "type": "suite", "event": "completed", "tests": 3, "benchmarks": 0, "total": 3, "ignored": 1 } diff --git a/tests/ui/thread-local/thread-local-static-ref-use-after-free.rs b/tests/ui/thread-local/thread-local-static-ref-use-after-free.rs new file mode 100644 index 000000000..c282e2185 --- /dev/null +++ b/tests/ui/thread-local/thread-local-static-ref-use-after-free.rs @@ -0,0 +1,46 @@ +// check-pass +// known-bug: #49682 +// edition:2021 + +// Should fail. Keeping references to thread local statics can result in a +// use-after-free. + +#![feature(thread_local)] + +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread; + +#[allow(dead_code)] +#[thread_local] +static FOO: AtomicUsize = AtomicUsize::new(0); + +#[allow(dead_code)] +async fn bar() {} + +#[allow(dead_code)] +async fn foo() { + let r = &FOO; + bar().await; + r.load(Ordering::SeqCst); +} + +fn main() { + // &FOO = 0x7fd1e9cbf6d0 + _ = thread::spawn(|| { + let g = foo(); + println!("&FOO = {:p}", &FOO); + g + }) + .join() + .unwrap(); + + // &FOO = 0x7fd1e9cc0f50 + println!("&FOO = {:p}", &FOO); + + // &FOO = 0x7fd1e9cbf6d0 + thread::spawn(move || { + println!("&FOO = {:p}", &FOO); + }) + .join() + .unwrap(); +} diff --git a/tests/ui/threads-sendsync/issue-43733-2.rs b/tests/ui/threads-sendsync/issue-43733-2.rs index 8f7a9c083..e9653dbe5 100644 --- a/tests/ui/threads-sendsync/issue-43733-2.rs +++ b/tests/ui/threads-sendsync/issue-43733-2.rs @@ -21,7 +21,7 @@ impl<T> Key<T> { } #[cfg(target_thread_local)] -use std::thread::__LocalKeyInner as Key; +use std::thread::local_impl::Key; static __KEY: Key<()> = Key::new(); //~^ ERROR `UnsafeCell<Option<()>>` cannot be shared between threads diff --git a/tests/ui/threads-sendsync/issue-43733.mir.stderr b/tests/ui/threads-sendsync/issue-43733.mir.stderr index 1e21a6b37..ff83e16ad 100644 --- a/tests/ui/threads-sendsync/issue-43733.mir.stderr +++ b/tests/ui/threads-sendsync/issue-43733.mir.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:21:5 + --> $DIR/issue-43733.rs:19:5 | LL | __KEY.get(Default::default) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | __KEY.get(Default::default) = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:26:42 + --> $DIR/issue-43733.rs:24:42 | LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function diff --git a/tests/ui/threads-sendsync/issue-43733.rs b/tests/ui/threads-sendsync/issue-43733.rs index 0eadef3e3..cac745f1e 100644 --- a/tests/ui/threads-sendsync/issue-43733.rs +++ b/tests/ui/threads-sendsync/issue-43733.rs @@ -1,8 +1,6 @@ // ignore-wasm32 // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck -// normalize-stderr-test: "__LocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" -// normalize-stderr-test: "__LocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" #![feature(thread_local)] #![feature(cfg_target_thread_local, thread_local_internals)] @@ -12,15 +10,15 @@ type Foo = std::cell::RefCell<String>; #[cfg(target_thread_local)] #[thread_local] -static __KEY: std::thread::__LocalKeyInner<Foo> = std::thread::__LocalKeyInner::new(); +static __KEY: std::thread::local_impl::Key<Foo> = std::thread::local_impl::Key::new(); #[cfg(not(target_thread_local))] -static __KEY: std::thread::__LocalKeyInner<Foo> = std::thread::__LocalKeyInner::new(); +static __KEY: std::thread::local_impl::Key<Foo> = std::thread::local_impl::Key::new(); fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> { __KEY.get(Default::default) //[mir]~^ ERROR call to unsafe function is unsafe - //[thir]~^^ ERROR call to unsafe function `__ + //[thir]~^^ ERROR call to unsafe function `Key::<T>::get` } static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit); diff --git a/tests/ui/threads-sendsync/issue-43733.thir.stderr b/tests/ui/threads-sendsync/issue-43733.thir.stderr index ea7ff4080..94ec72404 100644 --- a/tests/ui/threads-sendsync/issue-43733.thir.stderr +++ b/tests/ui/threads-sendsync/issue-43733.thir.stderr @@ -1,5 +1,5 @@ -error[E0133]: call to unsafe function `$LOCALKEYINNER::<T>::get` is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:21:5 +error[E0133]: call to unsafe function `Key::<T>::get` is unsafe and requires unsafe function or block + --> $DIR/issue-43733.rs:19:5 | LL | __KEY.get(Default::default) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function @@ -7,7 +7,7 @@ LL | __KEY.get(Default::default) = note: consult the function's documentation for information on how to avoid undefined behavior error[E0133]: call to unsafe function `LocalKey::<T>::new` is unsafe and requires unsafe function or block - --> $DIR/issue-43733.rs:26:42 + --> $DIR/issue-43733.rs:24:42 | LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function diff --git a/tests/ui/track-diagnostics/track6.rs b/tests/ui/track-diagnostics/track6.rs index 307e31018..fc6f5f23d 100644 --- a/tests/ui/track-diagnostics/track6.rs +++ b/tests/ui/track-diagnostics/track6.rs @@ -1,6 +1,9 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" pub trait Foo { diff --git a/tests/ui/track-diagnostics/track6.stderr b/tests/ui/track-diagnostics/track6.stderr index 1c7537633..89438aea9 100644 --- a/tests/ui/track-diagnostics/track6.stderr +++ b/tests/ui/track-diagnostics/track6.stderr @@ -1,9 +1,9 @@ error[E0658]: specialization is unstable - --> $DIR/track6.rs:11:5 + --> $DIR/track6.rs:LL:CC | LL | default fn bar() {} | ^^^^^^^^^^^^^^^^^^^ --Ztrack-diagnostics: created at $COMPILER_DIR/rustc_session/src/parse.rs:93:5 +-Ztrack-diagnostics: created at $COMPILER_DIR/rustc_session/src/parse.rs:LL:CC | = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information = help: add `#![feature(specialization)]` to the crate attributes to enable diff --git a/tests/ui/traits/coercion-generic-bad.stderr b/tests/ui/traits/coercion-generic-bad.stderr index 93d6770eb..e7e8a7967 100644 --- a/tests/ui/traits/coercion-generic-bad.stderr +++ b/tests/ui/traits/coercion-generic-bad.stderr @@ -5,7 +5,7 @@ LL | let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct` | = help: the trait `Trait<&'static str>` is implemented for `Struct` - = note: required for the cast from `Struct` to the object type `dyn Trait<isize>` + = note: required for the cast from `Box<Struct>` to `Box<dyn Trait<isize>>` error: aborting due to previous error diff --git a/tests/ui/traits/copy-guessing.rs b/tests/ui/traits/copy-guessing.rs index f031dd9ca..af25010e3 100644 --- a/tests/ui/traits/copy-guessing.rs +++ b/tests/ui/traits/copy-guessing.rs @@ -1,5 +1,6 @@ -// run-pass #![allow(dead_code)] +#![allow(dropping_copy_types)] + // "guessing" in trait selection can affect `copy_or_move`. Check that this // is correctly handled. I am not sure what is the "correct" behaviour, // but we should at least not ICE. @@ -17,6 +18,7 @@ fn assert_impls_fn<R,T: Fn()->R>(_: &T){} fn main() { let n = None; + //~^ ERROR type annotations needed for `Option<T>` let e = S(&n); let f = || { // S being copy is critical for this to work diff --git a/tests/ui/traits/copy-guessing.stderr b/tests/ui/traits/copy-guessing.stderr new file mode 100644 index 000000000..568b7e5a6 --- /dev/null +++ b/tests/ui/traits/copy-guessing.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `Option<T>` + --> $DIR/copy-guessing.rs:20:9 + | +LL | let n = None; + | ^ + | +help: consider giving `n` an explicit type, where the type for type parameter `T` is specified + | +LL | let n: Option<T> = None; + | +++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/cycle-cache-err-60010.stderr b/tests/ui/traits/cycle-cache-err-60010.stderr index eeee99760..aee41c43a 100644 --- a/tests/ui/traits/cycle-cache-err-60010.stderr +++ b/tests/ui/traits/cycle-cache-err-60010.stderr @@ -4,9 +4,12 @@ error[E0275]: overflow evaluating the requirement `SalsaStorage: RefUnwindSafe` LL | _parse: <ParseQuery as Query<RootDatabase>>::Data, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: required because it appears within the type `PhantomData<SalsaStorage>` - = note: required because it appears within the type `Unique<SalsaStorage>` - = note: required because it appears within the type `Box<SalsaStorage>` +note: required because it appears within the type `PhantomData<SalsaStorage>` + --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required because it appears within the type `Unique<SalsaStorage>` + --> $SRC_DIR/core/src/ptr/unique.rs:LL:COL +note: required because it appears within the type `Box<SalsaStorage>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required because it appears within the type `Runtime<RootDatabase>` --> $DIR/cycle-cache-err-60010.rs:23:8 | diff --git a/tests/ui/traits/impl-evaluation-order.rs b/tests/ui/traits/impl-evaluation-order.rs index 57809d89a..2ce0b6b0d 100644 --- a/tests/ui/traits/impl-evaluation-order.rs +++ b/tests/ui/traits/impl-evaluation-order.rs @@ -6,6 +6,8 @@ // check-pass +#![allow(dropping_copy_types)] + trait A { type B; } diff --git a/tests/ui/traits/infer-from-object-issue-26952.rs b/tests/ui/traits/infer-from-object-issue-26952.rs index ed258dbb2..9544b4f20 100644 --- a/tests/ui/traits/infer-from-object-issue-26952.rs +++ b/tests/ui/traits/infer-from-object-issue-26952.rs @@ -1,8 +1,8 @@ // run-pass #![allow(dead_code)] #![allow(unused_variables)] -// Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`, -// we unify with `_#0t` with `A`. In this code, if we failed to do +// Test that when we match a trait reference like `Foo<A>: Foo<?0t>`, +// we unify with `?0t` with `A`. In this code, if we failed to do // that, then you get an unconstrained type-variable in `call`. // // Also serves as a regression test for issue #26952, though the test diff --git a/tests/ui/traits/issue-106072.rs b/tests/ui/traits/issue-106072.rs index 7064a39d2..b17466954 100644 --- a/tests/ui/traits/issue-106072.rs +++ b/tests/ui/traits/issue-106072.rs @@ -1,5 +1,4 @@ #[derive(Clone)] //~ trait objects must include the `dyn` keyword - //~| trait objects must include the `dyn` keyword struct Foo; trait Foo {} //~ the name `Foo` is defined multiple times fn main() {} diff --git a/tests/ui/traits/issue-106072.stderr b/tests/ui/traits/issue-106072.stderr index f9b7b8146..1037603ce 100644 --- a/tests/ui/traits/issue-106072.stderr +++ b/tests/ui/traits/issue-106072.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-106072.rs:4:1 + --> $DIR/issue-106072.rs:3:1 | LL | struct Foo; | ----------- previous definition of the type `Foo` here @@ -16,15 +16,7 @@ LL | #[derive(Clone)] | = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0782]: trait objects must include the `dyn` keyword - --> $DIR/issue-106072.rs:1:10 - | -LL | #[derive(Clone)] - | ^^^^^ - | - = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0428, E0782. For more information about an error, try `rustc --explain E0428`. diff --git a/tests/ui/traits/issue-20692.stderr b/tests/ui/traits/issue-20692.stderr index 2028994cd..30e3c9da1 100644 --- a/tests/ui/traits/issue-20692.stderr +++ b/tests/ui/traits/issue-20692.stderr @@ -27,8 +27,7 @@ LL | trait Array: Sized + Copy {} | | | | | ...because it requires `Self: Sized` | this trait cannot be made into an object... - = note: required for `&T` to implement `CoerceUnsized<&dyn Array>` - = note: required by cast to type `&dyn Array` + = note: required for the cast from `&T` to `&dyn Array` error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-22384.rs b/tests/ui/traits/issue-22384.rs index 98988f27e..98988f27e 100644 --- a/tests/ui/issues/issue-22384.rs +++ b/tests/ui/traits/issue-22384.rs diff --git a/tests/ui/issues/issue-22384.stderr b/tests/ui/traits/issue-22384.stderr index 1f767a443..1f767a443 100644 --- a/tests/ui/issues/issue-22384.stderr +++ b/tests/ui/traits/issue-22384.stderr diff --git a/tests/ui/traits/issue-38404.rs b/tests/ui/traits/issue-38404.rs index 1a92acc34..05921b2c3 100644 --- a/tests/ui/traits/issue-38404.rs +++ b/tests/ui/traits/issue-38404.rs @@ -2,5 +2,6 @@ trait A<T>: std::ops::Add<Self> + Sized {} trait B<T>: A<T> {} trait C<T>: A<dyn B<T, Output=usize>> {} //~^ ERROR the trait `B` cannot be made into an object +//~| ERROR the trait `B` cannot be made into an object fn main() {} diff --git a/tests/ui/traits/issue-38404.stderr b/tests/ui/traits/issue-38404.stderr index d7721d7e6..f8625f53b 100644 --- a/tests/ui/traits/issue-38404.stderr +++ b/tests/ui/traits/issue-38404.stderr @@ -12,6 +12,20 @@ LL | trait A<T>: std::ops::Add<Self> + Sized {} LL | trait B<T>: A<T> {} | - this trait cannot be made into an object... -error: aborting due to previous error +error[E0038]: the trait `B` cannot be made into an object + --> $DIR/issue-38404.rs:3:15 + | +LL | trait C<T>: A<dyn B<T, Output=usize>> {} + | ^^^^^^^^^^^^^^^^^^^^^^ `B` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/issue-38404.rs:1:13 + | +LL | trait A<T>: std::ops::Add<Self> + Sized {} + | ^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter +LL | trait B<T>: A<T> {} + | - this trait cannot be made into an object... + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr index 50d6fb054..d53276024 100644 --- a/tests/ui/traits/issue-38604.stderr +++ b/tests/ui/traits/issue-38604.stderr @@ -25,8 +25,7 @@ LL | trait Foo where u32: Q<Self> { | --- ^^^^^^^ ...because it uses `Self` as a type parameter | | | this trait cannot be made into an object... - = note: required for `Box<()>` to implement `CoerceUnsized<Box<dyn Foo>>` - = note: required by cast to type `Box<dyn Foo>` + = note: required for the cast from `Box<()>` to `Box<dyn Foo>` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/issue-7013.stderr b/tests/ui/traits/issue-7013.stderr index 4575f4dba..1c0e8bcf1 100644 --- a/tests/ui/traits/issue-7013.stderr +++ b/tests/ui/traits/issue-7013.stderr @@ -5,13 +5,14 @@ LL | let a = A {v: Box::new(B{v: None}) as Box<dyn Foo + Send>}; | ^^^^^^^^^^^^^^^^^^^^ `Rc<RefCell<A>>` cannot be sent between threads safely | = help: within `B`, the trait `Send` is not implemented for `Rc<RefCell<A>>` - = note: required because it appears within the type `Option<Rc<RefCell<A>>>` +note: required because it appears within the type `Option<Rc<RefCell<A>>>` + --> $SRC_DIR/core/src/option.rs:LL:COL note: required because it appears within the type `B` --> $DIR/issue-7013.rs:8:8 | LL | struct B { | ^ - = note: required for the cast from `B` to the object type `dyn Foo + Send` + = note: required for the cast from `Box<B>` to `Box<dyn Foo + Send>` error: aborting due to previous error diff --git a/tests/ui/traits/map-types.stderr b/tests/ui/traits/map-types.stderr index f685c50b0..4315056f2 100644 --- a/tests/ui/traits/map-types.stderr +++ b/tests/ui/traits/map-types.stderr @@ -5,7 +5,7 @@ LL | let y: Box<dyn Map<usize, isize>> = Box::new(x); | ^^^^^^^^^^^ the trait `Map<usize, isize>` is not implemented for `Box<dyn Map<isize, isize>>` | = help: the trait `Map<K, V>` is implemented for `HashMap<K, V>` - = note: required for the cast from `Box<dyn Map<isize, isize>>` to the object type `dyn Map<usize, isize>` + = note: required for the cast from `Box<Box<dyn Map<isize, isize>>>` to `Box<dyn Map<usize, isize>>` error: aborting due to previous error diff --git a/tests/ui/traits/negative-bounds/associated-constraints.rs b/tests/ui/traits/negative-bounds/associated-constraints.rs new file mode 100644 index 000000000..bc1a0ef17 --- /dev/null +++ b/tests/ui/traits/negative-bounds/associated-constraints.rs @@ -0,0 +1,20 @@ +#![feature(negative_bounds, associated_type_bounds)] +//~^ WARN the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes + +trait Trait { + type Assoc; +} + +fn test<T: !Trait<Assoc = i32>>() {} +//~^ ERROR associated type constraints not allowed on negative bounds + +fn test2<T>() where T: !Trait<Assoc = i32> {} +//~^ ERROR associated type constraints not allowed on negative bounds + +fn test3<T: !Trait<Assoc: Send>>() {} +//~^ ERROR associated type constraints not allowed on negative bounds + +fn test4<T>() where T: !Trait<Assoc: Send> {} +//~^ ERROR associated type constraints not allowed on negative bounds + +fn main() {} diff --git a/tests/ui/traits/negative-bounds/associated-constraints.stderr b/tests/ui/traits/negative-bounds/associated-constraints.stderr new file mode 100644 index 000000000..335ac7e5a --- /dev/null +++ b/tests/ui/traits/negative-bounds/associated-constraints.stderr @@ -0,0 +1,34 @@ +error: associated type constraints not allowed on negative bounds + --> $DIR/associated-constraints.rs:8:19 + | +LL | fn test<T: !Trait<Assoc = i32>>() {} + | ^^^^^^^^^^^ + +error: associated type constraints not allowed on negative bounds + --> $DIR/associated-constraints.rs:11:31 + | +LL | fn test2<T>() where T: !Trait<Assoc = i32> {} + | ^^^^^^^^^^^ + +error: associated type constraints not allowed on negative bounds + --> $DIR/associated-constraints.rs:14:20 + | +LL | fn test3<T: !Trait<Assoc: Send>>() {} + | ^^^^^^^^^^^ + +error: associated type constraints not allowed on negative bounds + --> $DIR/associated-constraints.rs:17:31 + | +LL | fn test4<T>() where T: !Trait<Assoc: Send> {} + | ^^^^^^^^^^^ + +warning: the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/associated-constraints.rs:1:12 + | +LL | #![feature(negative_bounds, associated_type_bounds)] + | ^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted + diff --git a/tests/ui/traits/negative-bounds/simple.rs b/tests/ui/traits/negative-bounds/simple.rs new file mode 100644 index 000000000..f6d1d5169 --- /dev/null +++ b/tests/ui/traits/negative-bounds/simple.rs @@ -0,0 +1,42 @@ +#![feature(negative_bounds, negative_impls)] +//~^ WARN the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes + +fn not_copy<T: !Copy>() {} + +fn neg_param_env<T: !Copy>() { + not_copy::<T>(); +} + +fn pos_param_env<T: Copy>() { + not_copy::<T>(); + //~^ ERROR the trait bound `T: !Copy` is not satisfied +} + +fn unknown<T>() { + not_copy::<T>(); + //~^ ERROR the trait bound `T: !Copy` is not satisfied +} + +struct NotCopyable; +impl !Copy for NotCopyable {} + +fn neg_impl() { + not_copy::<NotCopyable>(); +} + +#[derive(Copy, Clone)] +struct Copyable; + +fn pos_impl() { + not_copy::<Copyable>(); + //~^ ERROR the trait bound `Copyable: !Copy` is not satisfied +} + +struct NotNecessarilyCopyable; + +fn unknown_impl() { + not_copy::<NotNecessarilyCopyable>(); + //~^ ERROR the trait bound `NotNecessarilyCopyable: !Copy` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/negative-bounds/simple.stderr b/tests/ui/traits/negative-bounds/simple.stderr new file mode 100644 index 000000000..a3cab41a2 --- /dev/null +++ b/tests/ui/traits/negative-bounds/simple.stderr @@ -0,0 +1,70 @@ +warning: the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/simple.rs:1:12 + | +LL | #![feature(negative_bounds, negative_impls)] + | ^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the trait bound `T: !Copy` is not satisfied + --> $DIR/simple.rs:11:16 + | +LL | not_copy::<T>(); + | ^ the trait `!Copy` is not implemented for `T` + | +note: required by a bound in `not_copy` + --> $DIR/simple.rs:4:16 + | +LL | fn not_copy<T: !Copy>() {} + | ^^^^^ required by this bound in `not_copy` + +error[E0277]: the trait bound `T: !Copy` is not satisfied + --> $DIR/simple.rs:16:16 + | +LL | not_copy::<T>(); + | ^ the trait `!Copy` is not implemented for `T` + | +note: required by a bound in `not_copy` + --> $DIR/simple.rs:4:16 + | +LL | fn not_copy<T: !Copy>() {} + | ^^^^^ required by this bound in `not_copy` + +error[E0277]: the trait bound `Copyable: !Copy` is not satisfied + --> $DIR/simple.rs:31:16 + | +LL | not_copy::<Copyable>(); + | ^^^^^^^^ the trait `!Copy` is not implemented for `Copyable` + | + = help: the trait `Copy` is implemented for `Copyable` +note: required by a bound in `not_copy` + --> $DIR/simple.rs:4:16 + | +LL | fn not_copy<T: !Copy>() {} + | ^^^^^ required by this bound in `not_copy` +help: consider annotating `Copyable` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct Copyable; + | + +error[E0277]: the trait bound `NotNecessarilyCopyable: !Copy` is not satisfied + --> $DIR/simple.rs:38:16 + | +LL | not_copy::<NotNecessarilyCopyable>(); + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `!Copy` is not implemented for `NotNecessarilyCopyable` + | +note: required by a bound in `not_copy` + --> $DIR/simple.rs:4:16 + | +LL | fn not_copy<T: !Copy>() {} + | ^^^^^ required by this bound in `not_copy` +help: consider annotating `NotNecessarilyCopyable` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct NotNecessarilyCopyable; + | + +error: aborting due to 4 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/negative-bounds/supertrait.rs b/tests/ui/traits/negative-bounds/supertrait.rs new file mode 100644 index 000000000..df0884b8b --- /dev/null +++ b/tests/ui/traits/negative-bounds/supertrait.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(negative_bounds)] +//~^ WARN the feature `negative_bounds` is incomplete + +trait A: !B {} +trait B: !A {} + +fn main() {} diff --git a/tests/ui/traits/negative-bounds/supertrait.stderr b/tests/ui/traits/negative-bounds/supertrait.stderr new file mode 100644 index 000000000..f44753b62 --- /dev/null +++ b/tests/ui/traits/negative-bounds/supertrait.stderr @@ -0,0 +1,10 @@ +warning: the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/supertrait.rs:3:12 + | +LL | #![feature(negative_bounds)] + | ^^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index b680ce7f9..a53879657 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -67,7 +67,8 @@ LL | is_send(Box::new(TestType)); | = note: the trait bound `Unique<dummy2::TestType>: Send` is not satisfied = note: required for `Unique<dummy2::TestType>` to implement `Send` - = note: required because it appears within the type `Box<TestType>` +note: required because it appears within the type `Box<TestType>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` --> $DIR/negated-auto-traits-error.rs:16:15 | @@ -93,7 +94,8 @@ note: required because it appears within the type `Outer2<TestType>` LL | struct Outer2<T>(T); | ^^^^^^ = note: required for `Unique<Outer2<dummy3::TestType>>` to implement `Send` - = note: required because it appears within the type `Box<Outer2<TestType>>` +note: required because it appears within the type `Box<Outer2<TestType>>` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` --> $DIR/negated-auto-traits-error.rs:16:15 | diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/new-solver/alias-bound-unsound.rs new file mode 100644 index 000000000..00294c708 --- /dev/null +++ b/tests/ui/traits/new-solver/alias-bound-unsound.rs @@ -0,0 +1,27 @@ +// compile-flags: -Ztrait-solver=next + +// Makes sure that alias bounds are not unsound! + +#![feature(trivial_bounds)] + +trait Foo { + type Item: Copy + where + <Self as Foo>::Item: Copy; + + fn copy_me(x: &Self::Item) -> Self::Item { + *x + } +} + +impl Foo for () { + type Item = String where String: Copy; +} + +fn main() { + let x = String::from("hello, world"); + drop(<() as Foo>::copy_me(&x)); + //~^ ERROR `<() as Foo>::Item: Copy` is not satisfied + //~| ERROR `<() as Foo>::Item` is not well-formed + println!("{x}"); +} diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/new-solver/alias-bound-unsound.stderr new file mode 100644 index 000000000..9a43d2a66 --- /dev/null +++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr @@ -0,0 +1,24 @@ +error[E0277]: the trait bound `<() as Foo>::Item: Copy` is not satisfied + --> $DIR/alias-bound-unsound.rs:23:10 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `<() as Foo>::Item` + | +note: required by a bound in `Foo::Item` + --> $DIR/alias-bound-unsound.rs:10:30 + | +LL | type Item: Copy + | ---- required by a bound in this associated type +LL | where +LL | <Self as Foo>::Item: Copy; + | ^^^^ required by this bound in `Foo::Item` + +error: the type `<() as Foo>::Item` is not well-formed + --> $DIR/alias-bound-unsound.rs:23:10 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs index 531203d9c..3c7fc7403 100644 --- a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs +++ b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs @@ -1,5 +1,8 @@ // compile-flags: -Ztrait-solver=next +// check-pass +// (should not pass, should be turned into a coherence-only test) + // check that when computing `alias-eq(<() as Foo<u16, T>>::Assoc, <() as Foo<?0, T>>::Assoc)` // we do not infer `?0 = u8` via the `for<STOP> (): Foo<u8, STOP>` impl or `?0 = u16` by // relating substs as either could be a valid solution. @@ -36,7 +39,6 @@ where { // `<() as Foo<u16, STOP>>::Assoc == <() as Foo<_, STOP>>::Assoc` let _: <() as Foo<u16, T>>::Assoc = output::<_, T>(); - //~^ error: type annotations needed // let _: <() as Foo<u16, T>>::Assoc = output::<u8, T>(); // OK // let _: <() as Foo<u16, T>>::Assoc = output::<u16, T>(); // OK diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr deleted file mode 100644 index a6712332c..000000000 --- a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/alias_eq_dont_use_normalizes_to_if_substs_eq.rs:38:41 - | -LL | let _: <() as Foo<u16, T>>::Assoc = output::<_, T>(); - | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `output` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs index d4cc380fa..b036411be 100644 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs +++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs @@ -1,5 +1,8 @@ // compile-flags: -Ztrait-solver=next +// check-pass +// (should not pass, should be turned into a coherence-only test) + // check that a `alias-eq(<?0 as TraitB>::Assoc, <T as TraitB>::Assoc)` goal fails. // FIXME(deferred_projection_equality): add a test that this is true during coherence @@ -14,7 +17,6 @@ fn needs_a<T: TraitB>() -> T::Assoc { fn bar<T: TraitB>() { let _: <_ as TraitB>::Assoc = needs_a::<T>(); - //~^ error: type annotations needed } fn main() {} diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr deleted file mode 100644 index d063d8fce..000000000 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/alias_eq_substs_eq_not_intercrate.rs:16:12 - | -LL | let _: <_ as TraitB>::Assoc = needs_a::<T>(); - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `<_ as TraitB>::Assoc` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr index 6a926534e..4aefdd6bb 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr @@ -1,5 +1,5 @@ error[E0277]: `impl Future<Output = ()>` cannot be sent between threads safely - --> $DIR/auto-with-drop_tracking_mir.rs:24:13 + --> $DIR/auto-with-drop_tracking_mir.rs:25:13 | LL | is_send(foo()); | ------- ^^^^^ `impl Future<Output = ()>` cannot be sent between threads safely @@ -8,7 +8,7 @@ LL | is_send(foo()); | = help: the trait `Send` is not implemented for `impl Future<Output = ()>` note: required by a bound in `is_send` - --> $DIR/auto-with-drop_tracking_mir.rs:23:24 + --> $DIR/auto-with-drop_tracking_mir.rs:24:24 | LL | fn is_send(_: impl Send) {} | ^^^^ required by this bound in `is_send` diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs index a5db7c463..e311a4af2 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs @@ -14,6 +14,7 @@ async fn foo() { #[cfg(fail)] let x = &NotSync; bar().await; + #[allow(dropping_references)] drop(x); } diff --git a/tests/ui/traits/new-solver/borrowck-error.rs b/tests/ui/traits/new-solver/borrowck-error.rs new file mode 100644 index 000000000..4787a2c7e --- /dev/null +++ b/tests/ui/traits/new-solver/borrowck-error.rs @@ -0,0 +1,11 @@ +// compile-flags: -Ztrait-solver=next + +use std::collections::HashMap; + +fn foo() -> &'static HashMap<i32, i32> +{ + &HashMap::new() + //~^ ERROR cannot return reference to temporary value +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/borrowck-error.stderr b/tests/ui/traits/new-solver/borrowck-error.stderr new file mode 100644 index 000000000..a7d820174 --- /dev/null +++ b/tests/ui/traits/new-solver/borrowck-error.stderr @@ -0,0 +1,12 @@ +error[E0515]: cannot return reference to temporary value + --> $DIR/borrowck-error.rs:7:5 + | +LL | &HashMap::new() + | ^-------------- + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff --git a/tests/ui/traits/new-solver/exponential-trait-goals.rs b/tests/ui/traits/new-solver/exponential-trait-goals.rs new file mode 100644 index 000000000..b37f09ee1 --- /dev/null +++ b/tests/ui/traits/new-solver/exponential-trait-goals.rs @@ -0,0 +1,20 @@ +// compile-flags: -Ztrait-solver=next + +trait Trait {} + +struct W<T>(T); + +impl<T, U> Trait for W<(W<T>, W<U>)> +where + W<T>: Trait, + W<U>: Trait, +{ +} + +fn impls<T: Trait>() {} + +fn main() { + impls::<W<_>>(); + //~^ ERROR type annotations needed + //~| ERROR overflow evaluating the requirement `W<_>: Trait` +} diff --git a/tests/ui/traits/new-solver/exponential-trait-goals.stderr b/tests/ui/traits/new-solver/exponential-trait-goals.stderr new file mode 100644 index 000000000..28a99cbbc --- /dev/null +++ b/tests/ui/traits/new-solver/exponential-trait-goals.stderr @@ -0,0 +1,23 @@ +error[E0282]: type annotations needed + --> $DIR/exponential-trait-goals.rs:17:5 + | +LL | impls::<W<_>>(); + | ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` + +error[E0275]: overflow evaluating the requirement `W<_>: Trait` + --> $DIR/exponential-trait-goals.rs:17:5 + | +LL | impls::<W<_>>(); + | ^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`exponential_trait_goals`) +note: required by a bound in `impls` + --> $DIR/exponential-trait-goals.rs:14:13 + | +LL | fn impls<T: Trait>() {} + | ^^^^^ required by this bound in `impls` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0275, E0282. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/int-var-alias-eq.rs b/tests/ui/traits/new-solver/int-var-alias-eq.rs index 2da387db4..790197e2d 100644 --- a/tests/ui/traits/new-solver/int-var-alias-eq.rs +++ b/tests/ui/traits/new-solver/int-var-alias-eq.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags: -Ztrait-solver=next -// HIR typeck ends up equating `<_#0i as Add>::Output == _#0i`. +// HIR typeck ends up equating `<?0i as Add>::Output == ?0i`. // Want to make sure that we emit an alias-eq goal for this, // instead of treating it as a type error and bailing. diff --git a/tests/ui/traits/new-solver/negative-coherence-bounds.rs b/tests/ui/traits/new-solver/negative-coherence-bounds.rs new file mode 100644 index 000000000..5436b02c3 --- /dev/null +++ b/tests/ui/traits/new-solver/negative-coherence-bounds.rs @@ -0,0 +1,40 @@ +// check-pass + +// This test verifies that negative trait predicate cannot be satisfied from a +// positive param-env candidate. + +// Negative coherence is one of the only places where we actually construct and +// evaluate negative predicates. Specifically, when verifying whether the first +// and second impls below overlap, we do not want to consider them disjoint, +// otherwise the second impl would be missing an associated type `type Item` +// which is provided by the first impl that it is specializing. + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete +#![feature(with_negative_coherence)] + +trait BoxIter { + type Item; + + fn last(self) -> Option<Self::Item>; +} + +impl<I: Iterator + ?Sized> BoxIter for Box<I> { + type Item = I::Item; + + default fn last(self) -> Option<I::Item> { + todo!() + } +} + +// When checking that this impl does/doesn't overlap the one above, we evaluate +// a negative version of all of the where-clause predicates of the impl below. +// For `I: !Iterator`, we should make sure that the param-env clause `I: Iterator` +// from above doesn't satisfy this predicate. +impl<I: Iterator> BoxIter for Box<I> { + fn last(self) -> Option<I::Item> { + (*self).last() + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/negative-coherence-bounds.stderr b/tests/ui/traits/new-solver/negative-coherence-bounds.stderr new file mode 100644 index 000000000..4127f51f5 --- /dev/null +++ b/tests/ui/traits/new-solver/negative-coherence-bounds.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/negative-coherence-bounds.rs:12:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/new-solver/nested-alias-bound.rs b/tests/ui/traits/new-solver/nested-alias-bound.rs new file mode 100644 index 000000000..c365902db --- /dev/null +++ b/tests/ui/traits/new-solver/nested-alias-bound.rs @@ -0,0 +1,20 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait A { + type A: B; +} + +trait B { + type B: C; +} + +trait C {} + +fn needs_c<T: C>() {} + +fn test<T: A>() { + needs_c::<<T::A as B>::B>(); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-rcvr-for-inherent.rs b/tests/ui/traits/new-solver/normalize-rcvr-for-inherent.rs new file mode 100644 index 000000000..d70534feb --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-rcvr-for-inherent.rs @@ -0,0 +1,25 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// Verify that we can assemble inherent impl candidates on a possibly +// unnormalized self type. + +trait Foo { + type Assoc; +} +impl Foo for i32 { + type Assoc = Bar; +} + +struct Bar; +impl Bar { + fn method(&self) {} +} + +fn build<T: Foo>(_: T) -> T::Assoc { + todo!() +} + +fn main() { + build(1i32).method(); +} diff --git a/tests/ui/traits/new-solver/structural-resolve-field.rs b/tests/ui/traits/new-solver/structural-resolve-field.rs new file mode 100644 index 000000000..01899c9ad --- /dev/null +++ b/tests/ui/traits/new-solver/structural-resolve-field.rs @@ -0,0 +1,13 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#[derive(Default)] +struct Foo { + x: i32, +} + +fn main() { + let mut xs = <[Foo; 1]>::default(); + xs[0].x = 1; + (&mut xs[0]).x = 2; +} diff --git a/tests/ui/traits/new-solver/temporary-ambiguity.rs b/tests/ui/traits/new-solver/temporary-ambiguity.rs index 18ee05457..c6c11a1a1 100644 --- a/tests/ui/traits/new-solver/temporary-ambiguity.rs +++ b/tests/ui/traits/new-solver/temporary-ambiguity.rs @@ -18,5 +18,5 @@ fn main() { let w = Wrapper(x); needs_foo(w); x = 1; - drop(x); + let _ = x; } diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs index cde2059ca..3c7fc0d81 100644 --- a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs +++ b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs @@ -1,7 +1,7 @@ // compile-flags: -Ztrait-solver=next // When we're solving `<T as Foo>::Assoc = i32`, we actually first solve -// `<T as Foo>::Assoc = _#1t`, then unify `_#1t` with `i32`. That goal +// `<T as Foo>::Assoc = ?1t`, then unify `?1t` with `i32`. That goal // with the inference variable is ambiguous when there are >1 param-env // candidates. diff --git a/tests/ui/traits/non_lifetime_binders/drop-impl-pred.no.stderr b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.no.stderr new file mode 100644 index 000000000..a985b1a6e --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.no.stderr @@ -0,0 +1,24 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/drop-impl-pred.rs:6:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0367]: `Drop` impl requires `H: Foo` but the struct it is implemented for does not + --> $DIR/drop-impl-pred.rs:19:15 + | +LL | for<H> H: Foo, + | ^^^ + | +note: the implementor must specify the same requirement + --> $DIR/drop-impl-pred.rs:12:1 + | +LL | struct Bar<T>(T) where T: Foo; + | ^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0367`. diff --git a/tests/ui/traits/non_lifetime_binders/drop-impl-pred.rs b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.rs new file mode 100644 index 000000000..c65b5ea9b --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.rs @@ -0,0 +1,25 @@ +// revisions: no yes +//[yes] check-pass + +// Issue 110557 + +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +pub trait Foo {} + +#[cfg(no)] +struct Bar<T>(T) where T: Foo; + +#[cfg(yes)] +struct Bar<T>(T) where for<H> H: Foo; + +impl<T> Drop for Bar<T> +where + for<H> H: Foo, +//[no]~^ ERROR `Drop` impl requires `H: Foo` but the struct it is implemented for does not +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/drop-impl-pred.yes.stderr b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.yes.stderr new file mode 100644 index 000000000..165cf2ee1 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/drop-impl-pred.yes.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/drop-impl-pred.rs:6:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr index 47fa29b66..d56519223 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr +++ b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr @@ -20,8 +20,7 @@ LL | trait Foo: for<T> Bar<T> {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | | this trait cannot be made into an object... - = note: required for `&()` to implement `CoerceUnsized<&dyn Foo>` - = note: required by cast to type `&dyn Foo` + = note: required for the cast from `&()` to `&dyn Foo` error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/supertrait-object-safety.rs:19:12 diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.rs b/tests/ui/traits/non_lifetime_binders/universe-error1.rs new file mode 100644 index 000000000..eadee6b71 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/universe-error1.rs @@ -0,0 +1,18 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +trait Other<U: ?Sized> {} + +impl<U: ?Sized> Other<U> for U {} + +#[rustfmt::skip] +fn foo<U: ?Sized>() +where + for<T> T: Other<U> {} + +fn bar() { + foo::<_>(); + //~^ ERROR the trait bound `T: Other<_>` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.stderr b/tests/ui/traits/non_lifetime_binders/universe-error1.stderr new file mode 100644 index 000000000..bfcad72e3 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/universe-error1.stderr @@ -0,0 +1,27 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/universe-error1.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the trait bound `T: Other<_>` is not satisfied + --> $DIR/universe-error1.rs:14:11 + | +LL | foo::<_>(); + | ^ the trait `Other<_>` is not implemented for `T` + | +note: required by a bound in `foo` + --> $DIR/universe-error1.rs:11:15 + | +LL | fn foo<U: ?Sized>() + | --- required by a bound in this function +LL | where +LL | for<T> T: Other<U> {} + | ^^^^^^^^ required by this bound in `foo` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index dc18adeaf..a51b69759 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -11,8 +11,7 @@ LL | trait Tr { | -- this trait cannot be made into an object... LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter - = note: required for `&St` to implement `CoerceUnsized<&dyn Tr>` - = note: required by cast to type `&dyn Tr` + = note: required for the cast from `&St` to `&dyn Tr` help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self); diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 6c0e8b8af..74a0fc427 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -76,8 +76,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | this trait cannot be made into an object... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait - = note: required for `Box<{integer}>` to implement `CoerceUnsized<Box<dyn bar>>` - = note: required by cast to type `Box<dyn bar>` + = note: required for the cast from `Box<{integer}>` to `Box<dyn bar>` error: aborting due to 5 previous errors diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.stderr index fe269d8e9..82b4e9bd7 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.stderr @@ -15,7 +15,7 @@ error[E0277]: the trait bound `&dyn Foo: Bar<_>` is not satisfied LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^ the trait `Bar<_>` is not implemented for `&dyn Foo` | - = note: required for the cast from `&dyn Foo` to the object type `dyn Bar<_>` + = note: required for the cast from `&&dyn Foo` to `&dyn Bar<_>` error: aborting due to 2 previous errors 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 ef007d5cb..856303ef4 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr @@ -15,7 +15,7 @@ error[E0277]: the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied LL | let _ = x as &dyn Bar<u32>; // Error | ^ the trait `Bar<u32>` is not implemented for `&dyn Foo<i32>` | - = note: required for the cast from `&dyn Foo<i32>` to the object type `dyn Bar<u32>` + = note: required for the cast from `&&dyn Foo<i32>` to `&dyn Bar<u32>` error[E0605]: non-primitive cast: `&dyn Foo<u32>` as `&dyn Bar<_>` --> $DIR/type-checking-test-2.rs:25:13 @@ -34,7 +34,7 @@ error[E0277]: the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied LL | let a = x as &dyn Bar<_>; // Ambiguous | ^ the trait `Bar<_>` is not implemented for `&dyn Foo<u32>` | - = note: required for the cast from `&dyn Foo<u32>` to the object type `dyn Bar<_>` + = note: required for the cast from `&&dyn Foo<u32>` to `&dyn Bar<_>` error: aborting due to 4 previous errors diff --git a/tests/ui/traits/unsend-future.stderr b/tests/ui/traits/unsend-future.stderr index 4aaa7c4a9..6ce1cf452 100644 --- a/tests/ui/traits/unsend-future.stderr +++ b/tests/ui/traits/unsend-future.stderr @@ -6,12 +6,12 @@ LL | require_handler(handler) | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const i32` note: future is not `Send` as this value is used across an await - --> $DIR/unsend-future.rs:15:13 + --> $DIR/unsend-future.rs:15:14 | LL | let a = &1 as *const i32; | - has type `*const i32` which is not `Send` LL | async {}.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | } | - `a` is later dropped here note: required by a bound in `require_handler` diff --git a/tests/ui/transmutability/issue-110467.rs b/tests/ui/transmutability/issue-110467.rs new file mode 100644 index 000000000..358733b98 --- /dev/null +++ b/tests/ui/transmutability/issue-110467.rs @@ -0,0 +1,17 @@ +// check-pass +#![crate_type = "lib"] +#![feature(transmutability)] +use std::mem::BikeshedIntrinsicFrom; +pub struct Context; + +pub fn is_maybe_transmutable<Src, Dst>() +where + Dst: BikeshedIntrinsicFrom<Src, Context>, +{ +} + +// The `T` here should not have any effect on checking +// if transmutability is allowed or not. +fn function_with_generic<T>() { + is_maybe_transmutable::<(), ()>(); +} diff --git a/tests/ui/transmutability/references.current.stderr b/tests/ui/transmutability/references.current.stderr index ecb095354..819c9b92b 100644 --- a/tests/ui/transmutability/references.current.stderr +++ b/tests/ui/transmutability/references.current.stderr @@ -1,8 +1,8 @@ -error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context` +error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context` --> $DIR/references.rs:29:52 | LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout + | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout | note: required by a bound in `is_maybe_transmutable` --> $DIR/references.rs:16:14 diff --git a/tests/ui/transmutability/references.next.stderr b/tests/ui/transmutability/references.next.stderr index ecb095354..819c9b92b 100644 --- a/tests/ui/transmutability/references.next.stderr +++ b/tests/ui/transmutability/references.next.stderr @@ -1,8 +1,8 @@ -error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context` +error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context` --> $DIR/references.rs:29:52 | LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout + | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout | note: required by a bound in `is_maybe_transmutable` --> $DIR/references.rs:16:14 diff --git a/tests/ui/transmutability/region-infer.rs b/tests/ui/transmutability/region-infer.rs new file mode 100644 index 000000000..09f602776 --- /dev/null +++ b/tests/ui/transmutability/region-infer.rs @@ -0,0 +1,22 @@ +#![feature(transmutability)] + +use std::mem::{Assume, BikeshedIntrinsicFrom}; +pub struct Context; + +#[repr(C)] +struct W<'a>(&'a ()); + +fn test<'a>() +where + W<'a>: BikeshedIntrinsicFrom< + (), + Context, + { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, + >, +{ +} + +fn main() { + test(); + //~^ ERROR `()` cannot be safely transmuted into `W<'_>` +} diff --git a/tests/ui/transmutability/region-infer.stderr b/tests/ui/transmutability/region-infer.stderr new file mode 100644 index 000000000..d6b65e9e4 --- /dev/null +++ b/tests/ui/transmutability/region-infer.stderr @@ -0,0 +1,23 @@ +error[E0277]: `()` cannot be safely transmuted into `W<'_>` in the defining scope of `Context` + --> $DIR/region-infer.rs:20:5 + | +LL | test(); + | ^^^^ `W<'_>` does not have a well-specified layout + | +note: required by a bound in `test` + --> $DIR/region-infer.rs:11:12 + | +LL | fn test<'a>() + | ---- required by a bound in this function +LL | where +LL | W<'a>: BikeshedIntrinsicFrom< + | ____________^ +LL | | (), +LL | | Context, +LL | | { Assume { alignment: true, lifetimes: true, safety: true, validity: true } }, +LL | | >, + | |_________^ required by this bound in `test` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr index 39b60c311..c054ddb89 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr @@ -7,7 +7,7 @@ LL | *t help: consider changing this to be a mutable reference | LL | fn reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | ~~~~~~~~~~~~~~~~~~~ + | +++ error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 @@ -18,7 +18,7 @@ LL | {*t} help: consider changing this to be a mutable reference | LL | fn copy_reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | ~~~~~~~~~~~~~~~~~~~ + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs index 3416503b8..f98c3164d 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs @@ -1,6 +1,8 @@ // check-pass // Check tautalogically false `Copy` bounds + #![feature(trivial_bounds)] +#![allow(dropping_references, dropping_copy_types)] fn copy_string(t: String) -> String where String: Copy { //~ WARNING trivial_bounds is_copy(&t); diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr index 1e2662389..deeb352a2 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr @@ -1,5 +1,5 @@ warning: trait bound String: Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:5:51 + --> $DIR/trivial-bounds-inconsistent-copy.rs:7:51 | LL | fn copy_string(t: String) -> String where String: Copy { | ^^^^ @@ -7,19 +7,19 @@ LL | fn copy_string(t: String) -> String where String: Copy { = note: `#[warn(trivial_bounds)]` on by default warning: trait bound String: Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:12:56 + --> $DIR/trivial-bounds-inconsistent-copy.rs:14:56 | LL | fn copy_out_string(t: &String) -> String where String: Copy { | ^^^^ warning: trait bound String: Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:16:55 + --> $DIR/trivial-bounds-inconsistent-copy.rs:18:55 | LL | fn copy_string_with_param<T>(x: String) where String: Copy { | ^^^^ warning: trait bound for<'b> &'b mut i32: Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:22:76 + --> $DIR/trivial-bounds-inconsistent-copy.rs:24:76 | LL | fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy { | ^^^^ diff --git a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index 758ff31ff..e24cb1128 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -115,7 +115,7 @@ LL | Self::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - Self::SVariant::<()> { v: () }; LL + Enum::<()>::SVariant { v: () }; @@ -196,7 +196,7 @@ LL | Self::<()>::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - Self::<()>::SVariant::<()> { v: () }; LL + Enum::<()>::SVariant { v: () }; @@ -359,7 +359,7 @@ LL | Alias::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - Alias::SVariant::<()> { v: () }; LL + Alias::<()>::SVariant { v: () }; @@ -374,7 +374,7 @@ LL | Alias::<()>::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - Alias::<()>::SVariant::<()> { v: () }; LL + Alias::<()>::SVariant { v: () }; @@ -389,7 +389,7 @@ LL | AliasFixed::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - AliasFixed::SVariant::<()> { v: () }; LL + AliasFixed::<()>::SVariant { v: () }; @@ -432,7 +432,7 @@ LL | AliasFixed::<()>::SVariant::<()> { v: () }; | not allowed on this type | = note: enum variants can't have type parameters -help: you might have meant to specity type parameters on enum `Enum` +help: you might have meant to specify type parameters on enum `Enum` | LL - AliasFixed::<()>::SVariant::<()> { v: () }; LL + AliasFixed::<()>::SVariant { v: () }; diff --git a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr index 576fc6a4f..c943a4918 100644 --- a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr +++ b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr @@ -29,7 +29,7 @@ note: ...which requires borrow-checking `Alpha::V3::{constant#0}`... | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `Alpha::V3::{constant#0}`... +note: ...which requires promoting constants in MIR for `Alpha::V3::{constant#0}`... --> $DIR/self-in-enum-definition.rs:5:10 | LL | V3 = Self::V1 {} as u8 + 2, diff --git a/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs b/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs index 551815d02..58eaa9c2c 100644 --- a/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs @@ -5,15 +5,16 @@ trait Trait { type Opaque1; type Opaque2; - fn constrain(self); + fn constrain(self) -> (Self::Opaque1, Self::Opaque2); } impl<'a> Trait for &'a () { type Opaque1 = impl Sized; type Opaque2 = impl Sized + 'a; - fn constrain(self) { - let _: Self::Opaque1 = (); - let _: Self::Opaque2 = self; + fn constrain(self) -> (Self::Opaque1, Self::Opaque2) { + let a: Self::Opaque1 = (); + let b: Self::Opaque2 = self; + (a, b) } } diff --git a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs index 475f4724f..3ff20d99a 100644 --- a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs +++ b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs @@ -12,7 +12,7 @@ // Basic test mod test1 { - // Hidden type = Closure['_#0r] + // Hidden type = Closure['?0] type Opaque = impl Sized; fn define<'a: 'a>() -> Opaque { @@ -24,8 +24,8 @@ mod test1 { mod test2 { trait Trait {} - // Hidden type = Closure['a, '_#0r, '_#1r] - // Constraints = [('_#0r: 'a), ('a: '_#1r)] + // Hidden type = Closure['a, '?0, '?1] + // Constraints = [('?0: 'a), ('a: '?1)] type Opaque<'a> where &'a (): Trait, @@ -45,8 +45,8 @@ mod test2 { mod test3 { trait Trait {} - // Hidden type = Closure['a, 'b, '_#0r] - // Constraints = [('_#0r: 'a), ('_#0r: 'b)] + // Hidden type = Closure['a, 'b, '?0] + // Constraints = [('?0: 'a), ('?0: 'b)] type Opaque<'a, 'b> where (&'a (), &'b ()): Trait, diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs new file mode 100644 index 000000000..e5bfbfdae --- /dev/null +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +type Tait<'a> = impl Sized + 'a; + +fn foo<'a, 'b>() { + if false { + if { return } { + let y: Tait<'b> = 1i32; + //~^ ERROR concrete type differs from previous defining opaque type use + } + } + let x: Tait<'a> = (); +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr new file mode 100644 index 000000000..f2eb7bc4d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/different_defining_uses_never_type-2.rs:8:31 + | +LL | let y: Tait<'b> = 1i32; + | ^^^^ expected `()`, got `i32` + | +note: previous use here + --> $DIR/different_defining_uses_never_type-2.rs:12:23 + | +LL | let x: Tait<'a> = (); + | ^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs new file mode 100644 index 000000000..2b30a9cd5 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +type Tait<T> = impl Sized; + +fn foo<T, U>() { + if false { + if { return } { + let y: Tait<U> = 1i32; + //~^ ERROR concrete type differs from previous defining opaque type use + } + } + let x: Tait<T> = (); +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr new file mode 100644 index 000000000..8fc2e2284 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/different_defining_uses_never_type-3.rs:8:30 + | +LL | let y: Tait<U> = 1i32; + | ^^^^ expected `()`, got `i32` + | +note: previous use here + --> $DIR/different_defining_uses_never_type-3.rs:12:22 + | +LL | let x: Tait<T> = (); + | ^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.rs b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.rs new file mode 100644 index 000000000..93c52126d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.rs @@ -0,0 +1,16 @@ +#![feature(impl_trait_in_assoc_type)] + +trait Foo { + type Foo; + fn bar(); +} + +impl Foo for () { + type Foo = impl std::fmt::Debug; + fn bar() { + let x: Self::Foo = (); + //~^ ERROR: mismatched types + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr new file mode 100644 index 000000000..2beed73cb --- /dev/null +++ b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/invalid_impl_trait_in_assoc_ty.rs:11:28 + | +LL | type Foo = impl std::fmt::Debug; + | -------------------- the expected opaque type +LL | fn bar() { +LL | let x: Self::Foo = (); + | --------- ^^ expected opaque type, found `()` + | | + | expected due to this + | + = note: expected opaque type `<() as Foo>::Foo` + found unit type `()` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/invalid_impl_trait_in_assoc_ty.rs:10:5 + | +LL | fn bar() { + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/issue-65918.rs b/tests/ui/type-alias-impl-trait/issue-65918.rs index af6d50109..82cc823e4 100644 --- a/tests/ui/type-alias-impl-trait/issue-65918.rs +++ b/tests/ui/type-alias-impl-trait/issue-65918.rs @@ -1,5 +1,3 @@ -// ignore-test: This now ICEs again. - // build-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/issue-98604.stderr b/tests/ui/type-alias-impl-trait/issue-98604.stderr index fa16d3218..af758d809 100644 --- a/tests/ui/type-alias-impl-trait/issue-98604.stderr +++ b/tests/ui/type-alias-impl-trait/issue-98604.stderr @@ -4,7 +4,7 @@ error[E0271]: expected `test` to be a fn item that returns `Pin<Box<dyn Future<O LL | Box::new(test) as AsyncFnPtr; | ^^^^^^^^^^^^^^ expected `Pin<Box<dyn Future<Output = ()>>>`, found future | - = note: required for the cast from `fn() -> impl Future<Output = ()> {test}` to the object type `dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>>` + = note: required for the cast from `Box<fn() -> impl Future<Output = ()> {test}>` to `Box<(dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> + 'static)>` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/issue-98608.stderr b/tests/ui/type-alias-impl-trait/issue-98608.stderr index 506d40cb7..9b6510083 100644 --- a/tests/ui/type-alias-impl-trait/issue-98608.stderr +++ b/tests/ui/type-alias-impl-trait/issue-98608.stderr @@ -9,7 +9,7 @@ LL | let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi); | = note: expected struct `Box<u8>` found opaque type `impl Sized` - = note: required for the cast from `fn() -> impl Sized {hi}` to the object type `dyn Fn() -> Box<u8>` + = note: required for the cast from `Box<fn() -> impl Sized {hi}>` to `Box<dyn Fn() -> Box<u8>>` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs index da845e861..9ae2c34b9 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs @@ -8,6 +8,7 @@ type X<A, B> = impl Into<&'static A>; fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) { //~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied + //~| ERROR concrete type differs from previous defining opaque type use (a, a) } diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr index 66a6b0bbf..0d24d42ba 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr @@ -10,6 +10,15 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) where &'static B: From<&A> { | ++++++++++++++++++++++++++ -error: aborting due to previous error +error: concrete type differs from previous defining opaque type use + --> $DIR/multiple-def-uses-in-one-fn.rs:9:45 + | +LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) { + | ^^^^^^^^^^^^^^^^^^ + | | + | expected `&B`, got `&A` + | this expression supplies two conflicting concrete types for the same opaque type + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr new file mode 100644 index 000000000..9e96323ab --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr @@ -0,0 +1,25 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/wf-in-associated-type.rs:36:23 + | +LL | type Opaque = impl Sized + 'a; + | ^^^^^^^^^^^^^^^ ...so that the type `&'a T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for () { + | ++++ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/wf-in-associated-type.rs:36:23 + | +LL | type Opaque = impl Sized + 'a; + | ^^^^^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for () { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs new file mode 100644 index 000000000..31fbef9f7 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs @@ -0,0 +1,45 @@ +// WF check for impl Trait in associated type position. +// +// revisions: pass fail +// [pass] check-pass +// [fail] check-fail + +#![feature(impl_trait_in_assoc_type)] + +// The hidden type here (`&'a T`) requires proving `T: 'a`. +// We know it holds because of implied bounds from the impl header. +#[cfg(pass)] +mod pass { + trait Trait<Req> { + type Opaque1; + fn constrain_opaque1(req: Req) -> Self::Opaque1; + } + + impl<'a, T> Trait<&'a T> for () { + type Opaque1 = impl IntoIterator<Item = impl Sized + 'a>; + fn constrain_opaque1(req: &'a T) -> Self::Opaque1 { + [req] + } + } +} + +// The hidden type here (`&'a T`) requires proving `T: 'a`, +// but that is not known to hold in the impl. +#[cfg(fail)] +mod fail { + trait Trait<'a, T> { + type Opaque; + fn constrain_opaque(req: &'a T) -> Self::Opaque; + } + + impl<'a, T> Trait<'a, T> for () { + type Opaque = impl Sized + 'a; + //[fail]~^ ERROR the parameter type `T` may not live long enough + //[fail]~| ERROR the parameter type `T` may not live long enough + fn constrain_opaque(req: &'a T) -> Self::Opaque { + req + } + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr new file mode 100644 index 000000000..753a46e88 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr @@ -0,0 +1,19 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-nested.rs:55:27 + | +LL | type InnerOpaque<T> = impl Sized; + | ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/wf-nested.rs:12:20 + | +LL | struct IsStatic<T: 'static>(T); + | ^^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | type InnerOpaque<T: 'static> = impl Sized; + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr new file mode 100644 index 000000000..9ab6685a7 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr @@ -0,0 +1,14 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-nested.rs:46:17 + | +LL | let _ = outer.get(); + | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn test<T: 'static>() { + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/type-alias-impl-trait/wf-nested.rs b/tests/ui/type-alias-impl-trait/wf-nested.rs new file mode 100644 index 000000000..de3883294 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-nested.rs @@ -0,0 +1,60 @@ +// Well-formedness of nested opaque types, i.e. `impl Sized` in +// `type Outer = impl Trait<Assoc = impl Sized>`. +// See the comments below. +// +// revisions: pass pass_sound fail +// [pass] check-pass +// [pass_sound] check-fail +// [fail] check-fail + +#![feature(type_alias_impl_trait)] + +struct IsStatic<T: 'static>(T); + +trait Trait<In> { + type Out; + + fn get(&self) -> Result<Self::Out, ()> { + Err(()) + } +} + +impl<T> Trait<&'static T> for () { + type Out = IsStatic<T>; +} + +// The hidden type for `impl Sized` is `IsStatic<T>`, which requires `T: 'static`. +// We know it is well-formed because it can *only* be referenced as a projection: +// <OuterOpaque<T> as Trait<&'static T>>::Out`. +// So any instantiation of the type already requires proving `T: 'static`. +#[cfg(pass)] +mod pass { + use super::*; + type OuterOpaque<T> = impl Trait<&'static T, Out = impl Sized>; + fn define<T>() -> OuterOpaque<T> {} +} + +// Test the soundness of `pass` - We should require `T: 'static` at the use site. +#[cfg(pass_sound)] +mod pass_sound { + use super::*; + type OuterOpaque<T> = impl Trait<&'static T, Out = impl Sized>; + fn define<T>() -> OuterOpaque<T> {} + + fn test<T>() { + let outer = define::<T>(); + let _ = outer.get(); //[pass_sound]~ ERROR `T` may not live long enough + } +} + +// Similar to `pass` but here `impl Sized` can be referenced directly as +// InnerOpaque<T>, so we require an explicit bound `T: 'static`. +#[cfg(fail)] +mod fail { + use super::*; + type InnerOpaque<T> = impl Sized; //[fail]~ ERROR `T` may not live long enough + type OuterOpaque<T> = impl Trait<&'static T, Out = InnerOpaque<T>>; + fn define<T>() -> OuterOpaque<T> {} +} + +fn main() {} diff --git a/tests/ui/type/ascription/issue-34255-1.rs b/tests/ui/type/ascription/issue-34255-1.rs index 44b47cc4e..7436f8359 100644 --- a/tests/ui/type/ascription/issue-34255-1.rs +++ b/tests/ui/type/ascription/issue-34255-1.rs @@ -1,13 +1,12 @@ +// rustfix + struct Reactor { input_cells: Vec<usize>, } impl Reactor { - pub fn new() -> Self { + pub fn new() -> Self { //~ ERROR struct literal body without path input_cells: Vec::new() - //~^ ERROR cannot find value `input_cells` in this scope - //~| ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| ERROR missing generics for struct `Vec` } } diff --git a/tests/ui/type/ascription/issue-34255-1.stderr b/tests/ui/type/ascription/issue-34255-1.stderr index fafff19f8..254d36cb9 100644 --- a/tests/ui/type/ascription/issue-34255-1.stderr +++ b/tests/ui/type/ascription/issue-34255-1.stderr @@ -1,36 +1,18 @@ -error[E0425]: cannot find value `input_cells` in this scope - --> $DIR/issue-34255-1.rs:7:9 +error: struct literal body without path + --> $DIR/issue-34255-1.rs:8:26 | -LL | input_cells: Vec::new() - | ^^^^^^^^^^^ a field by this name exists in `Self` +LL | pub fn new() -> Self { + | __________________________^ +LL | | input_cells: Vec::new() +LL | | } + | |_____^ | -help: you might have meant to write a `struct` literal +help: you might have forgotten to add the struct literal inside the block | LL ~ pub fn new() -> Self { SomeStruct { LL | input_cells: Vec::new() - ... -LL | -LL ~ }} - | - -error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-34255-1.rs:7:27 - | -LL | input_cells: Vec::new() - | ^^^^^ only `Fn` traits may use parentheses - -error[E0107]: missing generics for struct `Vec` - --> $DIR/issue-34255-1.rs:7:22 - | -LL | input_cells: Vec::new() - | ^^^ expected at least 1 generic argument - | -help: add missing generic argument +LL ~ } } | -LL | input_cells: Vec<T>::new() - | +++ -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0107, E0214, E0425. -For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/type/ascription/issue-47666.fixed b/tests/ui/type/ascription/issue-47666.fixed index c4db74755..027c692f9 100644 --- a/tests/ui/type/ascription/issue-47666.fixed +++ b/tests/ui/type/ascription/issue-47666.fixed @@ -1,4 +1,4 @@ // run-rustfix fn main() { - let _ = Option::Some(vec![0, 1]); //~ ERROR expected type, found + let _ = Option::Some(vec![0, 1]); //~ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-47666.rs b/tests/ui/type/ascription/issue-47666.rs index c67202e21..e2f5d03ef 100644 --- a/tests/ui/type/ascription/issue-47666.rs +++ b/tests/ui/type/ascription/issue-47666.rs @@ -1,4 +1,4 @@ // run-rustfix fn main() { - let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found + let _ = Option:Some(vec![0, 1]); //~ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-47666.stderr b/tests/ui/type/ascription/issue-47666.stderr index 0f90fce3a..74d85a75c 100644 --- a/tests/ui/type/ascription/issue-47666.stderr +++ b/tests/ui/type/ascription/issue-47666.stderr @@ -1,16 +1,10 @@ -error: expected type, found `<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([0, 1]))` - --> $DIR/issue-47666.rs:3:25 +error: path separator must be a double colon + --> $DIR/issue-47666.rs:3:19 | LL | let _ = Option:Some(vec![0, 1]); - | - ^^^^^^^^^^ - | | | - | | expected type - | | in this macro invocation - | | this macro call doesn't expand to a type - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: this error originates in the macro `$crate::__rust_force_expr` which comes from the expansion of the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/type/ascription/issue-54516.fixed b/tests/ui/type/ascription/issue-54516.fixed index f78268894..48622663b 100644 --- a/tests/ui/type/ascription/issue-54516.fixed +++ b/tests/ui/type/ascription/issue-54516.fixed @@ -3,5 +3,5 @@ use std::collections::BTreeMap; fn main() { println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>()); - //~^ ERROR type ascription cannot be followed by a function call + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-54516.rs b/tests/ui/type/ascription/issue-54516.rs index 1f34e6943..9e71d2af1 100644 --- a/tests/ui/type/ascription/issue-54516.rs +++ b/tests/ui/type/ascription/issue-54516.rs @@ -3,5 +3,5 @@ use std::collections::BTreeMap; fn main() { println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); - //~^ ERROR type ascription cannot be followed by a function call + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-54516.stderr b/tests/ui/type/ascription/issue-54516.stderr index 1ab9093e5..a1371432f 100644 --- a/tests/ui/type/ascription/issue-54516.stderr +++ b/tests/ui/type/ascription/issue-54516.stderr @@ -1,12 +1,10 @@ -error: type ascription cannot be followed by a function call - --> $DIR/issue-54516.rs:5:20 +error: path separator must be a double colon + --> $DIR/issue-54516.rs:5:28 | LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); - | ^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/type/ascription/issue-60933.fixed b/tests/ui/type/ascription/issue-60933.fixed index 3e8be3875..016ad4a7e 100644 --- a/tests/ui/type/ascription/issue-60933.fixed +++ b/tests/ui/type/ascription/issue-60933.fixed @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _: usize = std::mem::size_of::<u32>(); - //~^ ERROR type ascription cannot be followed by a function call + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-60933.rs b/tests/ui/type/ascription/issue-60933.rs index 2a4ad7bdc..972bf2827 100644 --- a/tests/ui/type/ascription/issue-60933.rs +++ b/tests/ui/type/ascription/issue-60933.rs @@ -1,5 +1,5 @@ // run-rustfix fn main() { let _: usize = std::mem:size_of::<u32>(); - //~^ ERROR type ascription cannot be followed by a function call + //~^ ERROR path separator must be a double colon } diff --git a/tests/ui/type/ascription/issue-60933.stderr b/tests/ui/type/ascription/issue-60933.stderr index 0b7f8edf6..0ec527ff5 100644 --- a/tests/ui/type/ascription/issue-60933.stderr +++ b/tests/ui/type/ascription/issue-60933.stderr @@ -1,12 +1,10 @@ -error: type ascription cannot be followed by a function call - --> $DIR/issue-60933.rs:3:20 +error: path separator must be a double colon + --> $DIR/issue-60933.rs:3:28 | LL | let _: usize = std::mem:size_of::<u32>(); - | ^^^^^^^^-^^^^^^^^^^^^^^ - | | - | help: maybe write a path separator here: `::` + | ^ help: use a double colon instead: `::` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error diff --git a/tests/ui/type/issue-58355.stderr b/tests/ui/type/issue-58355.stderr index 6f89a7b00..67078bcfe 100644 --- a/tests/ui/type/issue-58355.stderr +++ b/tests/ui/type/issue-58355.stderr @@ -6,7 +6,7 @@ LL | x = Some(Box::new(callback)); | = help: within `fn() -> dyn ToString`, the trait `Sized` is not implemented for `dyn ToString` = note: required because it appears within the type `fn() -> dyn ToString` - = note: required for the cast from `fn() -> dyn ToString` to the object type `dyn Fn() -> (dyn ToString + 'static)` + = note: required for the cast from `Box<fn() -> dyn ToString>` to `Box<dyn Fn() -> (dyn ToString + 'static)>` error: aborting due to previous error diff --git a/tests/ui/type/missing-let-in-binding-2.fixed b/tests/ui/type/missing-let-in-binding-2.fixed new file mode 100644 index 000000000..d64013c8c --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-2.fixed @@ -0,0 +1,5 @@ +// run-rustfix + +fn main() { + let _v: Vec<i32> = vec![1, 2, 3]; //~ ERROR expected identifier, found `:` +} diff --git a/tests/ui/type/missing-let-in-binding-2.rs b/tests/ui/type/missing-let-in-binding-2.rs new file mode 100644 index 000000000..f95f7bef2 --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-2.rs @@ -0,0 +1,5 @@ +// run-rustfix + +fn main() { + _v: Vec<i32> = vec![1, 2, 3]; //~ ERROR expected identifier, found `:` +} diff --git a/tests/ui/type/missing-let-in-binding-2.stderr b/tests/ui/type/missing-let-in-binding-2.stderr new file mode 100644 index 000000000..2e1012594 --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-2.stderr @@ -0,0 +1,13 @@ +error: expected identifier, found `:` + --> $DIR/missing-let-in-binding-2.rs:4:7 + | +LL | _v: Vec<i32> = vec![1, 2, 3]; + | ^ expected identifier + | +help: you might have meant to introduce a new binding + | +LL | let _v: Vec<i32> = vec![1, 2, 3]; + | +++ + +error: aborting due to previous error + diff --git a/tests/ui/type/missing-let-in-binding-3.rs b/tests/ui/type/missing-let-in-binding-3.rs new file mode 100644 index 000000000..d56b13933 --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-3.rs @@ -0,0 +1,5 @@ +struct A { + : :u8, //~ ERROR expected identifier, found `:` +} + +fn main() {} diff --git a/tests/ui/type/missing-let-in-binding-3.stderr b/tests/ui/type/missing-let-in-binding-3.stderr new file mode 100644 index 000000000..ca828ce37 --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-3.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `:` + --> $DIR/missing-let-in-binding-3.rs:2:5 + | +LL | struct A { + | - while parsing this struct +LL | : :u8, + | ^ expected identifier + +error: aborting due to previous error + diff --git a/tests/ui/type/missing-let-in-binding-4.rs b/tests/ui/type/missing-let-in-binding-4.rs new file mode 100644 index 000000000..879a6fedc --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-4.rs @@ -0,0 +1,5 @@ +struct A { + : u8 =, //~ ERROR expected identifier, found `:` +} + +fn main() {} diff --git a/tests/ui/type/missing-let-in-binding-4.stderr b/tests/ui/type/missing-let-in-binding-4.stderr new file mode 100644 index 000000000..e6f173a66 --- /dev/null +++ b/tests/ui/type/missing-let-in-binding-4.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `:` + --> $DIR/missing-let-in-binding-4.rs:2:5 + | +LL | struct A { + | - while parsing this struct +LL | : u8 =, + | ^ expected identifier + +error: aborting due to previous error + diff --git a/tests/ui/type/missing-let-in-binding.fixed b/tests/ui/type/missing-let-in-binding.fixed index d17876889..4301fed23 100644 --- a/tests/ui/type/missing-let-in-binding.fixed +++ b/tests/ui/type/missing-let-in-binding.fixed @@ -1,5 +1,5 @@ // run-rustfix fn main() { let mut _foo: i32 = 1; - let _foo: i32 = 4; //~ ERROR type ascription is experimental + let _foo: i32 = 4; //~ ERROR expected identifier, found `:` } diff --git a/tests/ui/type/missing-let-in-binding.rs b/tests/ui/type/missing-let-in-binding.rs index ca42f2e6e..c0f91d98f 100644 --- a/tests/ui/type/missing-let-in-binding.rs +++ b/tests/ui/type/missing-let-in-binding.rs @@ -1,5 +1,5 @@ // run-rustfix fn main() { let mut _foo: i32 = 1; - _foo: i32 = 4; //~ ERROR type ascription is experimental + _foo: i32 = 4; //~ ERROR expected identifier, found `:` } diff --git a/tests/ui/type/missing-let-in-binding.stderr b/tests/ui/type/missing-let-in-binding.stderr index 12759c509..fc094e8cb 100644 --- a/tests/ui/type/missing-let-in-binding.stderr +++ b/tests/ui/type/missing-let-in-binding.stderr @@ -1,11 +1,10 @@ -error[E0658]: type ascription is experimental - --> $DIR/missing-let-in-binding.rs:4:5 +error: expected identifier, found `:` + --> $DIR/missing-let-in-binding.rs:4:9 | LL | _foo: i32 = 4; - | ^^^^^^^^^ + | ^ expected identifier | - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information - = help: add `#![feature(type_ascription)]` to the crate attributes to enable + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> help: you might have meant to introduce a new binding | LL | let _foo: i32 = 4; @@ -13,4 +12,3 @@ LL | let _foo: i32 = 4; error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/type/type-ascription-instead-of-statement-end.rs b/tests/ui/type/type-ascription-instead-of-statement-end.rs index 1d5565ab5..e30e57138 100644 --- a/tests/ui/type/type-ascription-instead-of-statement-end.rs +++ b/tests/ui/type/type-ascription-instead-of-statement-end.rs @@ -1,10 +1,8 @@ -#![feature(type_ascription)] - fn main() { - println!("test"): - 0; //~ ERROR expected type, found `0` + println!("test"): //~ ERROR statements are terminated with a semicolon + 0; } fn foo() { - println!("test"): 0; //~ ERROR expected type, found `0` + println!("test"): 0; //~ ERROR expected one of } diff --git a/tests/ui/type/type-ascription-instead-of-statement-end.stderr b/tests/ui/type/type-ascription-instead-of-statement-end.stderr index 521ebcdf1..8c09e78bc 100644 --- a/tests/ui/type/type-ascription-instead-of-statement-end.stderr +++ b/tests/ui/type/type-ascription-instead-of-statement-end.stderr @@ -1,24 +1,16 @@ -error: expected type, found `0` - --> $DIR/type-ascription-instead-of-statement-end.rs:5:5 +error: statements are terminated with a semicolon + --> $DIR/type-ascription-instead-of-statement-end.rs:2:21 | LL | println!("test"): - | - help: try using a semicolon: `;` -LL | 0; - | ^ expected type + | ^ help: use a semicolon instead: `;` | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> -error: expected type, found `0` - --> $DIR/type-ascription-instead-of-statement-end.rs:9:23 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/type-ascription-instead-of-statement-end.rs:7:21 | LL | println!("test"): 0; - | - ^ expected type - | | - | tried to parse a type due to this type ascription - | - = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` - = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + | ^ expected one of `.`, `;`, `?`, `}`, or an operator error: aborting due to 2 previous errors diff --git a/tests/ui/type/type-ascription-precedence.rs b/tests/ui/type/type-ascription-precedence.rs index d3aef929b..1527bb7aa 100644 --- a/tests/ui/type/type-ascription-precedence.rs +++ b/tests/ui/type/type-ascription-precedence.rs @@ -1,10 +1,8 @@ // Operator precedence of type ascription // Type ascription has very high precedence, the same as operator `as` - #![feature(type_ascription)] use std::ops::*; - struct S; struct Z; @@ -25,30 +23,34 @@ impl Deref for S { fn deref(&self) -> &Z { panic!() } } -fn main() { - &S: &S; // OK - (&S): &S; // OK - &(S: &S); //~ ERROR mismatched types +fn test1() { + &S: &S; //~ ERROR expected one of + (&S): &S; + &(S: &S); +} + +fn test2() { + *(S: Z); //~ ERROR expected identifier +} - *S: Z; // OK - (*S): Z; // OK - *(S: Z); //~ ERROR mismatched types - //~^ ERROR type `Z` cannot be dereferenced +fn test3() { + -(S: Z); //~ ERROR expected identifier +} - -S: Z; // OK - (-S): Z; // OK - -(S: Z); //~ ERROR mismatched types - //~^ ERROR cannot apply unary operator `-` to type `Z` +fn test4() { + (S + Z): Z; //~ ERROR expected one of +} - S + Z: Z; // OK - S + (Z: Z); // OK - (S + Z): Z; //~ ERROR mismatched types +fn test5() { + (S * Z): Z; //~ ERROR expected one of +} - S * Z: Z; // OK - S * (Z: Z); // OK - (S * Z): Z; //~ ERROR mismatched types +fn test6() { + S .. S: S; //~ ERROR expected identifier, found `:` +} - S .. S: S; // OK - S .. (S: S); // OK - (S .. S): S; //~ ERROR mismatched types +fn test7() { + (S .. S): S; //~ ERROR expected one of } + +fn main() {} diff --git a/tests/ui/type/type-ascription-precedence.stderr b/tests/ui/type/type-ascription-precedence.stderr index d6d1e1d7d..09cdc3703 100644 --- a/tests/ui/type/type-ascription-precedence.stderr +++ b/tests/ui/type/type-ascription-precedence.stderr @@ -1,63 +1,46 @@ -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:31:7 +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:` + --> $DIR/type-ascription-precedence.rs:27:7 | -LL | &(S: &S); - | ^ expected `&S`, found `S` +LL | &S: &S; + | ^ expected one of 8 possible tokens -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:35:7 +error: expected identifier, found `:` + --> $DIR/type-ascription-precedence.rs:33:8 | LL | *(S: Z); - | ^ expected `Z`, found `S` + | ^ expected identifier -error[E0614]: type `Z` cannot be dereferenced - --> $DIR/type-ascription-precedence.rs:35:5 - | -LL | *(S: Z); - | ^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:40:7 - | -LL | -(S: Z); - | ^ expected `Z`, found `S` - -error[E0600]: cannot apply unary operator `-` to type `Z` - --> $DIR/type-ascription-precedence.rs:40:5 +error: expected identifier, found `:` + --> $DIR/type-ascription-precedence.rs:37:8 | LL | -(S: Z); - | ^^^^^^^ cannot apply unary operator `-` - | -note: an implementation of `std::ops::Neg` might be missing for `Z` - --> $DIR/type-ascription-precedence.rs:9:1 - | -LL | struct Z; - | ^^^^^^^^ must implement `std::ops::Neg` -note: the trait `std::ops::Neg` must be implemented - --> $SRC_DIR/core/src/ops/arith.rs:LL:COL + | ^ expected identifier -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:45:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/type-ascription-precedence.rs:41:12 | LL | (S + Z): Z; - | ^^^^^^^ expected `Z`, found `S` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:49:5 +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/type-ascription-precedence.rs:45:12 | LL | (S * Z): Z; - | ^^^^^^^ expected `Z`, found `S` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator -error[E0308]: mismatched types - --> $DIR/type-ascription-precedence.rs:53:5 +error: expected identifier, found `:` + --> $DIR/type-ascription-precedence.rs:49:11 | -LL | (S .. S): S; - | ^^^^^^^^ expected `S`, found `Range<S>` +LL | S .. S: S; + | ^ expected identifier | - = note: expected struct `S` - found struct `std::ops::Range<S>` + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:` + --> $DIR/type-ascription-precedence.rs:53:13 + | +LL | (S .. S): S; + | ^ expected one of `.`, `;`, `?`, `}`, or an operator -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -Some errors have detailed explanations: E0308, E0600, E0614. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/type/type-ascription-with-fn-call.fixed b/tests/ui/type/type-ascription-with-fn-call.fixed index 6d96c4303..847f33099 100644 --- a/tests/ui/type/type-ascription-with-fn-call.fixed +++ b/tests/ui/type/type-ascription-with-fn-call.fixed @@ -1,9 +1,7 @@ // run-rustfix -#![feature(type_ascription)] - fn main() { - f() ; - f(); //~ ERROR expected type, found function + f() ; //~ ERROR statements are terminated with a semicolon + f(); } fn f() {} diff --git a/tests/ui/type/type-ascription-with-fn-call.rs b/tests/ui/type/type-ascription-with-fn-call.rs index ed4f7c904..1db48b0ad 100644 --- a/tests/ui/type/type-ascription-with-fn-call.rs +++ b/tests/ui/type/type-ascription-with-fn-call.rs @@ -1,9 +1,7 @@ // run-rustfix -#![feature(type_ascription)] - fn main() { - f() : - f(); //~ ERROR expected type, found function + f() : //~ ERROR statements are terminated with a semicolon + f(); } fn f() {} diff --git a/tests/ui/type/type-ascription-with-fn-call.stderr b/tests/ui/type/type-ascription-with-fn-call.stderr index d78fd08fd..e3afa497a 100644 --- a/tests/ui/type/type-ascription-with-fn-call.stderr +++ b/tests/ui/type/type-ascription-with-fn-call.stderr @@ -1,11 +1,10 @@ -error[E0573]: expected type, found function `f` - --> $DIR/type-ascription-with-fn-call.rs:6:5 +error: statements are terminated with a semicolon + --> $DIR/type-ascription-with-fn-call.rs:3:10 | LL | f() : - | - help: maybe you meant to write `;` here -LL | f(); - | ^^^ expecting a type here because of type ascription + | ^ help: use a semicolon instead: `;` + | + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> error: aborting due to previous error -For more information about this error, try `rustc --explain E0573`. diff --git a/tests/ui/type/type-dependent-def-issue-49241.rs b/tests/ui/type/type-dependent-def-issue-49241.rs index caf5bade5..4b6bc6124 100644 --- a/tests/ui/type/type-dependent-def-issue-49241.rs +++ b/tests/ui/type/type-dependent-def-issue-49241.rs @@ -2,5 +2,4 @@ fn main() { let v = vec![0]; const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant let s: [u32; l] = v.into_iter().collect(); - //~^ constant } diff --git a/tests/ui/type/type-dependent-def-issue-49241.stderr b/tests/ui/type/type-dependent-def-issue-49241.stderr index af16a6e8f..64c7687f7 100644 --- a/tests/ui/type/type-dependent-def-issue-49241.stderr +++ b/tests/ui/type/type-dependent-def-issue-49241.stderr @@ -6,12 +6,6 @@ LL | const l: usize = v.count(); | | | help: consider using `let` instead of `const`: `let l` -note: erroneous constant used - --> $DIR/type-dependent-def-issue-49241.rs:4:18 - | -LL | let s: [u32; l] = v.into_iter().collect(); - | ^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/type/type-mismatch.stderr b/tests/ui/type/type-mismatch.stderr index 67a1f8930..ce6f29d35 100644 --- a/tests/ui/type/type-mismatch.stderr +++ b/tests/ui/type/type-mismatch.stderr @@ -378,10 +378,8 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:47:23 | LL | want::<&Foo<foo>>(f); - | ----------------- ^ - | | | - | | expected `&Foo<foo>`, found `Foo<foo>` - | | help: consider borrowing here: `&f` + | ----------------- ^ expected `&Foo<foo>`, found `Foo<foo>` + | | | arguments to this function are incorrect | = note: expected reference `&Foo<foo>` @@ -391,6 +389,10 @@ note: function defined here | LL | fn want<T>(t: T) {} | ^^^^ ---- +help: consider borrowing here + | +LL | want::<&Foo<foo>>(&f); + | + error[E0308]: mismatched types --> $DIR/type-mismatch.rs:48:26 @@ -556,10 +558,8 @@ error[E0308]: mismatched types --> $DIR/type-mismatch.rs:61:26 | LL | want::<&Foo<foo, B>>(f); - | -------------------- ^ - | | | - | | expected `&Foo<foo, B>`, found `Foo<foo, B>` - | | help: consider borrowing here: `&f` + | -------------------- ^ expected `&Foo<foo, B>`, found `Foo<foo, B>` + | | | arguments to this function are incorrect | = note: expected reference `&Foo<foo, B>` @@ -569,6 +569,10 @@ note: function defined here | LL | fn want<T>(t: T) {} | ^^^^ ---- +help: consider borrowing here + | +LL | want::<&Foo<foo, B>>(&f); + | + error[E0308]: mismatched types --> $DIR/type-mismatch.rs:65:19 diff --git a/tests/ui/type/type-path-err-node-types.stderr b/tests/ui/type/type-path-err-node-types.stderr index 1aed1dbe4..8b12aa1a3 100644 --- a/tests/ui/type/type-path-err-node-types.stderr +++ b/tests/ui/type/type-path-err-node-types.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `NonExistent` - --> $DIR/type-path-err-node-types.rs:15:5 - | -LL | NonExistent::Assoc::<u8>; - | ^^^^^^^^^^^ use of undeclared type `NonExistent` - error[E0412]: cannot find type `Nonexistent` in this scope --> $DIR/type-path-err-node-types.rs:7:12 | @@ -22,6 +16,12 @@ error[E0425]: cannot find value `nonexistent` in this scope LL | nonexistent.nonexistent::<u8>(); | ^^^^^^^^^^^ not found in this scope +error[E0433]: failed to resolve: use of undeclared type `NonExistent` + --> $DIR/type-path-err-node-types.rs:15:5 + | +LL | NonExistent::Assoc::<u8>; + | ^^^^^^^^^^^ use of undeclared type `NonExistent` + error[E0282]: type annotations needed --> $DIR/type-path-err-node-types.rs:23:14 | diff --git a/tests/ui/type/type-unsatisfiable.usage.stderr b/tests/ui/type/type-unsatisfiable.usage.stderr index 56e2e30af..0b76ba8eb 100644 --- a/tests/ui/type/type-unsatisfiable.usage.stderr +++ b/tests/ui/type/type-unsatisfiable.usage.stderr @@ -1,8 +1,8 @@ -error[E0369]: cannot subtract `(dyn Vector2<ScalarType = i32> + 'static)` from `dyn Vector2<ScalarType = i32>` +error[E0369]: cannot subtract `dyn Vector2<ScalarType = i32>` from `dyn Vector2<ScalarType = i32>` --> $DIR/type-unsatisfiable.rs:57:20 | LL | let bar = *hey - *word; - | ---- ^ ----- (dyn Vector2<ScalarType = i32> + 'static) + | ---- ^ ----- dyn Vector2<ScalarType = i32> | | | dyn Vector2<ScalarType = i32> diff --git a/tests/ui/typeck/bad-index-due-to-nested.rs b/tests/ui/typeck/bad-index-due-to-nested.rs new file mode 100644 index 000000000..2564b5300 --- /dev/null +++ b/tests/ui/typeck/bad-index-due-to-nested.rs @@ -0,0 +1,27 @@ +use std::hash::Hash; +use std::marker::PhantomData; +use std::ops::Index; + +struct HashMap<K, V>(PhantomData<(K, V)>); + +impl<K, V> Index<&K> for HashMap<K, V> +where + K: Hash, + V: Copy, +{ + type Output = V; + + fn index(&self, k: &K) -> &V { + todo!() + } +} + +fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { + map[k] + //~^ ERROR the trait bound `K: Hash` is not satisfied + //~| ERROR the trait bound `V: Copy` is not satisfied + //~| ERROR mismatched types + //~| ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.stderr new file mode 100644 index 000000000..f9cdb280e --- /dev/null +++ b/tests/ui/typeck/bad-index-due-to-nested.stderr @@ -0,0 +1,72 @@ +error[E0277]: the trait bound `K: Hash` is not satisfied + --> $DIR/bad-index-due-to-nested.rs:20:5 + | +LL | map[k] + | ^^^ the trait `Hash` is not implemented for `K` + | +note: required for `HashMap<K, V>` to implement `Index<&K>` + --> $DIR/bad-index-due-to-nested.rs:7:12 + | +LL | impl<K, V> Index<&K> for HashMap<K, V> + | ^^^^^^^^^ ^^^^^^^^^^^^^ +LL | where +LL | K: Hash, + | ---- unsatisfied trait bound introduced here +help: consider restricting type parameter `K` + | +LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { + | +++++++++++++++++ + +error[E0277]: the trait bound `V: Copy` is not satisfied + --> $DIR/bad-index-due-to-nested.rs:20:5 + | +LL | map[k] + | ^^^ the trait `Copy` is not implemented for `V` + | +note: required for `HashMap<K, V>` to implement `Index<&K>` + --> $DIR/bad-index-due-to-nested.rs:7:12 + | +LL | impl<K, V> Index<&K> for HashMap<K, V> + | ^^^^^^^^^ ^^^^^^^^^^^^^ +... +LL | V: Copy, + | ---- unsatisfied trait bound introduced here +help: consider restricting type parameter `V` + | +LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V { + | +++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/bad-index-due-to-nested.rs:20:9 + | +LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { + | - this type parameter +LL | map[k] + | ^ expected `&K`, found type parameter `K` + | + = note: expected reference `&K` + found type parameter `K` +help: consider borrowing here + | +LL | map[&k] + | + + +error[E0308]: mismatched types + --> $DIR/bad-index-due-to-nested.rs:20:5 + | +LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { + | - this type parameter ----- expected `&'a V` because of return type +LL | map[k] + | ^^^^^^ expected `&V`, found type parameter `V` + | + = note: expected reference `&'a V` + found type parameter `V` +help: consider borrowing here + | +LL | &map[k] + | + + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/bad-recursive-type-sig-infer.rs b/tests/ui/typeck/bad-recursive-type-sig-infer.rs new file mode 100644 index 000000000..9812d8c38 --- /dev/null +++ b/tests/ui/typeck/bad-recursive-type-sig-infer.rs @@ -0,0 +1,11 @@ +fn a() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + &a +} + +fn b() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + &a +} + +fn main() {} diff --git a/tests/ui/typeck/bad-recursive-type-sig-infer.stderr b/tests/ui/typeck/bad-recursive-type-sig-infer.stderr new file mode 100644 index 000000000..e145da562 --- /dev/null +++ b/tests/ui/typeck/bad-recursive-type-sig-infer.stderr @@ -0,0 +1,15 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/bad-recursive-type-sig-infer.rs:1:11 + | +LL | fn a() -> _ { + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/bad-recursive-type-sig-infer.rs:6:11 + | +LL | fn b() -> _ { + | ^ not allowed in type signatures + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/typeck/bad-type-in-vec-contains.stderr b/tests/ui/typeck/bad-type-in-vec-contains.stderr index 72533ab1f..b9b3a5fe5 100644 --- a/tests/ui/typeck/bad-type-in-vec-contains.stderr +++ b/tests/ui/typeck/bad-type-in-vec-contains.stderr @@ -2,16 +2,18 @@ error[E0308]: mismatched types --> $DIR/bad-type-in-vec-contains.rs:5:21 | LL | primes.contains(3); - | -------- ^ - | | | - | | expected `&_`, found integer - | | help: consider borrowing here: `&3` + | -------- ^ expected `&_`, found integer + | | | arguments to this method are incorrect | = note: expected reference `&_` found type `{integer}` note: method defined here --> $SRC_DIR/core/src/slice/mod.rs:LL:COL +help: consider borrowing here + | +LL | primes.contains(&3); + | + error: aborting due to previous error diff --git a/tests/ui/typeck/derive-sugg-arg-arity.rs b/tests/ui/typeck/derive-sugg-arg-arity.rs new file mode 100644 index 000000000..094c93a85 --- /dev/null +++ b/tests/ui/typeck/derive-sugg-arg-arity.rs @@ -0,0 +1,8 @@ +pub struct A; + +fn main() { + match () { + _ => match A::partial_cmp() {}, + //~^ ERROR the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied + } +} diff --git a/tests/ui/typeck/derive-sugg-arg-arity.stderr b/tests/ui/typeck/derive-sugg-arg-arity.stderr new file mode 100644 index 000000000..5b4c48171 --- /dev/null +++ b/tests/ui/typeck/derive-sugg-arg-arity.stderr @@ -0,0 +1,31 @@ +error[E0599]: the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied + --> $DIR/derive-sugg-arg-arity.rs:5:23 + | +LL | pub struct A; + | ------------ + | | + | function or associated item `partial_cmp` not found for this struct + | doesn't satisfy `A: Iterator` + | doesn't satisfy `A: PartialOrd<_>` +... +LL | _ => match A::partial_cmp() {}, + | ^^^^^^^^^^^ function or associated item cannot be called on `A` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `A: PartialOrd<_>` + which is required by `&A: PartialOrd<&_>` + `A: PartialOrd<_>` + which is required by `&mut A: PartialOrd<&mut _>` + `A: Iterator` + which is required by `&mut A: Iterator` +note: the trait `Iterator` must be implemented + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` + | +LL + #[derive(PartialEq, PartialOrd)] +LL | pub struct A; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/typeck/issue-13853.stderr b/tests/ui/typeck/issue-13853.stderr index 11d34f5b9..8ecb8b680 100644 --- a/tests/ui/typeck/issue-13853.stderr +++ b/tests/ui/typeck/issue-13853.stderr @@ -20,10 +20,8 @@ error[E0308]: mismatched types --> $DIR/issue-13853.rs:37:13 | LL | iterate(graph); - | ------- ^^^^^ - | | | - | | expected `&_`, found `Vec<Stuff>` - | | help: consider borrowing here: `&graph` + | ------- ^^^^^ expected `&_`, found `Vec<Stuff>` + | | | arguments to this function are incorrect | = note: expected reference `&_` @@ -33,6 +31,10 @@ note: function defined here | LL | fn iterate<N: Node, G: Graph<N>>(graph: &G) { | ^^^^^^^ --------- +help: consider borrowing here + | +LL | iterate(&graph); + | + error: aborting due to 3 previous errors diff --git a/tests/ui/typeck/pin-unsound-issue-85099-derefmut.rs b/tests/ui/typeck/pin-unsound-issue-85099-derefmut.rs new file mode 100644 index 000000000..03602144e --- /dev/null +++ b/tests/ui/typeck/pin-unsound-issue-85099-derefmut.rs @@ -0,0 +1,68 @@ +// check-pass +// known-bug: #85099 + +// Should fail. Can coerce `Pin<T>` into `Pin<U>` where +// `T: Deref<Target: Unpin>` and `U: Deref<Target: !Unpin>`, using the +// `CoerceUnsized` impl on `Pin` and an unorthodox `DerefMut` impl for +// `Pin<&_>`. + +// This should not be allowed, since one can unpin `T::Target` (since it is +// `Unpin`) to gain unpinned access to the previously pinned `U::Target` (which +// is `!Unpin`) and then move it. + +use std::{ + cell::{RefCell, RefMut}, + future::Future, + ops::DerefMut, + pin::Pin, +}; + +struct SomeLocalStruct<'a, Fut>(&'a RefCell<Fut>); + +trait SomeTrait<'a, Fut> { + #[allow(clippy::mut_from_ref)] + fn deref_helper(&self) -> &mut (dyn SomeTrait<'a, Fut> + 'a) { + unimplemented!() + } + fn downcast(self: Pin<&mut Self>) -> Pin<&mut Fut> { + unimplemented!() + } +} + +impl<'a, Fut: Future<Output = ()>> SomeTrait<'a, Fut> for SomeLocalStruct<'a, Fut> { + fn deref_helper(&self) -> &mut (dyn SomeTrait<'a, Fut> + 'a) { + let x = Box::new(self.0.borrow_mut()); + let x: &'a mut RefMut<'a, Fut> = Box::leak(x); + &mut **x + } +} +impl<'a, Fut: Future<Output = ()>> SomeTrait<'a, Fut> for Fut { + fn downcast(self: Pin<&mut Self>) -> Pin<&mut Fut> { + self + } +} + +impl<'b, 'a, Fut> DerefMut for Pin<&'b dyn SomeTrait<'a, Fut>> { + fn deref_mut<'c>( + self: &'c mut Pin<&'b dyn SomeTrait<'a, Fut>>, + ) -> &'c mut (dyn SomeTrait<'a, Fut> + 'b) { + self.deref_helper() + } +} + +// obviously a "working" function with this signature is problematic +pub fn unsound_pin<Fut: Future<Output = ()>>( + fut: Fut, + callback: impl FnOnce(Pin<&mut Fut>), +) -> Fut { + let cell = RefCell::new(fut); + let s: &SomeLocalStruct<'_, Fut> = &SomeLocalStruct(&cell); + let p: Pin<Pin<&SomeLocalStruct<'_, Fut>>> = Pin::new(Pin::new(s)); + let mut p: Pin<Pin<&dyn SomeTrait<'_, Fut>>> = p; + let r: Pin<&mut dyn SomeTrait<'_, Fut>> = p.as_mut(); + let f: Pin<&mut Fut> = r.downcast(); + callback(f); + cell.into_inner() +} + +fn main() {} diff --git a/tests/ui/typeck/repeat-expr-checks-wf.rs b/tests/ui/typeck/repeat-expr-checks-wf.rs new file mode 100644 index 000000000..b8a2a0ceb --- /dev/null +++ b/tests/ui/typeck/repeat-expr-checks-wf.rs @@ -0,0 +1,10 @@ +trait Foo { + const ASSOC: [u8]; +} + +fn bar<T: Foo>() { + let a = [T::ASSOC; 2]; + //~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time +} + +fn main() {} diff --git a/tests/ui/typeck/repeat-expr-checks-wf.stderr b/tests/ui/typeck/repeat-expr-checks-wf.stderr new file mode 100644 index 000000000..a821088a4 --- /dev/null +++ b/tests/ui/typeck/repeat-expr-checks-wf.stderr @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/repeat-expr-checks-wf.rs:6:13 + | +LL | let a = [T::ASSOC; 2]; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: slice and array elements must have `Sized` type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/typeck-builtin-bound-type-parameters.rs b/tests/ui/typeck/typeck-builtin-bound-type-parameters.rs index 7ff9199f6..e7e62c077 100644 --- a/tests/ui/typeck/typeck-builtin-bound-type-parameters.rs +++ b/tests/ui/typeck/typeck-builtin-bound-type-parameters.rs @@ -3,6 +3,7 @@ fn foo1<T:Copy<U>, U>(x: T) {} trait Trait: Copy<dyn Send> {} //~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied +//~| ERROR trait takes 0 generic arguments but 1 generic argument was supplied struct MyStruct1<T: Copy<T>>; //~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied diff --git a/tests/ui/typeck/typeck-builtin-bound-type-parameters.stderr b/tests/ui/typeck/typeck-builtin-bound-type-parameters.stderr index a71fd9536..a3517af87 100644 --- a/tests/ui/typeck/typeck-builtin-bound-type-parameters.stderr +++ b/tests/ui/typeck/typeck-builtin-bound-type-parameters.stderr @@ -15,7 +15,15 @@ LL | trait Trait: Copy<dyn Send> {} | expected 0 generic arguments error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/typeck-builtin-bound-type-parameters.rs:7:21 + --> $DIR/typeck-builtin-bound-type-parameters.rs:4:14 + | +LL | trait Trait: Copy<dyn Send> {} + | ^^^^---------- help: remove these generics + | | + | expected 0 generic arguments + +error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/typeck-builtin-bound-type-parameters.rs:8:21 | LL | struct MyStruct1<T: Copy<T>>; | ^^^^--- help: remove these generics @@ -23,7 +31,7 @@ LL | struct MyStruct1<T: Copy<T>>; | expected 0 generic arguments error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/typeck-builtin-bound-type-parameters.rs:10:25 + --> $DIR/typeck-builtin-bound-type-parameters.rs:11:25 | LL | struct MyStruct2<'a, T: Copy<'a>>; | ^^^^---- help: remove these generics @@ -31,7 +39,7 @@ LL | struct MyStruct2<'a, T: Copy<'a>>; | expected 0 lifetime arguments error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/typeck-builtin-bound-type-parameters.rs:13:15 + --> $DIR/typeck-builtin-bound-type-parameters.rs:14:15 | LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} | ^^^^ -- help: remove this lifetime argument @@ -39,13 +47,13 @@ LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} | expected 0 lifetime arguments error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/typeck-builtin-bound-type-parameters.rs:13:15 + --> $DIR/typeck-builtin-bound-type-parameters.rs:14:15 | LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} | ^^^^ - help: remove this generic argument | | | expected 0 generic arguments -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index a450dbb82..46aed0f60 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -227,6 +227,4 @@ fn evens_squared(n: usize) -> _ { } const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); -//~^ ERROR the trait bound -//~| ERROR the trait bound -//~| ERROR the placeholder +//~^ ERROR the placeholder diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index bc6c9fd07..bc02547c6 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -437,37 +437,17 @@ LL | fn evens_squared(n: usize) -> _ { | not allowed in type signatures | help: replace with an appropriate return type: `impl Iterator<Item = usize>` -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/typeck_type_placeholder_item.rs:229:22 - | -LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^^^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/typeck_type_placeholder_item.rs:229:14 - | -LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^^^^^^^ - -error[E0277]: the trait bound `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>: Iterator` is not satisfied - --> $DIR/typeck_type_placeholder_item.rs:229:45 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/typeck_type_placeholder_item.rs:229:10 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^^^ `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>` is not an iterator + | ^ not allowed in type signatures | - = help: the trait `~const Iterator` is not implemented for `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>` -note: the trait `Iterator` is implemented for `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>`, but that implementation is not `const` +note: however, the inferred type `Map<Filter<Range<i32>, [closure@typeck_type_placeholder_item.rs:229:29]>, [closure@typeck_type_placeholder_item.rs:229:49]>` cannot be named --> $DIR/typeck_type_placeholder_item.rs:229:14 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:229:10 - | -LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^ not allowed in type signatures + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:140:31 @@ -677,7 +657,7 @@ LL | const D: _ = 42; | not allowed in type signatures | help: replace with the correct type: `i32` -error: aborting due to 73 previous errors +error: aborting due to 71 previous errors -Some errors have detailed explanations: E0121, E0277, E0282, E0403. +Some errors have detailed explanations: E0121, E0282, E0403. For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs index a6c86311b..e7f7fdc51 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -2,7 +2,7 @@ trait One<A> { fn foo(&self) -> A; } -fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One<()>` +fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One` {} fn main() { } diff --git a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr index 59e7bc8c8..e4772478b 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr @@ -1,4 +1,4 @@ -error[E0220]: associated type `Output` not found for `One<()>` +error[E0220]: associated type `Output` not found for `One` --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:16 | LL | fn foo(_: &dyn One()) diff --git a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr index 5d7fe3fa5..eb18b1219 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -12,7 +12,7 @@ note: trait defined here, with 3 generic parameters: `A`, `B`, `C` LL | trait Three<A,B,C> { fn dummy(&self) -> (A,B,C); } | ^^^^^ - - - -error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` +error[E0220]: associated type `Output` not found for `Three` --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 | LL | fn foo(_: &dyn Three()) diff --git a/tests/ui/underscore-imports/issue-110164.rs b/tests/ui/underscore-imports/issue-110164.rs new file mode 100644 index 000000000..6fd134145 --- /dev/null +++ b/tests/ui/underscore-imports/issue-110164.rs @@ -0,0 +1,19 @@ +use self::*; +//~^ ERROR unresolved import `self::*` +use crate::*; +//~^ ERROR unresolved import `crate::*` +use _::a; +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR unresolved import `_` +use _::*; +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR unresolved import `_` + +fn main() { + use _::a; + //~^ ERROR expected identifier, found reserved identifier `_` + //~| ERROR unresolved import `_` + use _::*; + //~^ ERROR expected identifier, found reserved identifier `_` + //~| ERROR unresolved import `_` +} diff --git a/tests/ui/underscore-imports/issue-110164.stderr b/tests/ui/underscore-imports/issue-110164.stderr new file mode 100644 index 000000000..5016c41e8 --- /dev/null +++ b/tests/ui/underscore-imports/issue-110164.stderr @@ -0,0 +1,71 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:5:5 + | +LL | use _::a; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:8:5 + | +LL | use _::*; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:13:9 + | +LL | use _::a; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:16:9 + | +LL | use _::*; + | ^ expected identifier, found reserved identifier + +error[E0432]: unresolved import `self::*` + --> $DIR/issue-110164.rs:1:5 + | +LL | use self::*; + | ^^^^^^^ cannot glob-import a module into itself + +error[E0432]: unresolved import `crate::*` + --> $DIR/issue-110164.rs:3:5 + | +LL | use crate::*; + | ^^^^^^^^ cannot glob-import a module into itself + +error[E0432]: unresolved import `_` + --> $DIR/issue-110164.rs:8:5 + | +LL | use _::*; + | ^ maybe a missing crate `_`? + | + = help: consider adding `extern crate _` to use the `_` crate + +error[E0432]: unresolved import `_` + --> $DIR/issue-110164.rs:5:5 + | +LL | use _::a; + | ^ maybe a missing crate `_`? + | + = help: consider adding `extern crate _` to use the `_` crate + +error[E0432]: unresolved import `_` + --> $DIR/issue-110164.rs:13:9 + | +LL | use _::a; + | ^ maybe a missing crate `_`? + | + = help: consider adding `extern crate _` to use the `_` crate + +error[E0432]: unresolved import `_` + --> $DIR/issue-110164.rs:16:9 + | +LL | use _::*; + | ^ maybe a missing crate `_`? + | + = help: consider adding `extern crate _` to use the `_` crate + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.rs b/tests/ui/uninhabited/uninhabited-irrefutable.rs index 4b001aca2..cfd60a8d9 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.rs +++ b/tests/ui/uninhabited/uninhabited-irrefutable.rs @@ -16,7 +16,9 @@ struct NotSoSecretlyEmpty { } enum Foo { + //~^ NOTE `Foo` defined here A(foo::SecretlyEmpty), + //~^ NOTE not covered B(foo::NotSoSecretlyEmpty), C(NotSoSecretlyEmpty), D(u32, u32), @@ -27,4 +29,9 @@ fn main() { let Foo::D(_y, _z) = x; //~^ ERROR refutable pattern in local binding //~| `Foo::A(_)` not covered + //~| NOTE `let` bindings require an "irrefutable pattern" + //~| NOTE for more information + //~| NOTE pattern `Foo::A(_)` is currently uninhabited + //~| NOTE the matched value is of type `Foo` + //~| HELP you might want to use `let else` } diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.stderr index 8cafea555..daf75f51b 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-irrefutable.rs:27:9 + --> $DIR/uninhabited-irrefutable.rs:29:9 | LL | let Foo::D(_y, _z) = x; | ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered @@ -11,8 +11,10 @@ note: `Foo` defined here | LL | enum Foo { | ^^^ +LL | LL | A(foo::SecretlyEmpty), | - not covered + = note: pattern `Foo::A(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future = note: the matched value is of type `Foo` help: you might want to use `let else` to handle the variant that isn't matched | diff --git a/tests/ui/union/union-sized-field.stderr b/tests/ui/union/union-sized-field.stderr index 771e8f261..bf1ff9c8b 100644 --- a/tests/ui/union/union-sized-field.stderr +++ b/tests/ui/union/union-sized-field.stderr @@ -6,7 +6,8 @@ LL | union Foo<T: ?Sized> { LL | value: ManuallyDrop<T>, | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `ManuallyDrop<T>` +note: required because it appears within the type `ManuallyDrop<T>` + --> $SRC_DIR/core/src/mem/manually_drop.rs:LL:COL = note: no field of a union may have a dynamically sized type = help: change the field's type to have a statically known size help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -31,7 +32,8 @@ LL | struct Foo2<T: ?Sized> { LL | value: ManuallyDrop<T>, | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `ManuallyDrop<T>` +note: required because it appears within the type `ManuallyDrop<T>` + --> $SRC_DIR/core/src/mem/manually_drop.rs:LL:COL = note: only the last field of a struct may have a dynamically sized type = help: change the field's type to have a statically known size help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -56,7 +58,8 @@ LL | enum Foo3<T: ?Sized> { LL | Value(ManuallyDrop<T>), | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: required because it appears within the type `ManuallyDrop<T>` +note: required because it appears within the type `ManuallyDrop<T>` + --> $SRC_DIR/core/src/mem/manually_drop.rs:LL:COL = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/unsized-locals/align.rs b/tests/ui/unsized-locals/align.rs new file mode 100644 index 000000000..01be8f3bb --- /dev/null +++ b/tests/ui/unsized-locals/align.rs @@ -0,0 +1,30 @@ +// Test that unsized locals uphold alignment requirements. +// Regression test for #71416. +// run-pass +#![feature(unsized_locals)] +#![allow(incomplete_features)] +use std::any::Any; + +#[repr(align(256))] +#[allow(dead_code)] +struct A { + v: u8 +} + +impl A { + fn f(&self) -> *const A { + assert_eq!(self as *const A as usize % 256, 0); + self + } +} + +fn mk() -> Box<dyn Any> { + Box::new(A { v: 4 }) +} + +fn main() { + let x = *mk(); + let dwncst = x.downcast_ref::<A>().unwrap(); + let addr = dwncst.f(); + assert_eq!(addr as usize % 256, 0); +} diff --git a/tests/ui/unsized-locals/issue-67981.rs b/tests/ui/unsized-locals/issue-67981.rs new file mode 100644 index 000000000..3eb6498e9 --- /dev/null +++ b/tests/ui/unsized-locals/issue-67981.rs @@ -0,0 +1,9 @@ +#![feature(unsized_fn_params)] + +fn main() { + let f: fn([u8]) = |_| {}; + //~^ERROR the size for values of type `[u8]` cannot be known at compilation time + let slice: Box<[u8]> = Box::new([1; 8]); + + f(*slice); +} diff --git a/tests/ui/unsized-locals/issue-67981.stderr b/tests/ui/unsized-locals/issue-67981.stderr new file mode 100644 index 000000000..a4b179ae2 --- /dev/null +++ b/tests/ui/unsized-locals/issue-67981.stderr @@ -0,0 +1,15 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/issue-67981.rs:4:24 + | +LL | let f: fn([u8]) = |_| {}; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | let f: fn([u8]) = |&_| {}; + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/suggest-borrow.stderr b/tests/ui/unsized-locals/suggest-borrow.stderr index d456c16de..8741b35cd 100644 --- a/tests/ui/unsized-locals/suggest-borrow.stderr +++ b/tests/ui/unsized-locals/suggest-borrow.stderr @@ -16,11 +16,14 @@ error[E0308]: mismatched types --> $DIR/suggest-borrow.rs:3:20 | LL | let x: &[u8] = vec!(1, 2, 3)[..]; - | ----- ^^^^^^^^^^^^^^^^^ - | | | - | | expected `&[u8]`, found `[{integer}]` - | | help: consider borrowing here: `&vec!(1, 2, 3)[..]` + | ----- ^^^^^^^^^^^^^^^^^ expected `&[u8]`, found `[{integer}]` + | | | expected due to this + | +help: consider borrowing here + | +LL | let x: &[u8] = &vec!(1, 2, 3)[..]; + | + error[E0308]: mismatched types --> $DIR/suggest-borrow.rs:4:19 diff --git a/tests/ui/unsized/box-instead-of-dyn-fn.rs b/tests/ui/unsized/box-instead-of-dyn-fn.rs index 2fa741bc1..321c2ebf5 100644 --- a/tests/ui/unsized/box-instead-of-dyn-fn.rs +++ b/tests/ui/unsized/box-instead-of-dyn-fn.rs @@ -8,7 +8,6 @@ fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a { move || println!("{a}") } else { Box::new(move || println!("{}", b)) - //~^ ERROR `if` and `else` have incompatible types } } diff --git a/tests/ui/unsized/box-instead-of-dyn-fn.stderr b/tests/ui/unsized/box-instead-of-dyn-fn.stderr index bfb7c3957..6087f5c54 100644 --- a/tests/ui/unsized/box-instead-of-dyn-fn.stderr +++ b/tests/ui/unsized/box-instead-of-dyn-fn.stderr @@ -1,42 +1,21 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/box-instead-of-dyn-fn.rs:10:9 - | -LL | / if a % 2 == 0 { -LL | | move || println!("{a}") - | | ----------------------- - | | | - | | the expected closure - | | expected because of this -LL | | } else { -LL | | Box::new(move || println!("{}", b)) - | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found `Box<[closure@box-instead-of-dyn-fn.rs:10:18]>` -LL | | -LL | | } - | |_____- `if` and `else` have incompatible types - | - = note: expected closure `[closure@$DIR/box-instead-of-dyn-fn.rs:8:9: 8:16]` - found struct `Box<[closure@$DIR/box-instead-of-dyn-fn.rs:10:18: 10:25]>` - error[E0746]: return type cannot have an unboxed trait object --> $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 { | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> - = note: if all the returned values were of the same type you could use `impl Fn() + 'a` as the return type - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> - = note: you can create a new `enum` with a variant for each returned type -help: return a boxed trait object instead +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type + | +LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> impl Fn() + 'a { + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> Box<dyn Fn() + 'a> { - | ++++ + -help: ... and box this value +LL ~ fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> Box<dyn Fn() + 'a> { +LL | +LL | if a % 2 == 0 { +LL ~ Box::new(move || println!("{a}")) | -LL | Box::new(move || println!("{a}")) - | +++++++++ + -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0308, E0746. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0746`. diff --git a/tests/ui/unsized/issue-91801.stderr b/tests/ui/unsized/issue-91801.stderr index 8795aa168..da5c43224 100644 --- a/tests/ui/unsized/issue-91801.stderr +++ b/tests/ui/unsized/issue-91801.stderr @@ -4,11 +4,10 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> { | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` as the return type, as all return paths are of type `Box<[closure@$DIR/issue-91801.rs:10:21: 10:70]>`, which implements `Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` +help: box the return type, and wrap all of the returned values in `Box::new` | -LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a { - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Box<Validator<'a>> { + | ++++ + error: aborting due to previous error diff --git a/tests/ui/unsized/issue-91803.stderr b/tests/ui/unsized/issue-91803.stderr index 2dad9e892..a43b8d074 100644 --- a/tests/ui/unsized/issue-91803.stderr +++ b/tests/ui/unsized/issue-91803.stderr @@ -4,11 +4,14 @@ error[E0746]: return type cannot have an unboxed trait object LL | fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> { | ^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> -help: use `impl Foo<'a>` as the return type, as all return paths are of type `Box<_>`, which implements `Foo<'a>` +help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type | LL | fn or<'a>(first: &'static dyn Foo<'a>) -> impl Foo<'a> { - | ~~~~~~~~~~~~ + | ~~~~ +help: box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn or<'a>(first: &'static dyn Foo<'a>) -> Box<dyn Foo<'a>> { + | ++++ + error: aborting due to previous error diff --git a/tests/ui/unsized/unsized-fn-param.stderr b/tests/ui/unsized/unsized-fn-param.stderr index b47726054..0de3dbbb5 100644 --- a/tests/ui/unsized/unsized-fn-param.stderr +++ b/tests/ui/unsized/unsized-fn-param.stderr @@ -5,8 +5,8 @@ LL | foo11("bar", &"baz"); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn AsRef<Path>` -help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<Path>` + = note: required for the cast from `&'static str` to `&dyn AsRef<Path>` +help: consider borrowing the value, since `&&'static str` can be coerced into `&dyn AsRef<Path>` | LL | foo11(&"bar", &"baz"); | + @@ -18,8 +18,8 @@ LL | foo12(&"bar", "baz"); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn AsRef<Path>` -help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<Path>` + = note: required for the cast from `&'static str` to `&dyn AsRef<Path>` +help: consider borrowing the value, since `&&'static str` can be coerced into `&dyn AsRef<Path>` | LL | foo12(&"bar", &"baz"); | + @@ -31,8 +31,8 @@ LL | foo21("bar", &"baz"); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn AsRef<str>` -help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<str>` + = note: required for the cast from `&'static str` to `&dyn AsRef<str>` +help: consider borrowing the value, since `&&'static str` can be coerced into `&dyn AsRef<str>` | LL | foo21(&"bar", &"baz"); | + @@ -44,8 +44,8 @@ LL | foo22(&"bar", "baz"); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: required for the cast from `str` to the object type `dyn AsRef<str>` -help: consider borrowing the value, since `&str` can be coerced into `dyn AsRef<str>` + = note: required for the cast from `&'static str` to `&dyn AsRef<str>` +help: consider borrowing the value, since `&&'static str` can be coerced into `&dyn AsRef<str>` | LL | foo22(&"bar", &"baz"); | + diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs b/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs deleted file mode 100644 index 6ff5dbda2..000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Test that the "C-unwind" ABI is feature-gated, and *can* be used when the -// `c_unwind` feature gate is enabled. - -// check-pass - -#![feature(c_unwind)] - -extern "C-unwind" fn f() {} - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind.rs b/tests/ui/unwind-abis/feature-gate-c-unwind.rs deleted file mode 100644 index ba72f74f2..000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Test that the "C-unwind" ABI is feature-gated, and cannot be used when the -// `c_unwind` feature gate is not used. - -#![allow(ffi_unwind_calls)] -//~^ WARNING unknown lint: `ffi_unwind_calls` -//~| WARNING unknown lint: `ffi_unwind_calls` - -extern "C-unwind" fn f() {} -//~^ ERROR C-unwind ABI is experimental and subject to change [E0658] - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind.stderr b/tests/ui/unwind-abis/feature-gate-c-unwind.stderr deleted file mode 100644 index 214ddc45c..000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind.stderr +++ /dev/null @@ -1,33 +0,0 @@ -warning: unknown lint: `ffi_unwind_calls` - --> $DIR/feature-gate-c-unwind.rs:4:1 - | -LL | #![allow(ffi_unwind_calls)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `ffi_unwind_calls` lint is unstable - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - = note: `#[warn(unknown_lints)]` on by default - -error[E0658]: C-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-c-unwind.rs:8:8 - | -LL | extern "C-unwind" fn f() {} - | ^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -warning: unknown lint: `ffi_unwind_calls` - --> $DIR/feature-gate-c-unwind.rs:4:1 - | -LL | #![allow(ffi_unwind_calls)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `ffi_unwind_calls` lint is unstable - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to previous error; 2 warnings emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/feature-gate-c_unwind.rs b/tests/ui/unwind-abis/feature-gate-c_unwind.rs new file mode 100644 index 000000000..d73fe3e0b --- /dev/null +++ b/tests/ui/unwind-abis/feature-gate-c_unwind.rs @@ -0,0 +1,4 @@ +// ignore-test + +// After partial stabilisation, `c_unwind` only contains codegen behaviour changes +// and are tested in `src/test/codegen/unwind-abis` diff --git a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs b/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs deleted file mode 100644 index cfa8eb3ca..000000000 --- a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs +++ /dev/null @@ -1,30 +0,0 @@ -// gate-test-c_unwind -// needs-llvm-components: x86 -// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -#![no_core] -#![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } - -// Test that the "stdcall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. - -extern "stdcall-unwind" fn fu() {} //~ ERROR stdcall-unwind ABI is experimental - -trait T { - extern "stdcall-unwind" fn mu(); //~ ERROR stdcall-unwind ABI is experimental - extern "stdcall-unwind" fn dmu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -struct S; -impl T for S { - extern "stdcall-unwind" fn mu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -impl S { - extern "stdcall-unwind" fn imu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -type TAU = extern "stdcall-unwind" fn(); //~ ERROR stdcall-unwind ABI is experimental - -extern "stdcall-unwind" {} //~ ERROR stdcall-unwind ABI is experimental diff --git a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr b/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr deleted file mode 100644 index c2cce0e11..000000000 --- a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:12:8 - | -LL | extern "stdcall-unwind" fn fu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:15:12 - | -LL | extern "stdcall-unwind" fn mu(); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:16:12 - | -LL | extern "stdcall-unwind" fn dmu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:21:12 - | -LL | extern "stdcall-unwind" fn mu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:25:12 - | -LL | extern "stdcall-unwind" fn imu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:28:19 - | -LL | type TAU = extern "stdcall-unwind" fn(); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:30:8 - | -LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/feature-gate-system-unwind.rs b/tests/ui/unwind-abis/feature-gate-system-unwind.rs deleted file mode 100644 index 26c2de4e8..000000000 --- a/tests/ui/unwind-abis/feature-gate-system-unwind.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Test that the "system-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. - -extern "system-unwind" fn f() {} -//~^ ERROR system-unwind ABI is experimental and subject to change [E0658] - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-system-unwind.stderr b/tests/ui/unwind-abis/feature-gate-system-unwind.stderr deleted file mode 100644 index 878773364..000000000 --- a/tests/ui/unwind-abis/feature-gate-system-unwind.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: system-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-system-unwind.rs:4:8 - | -LL | extern "system-unwind" fn f() {} - | ^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs b/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs index 9a324f004..8f0007376 100644 --- a/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs +++ b/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs @@ -1,7 +1,6 @@ // build-pass // needs-unwind -#![feature(c_unwind)] #![warn(ffi_unwind_calls)] mod foo { diff --git a/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr b/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr index 937a2b3df..cf8a7782e 100644 --- a/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr +++ b/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr @@ -1,17 +1,17 @@ warning: call to foreign function with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:20:14 + --> $DIR/ffi-unwind-calls-lint.rs:19:14 | LL | unsafe { foo(); } | ^^^^^ call to foreign function with FFI-unwind ABI | note: the lint level is defined here - --> $DIR/ffi-unwind-calls-lint.rs:5:9 + --> $DIR/ffi-unwind-calls-lint.rs:4:9 | LL | #![warn(ffi_unwind_calls)] | ^^^^^^^^^^^^^^^^ warning: call to function pointer with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:24:5 + --> $DIR/ffi-unwind-calls-lint.rs:23:5 | LL | ptr(); | ^^^^^ call to function pointer with FFI-unwind ABI diff --git a/tests/ui/use/use-self-type.stderr b/tests/ui/use/use-self-type.stderr index e61539411..3da04a851 100644 --- a/tests/ui/use/use-self-type.stderr +++ b/tests/ui/use/use-self-type.stderr @@ -8,7 +8,7 @@ error[E0432]: unresolved import `Self` --> $DIR/use-self-type.rs:6:13 | LL | use Self::f; - | ^^^^ `Self` is only available in impls, traits, and type definitions + | ^^^^ `Self` cannot be used in imports error: aborting due to 2 previous errors diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index d65703ef5..c4fa850a4 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -5,13 +5,16 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] +#![allow(redundant_semicolons)] #![allow(unreachable_code)] #![allow(unused_braces, unused_must_use, unused_parens)] #![allow(uncommon_codepoints, confusable_idents)] +#![allow(unused_imports)] #![allow(unreachable_patterns)] #![recursion_limit = "256"] +extern crate core; use std::cell::Cell; use std::mem::swap; @@ -204,6 +207,30 @@ fn closure_matching() { assert!(matches!(x(..), |_| Some(4))); } +fn semisemisemisemisemi() { + ;;;;;;; ;;;;;;; ;;; ;;; ;; + ;; ;; ;;;; ;;;; ;; + ;;;;;;; ;;;;; ;; ;;;; ;; ;; + ;; ;; ;; ;; ;; ;; + ;;;;;;; ;;;;;;; ;; ;; ;; +} + +fn useful_syntax() { + use {{std::{{collections::{{HashMap}}}}}}; + use ::{{{{core}, {std}}}}; + use {{::{{core as core2}}}}; +} + +fn infcx() { + pub mod cx { + pub mod cx { + pub use super::cx; + pub struct Cx; + } + } + let _cx: cx::cx::Cx = cx::cx::cx::cx::cx::Cx; +} + pub fn main() { strange(); funny(); @@ -227,4 +254,7 @@ pub fn main() { function(); bathroom_stall(); closure_matching(); + semisemisemisemisemi(); + useful_syntax(); + infcx(); } diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr index 6cf4f33f9..40a25c7df 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr @@ -11,8 +11,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `Box<S>` to implement `CoerceUnsized<Box<dyn Trait>>` - = note: required by cast to type `Box<dyn Trait>` + = note: required for the cast from `Box<S>` to `Box<dyn Trait>` error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/wf-convert-unsafe-trait-obj-box.rs:17:15 @@ -27,8 +26,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `Box<S>` to implement `CoerceUnsized<Box<dyn Trait>>` - = note: required by cast to type `Box<(dyn Trait + 'static)>` + = note: required for the cast from `Box<S>` to `Box<(dyn Trait + 'static)>` error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/wf-convert-unsafe-trait-obj-box.rs:15:5 @@ -43,8 +41,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `Box<S>` to implement `CoerceUnsized<Box<dyn Trait>>` - = note: required by cast to type `Box<dyn Trait>` + = note: required for the cast from `Box<S>` to `Box<dyn Trait>` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr index c9bd4549a..e2c71df2f 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr @@ -11,8 +11,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&S` to implement `CoerceUnsized<&dyn Trait>` - = note: required by cast to type `&dyn Trait` + = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/wf-convert-unsafe-trait-obj.rs:17:17 @@ -27,8 +26,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&S` to implement `CoerceUnsized<&dyn Trait>` - = note: required by cast to type `&dyn Trait` + = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/wf-convert-unsafe-trait-obj.rs:15:5 @@ -43,8 +41,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&S` to implement `CoerceUnsized<&dyn Trait>` - = note: required by cast to type `&dyn Trait` + = note: required for the cast from `&S` to `&dyn Trait` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-in-fn-type-implicit.rs b/tests/ui/wf/wf-in-fn-type-implicit.rs new file mode 100644 index 000000000..c5ff92c88 --- /dev/null +++ b/tests/ui/wf/wf-in-fn-type-implicit.rs @@ -0,0 +1,37 @@ +// check-pass +// known-bug: #104005 + +// Should fail. Function type parameters with implicit type annotations are not +// checked for well-formedness, which allows incorrect borrowing. + +// In contrast, user annotations are always checked for well-formedness, and the +// commented code below is correctly rejected by the borrow checker. + +use std::fmt::Display; + +trait Displayable { + fn display(self) -> Box<dyn Display>; +} + +impl<T: Display> Displayable for (T, Option<&'static T>) { + fn display(self) -> Box<dyn Display> { + Box::new(self.0) + } +} + +fn extend_lt<T, U>(val: T) -> Box<dyn Display> +where + (T, Option<U>): Displayable, +{ + Displayable::display((val, None)) +} + +fn main() { + // *incorrectly* compiles + let val = extend_lt(&String::from("blah blah blah")); + println!("{}", val); + + // *correctly* fails to compile + // let val = extend_lt::<_, &_>(&String::from("blah blah blah")); + // println!("{}", val); +} diff --git a/tests/ui/wf/wf-in-where-clause-static.rs b/tests/ui/wf/wf-in-where-clause-static.rs new file mode 100644 index 000000000..86722afdf --- /dev/null +++ b/tests/ui/wf/wf-in-where-clause-static.rs @@ -0,0 +1,23 @@ +// check-pass +// known-bug: #98117 + +// Should fail. Functions are responsible for checking the well-formedness of +// their own where clauses, so this should fail and require an explicit bound +// `T: 'static`. + +use std::fmt::Display; + +trait Static: 'static {} +impl<T> Static for &'static T {} + +fn foo<S: Display>(x: S) -> Box<dyn Display> +where + &'static S: Static, +{ + Box::new(x) +} + +fn main() { + let s = foo(&String::from("blah blah blah")); + println!("{}", s); +} diff --git a/tests/ui/wf/wf-normalization-sized.rs b/tests/ui/wf/wf-normalization-sized.rs new file mode 100644 index 000000000..473fc79a8 --- /dev/null +++ b/tests/ui/wf/wf-normalization-sized.rs @@ -0,0 +1,19 @@ +// check-pass +// known-bug: #100041 + +// Should fail. Normalization can bypass well-formedness checking. +// `[[[[[[u8]]]]]]` is not a well-formed type since size of type `[u8]` cannot +// be known at compile time (since `Sized` is not implemented for `[u8]`). + +trait WellUnformed { + type RequestNormalize; +} + +impl<T: ?Sized> WellUnformed for T { + type RequestNormalize = (); +} + +const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); +const _: <Vec<str> as WellUnformed>::RequestNormalize = (); + +fn main() {} diff --git a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr index d2b416309..66504e440 100644 --- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr +++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr @@ -25,8 +25,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&S` to implement `CoerceUnsized<&dyn Trait>` - = note: required by cast to type `&dyn Trait` + = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/wf-unsafe-trait-obj-match.rs:25:25 @@ -45,8 +44,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... - = note: required for `&R` to implement `CoerceUnsized<&dyn Trait>` - = note: required by cast to type `&dyn Trait` + = note: required for the cast from `&R` to `&dyn Trait` error: aborting due to 3 previous errors |