diff options
Diffstat (limited to 'tests')
45 files changed, 934 insertions, 321 deletions
diff --git a/tests/assembly/simd-intrinsic-gather.rs b/tests/assembly/simd-intrinsic-gather.rs index 2cbb6cfbb50..d2b5a1507f0 100644 --- a/tests/assembly/simd-intrinsic-gather.rs +++ b/tests/assembly/simd-intrinsic-gather.rs @@ -38,6 +38,6 @@ pub unsafe extern "C" fn gather_f64x4(mask: m64x4, ptrs: pf64x4) -> f64x4 { // x86-avx512: vpsllq ymm0, ymm0, 63 // x86-avx512-NEXT: vpmovq2m k1, ymm0 // x86-avx512-NEXT: vpxor xmm0, xmm0, xmm0 - // x86-avx512-NEXT: vgatherqpd ymm0 {k1}, ymmword ptr [1*ymm1] + // x86-avx512-NEXT: vgatherqpd ymm0 {k1}, {{(ymmword)|(qword)}} ptr [1*ymm1] simd_gather(f64x4([0_f64, 0_f64, 0_f64, 0_f64]), ptrs, mask) } diff --git a/tests/assembly/simd-intrinsic-scatter.rs b/tests/assembly/simd-intrinsic-scatter.rs index 679972d9b86..f7e08e33faa 100644 --- a/tests/assembly/simd-intrinsic-scatter.rs +++ b/tests/assembly/simd-intrinsic-scatter.rs @@ -34,6 +34,6 @@ extern "rust-intrinsic" { pub unsafe extern "C" fn scatter_f64x4(values: f64x4, ptrs: pf64x4, mask: m64x4) { // x86-avx512: vpsllq ymm2, ymm2, 63 // x86-avx512-NEXT: vpmovq2m k1, ymm2 - // x86-avx512-NEXT: vscatterqpd ymmword ptr [1*ymm1] {k1}, ymm0 + // x86-avx512-NEXT: vscatterqpd {{(ymmword)|(qword)}} ptr [1*ymm1] {k1}, ymm0 simd_scatter(values, ptrs, mask) } diff --git a/tests/codegen-units/item-collection/drop-glue-eager.rs b/tests/codegen-units/item-collection/drop-glue-eager.rs new file mode 100644 index 00000000000..77470767ee1 --- /dev/null +++ b/tests/codegen-units/item-collection/drop-glue-eager.rs @@ -0,0 +1,43 @@ +// Ensure that we *eagerly* monomorphize drop instances for structs with lifetimes. + +//@ compile-flags:-Zprint-mono-items=eager +//@ compile-flags:--crate-type=lib + +//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) +struct StructWithDrop { + x: i32, +} + +impl Drop for StructWithDrop { + //~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +struct StructNoDrop { + x: i32, +} + +//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) +enum EnumWithDrop { + A(i32), +} + +impl Drop for EnumWithDrop { + //~ MONO_ITEM fn <EnumWithDrop as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +enum EnumNoDrop { + A(i32), +} + +// We should be able to monomorphize drops for struct with lifetimes. +impl<'a> Drop for StructWithDropAndLt<'a> { + //~ MONO_ITEM fn <StructWithDropAndLt<'_> as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDropAndLt<'_>> - shim(Some(StructWithDropAndLt<'_>)) +struct StructWithDropAndLt<'a> { + x: &'a i32, +} diff --git a/tests/codegen/abi-win64-zst.rs b/tests/codegen/abi-win64-zst.rs new file mode 100644 index 00000000000..dd361898144 --- /dev/null +++ b/tests/codegen/abi-win64-zst.rs @@ -0,0 +1,52 @@ +//@ compile-flags: -Z merge-functions=disabled + +//@ revisions: windows-gnu +//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu +//@[windows-gnu] needs-llvm-components: x86 + +//@ revisions: windows-msvc +//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc +//@[windows-msvc] needs-llvm-components: x86 + +// Also test what happens when using a Windows ABI on Linux. +//@ revisions: linux +//@[linux] compile-flags: --target x86_64-unknown-linux-gnu +//@[linux] needs-llvm-components: x86 + +#![feature(no_core, lang_items, rustc_attrs, abi_vectorcall)] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +// Make sure the argument is always passed when explicitly requesting a Windows ABI. +// Our goal here is to match clang: <https://clang.godbolt.org/z/Wr4jMWq3P>. + +// CHECK: define win64cc void @pass_zst_win64(ptr {{[^,]*}}) +#[no_mangle] +extern "win64" fn pass_zst_win64(_: ()) {} + +// CHECK: define x86_vectorcallcc void @pass_zst_vectorcall(ptr {{[^,]*}}) +#[no_mangle] +extern "vectorcall" fn pass_zst_vectorcall(_: ()) {} + +// windows-gnu: define void @pass_zst_fastcall(ptr {{[^,]*}}) +// windows-msvc: define void @pass_zst_fastcall(ptr {{[^,]*}}) +#[no_mangle] +#[cfg(windows)] // "fastcall" is not valid on 64bit Linux +extern "fastcall" fn pass_zst_fastcall(_: ()) {} + +// The sysv64 ABI ignores ZST. + +// CHECK: define x86_64_sysvcc void @pass_zst_sysv64() +#[no_mangle] +extern "sysv64" fn pass_zst_sysv64(_: ()) {} + +// For `extern "C"` functions, ZST are ignored on Linux put passed on Windows. + +// linux: define void @pass_zst_c() +// windows-msvc: define void @pass_zst_c(ptr {{[^,]*}}) +// windows-gnu: define void @pass_zst_c(ptr {{[^,]*}}) +#[no_mangle] +extern "C" fn pass_zst_c(_: ()) {} diff --git a/tests/debuginfo/closures.rs b/tests/debuginfo/closures.rs new file mode 100644 index 00000000000..f5220a49e29 --- /dev/null +++ b/tests/debuginfo/closures.rs @@ -0,0 +1,155 @@ +//@ only-cdb +//@ compile-flags:-g + +// === CDB TESTS =================================================================================== +// Generic functions cause ambigious breakpoints. +// cdb-command:dx @$debuggerRootNamespace.Debugger.Settings.EngineInitialization.ResolveAmbiguousBreakpoints = true; +// cdb-command:bp `closures.rs:57` +// cdb-command:g +// cdb-command:dx add_closure +// cdb-check:add_closure [Type: closures::main::closure_env$0] +// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +// cdb-command:dx increment +// cdb-check:increment [Type: closures::main::closure_env$1] +// cdb-check: [+0x[...]] _ref__count : 0x[...] : 2 [Type: int *] +// cdb-command:dx consume_closure +// cdb-check:consume_closure [Type: closures::main::closure_env$2] +// cdb-check: [+0x[...]] x : [...] [Type: alloc::string::String] +// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +// cdb-command:dx simple_closure +// cdb-checksimple_closure [Type: closures::main::closure_env$5] +// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +// cdb-command:g +// cdb-command:dx first_closure +// cdb-check:first_closure [Type: closures::main::closure_env$6] +// cdb-check: [+0x[...]] _ref__variable : 0x[...] : 1 [Type: int *] +// cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] +// cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] +// cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] +// cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] +// cdb-command:g +// cdb-command:dx many_param_closure +// cdb-check:many_param_closure [Type: closures::main::closure_env$7] +// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +// cdb-command:g +// cdb-command:dv +// cdb-command:dx generic_closure +// cdb-check:generic_closure [Type: closures::generic_func::closure_env$0<i32>] +// cdb-check: [+0x[...]] _ref__x : 0x[...] : 42 [Type: int *] +// cdb-command:g +// cdb-command:dx generic_closure +// cdb-check:generic_closure [Type: closures::generic_func::closure_env$0<ref$<str$> >] +// cdb-check: [+0x000] _ref__x : 0x[...] : "base_value" [Type: ref$<str$> *] +// cdb-command:g +// cdb-command:dx second_closure +// cdb-check:second_closure [Type: closures::main::closure_env$8] +// cdb-check: [+0x[...]] _ref__variable : 0x[...] : 2 [Type: int *] +// cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] +// cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] +// cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] +// cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] + +#[inline(never)] +fn generic_func<Tfunc: std::fmt::Debug>(x: Tfunc) { + let generic_closure = |a: i32| { + println!("{:?} {}", x, a); + }; + + _zzz(); // #break + + // rustc really wants to inline this closure, so we use black_box instead of calling it + std::hint::black_box(generic_closure); +} + +struct Struct { + a: isize, + b: f64, + c: usize, +} + +fn main() { + let base_value: i32 = 42; + let mut count: i32 = 0; + + let add_closure = |a: i32, b: i32| a + b + base_value; + + add_closure(40, 2); + + let mut increment = || { + count += 1; + }; + + increment(); // count: 1 + increment(); // count: 2 + + let x = String::from("hello"); + + // Define a closure that consumes the captured variable `x` + let consume_closure = move || { + drop(x); + base_value + 1 + }; + + consume_closure(); + + let paramless_closure = || 42_i32; + + let void_closure = |a: i32| { + println!("Closure with arg: {:?}", a); + }; + + let simple_closure = || { + let incremented_value = base_value + 1; + incremented_value + }; + + let result = /*42; */ add_closure(40, 2); + println!("Result: {:?}", result); + void_closure(result); + let result = simple_closure(); + println!("Result: {:?}", result); + + let mut variable: i32 = 1; + let constant: i32 = 2; + + let a_struct = Struct { a: -3, b: 4.5, c: 5 }; + + _zzz(); // #break + + let struct_ref = &a_struct; + let owned_value: Box<i32> = Box::new(6); + + { + let mut first_closure = || { + variable = constant + a_struct.a as i32 + struct_ref.a as i32 + *owned_value; + }; + + _zzz(); // #break + + first_closure(); + } + + let many_param_closure = + |a: i32, b: f64, c: usize, d: Struct| base_value + a + b as i32 + c as i32 + d.c as i32; + + _zzz(); // #break + + many_param_closure(1, 2.0, 3, Struct { a: 4, b: 5.0, c: 6 }); + + generic_func(42); + generic_func("base_value"); + + { + let mut second_closure = || { + variable = constant + a_struct.a as i32 + struct_ref.a as i32 + *owned_value; + }; + + _zzz(); // #break + + second_closure(); + } +} + +fn _zzz() { + () +} diff --git a/tests/debuginfo/coroutine-closure.rs b/tests/debuginfo/coroutine-closure.rs new file mode 100644 index 00000000000..ffb6ae68a2b --- /dev/null +++ b/tests/debuginfo/coroutine-closure.rs @@ -0,0 +1,29 @@ +#![feature(async_closure)] +//@ only-cdb +//@ compile-flags:-g --edition=2021 + +// === CDB TESTS ================================================================================== + +// cdb-command: g +// cdb-command: dx closure +// cdb-check:closure [Type: coroutine_closure::main::closure_env$0] +// cdb-check: [+0x[...]] y : "" [Type: alloc::string::String] +// cdb-check: [+0x[...]] x : "" [Type: alloc::string::String] +#![allow(unused)] +fn main() { + let x = String::new(); + let y = String::new(); + let closure = async move || { + drop(y); + println!("{x}"); + }; + + _zzz(); // #break + + std::hint::black_box(closure); +} + +#[inline(never)] +fn _zzz() { + () +} diff --git a/tests/debuginfo/fn_ptr.rs b/tests/debuginfo/fn_ptr.rs new file mode 100644 index 00000000000..b6eb0f11a25 --- /dev/null +++ b/tests/debuginfo/fn_ptr.rs @@ -0,0 +1,51 @@ +//@ only-cdb +//@ compile-flags:-g + +// === CDB TESTS ================================================================================== + +// cdb-command: g +// cdb-command: dx basic +// cdb-check: basic : [...] : a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$0,tuple$<i32,i32> >+0x0 [Type: int (__cdecl*)(int,int)] +// cdb-check: a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$0,tuple$<i32,i32> >+0x0 [Type: int __cdecl(int,int)] + +// cdb-command: dx paramless +// cdb-check: paramless : [...] : a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$1,tuple$<> >+0x0 [Type: int (__cdecl*)()] +// cdb-check: a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$1,tuple$<> >+0x0 [Type: int __cdecl()] + +// cdb-command: dx my_struct +// cdb-check: my_struct [Type: fn_ptr::MyStruct] +// cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$2,tuple$<ref$<fn_ptr::MyStruct> > >+0x0 [Type: int (__cdecl*)(fn_ptr::MyStruct *)] + +// cdb-command: dx non_rec_struct +// cdb-check: non_rec_struct [Type: fn_ptr::NonRecStruct] +// cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once<fn_ptr::main::closure_env$3,tuple$<i32> >+0x0 [Type: int (__cdecl*)(int)] + +type BasicFnPtr = fn(i32, i32) -> i32; + +pub type ParamlessFnPtr = fn() -> i32; + +type MyFnPtr = fn(b: &MyStruct) -> i32; + +type NonRecFnPtr = fn(i: i32) -> i32; + +struct MyStruct { + my_field: MyFnPtr, +} + +struct NonRecStruct { + my_field: NonRecFnPtr, +} + +fn main() { + let basic: BasicFnPtr = |a, b| a + b; + let paramless: ParamlessFnPtr = || 1; + let my_struct = MyStruct { my_field: |_| 1 }; + let non_rec_struct = NonRecStruct { my_field: |i| i }; + + _zzz(); // #break +} + +#[inline(never)] +fn _zzz() { + () +} diff --git a/tests/debuginfo/lexical-scope-in-if-let.rs b/tests/debuginfo/lexical-scope-in-if-let.rs index 6e5e9900abe..b2c7790eab2 100644 --- a/tests/debuginfo/lexical-scope-in-if-let.rs +++ b/tests/debuginfo/lexical-scope-in-if-let.rs @@ -47,30 +47,33 @@ // === CDB TESTS ================================================================================== +// Note: `/n` causes the the output to be sorted to avoid depending on the order in PDB which may +// be arbitrary. + // cdb-command: g -// cdb-command: dv +// cdb-command: dv /n // cdb-check:[...]a = 0n123 // cdb-command: g -// cdb-command: dv +// cdb-command: dv /n // cdb-check:[...]a = 0n123 // cdb-check:[...]x = 0n42 // cdb-command: g -// cdb-command: dv +// cdb-command: dv /n // cdb-check:[...]a = 0n123 -// cdb-check:[...]x = 0n42 // cdb-check:[...]b = 0n456 +// cdb-check:[...]x = 0n42 // cdb-check:[...]y = true // cdb-command: g -// cdb-command: dv -// cdb-check:[...]z = 0n10 -// cdb-check:[...]c = 0n789 +// cdb-command: dv /n // cdb-check:[...]a = 0n123 -// cdb-check:[...]x = 0n42 // cdb-check:[...]b = 0n456 +// cdb-check:[...]c = 0n789 +// cdb-check:[...]x = 0n42 // cdb-check:[...]y = true +// cdb-check:[...]z = 0n10 fn main() { let a = id(123); @@ -95,6 +98,8 @@ fn main() { } #[inline(never)] -fn id<T>(value: T) -> T { value } +fn id<T>(value: T) -> T { + value +} -fn zzz() { } +fn zzz() {} diff --git a/tests/debuginfo/step-into-match.rs b/tests/debuginfo/step-into-match.rs index f702b116b20..577e553c119 100644 --- a/tests/debuginfo/step-into-match.rs +++ b/tests/debuginfo/step-into-match.rs @@ -117,7 +117,7 @@ // gdb-check:[...]match (a, b) { // gdb-command: s -// gdb-check:[...](_, _) => 5 +// gdb-check:[...](_, _) => 5, // gdb-command: s // gdb-check:[...]} @@ -300,7 +300,7 @@ // cdb-check: [...]: match (a, b) { // cdb-command: t -// cdb-check: [...]: (_, _) => 5 +// cdb-check: [...]: (_, _) => 5, // cdb-command: t // cdb-check: [...]: } @@ -378,6 +378,6 @@ fn match_tuple(a: u8, b: i8) -> u32 { (29, _) => 2, (5, 12) => 3, (_, 9) => 4, - (_, _) => 5 + (_, _) => 5, } } diff --git a/tests/debuginfo/type-names.rs b/tests/debuginfo/type-names.rs index 4caaf3fc97f..4df6daf7b6e 100644 --- a/tests/debuginfo/type-names.rs +++ b/tests/debuginfo/type-names.rs @@ -5,7 +5,7 @@ //@ compile-flags:-g -// === GDB TESTS =================================================================================== +// === GDB TESTS ================================================================================== // gdb-command:run @@ -17,7 +17,7 @@ // gdb-check:type = type_names::GenericStruct<type_names::mod1::Struct2, type_names::mod1::mod2::Struct3> // gdb-command:whatis generic_struct2 -// gdb-check:type = type_names::GenericStruct<type_names::Struct1, extern "system" fn(isize) -> usize> +// gdb-check:type = type_names::GenericStruct<type_names::Struct1, extern "fastcall" fn(isize) -> usize> // gdb-command:whatis mod_struct // gdb-check:type = type_names::mod1::Struct2 @@ -169,81 +169,85 @@ // === CDB TESTS ================================================================================== +// Note: `/n` causes the wildcard matches to be sorted to avoid depending on order in PDB which +// can be arbitrary. + // cdb-command: g // STRUCTS // 0-sized structs appear to be optimized away in some cases, so only check the structs that do // actually appear. -// cdb-command:dv /t *_struct +// cdb-command:dv /t /n *_struct // ENUMS -// cdb-command:dv /t *_enum_* +// cdb-command:dv /t /n *_enum_* +// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > generic_enum_1 = [...] +// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > generic_enum_2 = [...] // cdb-check:union enum2$<type_names::Enum1> simple_enum_1 = [...] // cdb-check:union enum2$<type_names::Enum1> simple_enum_2 = [...] // cdb-check:union enum2$<type_names::mod1::Enum2> simple_enum_3 = [...] -// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > generic_enum_1 = [...] -// cdb-check:union enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > generic_enum_2 = [...] // TUPLES -// cdb-command:dv /t tuple* +// cdb-command:dv /t /n tuple* // cdb-check:struct tuple$<u32,type_names::Struct1,enum2$<type_names::mod1::mod2::Enum3<type_names::mod1::Struct2> > > tuple1 = [...] // cdb-check:struct tuple$<tuple$<type_names::Struct1,type_names::mod1::mod2::Struct3>,enum2$<type_names::mod1::Enum2>,char> tuple2 = [...] // BOX -// cdb-command:dv /t box* +// cdb-command:dv /t /n box* // cdb-check:struct tuple$<alloc::boxed::Box<f32,alloc::alloc::Global>,i32> box1 = [...] // cdb-check:struct tuple$<alloc::boxed::Box<enum2$<type_names::mod1::mod2::Enum3<f32> >,alloc::alloc::Global>,i32> box2 = [...] // REFERENCES -// cdb-command:dv /t *ref* -// cdb-check:struct tuple$<ref$<type_names::Struct1>,i32> ref1 = [...] -// cdb-check:struct tuple$<ref$<type_names::GenericStruct<char,type_names::Struct1> >,i32> ref2 = [...] +// cdb-command:dv /t /n *ref* // cdb-check:struct tuple$<ref_mut$<type_names::Struct1>,i32> mut_ref1 = [...] // cdb-check:struct tuple$<ref_mut$<type_names::GenericStruct<enum2$<type_names::mod1::Enum2>,f64> >,i32> mut_ref2 = [...] +// cdb-check:struct tuple$<ref$<type_names::Struct1>,i32> ref1 = [...] +// cdb-check:struct tuple$<ref$<type_names::GenericStruct<char,type_names::Struct1> >,i32> ref2 = [...] // RAW POINTERS -// cdb-command:dv /t *_ptr* -// cdb-check:struct tuple$<ptr_mut$<type_names::Struct1>,isize> mut_ptr1 = [...] -// cdb-check:struct tuple$<ptr_mut$<isize>,isize> mut_ptr2 = [...] -// cdb-check:struct tuple$<ptr_mut$<enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> mut_ptr3 = [...] +// cdb-command:dv /t /n *_ptr* // cdb-check:struct tuple$<ptr_const$<type_names::Struct1>,isize> const_ptr1 = [...] // cdb-check:struct tuple$<ptr_const$<isize>,isize> const_ptr2 = [...] // cdb-check:struct tuple$<ptr_const$<enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> const_ptr3 = [...] +// cdb-check:struct tuple$<ptr_mut$<type_names::Struct1>,isize> mut_ptr1 = [...] +// cdb-check:struct tuple$<ptr_mut$<isize>,isize> mut_ptr2 = [...] +// cdb-check:struct tuple$<ptr_mut$<enum2$<type_names::mod1::mod2::Enum3<type_names::Struct1> > >,isize> mut_ptr3 = [...] // VECTORS -// cdb-command:dv /t *vec* +// cdb-command:dv /t /n *vec* // cdb-check:struct tuple$<array$<type_names::Struct1,3>,i16> fixed_size_vec1 = [...] // cdb-check:struct tuple$<array$<usize,3>,i16> fixed_size_vec2 = [...] // cdb-check:struct alloc::vec::Vec<usize,alloc::alloc::Global> vec1 = [...] // cdb-check:struct alloc::vec::Vec<enum2$<type_names::mod1::Enum2>,alloc::alloc::Global> vec2 = [...] -// cdb-command:dv /t slice* +// cdb-command:dv /t /n slice* // cdb-check:struct ref$<slice2$<usize> > slice1 = [...] // cdb-check:struct ref_mut$<slice2$<enum2$<type_names::mod1::Enum2> > > slice2 = [...] // TRAITS -// cdb-command:dv /t *_trait +// cdb-command:dv /t /n *_trait + +// cdb-check:struct alloc::boxed::Box<dyn$<type_names::Trait1>,alloc::alloc::Global> box_trait = [...] +// cdb-check:struct alloc::boxed::Box<dyn$<type_names::Trait2<i32,type_names::mod1::Struct2> >,alloc::alloc::Global> generic_box_trait = [...] // cdb-check:struct ref_mut$<dyn$<type_names::Trait2<type_names::mod1::mod2::Struct3,type_names::GenericStruct<usize,isize> > > > generic_mut_ref_trait = [...] // cdb-check:struct ref$<dyn$<type_names::Trait2<type_names::Struct1,type_names::Struct1> > > generic_ref_trait = [...] -// cdb-check:struct alloc::boxed::Box<dyn$<type_names::Trait2<i32,type_names::mod1::Struct2> >,alloc::alloc::Global> generic_box_trait = [...] -// cdb-check:struct alloc::boxed::Box<dyn$<type_names::Trait1>,alloc::alloc::Global> box_trait = [...] -// cdb-check:struct ref$<dyn$<type_names::Trait1> > ref_trait = [...] +// cdb-check:struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > > has_associated_type_but_no_generics_trait = struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > > +// cdb-check:struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> > has_associated_type_trait = struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> > // cdb-check:struct ref_mut$<dyn$<type_names::Trait1> > mut_ref_trait = [...] // cdb-check:struct alloc::boxed::Box<dyn$<core::marker::Send,core::marker::Sync>,alloc::alloc::Global> no_principal_trait = [...] -// cdb-check:struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> > has_associated_type_trait = struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> > -// cdb-check:struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > > has_associated_type_but_no_generics_trait = struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > > +// cdb-check:struct ref$<dyn$<type_names::Trait1> > ref_trait = [...] // BARE FUNCTIONS -// cdb-command:dv /t *_fn* -// cdb-check:struct tuple$<type_names::mod1::Struct2 (*)(type_names::GenericStruct<u16,u8>),usize> unsafe_fn_with_return_value = [...] +// cdb-command:dv /t /n *_fn* +// cdb-check:struct tuple$<void (*)(isize),usize> extern_c_fn = [...] // cdb-check:struct tuple$<type_names::Struct1 (*)(),usize> extern_c_fn_with_return_value = [...] +// cdb-check:struct tuple$<void (*)(enum2$<core::option::Option<isize> >,enum2$<core::option::Option<ref$<type_names::mod1::Struct2> > >),usize> rust_fn = [...] // cdb-check:struct tuple$<usize (*)(f64),usize> rust_fn_with_return_value = [...] // cdb-check:struct tuple$<void (*)(enum2$<core::result::Result<char,f64> >),usize> unsafe_fn = [...] -// cdb-check:struct tuple$<void (*)(isize),usize> extern_c_fn = [...] -// cdb-check:struct tuple$<void (*)(enum2$<core::option::Option<isize> >,enum2$<core::option::Option<ref$<type_names::mod1::Struct2> > >),usize> rust_fn = [...] -// cdb-command:dv /t *_function* -// cdb-check:struct tuple$<isize (*)(ptr_const$<u8>, ...),usize> variadic_function = [...] -// cdb-check:struct tuple$<type_names::mod1::mod2::Struct3 (*)(type_names::mod1::mod2::Struct3),usize> generic_function_struct3 = [...] +// cdb-check:struct tuple$<type_names::mod1::Struct2 (*)(type_names::GenericStruct<u16,u8>),usize> unsafe_fn_with_return_value = [...] +// cdb-command:dv /t /n *_function* // cdb-check:struct tuple$<isize (*)(isize),usize> generic_function_int = [...] +// cdb-check:struct tuple$<type_names::mod1::mod2::Struct3 (*)(type_names::mod1::mod2::Struct3),usize> generic_function_struct3 = [...] +// cdb-check:struct tuple$<isize (*)(ptr_const$<u8>, ...),usize> variadic_function = [...] // cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn") // cdb-check:Return Type: void // cdb-check:Parameter Types: enum2$<core::option::Option<isize> >,enum2$<core::option::Option<ref$<type_names::mod1::Struct2> > > @@ -255,24 +259,25 @@ // cdb-check:Parameter Types: // CLOSURES -// cdb-command:dv /t closure* -// cdb-check:struct tuple$<type_names::main::closure_env$1,usize> closure2 = [...] +// cdb-command:dv /t /n closure* // cdb-check:struct tuple$<type_names::main::closure_env$0,usize> closure1 = [...] +// cdb-check:struct tuple$<type_names::main::closure_env$1,usize> closure2 = [...] // FOREIGN TYPES -// cdb-command:dv /t foreign* -// cdb-check:struct type_names::mod1::extern$0::ForeignType2 * foreign2 = [...] +// cdb-command:dv /t /n foreign* // cdb-check:struct type_names::extern$0::ForeignType1 * foreign1 = [...] +// cdb-check:struct type_names::mod1::extern$0::ForeignType2 * foreign2 = [...] #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] #![feature(extern_types)] -use self::Enum1::{Variant1, Variant2}; use std::marker::PhantomData; use std::ptr; +use self::Enum1::{Variant1, Variant2}; + pub struct Struct1; struct GenericStruct<T1, T2>(PhantomData<(T1, T2)>); @@ -372,7 +377,7 @@ fn main() { let simple_struct = Struct1; let generic_struct1: GenericStruct<mod1::Struct2, mod1::mod2::Struct3> = GenericStruct(PhantomData); - let generic_struct2: GenericStruct<Struct1, extern "system" fn(isize) -> usize> = + let generic_struct2: GenericStruct<Struct1, extern "fastcall" fn(isize) -> usize> = GenericStruct(PhantomData); let mod_struct = mod1::Struct2; diff --git a/tests/mir-opt/building/dump_mir_cycle.rs b/tests/mir-opt/building/dump_mir_cycle.rs new file mode 100644 index 00000000000..8e13420aed7 --- /dev/null +++ b/tests/mir-opt/building/dump_mir_cycle.rs @@ -0,0 +1,19 @@ +#[derive(Debug)] +pub struct Thing { + pub next: &'static Thing, +} + +pub static THING: Thing = Thing { next: &THING }; +// CHECK: alloc{{.+}} (static: THING) + +const fn thing() -> &'static Thing { + &MUTUALLY_RECURSIVE +} + +pub static MUTUALLY_RECURSIVE: Thing = Thing { next: thing() }; +// CHECK: alloc{{.+}} (static: MUTUALLY_RECURSIVE) + +fn main() { + // Generate optimized MIR for the const fn, too. + thing(); +} diff --git a/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir b/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir index 7affbf6dd40..344851bb088 100644 --- a/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir +++ b/tests/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir @@ -15,6 +15,4 @@ const BAR::promoted[0]: &[&i32; 1] = { } } -ALLOC0 (static: Y, size: 4, align: 4) { - 2a 00 00 00 │ *... -} +ALLOC0 (static: Y) diff --git a/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff index 487f68a8d4d..5f8f84244af 100644 --- a/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff +++ b/tests/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff @@ -38,9 +38,7 @@ bb2 (cleanup): { resume; } -- } -- -- ALLOC0 (static: Y, size: 4, align: 4) { -- 2a 00 00 00 │ *... } +- +- ALLOC0 (static: Y) diff --git a/tests/rustdoc-json/reexport/simple_private.rs b/tests/rustdoc-json/reexport/simple_private.rs index 8a936f5da1b..405d57d342e 100644 --- a/tests/rustdoc-json/reexport/simple_private.rs +++ b/tests/rustdoc-json/reexport/simple_private.rs @@ -12,3 +12,9 @@ mod inner { pub use inner::Public; //@ ismany "$.index[*][?(@.name=='simple_private')].inner.module.items[*]" $use_id + +// Test for https://github.com/rust-lang/rust/issues/135309 +//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_private"]' +//@ !has "$.paths[*].path" '["simple_private", "inner"]' +//@ has "$.paths[*][?(@.kind=='struct')].path" '["simple_private", "inner", "Public"]' +//@ !has "$.paths[*].path" '["simple_private", "Public"]' diff --git a/tests/rustdoc-json/reexport/simple_public.rs b/tests/rustdoc-json/reexport/simple_public.rs index e5a8dc7d2ad..f1335828314 100644 --- a/tests/rustdoc-json/reexport/simple_public.rs +++ b/tests/rustdoc-json/reexport/simple_public.rs @@ -14,3 +14,8 @@ pub mod inner { pub use inner::Public; //@ ismany "$.index[*][?(@.name=='simple_public')].inner.module.items[*]" $import_id $inner_id + +//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_public"]' +//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_public", "inner"]' +//@ has "$.paths[*][?(@.kind=='struct')].path" '["simple_public", "inner", "Public"]' +//@ !has "$.paths[*].path" '["simple_public", "Public"]' diff --git a/tests/rustdoc-ui/crate-reference-in-block-module.stderr b/tests/rustdoc-ui/crate-reference-in-block-module.stderr deleted file mode 100644 index e69de29bb2d..00000000000 --- a/tests/rustdoc-ui/crate-reference-in-block-module.stderr +++ /dev/null diff --git a/tests/rustdoc-ui/macro-docs.stdout b/tests/rustdoc-ui/macro-docs.stdout deleted file mode 100644 index e69de29bb2d..00000000000 --- a/tests/rustdoc-ui/macro-docs.stdout +++ /dev/null diff --git a/tests/rustdoc/inline_local/staged-inline.rs b/tests/rustdoc/inline_local/staged-inline.rs new file mode 100644 index 00000000000..f2131ad5f94 --- /dev/null +++ b/tests/rustdoc/inline_local/staged-inline.rs @@ -0,0 +1,18 @@ +// https://github.com/rust-lang/rust/issues/135078 +#![crate_name = "foo"] +#![feature(staged_api)] +#![stable(feature = "v1", since="1.0.0")] + +#[stable(feature = "v1", since="1.0.0")] +pub mod ffi { + #[stable(feature = "core_ffi", since="1.99.0")] + //@ has "foo/ffi/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.99.0" + //@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.0.0" + pub struct CStr; +} + +#[stable(feature = "v1", since = "1.0.0")] +#[doc(inline)] +//@ has "foo/struct.CStr.html" "//span[@class='sub-heading']/span[@class='since']" "1.0.0" +//@ !has - "//span[@class='sub-heading']/span[@class='since']" "1.99.0" +pub use ffi::CStr; diff --git a/tests/ui/abi/win64-zst.rs b/tests/ui/abi/win64-zst.rs deleted file mode 100644 index bc4e0e629eb..00000000000 --- a/tests/ui/abi/win64-zst.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ normalize-stderr: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN" -//@ only-x86_64 - -//@ revisions: x86_64-linux -//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu -//@[x86_64-linux] needs-llvm-components: x86 - -//@ revisions: x86_64-windows-gnu -//@[x86_64-windows-gnu] compile-flags: --target x86_64-pc-windows-gnu -//@[x86_64-windows-gnu] needs-llvm-components: x86 - -//@ revisions: x86_64-windows-msvc -//@[x86_64-windows-msvc] compile-flags: --target x86_64-pc-windows-msvc -//@[x86_64-windows-msvc] needs-llvm-components: x86 - -#![feature(no_core, lang_items, rustc_attrs)] -#![no_core] -#![crate_type = "lib"] - -#[lang = "sized"] -trait Sized {} - -#[rustc_abi(debug)] -extern "win64" fn pass_zst(_: ()) {} //~ ERROR: fn_abi diff --git a/tests/ui/abi/win64-zst.x86_64-linux.stderr b/tests/ui/abi/win64-zst.x86_64-linux.stderr deleted file mode 100644 index a28a59fdd8d..00000000000 --- a/tests/ui/abi/win64-zst.x86_64-linux.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error: fn_abi_of(pass_zst) = FnAbi { - args: [ - ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Ignore, - }, - ], - ret: ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Ignore, - }, - c_variadic: false, - fixed_count: 1, - conv: X86_64Win64, - can_unwind: false, - } - --> $DIR/win64-zst.rs:24:1 - | -LL | extern "win64" fn pass_zst(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr b/tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr deleted file mode 100644 index cf0cc00c5ed..00000000000 --- a/tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr +++ /dev/null @@ -1,80 +0,0 @@ -error: fn_abi_of(pass_zst) = FnAbi { - args: [ - ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Indirect { - attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, - arg_ext: None, - pointee_size: Size(0 bytes), - pointee_align: Some( - Align(1 bytes), - ), - }, - meta_attrs: None, - on_stack: false, - }, - }, - ], - ret: ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Ignore, - }, - c_variadic: false, - fixed_count: 1, - conv: X86_64Win64, - can_unwind: false, - } - --> $DIR/win64-zst.rs:24:1 - | -LL | extern "win64" fn pass_zst(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/abi/win64-zst.x86_64-windows-msvc.stderr b/tests/ui/abi/win64-zst.x86_64-windows-msvc.stderr deleted file mode 100644 index a28a59fdd8d..00000000000 --- a/tests/ui/abi/win64-zst.x86_64-windows-msvc.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error: fn_abi_of(pass_zst) = FnAbi { - args: [ - ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Ignore, - }, - ], - ret: ArgAbi { - layout: TyAndLayout { - ty: (), - layout: Layout { - size: Size(0 bytes), - align: AbiAndPrefAlign { - abi: $SOME_ALIGN, - pref: $SOME_ALIGN, - }, - abi: Memory { - sized: true, - }, - fields: Arbitrary { - offsets: [], - memory_index: [], - }, - largest_niche: None, - variants: Single { - index: 0, - }, - max_repr_align: None, - unadjusted_abi_align: $SOME_ALIGN, - randomization_seed: 0, - }, - }, - mode: Ignore, - }, - c_variadic: false, - fixed_count: 1, - conv: X86_64Win64, - can_unwind: false, - } - --> $DIR/win64-zst.rs:24:1 - | -LL | extern "win64" fn pass_zst(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs new file mode 100644 index 00000000000..ba37087135f --- /dev/null +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs @@ -0,0 +1,18 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/122638>. +//@ check-fail +#![feature(min_specialization)] +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + //~^ ERROR not all trait items implemented, missing: `Item` [E0046] + fn next(&mut self) -> Option<Self::Item> {} + //~^ ERROR mismatched types [E0308] +} +struct ConstChunksExact<'a, T: '_, const assert: usize> {} +//~^ ERROR `'_` cannot be used here [E0637] +//~| ERROR lifetime parameter `'a` is never used [E0392] +//~| ERROR type parameter `T` is never used [E0392] +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + //~^ ERROR mismatched types [E0308] + //~| ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates [E0207] + type Item = &'a [T; N]; } + +fn main() {} diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr new file mode 100644 index 00000000000..1ee68647594 --- /dev/null +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr @@ -0,0 +1,60 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/normalizing_with_unconstrained_impl_params.rs:9:32 + | +LL | struct ConstChunksExact<'a, T: '_, const assert: usize> {} + | ^^ `'_` is a reserved lifetime name + +error[E0308]: mismatched types + --> $DIR/normalizing_with_unconstrained_impl_params.rs:13:83 + | +LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^ expected `usize`, found `()` + +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/normalizing_with_unconstrained_impl_params.rs:4:1 + | +LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation + | + = help: implement the missing item: `type Item = /* Type */;` + +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/normalizing_with_unconstrained_impl_params.rs:9:25 + | +LL | struct ConstChunksExact<'a, T: '_, const assert: usize> {} + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + +error[E0392]: type parameter `T` is never used + --> $DIR/normalizing_with_unconstrained_impl_params.rs:9:29 + | +LL | struct ConstChunksExact<'a, T: '_, const assert: usize> {} + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + +error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates + --> $DIR/normalizing_with_unconstrained_impl_params.rs:13:30 + | +LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^^^^^^^^^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error[E0308]: mismatched types + --> $DIR/normalizing_with_unconstrained_impl_params.rs:6:27 + | +LL | fn next(&mut self) -> Option<Self::Item> {} + | ---- ^^^^^^^^^^^^^^^^^^ expected `Option<_>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected enum `Option<_>` + found unit type `()` + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0046, E0207, E0308, E0392, E0637. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/consts/recursive-block.rs b/tests/ui/consts/recursive-block.rs new file mode 100644 index 00000000000..a3dcaa42836 --- /dev/null +++ b/tests/ui/consts/recursive-block.rs @@ -0,0 +1,7 @@ +const fn foo<T>() { + const { foo::<&T>() } //~ ERROR: queries overflow the depth limit! +} + +fn main () { + const X: () = foo::<i32>(); +} diff --git a/tests/ui/consts/recursive-block.stderr b/tests/ui/consts/recursive-block.stderr new file mode 100644 index 00000000000..90814e2e000 --- /dev/null +++ b/tests/ui/consts/recursive-block.stderr @@ -0,0 +1,11 @@ +error: queries overflow the depth limit! + --> $DIR/recursive-block.rs:2:11 + | +LL | const { foo::<&T>() } + | ^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_block`) + = note: query depth increased by 1 when computing layout of `foo<&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&i32>` + +error: aborting due to 1 previous error + diff --git a/tests/ui/consts/recursive-const-in-impl.rs b/tests/ui/consts/recursive-const-in-impl.rs new file mode 100644 index 00000000000..93f7201f921 --- /dev/null +++ b/tests/ui/consts/recursive-const-in-impl.rs @@ -0,0 +1,12 @@ +//@ build-fail +#![recursion_limit = "7"] + +struct Thing<T>(T); + +impl<T> Thing<T> { + const X: usize = Thing::<Option<T>>::X; +} + +fn main() { + println!("{}", Thing::<i32>::X); //~ ERROR: queries overflow the depth limit! +} diff --git a/tests/ui/consts/recursive-const-in-impl.stderr b/tests/ui/consts/recursive-const-in-impl.stderr new file mode 100644 index 00000000000..6175112c8cc --- /dev/null +++ b/tests/ui/consts/recursive-const-in-impl.stderr @@ -0,0 +1,11 @@ +error: queries overflow the depth limit! + --> $DIR/recursive-const-in-impl.rs:11:14 + | +LL | println!("{}", Thing::<i32>::X); + | ^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "14"]` attribute to your crate (`recursive_const_in_impl`) + = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[1]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed new file mode 100644 index 00000000000..914ca1f3a06 --- /dev/null +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed @@ -0,0 +1,22 @@ +//@ run-rustfix +#![deny(unused_assignments, unused_variables)] +struct Object; + +fn change_object(object: &mut Object) { //~ HELP you might have meant to mutate + let object2 = Object; + *object = object2; //~ ERROR mismatched types +} + +fn change_object2(object: &mut Object) { //~ ERROR variable `object` is assigned to, but never used + //~^ HELP you might have meant to mutate + let object2 = Object; + *object = object2; + //~^ ERROR `object2` does not live long enough + //~| ERROR value assigned to `object` is never read +} + +fn main() { + let mut object = Object; + change_object(&mut object); + change_object2(&mut object); +} diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs new file mode 100644 index 00000000000..331359a98d1 --- /dev/null +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs @@ -0,0 +1,22 @@ +//@ run-rustfix +#![deny(unused_assignments, unused_variables)] +struct Object; + +fn change_object(mut object: &Object) { //~ HELP you might have meant to mutate + let object2 = Object; + object = object2; //~ ERROR mismatched types +} + +fn change_object2(mut object: &Object) { //~ ERROR variable `object` is assigned to, but never used + //~^ HELP you might have meant to mutate + let object2 = Object; + object = &object2; + //~^ ERROR `object2` does not live long enough + //~| ERROR value assigned to `object` is never read +} + +fn main() { + let mut object = Object; + change_object(&mut object); + change_object2(&mut object); +} diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr new file mode 100644 index 00000000000..e7e4003936a --- /dev/null +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr @@ -0,0 +1,69 @@ +error[E0308]: mismatched types + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:7:14 + | +LL | fn change_object(mut object: &Object) { + | ------- expected due to this parameter type +LL | let object2 = Object; +LL | object = object2; + | ^^^^^^^ expected `&Object`, found `Object` + | +help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding + | +LL ~ fn change_object(object: &mut Object) { +LL | let object2 = Object; +LL ~ *object = object2; + | + +error: value assigned to `object` is never read + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:13:5 + | +LL | object = &object2; + | ^^^^^^ + | +note: the lint level is defined here + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:9 + | +LL | #![deny(unused_assignments, unused_variables)] + | ^^^^^^^^^^^^^^^^^^ +help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding + | +LL ~ fn change_object2(object: &mut Object) { +LL | +LL | let object2 = Object; +LL ~ *object = object2; + | + +error: variable `object` is assigned to, but never used + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:10:23 + | +LL | fn change_object2(mut object: &Object) { + | ^^^^^^ + | + = note: consider using `_object` instead +note: the lint level is defined here + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:29 + | +LL | #![deny(unused_assignments, unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error[E0597]: `object2` does not live long enough + --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:13:14 + | +LL | fn change_object2(mut object: &Object) { + | - let's call the lifetime of this reference `'1` +LL | +LL | let object2 = Object; + | ------- binding `object2` declared here +LL | object = &object2; + | ---------^^^^^^^^ + | | | + | | borrowed value does not live long enough + | assignment requires that `object2` is borrowed for `'1` +... +LL | } + | - `object2` dropped here while still borrowed + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0597. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/generic-const-items/recursive.rs b/tests/ui/generic-const-items/recursive.rs index 8244772168b..94cf98ec64b 100644 --- a/tests/ui/generic-const-items/recursive.rs +++ b/tests/ui/generic-const-items/recursive.rs @@ -1,12 +1,11 @@ -// FIXME(generic_const_items): This leads to a stack overflow in the compiler! -//@ known-bug: unknown -//@ ignore-test +//@ build-fail #![feature(generic_const_items)] #![allow(incomplete_features)] +#![recursion_limit = "15"] const RECUR<T>: () = RECUR::<(T,)>; fn main() { - let _ = RECUR::<()>; + let _ = RECUR::<()>; //~ ERROR: queries overflow the depth limit! } diff --git a/tests/ui/generic-const-items/recursive.stderr b/tests/ui/generic-const-items/recursive.stderr new file mode 100644 index 00000000000..c9a57937428 --- /dev/null +++ b/tests/ui/generic-const-items/recursive.stderr @@ -0,0 +1,11 @@ +error: queries overflow the depth limit! + --> $DIR/recursive.rs:10:13 + | +LL | let _ = RECUR::<()>; + | ^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "30"]` attribute to your crate (`recursive`) + = note: query depth increased by 17 when simplifying constant for the type system `RECUR` + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/precise-capturing/redundant.rs b/tests/ui/impl-trait/precise-capturing/redundant.rs index 075d7c70ac6..32dc0927317 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.rs +++ b/tests/ui/impl-trait/precise-capturing/redundant.rs @@ -1,24 +1,24 @@ //@ edition: 2024 -//@ check-pass #![feature(precise_capturing_in_traits)] +#![deny(impl_trait_redundant_captures)] fn hello<'a>() -> impl Sized + use<'a> {} -//~^ WARN all possible in-scope parameters are already captured +//~^ ERROR all possible in-scope parameters are already captured struct Inherent; impl Inherent { fn inherent(&self) -> impl Sized + use<'_> {} - //~^ WARN all possible in-scope parameters are already captured + //~^ ERROR all possible in-scope parameters are already captured } trait Test<'a> { fn in_trait() -> impl Sized + use<'a, Self>; - //~^ WARN all possible in-scope parameters are already captured + //~^ ERROR all possible in-scope parameters are already captured } impl<'a> Test<'a> for () { fn in_trait() -> impl Sized + use<'a> {} - //~^ WARN all possible in-scope parameters are already captured + //~^ ERROR all possible in-scope parameters are already captured } fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/redundant.stderr b/tests/ui/impl-trait/precise-capturing/redundant.stderr index 274d9d2375f..5c8b35c2285 100644 --- a/tests/ui/impl-trait/precise-capturing/redundant.stderr +++ b/tests/ui/impl-trait/precise-capturing/redundant.stderr @@ -1,4 +1,4 @@ -warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant +error: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant --> $DIR/redundant.rs:6:19 | LL | fn hello<'a>() -> impl Sized + use<'a> {} @@ -6,9 +6,13 @@ LL | fn hello<'a>() -> impl Sized + use<'a> {} | | | help: remove the `use<...>` syntax | - = note: `#[warn(impl_trait_redundant_captures)]` on by default +note: the lint level is defined here + --> $DIR/redundant.rs:4:9 + | +LL | #![deny(impl_trait_redundant_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant +error: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant --> $DIR/redundant.rs:11:27 | LL | fn inherent(&self) -> impl Sized + use<'_> {} @@ -16,7 +20,7 @@ LL | fn inherent(&self) -> impl Sized + use<'_> {} | | | help: remove the `use<...>` syntax -warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant +error: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant --> $DIR/redundant.rs:16:22 | LL | fn in_trait() -> impl Sized + use<'a, Self>; @@ -24,7 +28,7 @@ LL | fn in_trait() -> impl Sized + use<'a, Self>; | | | help: remove the `use<...>` syntax -warning: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant +error: all possible in-scope parameters are already captured, so `use<...>` syntax is redundant --> $DIR/redundant.rs:20:22 | LL | fn in_trait() -> impl Sized + use<'a> {} @@ -32,5 +36,5 @@ LL | fn in_trait() -> impl Sized + use<'a> {} | | | help: remove the `use<...>` syntax -warning: 4 warnings emitted +error: aborting due to 4 previous errors diff --git a/tests/crashes/114484.rs b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs index 9d90c153624..410862c5326 100644 --- a/tests/crashes/114484.rs +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs @@ -1,4 +1,12 @@ -//@ known-bug: #114484 +//@ build-fail + +//@ error-pattern: reached the recursion limit while instantiating +//@ error-pattern: reached the recursion limit finding the struct tail + +// Regression test for #114484: This used to ICE during monomorphization, because we treated +// `<VirtualWrapper<...> as Pointee>::Metadata` as a rigid projection after reaching the recursion +// limit when finding the struct tail. + use std::marker::PhantomData; trait MyTrait { diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr new file mode 100644 index 00000000000..7c961b79c0c --- /dev/null +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr @@ -0,0 +1,86 @@ +error: reached the recursion limit finding the struct tail for `[u8; 256]` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + +error: reached the recursion limit finding the struct tail for `[u8; 256]` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `[u8; 256]` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `[u8; 256]` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:26:18 + | +LL | unsafe { virtualize_my_trait(L, self) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: reached the recursion limit finding the struct tail for `SomeData<256>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + +error: reached the recursion limit finding the struct tail for `SomeData<256>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `SomeData<256>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `SomeData<256>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:26:18 + | +LL | unsafe { virtualize_my_trait(L, self) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + +error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:26:18 + | +LL | unsafe { virtualize_my_trait(L, self) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: reached the recursion limit while instantiating `<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<..., 1>, 1>, 1>, 1>, 1> as MyTrait>::virtualize` + | +note: `<VirtualWrapper<T, L> as MyTrait>::virtualize` defined here + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:5 + | +LL | fn virtualize(&self) -> &dyn MyTrait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type.txt' + +error: aborting due to 13 previous errors + diff --git a/tests/ui/privacy/sysroot-private.default.stderr b/tests/ui/privacy/sysroot-private.default.stderr new file mode 100644 index 00000000000..845d4558d13 --- /dev/null +++ b/tests/ui/privacy/sysroot-private.default.stderr @@ -0,0 +1,39 @@ +error[E0405]: cannot find trait `Equivalent` in this scope + --> $DIR/sysroot-private.rs:26:18 + | +LL | trait Trait2<K>: Equivalent<K> {} + | ^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `K` in this scope + --> $DIR/sysroot-private.rs:31:35 + | +LL | fn trait_member<T>(val: &T, key: &K) -> bool { + | - ^ + | | + | similarly named type parameter `T` defined here + | +help: a type parameter with a similar name exists + | +LL | fn trait_member<T>(val: &T, key: &T) -> bool { + | ~ +help: you might be missing a type parameter + | +LL | fn trait_member<T, K>(val: &T, key: &K) -> bool { + | +++ + +error[E0220]: associated type `ExpressionStack` not found for `Trait` + --> $DIR/sysroot-private.rs:21:31 + | +LL | type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; + | ^^^^^^^^^^^^^^^ help: `Trait` has the following associated type: `Bar` + +error[E0425]: cannot find function `memchr2` in this scope + --> $DIR/sysroot-private.rs:39:5 + | +LL | memchr2(b'a', b'b', buf) + | ^^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0220, E0405, E0412, E0425. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/privacy/sysroot-private.rs b/tests/ui/privacy/sysroot-private.rs new file mode 100644 index 00000000000..67ab67c7f5c --- /dev/null +++ b/tests/ui/privacy/sysroot-private.rs @@ -0,0 +1,42 @@ +//! Test that private dependencies of `std` that live in the sysroot do not reach through to +//! diagnostics. +//! +//! This test would be more robust if we could patch the sysroot with an "evil" crate that +//! provided known types that we control; however, this would effectively require rebuilding +//! `std` (or patching crate metadata). So, this test relies on what is currently public API +//! of `std`'s dependencies, but may not be robust against dependency upgrades/changes. + +//@ only-unix Windows sysroots seem to not expose this dependency +//@ revisions: default rustc_private_enabled + +// Enabling `rustc_private` should `std`'s dependencies accessible, so they should show up +// in diagnostics. NB: not all diagnostics are affected by this. +#![cfg_attr(rustc_private_enabled, feature(rustc_private))] +#![crate_type = "lib"] + +trait Trait { type Bar; } + +// Attempt to get a suggestion for `gimli::read::op::EvaluationStoreage`, which should not be +// present in diagnostics (it is a dependency of the compiler). +type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; +//~^ ERROR associated type `ExpressionStack` not found +//[rustc_private_enabled]~| NOTE there is an associated type `ExpressionStack` in the trait `gimli::read::op::EvaluationStorage` + +// Attempt to get a suggestion for `hashbrown::Equivalent` +trait Trait2<K>: Equivalent<K> {} +//~^ ERROR cannot find trait +//~| NOTE not found + +// Attempt to get a suggestion for `hashbrown::Equivalent::equivalent` +fn trait_member<T>(val: &T, key: &K) -> bool { + //~^ ERROR cannot find type `K` + //~| NOTE similarly named + val.equivalent(key) +} + +// Attempt to get a suggestion for `memchr::memchr2` +fn free_function(buf: &[u8]) -> Option<usize> { + memchr2(b'a', b'b', buf) + //~^ ERROR cannot find function + //~| NOTE not found +} diff --git a/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr b/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr new file mode 100644 index 00000000000..98e6922428a --- /dev/null +++ b/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr @@ -0,0 +1,39 @@ +error[E0405]: cannot find trait `Equivalent` in this scope + --> $DIR/sysroot-private.rs:26:18 + | +LL | trait Trait2<K>: Equivalent<K> {} + | ^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `K` in this scope + --> $DIR/sysroot-private.rs:31:35 + | +LL | fn trait_member<T>(val: &T, key: &K) -> bool { + | - ^ + | | + | similarly named type parameter `T` defined here + | +help: a type parameter with a similar name exists + | +LL | fn trait_member<T>(val: &T, key: &T) -> bool { + | ~ +help: you might be missing a type parameter + | +LL | fn trait_member<T, K>(val: &T, key: &K) -> bool { + | +++ + +error[E0220]: associated type `ExpressionStack` not found for `Trait` + --> $DIR/sysroot-private.rs:21:31 + | +LL | type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; + | ^^^^^^^^^^^^^^^ there is an associated type `ExpressionStack` in the trait `gimli::read::op::EvaluationStorage` + +error[E0425]: cannot find function `memchr2` in this scope + --> $DIR/sysroot-private.rs:39:5 + | +LL | memchr2(b'a', b'b', buf) + | ^^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0220, E0405, E0412, E0425. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/query-system/query_depth.stderr b/tests/ui/query-system/query_depth.stderr index d455e0e4ff8..f738b01ed6c 100644 --- a/tests/ui/query-system/query_depth.stderr +++ b/tests/ui/query-system/query_depth.stderr @@ -5,7 +5,7 @@ LL | fn main() { | ^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "128"]` attribute to your crate (`query_depth`) - = note: query depth increased by 66 when computing layout of `core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<alloc::boxed::Box<alloc::string::String>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: query depth increased by 65 when computing layout of `core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<alloc::boxed::Box<alloc::string::String>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary-self-from-method-substs-ice.rs b/tests/ui/self/arbitrary-self-from-method-substs-ice.rs index 2c0f25fc6ff..2d6df816bb1 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs-ice.rs +++ b/tests/ui/self/arbitrary-self-from-method-substs-ice.rs @@ -11,7 +11,7 @@ impl Foo { //~^ ERROR invalid generic `self` parameter type //~| ERROR destructor of `R` cannot be evaluated at compile-time self.0 - //~^ ERROR cannot call conditionally-const method `<R as Deref>::deref` in constant function + //~^ ERROR cannot perform conditionally-const deref coercion on `R` in constant functions } } diff --git a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr index 90b63249eca..e6319d5a2c9 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr +++ b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr @@ -1,9 +1,10 @@ -error[E0658]: cannot call conditionally-const method `<R as Deref>::deref` in constant functions +error[E0658]: cannot perform conditionally-const deref coercion on `R` in constant functions --> $DIR/arbitrary-self-from-method-substs-ice.rs:13:9 | LL | self.0 | ^^^^^^ | + = note: attempting to deref into `Foo` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/structs/ice-struct-tail-normalization-113272.rs b/tests/ui/structs/ice-struct-tail-normalization-113272.rs index 85d3d1b4886..0ae24a7b71b 100644 --- a/tests/ui/structs/ice-struct-tail-normalization-113272.rs +++ b/tests/ui/structs/ice-struct-tail-normalization-113272.rs @@ -13,5 +13,6 @@ struct Other { fn main() { unsafe { std::mem::transmute::<Option<()>, Option<&Other>>(None); + //~^ ERROR cannot transmute } } diff --git a/tests/ui/structs/ice-struct-tail-normalization-113272.stderr b/tests/ui/structs/ice-struct-tail-normalization-113272.stderr index a205eb80f5c..8c55dbca187 100644 --- a/tests/ui/structs/ice-struct-tail-normalization-113272.stderr +++ b/tests/ui/structs/ice-struct-tail-normalization-113272.stderr @@ -13,7 +13,16 @@ LL | type RefTarget; LL | impl Trait for () where Missing: Trait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `RefTarget` in implementation -error: aborting due to 2 previous errors +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/ice-struct-tail-normalization-113272.rs:15:9 + | +LL | std::mem::transmute::<Option<()>, Option<&Other>>(None); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `Option<()>` (8 bits) + = note: target type: `Option<&Other>` (unable to determine layout for `Other` because `<() as Trait>::RefTarget` cannot be normalized) + +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0046, E0412. +Some errors have detailed explanations: E0046, E0412, E0512. For more information about an error, try `rustc --explain E0046`. |
