diff options
Diffstat (limited to 'tests')
70 files changed, 687 insertions, 1050 deletions
diff --git a/tests/codegen/enum-debug-niche-2.rs b/tests/codegen/enum-debug-niche-2.rs index 9c72ad9d248..4b607d50574 100644 --- a/tests/codegen/enum-debug-niche-2.rs +++ b/tests/codegen/enum-debug-niche-2.rs @@ -7,8 +7,8 @@ // compile-flags: -g -C no-prepopulate-passes // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}} -// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}} +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}} #![feature(never_type)] diff --git a/tests/codegen/enum-u128.rs b/tests/codegen/enum-u128.rs new file mode 100644 index 00000000000..f50d360ac9f --- /dev/null +++ b/tests/codegen/enum-u128.rs @@ -0,0 +1,27 @@ +// This tests that debug info for "c-like" 128bit enums is properly emitted. +// This is ignored for the fallback mode on MSVC due to problems with PDB. + +// +// ignore-msvc + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "Foo",{{.*}}flags: DIFlagEnumClass,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Lo",{{.*}}value: 0,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Hi",{{.*}}value: 18446744073709551616,{{.*}} +// CHECK: {{.*}}DIEnumerator{{.*}}name: "Bar",{{.*}}value: 18446745000000000123,{{.*}} + +#![allow(incomplete_features)] +#![feature(repr128)] + +#[repr(u128)] +pub enum Foo { + Lo, + Hi = 1 << 64, + Bar = 18_446_745_000_000_000_123, +} + +pub fn main() { + let foo = Foo::Bar; +} diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index a977ebf1bb7..573ae1ba68d 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -2,6 +2,7 @@ // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-asm-support +// compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(asm_unwind)] struct D; @@ -10,7 +11,7 @@ impl Drop for D { fn drop(&mut self) {} } -#[inline(always)] +#[inline] fn foo() { let _d = D; unsafe { std::arch::asm!("", options(may_unwind)) }; diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index af2ca895cc6..1b74d818451 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -1,4 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 // EMIT_MIR cycle.f.Inline.diff #[inline(always)] diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index febf1a8a6bf..e01c4c1dd02 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -1,6 +1,7 @@ // Tests inlining of diverging calls. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 #![crate_type = "lib"] // EMIT_MIR inline_diverging.f.Inline.diff diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff index fa48c56d185..e05c605a4e4 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff @@ -4,30 +4,30 @@ fn main() -> () { let mut _0: (); let _1: std::ops::GeneratorState<i32, bool>; - let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; - let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; - let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; + let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>; + let mut _3: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _4: [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new) { ++ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; ++ let mut _6: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _7: u32; + let mut _8: i32; -+ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; -+ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + } bb0: { @@ -39,18 +39,18 @@ - } - - bb1: { -+ _4 = [generator@$DIR/inline_generator.rs:15:5: 15:8 (#0)]; ++ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)]; _3 = &mut _4; -- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind unreachable]; +- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind unreachable]; - } - - bb2: { -+ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> { pointer: move _3 }; ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]> { pointer: move _3 }; StorageDead(_3); -- _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; +- _1 = <[generator@$DIR/inline_generator.rs:16:5: 16:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; + StorageLive(_5); + _5 = const false; -+ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb2, 1: bb6, 3: bb7, otherwise: bb8]; } @@ -82,7 +82,7 @@ + + bb5: { + _1 = GeneratorState::<i32, bool>::Yielded(move _8); -+ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + discriminant((*_9)) = 3; + goto -> bb1; + } @@ -95,7 +95,7 @@ + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::<i32, bool>::Complete(_5); -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + discriminant((*_10)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff index 63f70ccc3b5..588f04048d6 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -4,30 +4,30 @@ fn main() -> () { let mut _0: (); let _1: std::ops::GeneratorState<i32, bool>; - let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; - let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; - let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; + let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>; + let mut _3: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _4: [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new) { ++ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; ++ let mut _6: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _7: u32; + let mut _8: i32; -+ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; -+ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + } bb0: { @@ -39,18 +39,18 @@ - } - - bb1: { -+ _4 = [generator@$DIR/inline_generator.rs:15:5: 15:8 (#0)]; ++ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)]; _3 = &mut _4; -- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; +- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind: bb4]; - } - - bb2: { -+ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> { pointer: move _3 }; ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]> { pointer: move _3 }; StorageDead(_3); -- _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; +- _1 = <[generator@$DIR/inline_generator.rs:16:5: 16:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; + StorageLive(_5); + _5 = const false; -+ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; } @@ -87,7 +87,7 @@ + + bb6: { + _1 = GeneratorState::<i32, bool>::Yielded(move _8); -+ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + discriminant((*_9)) = 3; + goto -> bb1; + } @@ -100,7 +100,7 @@ + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::<i32, bool>::Complete(_5); -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); + discriminant((*_10)) = 1; + goto -> bb1; + } diff --git a/tests/mir-opt/inline/inline_generator.rs b/tests/mir-opt/inline/inline_generator.rs index 61f1da897bd..2d71458c174 100644 --- a/tests/mir-opt/inline/inline_generator.rs +++ b/tests/mir-opt/inline/inline_generator.rs @@ -1,4 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(generators, generator_trait)] use std::ops::Generator; @@ -9,8 +10,8 @@ fn main() { let _r = Pin::new(&mut g()).resume(false); } -#[inline(always)] +#[inline] pub fn g() -> impl Generator<bool> { - #[inline(always)] + #[inline] |a| { yield if a { 7 } else { 13 } } } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff index b186a701f65..f3a6923415a 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff @@ -18,6 +18,99 @@ + let mut _6: *mut u8; + let mut _7: *const std::vec::Vec<u32>; + scope 4 { ++ scope 5 (inlined alloc::alloc::exchange_malloc) { ++ debug size => _4; ++ debug align => _5; ++ let _8: std::alloc::Layout; ++ let mut _9: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; ++ let mut _10: isize; ++ let mut _12: !; ++ scope 6 { ++ debug layout => _8; ++ let _11: std::ptr::NonNull<[u8]>; ++ let mut _13: &std::alloc::Global; ++ scope 8 { ++ debug ptr => _11; ++ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { ++ debug self => _11; ++ let mut _15: std::ptr::NonNull<u8>; ++ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { ++ debug self => _11; ++ let mut _16: *mut u8; ++ let mut _17: *mut [u8]; ++ scope 20 { ++ scope 21 (inlined NonNull::<[u8]>::as_ptr) { ++ debug self => _11; ++ let mut _18: *const [u8]; ++ } ++ scope 22 (inlined ptr::mut_ptr::<impl *mut [u8]>::as_mut_ptr) { ++ debug self => _17; ++ } ++ scope 23 (inlined NonNull::<u8>::new_unchecked) { ++ debug ptr => _16; ++ let mut _19: *const u8; ++ scope 24 { ++ scope 25 (inlined NonNull::<T>::new_unchecked::runtime::<u8>) { ++ debug ptr => _16; ++ scope 26 (inlined ptr::mut_ptr::<impl *mut u8>::is_null) { ++ debug self => _16; ++ let mut _20: *mut u8; ++ scope 27 { ++ scope 28 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { ++ debug ptr => _20; ++ scope 29 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { ++ debug self => _20; ++ scope 30 { ++ scope 31 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { ++ debug self => _20; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ scope 32 (inlined NonNull::<u8>::as_ptr) { ++ debug self => _15; ++ let mut _21: *const u8; ++ } ++ } ++ } ++ scope 17 (inlined <std::alloc::Global as Allocator>::allocate) { ++ debug self => const _; ++ debug layout => _8; ++ } ++ } ++ scope 7 { ++ scope 9 (inlined Layout::from_size_align_unchecked) { ++ debug size => _4; ++ debug align => _5; ++ let mut _14: std::ptr::Alignment; ++ scope 10 { ++ scope 11 (inlined std::ptr::Alignment::new_unchecked) { ++ debug align => _5; ++ scope 12 { ++ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { ++ debug align => _5; ++ scope 15 (inlined core::num::<impl usize>::is_power_of_two) { ++ debug self => _5; ++ scope 16 (inlined core::num::<impl usize>::count_ones) { ++ debug self => _5; ++ } ++ } ++ } ++ } ++ scope 13 { ++ } ++ } ++ } ++ } ++ } ++ } + } + } @@ -31,7 +124,17 @@ + StorageDead(_3); + _4 = SizeOf(std::vec::Vec<u32>); + _5 = AlignOf(std::vec::Vec<u32>); -+ _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb2, unwind unreachable]; ++ StorageLive(_8); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ _14 = _5 as std::ptr::Alignment (Transmute); ++ _8 = Layout { size: _4, align: move _14 }; ++ StorageDead(_14); ++ StorageLive(_9); ++ _13 = const _; ++ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb5, unwind unreachable]; } bb1: { @@ -41,18 +144,56 @@ } bb2: { ++ _12 = handle_alloc_error(_8) -> unwind unreachable; ++ } ++ ++ bb3: { ++ unreachable; ++ } ++ ++ bb4: { ++ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_15); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ _18 = (_11.0: *const [u8]); ++ _17 = move _18 as *mut [u8] (PtrToPtr); ++ StorageDead(_18); ++ _16 = _17 as *mut u8 (PtrToPtr); ++ StorageDead(_17); ++ StorageLive(_19); ++ StorageLive(_20); ++ _19 = _16 as *const u8 (Pointer(MutToConstPointer)); ++ _15 = NonNull::<u8> { pointer: _19 }; ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageDead(_16); ++ StorageLive(_21); ++ _21 = (_15.0: *const u8); ++ _6 = move _21 as *mut u8 (PtrToPtr); ++ StorageDead(_21); ++ StorageDead(_15); ++ StorageDead(_9); ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ StorageDead(_8); + _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); + _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); + (*_7) = move _2; StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; -- } -- ++ drop(_1) -> [return: bb1, unwind unreachable]; + } + - bb3: { - StorageDead(_1); - return; -+ drop(_1) -> [return: bb1, unwind unreachable]; ++ bb5: { ++ _10 = discriminant(_9); ++ switchInt(move _10) -> [0: bb4, 1: bb2, otherwise: bb3]; } } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff index a789f9933b4..4615a3f9826 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff @@ -18,6 +18,99 @@ + let mut _6: *mut u8; + let mut _7: *const std::vec::Vec<u32>; + scope 4 { ++ scope 5 (inlined alloc::alloc::exchange_malloc) { ++ debug size => _4; ++ debug align => _5; ++ let _8: std::alloc::Layout; ++ let mut _9: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; ++ let mut _10: isize; ++ let mut _12: !; ++ scope 6 { ++ debug layout => _8; ++ let _11: std::ptr::NonNull<[u8]>; ++ let mut _13: &std::alloc::Global; ++ scope 8 { ++ debug ptr => _11; ++ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { ++ debug self => _11; ++ let mut _15: std::ptr::NonNull<u8>; ++ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { ++ debug self => _11; ++ let mut _16: *mut u8; ++ let mut _17: *mut [u8]; ++ scope 20 { ++ scope 21 (inlined NonNull::<[u8]>::as_ptr) { ++ debug self => _11; ++ let mut _18: *const [u8]; ++ } ++ scope 22 (inlined ptr::mut_ptr::<impl *mut [u8]>::as_mut_ptr) { ++ debug self => _17; ++ } ++ scope 23 (inlined NonNull::<u8>::new_unchecked) { ++ debug ptr => _16; ++ let mut _19: *const u8; ++ scope 24 { ++ scope 25 (inlined NonNull::<T>::new_unchecked::runtime::<u8>) { ++ debug ptr => _16; ++ scope 26 (inlined ptr::mut_ptr::<impl *mut u8>::is_null) { ++ debug self => _16; ++ let mut _20: *mut u8; ++ scope 27 { ++ scope 28 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { ++ debug ptr => _20; ++ scope 29 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { ++ debug self => _20; ++ scope 30 { ++ scope 31 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { ++ debug self => _20; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ scope 32 (inlined NonNull::<u8>::as_ptr) { ++ debug self => _15; ++ let mut _21: *const u8; ++ } ++ } ++ } ++ scope 17 (inlined <std::alloc::Global as Allocator>::allocate) { ++ debug self => const _; ++ debug layout => _8; ++ } ++ } ++ scope 7 { ++ scope 9 (inlined Layout::from_size_align_unchecked) { ++ debug size => _4; ++ debug align => _5; ++ let mut _14: std::ptr::Alignment; ++ scope 10 { ++ scope 11 (inlined std::ptr::Alignment::new_unchecked) { ++ debug align => _5; ++ scope 12 { ++ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { ++ debug align => _5; ++ scope 15 (inlined core::num::<impl usize>::is_power_of_two) { ++ debug self => _5; ++ scope 16 (inlined core::num::<impl usize>::count_ones) { ++ debug self => _5; ++ } ++ } ++ } ++ } ++ scope 13 { ++ } ++ } ++ } ++ } ++ } ++ } + } + } @@ -31,7 +124,17 @@ + StorageDead(_3); + _4 = SizeOf(std::vec::Vec<u32>); + _5 = AlignOf(std::vec::Vec<u32>); -+ _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb3, unwind: bb4]; ++ StorageLive(_8); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ _14 = _5 as std::ptr::Alignment (Transmute); ++ _8 = Layout { size: _4, align: move _14 }; ++ StorageDead(_14); ++ StorageLive(_9); ++ _13 = const _; ++ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb7, unwind: bb3]; } bb1: { @@ -48,20 +151,62 @@ + resume; } - bb3: { +- bb3: { - StorageDead(_1); - return; ++ bb3 (cleanup): { ++ drop(_2) -> [return: bb2, unwind terminate]; + } + +- bb4 (cleanup): { +- resume; ++ bb4: { ++ _12 = handle_alloc_error(_8) -> bb3; ++ } ++ ++ bb5: { ++ unreachable; ++ } ++ ++ bb6: { ++ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_15); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ _18 = (_11.0: *const [u8]); ++ _17 = move _18 as *mut [u8] (PtrToPtr); ++ StorageDead(_18); ++ _16 = _17 as *mut u8 (PtrToPtr); ++ StorageDead(_17); ++ StorageLive(_19); ++ StorageLive(_20); ++ _19 = _16 as *const u8 (Pointer(MutToConstPointer)); ++ _15 = NonNull::<u8> { pointer: _19 }; ++ StorageDead(_20); ++ StorageDead(_19); ++ StorageDead(_16); ++ StorageLive(_21); ++ _21 = (_15.0: *const u8); ++ _6 = move _21 as *mut u8 (PtrToPtr); ++ StorageDead(_21); ++ StorageDead(_15); ++ StorageDead(_9); ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ StorageDead(_8); + _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); + _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); + (*_7) = move _2; + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb1, unwind: bb2]; - } - - bb4 (cleanup): { -- resume; -+ drop(_2) -> [return: bb2, unwind terminate]; ++ } ++ ++ bb7: { ++ _10 = discriminant(_9); ++ switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; } } diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index bc578ec90e8..56f174e515b 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,7 +1,7 @@ // ignore-endian-big // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-debug MIR alignment checks in std alter the diff, breaking the test -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Zmir-opt-level=4 -Zinline-mir-hint-threshold=200 // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index 890d9b109fb..093925b8e4f 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -7,129 +7,19 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { -+ debug self => _3; -+ debug rhs => _4; -+ let mut _5: u16; -+ scope 2 { -+ scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { -+ debug x => _4; -+ let mut _6: std::option::Option<u16>; -+ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<u16>>::try_into) { -+ debug self => _4; -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { -+ debug u => _4; -+ let mut _8: bool; -+ let mut _9: u32; -+ let mut _10: u16; -+ } -+ } -+ scope 7 (inlined Result::<u16, TryFromIntError>::ok) { -+ debug self => _7; -+ let mut _11: isize; -+ let _12: u16; -+ scope 8 { -+ debug x => _12; -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { -+ debug self => _6; -+ let mut _13: &std::option::Option<u16>; -+ let mut _14: isize; -+ scope 10 { -+ debug val => _5; -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<u16>::is_some) { -+ debug self => _13; -+ } -+ } -+ } -+ } -+ } -+ } bb0: { StorageLive(_3); _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ StorageLive(_8); -+ StorageLive(_9); -+ _9 = const 65535_u32; -+ _8 = Gt(_4, move _9); -+ StorageDead(_9); -+ switchInt(move _8) -> [0: bb3, otherwise: bb2]; + _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; } bb1: { -+ StorageDead(_5); StorageDead(_4); StorageDead(_3); return; -+ } -+ -+ bb2: { -+ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); -+ goto -> bb4; -+ } -+ -+ bb3: { -+ StorageLive(_10); -+ _10 = _4 as u16 (IntToInt); -+ _7 = Result::<u16, TryFromIntError>::Ok(move _10); -+ StorageDead(_10); -+ goto -> bb4; -+ } -+ -+ bb4: { -+ StorageDead(_8); -+ StorageLive(_12); -+ _11 = discriminant(_7); -+ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; -+ } -+ -+ bb5: { -+ _6 = Option::<u16>::None; -+ goto -> bb8; -+ } -+ -+ bb6: { -+ unreachable; -+ } -+ -+ bb7: { -+ _12 = move ((_7 as Ok).0: u16); -+ _6 = Option::<u16>::Some(move _12); -+ goto -> bb8; -+ } -+ -+ bb8: { -+ StorageDead(_12); -+ StorageDead(_7); -+ StorageLive(_13); -+ _14 = discriminant(_6); -+ switchInt(move _14) -> [1: bb9, otherwise: bb6]; -+ } -+ -+ bb9: { -+ _5 = move ((_6 as Some).0: u16); -+ StorageDead(_13); -+ StorageDead(_6); -+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index 118e601b136..50934e0439a 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -7,129 +7,19 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { -+ debug self => _3; -+ debug rhs => _4; -+ let mut _5: u16; -+ scope 2 { -+ scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { -+ debug x => _4; -+ let mut _6: std::option::Option<u16>; -+ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<u16>>::try_into) { -+ debug self => _4; -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { -+ debug u => _4; -+ let mut _8: bool; -+ let mut _9: u32; -+ let mut _10: u16; -+ } -+ } -+ scope 7 (inlined Result::<u16, TryFromIntError>::ok) { -+ debug self => _7; -+ let mut _11: isize; -+ let _12: u16; -+ scope 8 { -+ debug x => _12; -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { -+ debug self => _6; -+ let mut _13: &std::option::Option<u16>; -+ let mut _14: isize; -+ scope 10 { -+ debug val => _5; -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<u16>::is_some) { -+ debug self => _13; -+ } -+ } -+ } -+ } -+ } -+ } bb0: { StorageLive(_3); _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ StorageLive(_8); -+ StorageLive(_9); -+ _9 = const 65535_u32; -+ _8 = Gt(_4, move _9); -+ StorageDead(_9); -+ switchInt(move _8) -> [0: bb3, otherwise: bb2]; + _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; } bb1: { -+ StorageDead(_5); StorageDead(_4); StorageDead(_3); return; -+ } -+ -+ bb2: { -+ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); -+ goto -> bb4; -+ } -+ -+ bb3: { -+ StorageLive(_10); -+ _10 = _4 as u16 (IntToInt); -+ _7 = Result::<u16, TryFromIntError>::Ok(move _10); -+ StorageDead(_10); -+ goto -> bb4; -+ } -+ -+ bb4: { -+ StorageDead(_8); -+ StorageLive(_12); -+ _11 = discriminant(_7); -+ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; -+ } -+ -+ bb5: { -+ _6 = Option::<u16>::None; -+ goto -> bb8; -+ } -+ -+ bb6: { -+ unreachable; -+ } -+ -+ bb7: { -+ _12 = move ((_7 as Ok).0: u16); -+ _6 = Option::<u16>::Some(move _12); -+ goto -> bb8; -+ } -+ -+ bb8: { -+ StorageDead(_12); -+ StorageDead(_7); -+ StorageLive(_13); -+ _14 = discriminant(_6); -+ switchInt(move _14) -> [1: bb9, otherwise: bb6]; -+ } -+ -+ bb9: { -+ _5 = move ((_6 as Some).0: u16); -+ StorageDead(_13); -+ StorageDead(_6); -+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir index 0d692251051..46f3511b14c 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -4,121 +4,12 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::<impl u16>::unchecked_shl) { - debug self => _1; - debug rhs => _2; - let mut _11: u16; - scope 2 { - scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { - debug x => _2; - let mut _6: std::result::Result<u16, std::num::TryFromIntError>; - let mut _9: std::option::Option<u16>; - scope 4 { - scope 5 (inlined <u32 as TryInto<u16>>::try_into) { - debug self => _2; - scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { - debug u => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: u16; - } - } - scope 7 (inlined Result::<u16, TryFromIntError>::ok) { - debug self => _6; - let mut _7: isize; - let _8: u16; - scope 8 { - debug x => _8; - } - } - scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { - debug self => _9; - let mut _10: isize; - let mut _12: &std::option::Option<u16>; - scope 10 { - debug val => _11; - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { - } - } - } - } - scope 12 (inlined Option::<u16>::is_some) { - debug self => _12; - } - } - } - } - } - } bb0: { - StorageLive(_11); - StorageLive(_9); - StorageLive(_6); - StorageLive(_4); - StorageLive(_3); - _3 = const 65535_u32; - _4 = Gt(_2, move _3); - StorageDead(_3); - switchInt(move _4) -> [0: bb1, otherwise: bb2]; + _0 = core::num::<impl u16>::unchecked_shl(_1, _2) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_5); - _5 = _2 as u16 (IntToInt); - _6 = Result::<u16, TryFromIntError>::Ok(move _5); - StorageDead(_5); - goto -> bb3; - } - - bb2: { - _6 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); - goto -> bb3; - } - - bb3: { - StorageDead(_4); - StorageLive(_8); - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; - } - - bb4: { - _8 = move ((_6 as Ok).0: u16); - _9 = Option::<u16>::Some(move _8); - goto -> bb6; - } - - bb5: { - _9 = Option::<u16>::None; - goto -> bb6; - } - - bb6: { - StorageDead(_8); - StorageDead(_6); - StorageLive(_12); - _10 = discriminant(_9); - switchInt(move _10) -> [1: bb7, otherwise: bb9]; - } - - bb7: { - _11 = move ((_9 as Some).0: u16); - StorageDead(_12); - StorageDead(_9); - _0 = unchecked_shl::<u16>(_1, move _11) -> [return: bb8, unwind unreachable]; - } - - bb8: { - StorageDead(_11); return; } - - bb9: { - unreachable; - } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir index 0d692251051..35fee449c35 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -4,121 +4,12 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::<impl u16>::unchecked_shl) { - debug self => _1; - debug rhs => _2; - let mut _11: u16; - scope 2 { - scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { - debug x => _2; - let mut _6: std::result::Result<u16, std::num::TryFromIntError>; - let mut _9: std::option::Option<u16>; - scope 4 { - scope 5 (inlined <u32 as TryInto<u16>>::try_into) { - debug self => _2; - scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { - debug u => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: u16; - } - } - scope 7 (inlined Result::<u16, TryFromIntError>::ok) { - debug self => _6; - let mut _7: isize; - let _8: u16; - scope 8 { - debug x => _8; - } - } - scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { - debug self => _9; - let mut _10: isize; - let mut _12: &std::option::Option<u16>; - scope 10 { - debug val => _11; - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { - } - } - } - } - scope 12 (inlined Option::<u16>::is_some) { - debug self => _12; - } - } - } - } - } - } bb0: { - StorageLive(_11); - StorageLive(_9); - StorageLive(_6); - StorageLive(_4); - StorageLive(_3); - _3 = const 65535_u32; - _4 = Gt(_2, move _3); - StorageDead(_3); - switchInt(move _4) -> [0: bb1, otherwise: bb2]; + _0 = core::num::<impl u16>::unchecked_shl(_1, _2) -> bb1; } bb1: { - StorageLive(_5); - _5 = _2 as u16 (IntToInt); - _6 = Result::<u16, TryFromIntError>::Ok(move _5); - StorageDead(_5); - goto -> bb3; - } - - bb2: { - _6 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); - goto -> bb3; - } - - bb3: { - StorageDead(_4); - StorageLive(_8); - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; - } - - bb4: { - _8 = move ((_6 as Ok).0: u16); - _9 = Option::<u16>::Some(move _8); - goto -> bb6; - } - - bb5: { - _9 = Option::<u16>::None; - goto -> bb6; - } - - bb6: { - StorageDead(_8); - StorageDead(_6); - StorageLive(_12); - _10 = discriminant(_9); - switchInt(move _10) -> [1: bb7, otherwise: bb9]; - } - - bb7: { - _11 = move ((_9 as Some).0: u16); - StorageDead(_12); - StorageDead(_9); - _0 = unchecked_shl::<u16>(_1, move _11) -> [return: bb8, unwind unreachable]; - } - - bb8: { - StorageDead(_11); return; } - - bb9: { - unreachable; - } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff index 61155f5078f..1659a51b090 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff @@ -7,129 +7,19 @@ let mut _0: i16; let mut _3: i16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { -+ debug self => _3; -+ debug rhs => _4; -+ let mut _5: i16; -+ scope 2 { -+ scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { -+ debug x => _4; -+ let mut _6: std::option::Option<i16>; -+ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<i16>>::try_into) { -+ debug self => _4; -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { -+ debug u => _4; -+ let mut _8: bool; -+ let mut _9: u32; -+ let mut _10: i16; -+ } -+ } -+ scope 7 (inlined Result::<i16, TryFromIntError>::ok) { -+ debug self => _7; -+ let mut _11: isize; -+ let _12: i16; -+ scope 8 { -+ debug x => _12; -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { -+ debug self => _6; -+ let mut _13: &std::option::Option<i16>; -+ let mut _14: isize; -+ scope 10 { -+ debug val => _5; -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<i16>::is_some) { -+ debug self => _13; -+ } -+ } -+ } -+ } -+ } -+ } bb0: { StorageLive(_3); _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ StorageLive(_8); -+ StorageLive(_9); -+ _9 = const 32767_u32; -+ _8 = Gt(_4, move _9); -+ StorageDead(_9); -+ switchInt(move _8) -> [0: bb3, otherwise: bb2]; + _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; } bb1: { -+ StorageDead(_5); StorageDead(_4); StorageDead(_3); return; -+ } -+ -+ bb2: { -+ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); -+ goto -> bb4; -+ } -+ -+ bb3: { -+ StorageLive(_10); -+ _10 = _4 as i16 (IntToInt); -+ _7 = Result::<i16, TryFromIntError>::Ok(move _10); -+ StorageDead(_10); -+ goto -> bb4; -+ } -+ -+ bb4: { -+ StorageDead(_8); -+ StorageLive(_12); -+ _11 = discriminant(_7); -+ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; -+ } -+ -+ bb5: { -+ _6 = Option::<i16>::None; -+ goto -> bb8; -+ } -+ -+ bb6: { -+ unreachable; -+ } -+ -+ bb7: { -+ _12 = move ((_7 as Ok).0: i16); -+ _6 = Option::<i16>::Some(move _12); -+ goto -> bb8; -+ } -+ -+ bb8: { -+ StorageDead(_12); -+ StorageDead(_7); -+ StorageLive(_13); -+ _14 = discriminant(_6); -+ switchInt(move _14) -> [1: bb9, otherwise: bb6]; -+ } -+ -+ bb9: { -+ _5 = move ((_6 as Some).0: i16); -+ StorageDead(_13); -+ StorageDead(_6); -+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff index 181a423164b..cb5ec37feb3 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff @@ -7,129 +7,19 @@ let mut _0: i16; let mut _3: i16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { -+ debug self => _3; -+ debug rhs => _4; -+ let mut _5: i16; -+ scope 2 { -+ scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { -+ debug x => _4; -+ let mut _6: std::option::Option<i16>; -+ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<i16>>::try_into) { -+ debug self => _4; -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { -+ debug u => _4; -+ let mut _8: bool; -+ let mut _9: u32; -+ let mut _10: i16; -+ } -+ } -+ scope 7 (inlined Result::<i16, TryFromIntError>::ok) { -+ debug self => _7; -+ let mut _11: isize; -+ let _12: i16; -+ scope 8 { -+ debug x => _12; -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { -+ debug self => _6; -+ let mut _13: &std::option::Option<i16>; -+ let mut _14: isize; -+ scope 10 { -+ debug val => _5; -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<i16>::is_some) { -+ debug self => _13; -+ } -+ } -+ } -+ } -+ } -+ } bb0: { StorageLive(_3); _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> bb1; -+ StorageLive(_5); -+ StorageLive(_6); -+ StorageLive(_7); -+ StorageLive(_8); -+ StorageLive(_9); -+ _9 = const 32767_u32; -+ _8 = Gt(_4, move _9); -+ StorageDead(_9); -+ switchInt(move _8) -> [0: bb3, otherwise: bb2]; + _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> bb1; } bb1: { -+ StorageDead(_5); StorageDead(_4); StorageDead(_3); return; -+ } -+ -+ bb2: { -+ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); -+ goto -> bb4; -+ } -+ -+ bb3: { -+ StorageLive(_10); -+ _10 = _4 as i16 (IntToInt); -+ _7 = Result::<i16, TryFromIntError>::Ok(move _10); -+ StorageDead(_10); -+ goto -> bb4; -+ } -+ -+ bb4: { -+ StorageDead(_8); -+ StorageLive(_12); -+ _11 = discriminant(_7); -+ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; -+ } -+ -+ bb5: { -+ _6 = Option::<i16>::None; -+ goto -> bb8; -+ } -+ -+ bb6: { -+ unreachable; -+ } -+ -+ bb7: { -+ _12 = move ((_7 as Ok).0: i16); -+ _6 = Option::<i16>::Some(move _12); -+ goto -> bb8; -+ } -+ -+ bb8: { -+ StorageDead(_12); -+ StorageDead(_7); -+ StorageLive(_13); -+ _14 = discriminant(_6); -+ switchInt(move _14) -> [1: bb9, otherwise: bb6]; -+ } -+ -+ bb9: { -+ _5 = move ((_6 as Some).0: i16); -+ StorageDead(_13); -+ StorageDead(_6); -+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir index 66936df380b..9f2f40002a3 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir @@ -4,121 +4,12 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { debug a => _1; debug b => _2; let mut _0: i16; - scope 1 (inlined core::num::<impl i16>::unchecked_shr) { - debug self => _1; - debug rhs => _2; - let mut _11: i16; - scope 2 { - scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { - debug x => _2; - let mut _6: std::result::Result<i16, std::num::TryFromIntError>; - let mut _9: std::option::Option<i16>; - scope 4 { - scope 5 (inlined <u32 as TryInto<i16>>::try_into) { - debug self => _2; - scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { - debug u => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: i16; - } - } - scope 7 (inlined Result::<i16, TryFromIntError>::ok) { - debug self => _6; - let mut _7: isize; - let _8: i16; - scope 8 { - debug x => _8; - } - } - scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { - debug self => _9; - let mut _10: isize; - let mut _12: &std::option::Option<i16>; - scope 10 { - debug val => _11; - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { - } - } - } - } - scope 12 (inlined Option::<i16>::is_some) { - debug self => _12; - } - } - } - } - } - } bb0: { - StorageLive(_11); - StorageLive(_9); - StorageLive(_6); - StorageLive(_4); - StorageLive(_3); - _3 = const 32767_u32; - _4 = Gt(_2, move _3); - StorageDead(_3); - switchInt(move _4) -> [0: bb1, otherwise: bb2]; + _0 = core::num::<impl i16>::unchecked_shr(_1, _2) -> [return: bb1, unwind unreachable]; } bb1: { - StorageLive(_5); - _5 = _2 as i16 (IntToInt); - _6 = Result::<i16, TryFromIntError>::Ok(move _5); - StorageDead(_5); - goto -> bb3; - } - - bb2: { - _6 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); - goto -> bb3; - } - - bb3: { - StorageDead(_4); - StorageLive(_8); - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; - } - - bb4: { - _8 = move ((_6 as Ok).0: i16); - _9 = Option::<i16>::Some(move _8); - goto -> bb6; - } - - bb5: { - _9 = Option::<i16>::None; - goto -> bb6; - } - - bb6: { - StorageDead(_8); - StorageDead(_6); - StorageLive(_12); - _10 = discriminant(_9); - switchInt(move _10) -> [1: bb7, otherwise: bb9]; - } - - bb7: { - _11 = move ((_9 as Some).0: i16); - StorageDead(_12); - StorageDead(_9); - _0 = unchecked_shr::<i16>(_1, move _11) -> [return: bb8, unwind unreachable]; - } - - bb8: { - StorageDead(_11); return; } - - bb9: { - unreachable; - } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir index 66936df380b..aaf3bb62e8a 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir @@ -4,121 +4,12 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { debug a => _1; debug b => _2; let mut _0: i16; - scope 1 (inlined core::num::<impl i16>::unchecked_shr) { - debug self => _1; - debug rhs => _2; - let mut _11: i16; - scope 2 { - scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { - debug x => _2; - let mut _6: std::result::Result<i16, std::num::TryFromIntError>; - let mut _9: std::option::Option<i16>; - scope 4 { - scope 5 (inlined <u32 as TryInto<i16>>::try_into) { - debug self => _2; - scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { - debug u => _2; - let mut _3: u32; - let mut _4: bool; - let mut _5: i16; - } - } - scope 7 (inlined Result::<i16, TryFromIntError>::ok) { - debug self => _6; - let mut _7: isize; - let _8: i16; - scope 8 { - debug x => _8; - } - } - scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { - debug self => _9; - let mut _10: isize; - let mut _12: &std::option::Option<i16>; - scope 10 { - debug val => _11; - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { - } - } - } - } - scope 12 (inlined Option::<i16>::is_some) { - debug self => _12; - } - } - } - } - } - } bb0: { - StorageLive(_11); - StorageLive(_9); - StorageLive(_6); - StorageLive(_4); - StorageLive(_3); - _3 = const 32767_u32; - _4 = Gt(_2, move _3); - StorageDead(_3); - switchInt(move _4) -> [0: bb1, otherwise: bb2]; + _0 = core::num::<impl i16>::unchecked_shr(_1, _2) -> bb1; } bb1: { - StorageLive(_5); - _5 = _2 as i16 (IntToInt); - _6 = Result::<i16, TryFromIntError>::Ok(move _5); - StorageDead(_5); - goto -> bb3; - } - - bb2: { - _6 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); - goto -> bb3; - } - - bb3: { - StorageDead(_4); - StorageLive(_8); - _7 = discriminant(_6); - switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; - } - - bb4: { - _8 = move ((_6 as Ok).0: i16); - _9 = Option::<i16>::Some(move _8); - goto -> bb6; - } - - bb5: { - _9 = Option::<i16>::None; - goto -> bb6; - } - - bb6: { - StorageDead(_8); - StorageDead(_6); - StorageLive(_12); - _10 = discriminant(_9); - switchInt(move _10) -> [1: bb7, otherwise: bb9]; - } - - bb7: { - _11 = move ((_9 as Some).0: i16); - StorageDead(_12); - StorageDead(_9); - _0 = unchecked_shr::<i16>(_1, move _11) -> [return: bb8, unwind unreachable]; - } - - bb8: { - StorageDead(_11); return; } - - bb9: { - unreachable; - } } diff --git a/tests/rustdoc-gui/search-reexport.goml b/tests/rustdoc-gui/search-reexport.goml index c5c386ce750..6ea6d53e287 100644 --- a/tests/rustdoc-gui/search-reexport.goml +++ b/tests/rustdoc-gui/search-reexport.goml @@ -14,7 +14,7 @@ assert-attribute: ( "//a[@class='result-import']", {"href": "../test_docs/index.html#reexport.TheStdReexport"}, ) -assert-text: ("//a[@class='result-import']", "test_docs::TheStdReexport") +assert-text: ("a.result-import .result-name", "re-export test_docs::TheStdReexport") click: "//a[@class='result-import']" // We check that it has the background modified thanks to the focus. wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a3d"}) @@ -25,8 +25,8 @@ press-key: 'Enter' write: (".search-input", "AliasForTheStdReexport") wait-for: "//a[@class='result-import']" assert-text: ( - "//a[@class='result-import']", - "AliasForTheStdReexport - see test_docs::TheStdReexport", + "a.result-import .result-name", + "AliasForTheStdReexport - see re-export test_docs::TheStdReexport", ) // Same thing again, we click on it to ensure the background is once again set as expected. click: "//a[@class='result-import']" diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index 90f7160b724..c75e4141434 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -65,12 +65,6 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color of "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#788797"}, -) - 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 @@ -182,12 +176,6 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color for "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#ddd"}, -) - 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 @@ -284,12 +272,6 @@ assert-css: ( {"border-bottom-color": "#aaa3"} ) -// Checking the color for "keyword" text. -assert-css: ( - "//*[@class='result-name']//*[text()='(keyword)']", - {"color": "#000"}, -) - 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 diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index bf096f62c48..afb3a44be30 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -7,11 +7,11 @@ press-key: 'Enter' wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... -assert-css: (".search-results div.desc", {"width": "310px"}) +assert-size: (".search-results div.desc", {"width": 310}) set-window-size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. -assert-css: (".search-results div.desc", {"width": "566px"}) +assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. assert-css: (".search-results .result-name > span", {"display": "inline"}) diff --git a/tests/rustdoc-gui/search-result-keyword.goml b/tests/rustdoc-gui/search-result-keyword.goml index 5d56e9d9cd4..1b2be6d4e3e 100644 --- a/tests/rustdoc-gui/search-result-keyword.goml +++ b/tests/rustdoc-gui/search-result-keyword.goml @@ -5,9 +5,4 @@ write: (".search-input", "CookieMonster") press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#search-tabs" -// Note: The two next assert commands could be merged as one but readability would be -// less good. -// -// Checking that the CSS is displaying " (keyword)" in italic. -assert-text: (".result-name span.keyword > i", "(keyword)") -assert-text: (".result-name span.keyword", "CookieMonster (keyword)") +assert-text: (".result-keyword .result-name", "keyword CookieMonster") diff --git a/tests/rustdoc/generic-associated-types/gats.rs b/tests/rustdoc/generic-associated-types/gats.rs index 7ab82bb5829..605176e5fea 100644 --- a/tests/rustdoc/generic-associated-types/gats.rs +++ b/tests/rustdoc/generic-associated-types/gats.rs @@ -23,9 +23,9 @@ impl LendingIterator for () { pub struct Infinite<T>(T); // @has foo/trait.LendingIterator.html -// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T" +// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> = &'a T where Self: 'a" impl<T> LendingIterator for Infinite<T> { - type Item<'a> where Self: 'a = &'a T; + type Item<'a> = &'a T where Self: 'a; fn next<'a>(&'a self) -> Self::Item<'a> { &self.0 diff --git a/tests/ui/impl-trait/nested-return-type2-tait.stderr b/tests/ui/impl-trait/nested-return-type2-tait.stderr index a8eb69cfcb7..4383e8ab3a0 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait.stderr +++ b/tests/ui/impl-trait/nested-return-type2-tait.stderr @@ -8,10 +8,6 @@ LL | fn foo() -> impl Trait<Assoc = Sendable> { | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/nested-return-type3-tait.stderr b/tests/ui/impl-trait/nested-return-type3-tait.stderr index 5f58c8dca4a..d32944a0d72 100644 --- a/tests/ui/impl-trait/nested-return-type3-tait.stderr +++ b/tests/ui/impl-trait/nested-return-type3-tait.stderr @@ -8,10 +8,6 @@ LL | fn foo() -> impl Trait<Assoc = Sendable> { | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/nested-return-type3-tait2.stderr b/tests/ui/impl-trait/nested-return-type3-tait2.stderr index c07f6ead750..a2eddd11665 100644 --- a/tests/ui/impl-trait/nested-return-type3-tait2.stderr +++ b/tests/ui/impl-trait/nested-return-type3-tait2.stderr @@ -8,10 +8,6 @@ LL | type Traitable = impl Trait<Assoc = Sendable>; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs index af9dfe25bb4..01c933473ea 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs @@ -1,5 +1,7 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl PartialEq<(Foo, i32)>; struct Bar; @@ -11,7 +13,6 @@ impl PartialEq<(Foo, i32)> for Bar { } fn foo() -> Foo { - //~^ ERROR can't compare `Bar` with `(Bar, i32)` Bar } diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr deleted file mode 100644 index 7b63a3d0b9f..00000000000 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: can't compare `Bar` with `(Bar, i32)` - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:13:13 - | -LL | fn foo() -> Foo { - | ^^^ no implementation for `Bar == (Bar, i32)` -LL | -LL | Bar - | --- return type was inferred to be `Bar` here - | - = help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar` - = help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. 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 fe62a8f3288..bbd60d4398b 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 @@ -20,6 +20,11 @@ LL | fn eq(&self, _other: &(Foo, i32)) -> bool { | = note: expected signature `fn(&a::Bar, &(a::Bar, i32)) -> _` found signature `fn(&a::Bar, &(a::Foo, 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:10:9 + | +LL | fn eq(&self, _other: &(Foo, i32)) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unconstrained opaque type --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16 diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs index ad0a003e879..aab10be2de2 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs @@ -1,5 +1,3 @@ -// check-pass - #![feature(type_alias_impl_trait)] type Foo = impl PartialEq<(Foo, i32)>; @@ -13,6 +11,7 @@ impl PartialEq<(Bar, i32)> for Bar { } fn foo() -> Foo { + //~^ ERROR can't compare `Bar` with `(Foo, i32)` Bar } diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr new file mode 100644 index 00000000000..b98b859a99b --- /dev/null +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr @@ -0,0 +1,15 @@ +error[E0277]: can't compare `Bar` with `(Foo, i32)` + --> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13 + | +LL | fn foo() -> Foo { + | ^^^ no implementation for `Bar == (Foo, i32)` +LL | +LL | Bar + | --- return type was inferred to be `Bar` here + | + = help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar` + = help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lint/lint-ctypes-73249-2.rs b/tests/ui/lint/lint-ctypes-73249-2.rs index 691047c8a40..f30377d6c16 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.rs +++ b/tests/ui/lint/lint-ctypes-73249-2.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Baz {} +trait Baz {} impl Baz for () {} @@ -9,7 +9,7 @@ type Qux = impl Baz; fn assign() -> Qux {} -pub trait Foo { +trait Foo { type Assoc: 'static; } @@ -18,12 +18,12 @@ impl Foo for () { } #[repr(transparent)] -pub struct A<T: Foo> { +struct A<T: Foo> { x: &'static <T as Foo>::Assoc, } extern "C" { - pub fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` + fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73249-2.stderr b/tests/ui/lint/lint-ctypes-73249-2.stderr index 8073c33dd46..49fa54114b2 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.stderr +++ b/tests/ui/lint/lint-ctypes-73249-2.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73249-2.rs:26:25 + --> $DIR/lint-ctypes-73249-2.rs:26:21 | -LL | pub fn lint_me() -> A<()>; - | ^^^^^ not FFI-safe +LL | fn lint_me() -> A<()>; + | ^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251-1.rs b/tests/ui/lint/lint-ctypes-73251-1.rs index 145ba784f7c..fc11f23a104 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.rs +++ b/tests/ui/lint/lint-ctypes-73251-1.rs @@ -1,13 +1,13 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Baz {} +trait Baz {} impl Baz for u32 {} type Qux = impl Baz; -pub trait Foo { +trait Foo { type Assoc; } @@ -20,7 +20,7 @@ fn assign() -> Qux { } extern "C" { - pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `Qux` + fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73251-1.stderr b/tests/ui/lint/lint-ctypes-73251-1.stderr index 9f43576ad73..b4eb921b97e 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.stderr +++ b/tests/ui/lint/lint-ctypes-73251-1.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-1.rs:23:25 + --> $DIR/lint-ctypes-73251-1.rs:23:21 | -LL | pub fn lint_me() -> <u32 as Foo>::Assoc; - | ^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn lint_me() -> <u32 as Foo>::Assoc; + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251-2.rs b/tests/ui/lint/lint-ctypes-73251-2.rs index df71a945796..fbe0a58f3b5 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.rs +++ b/tests/ui/lint/lint-ctypes-73251-2.rs @@ -33,7 +33,7 @@ fn use_of_b() -> AliasB { } extern "C" { - pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `AliasA` + fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `AliasA` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73251-2.stderr b/tests/ui/lint/lint-ctypes-73251-2.stderr index 0b3de379c19..e44cd45bd30 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.stderr +++ b/tests/ui/lint/lint-ctypes-73251-2.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `AliasA`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-2.rs:36:25 + --> $DIR/lint-ctypes-73251-2.rs:36:21 | -LL | pub fn lint_me() -> <AliasB as TraitB>::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn lint_me() -> <AliasB as TraitB>::Assoc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251.rs b/tests/ui/lint/lint-ctypes-73251.rs index ebc2ca77b67..a00d1a75aec 100644 --- a/tests/ui/lint/lint-ctypes-73251.rs +++ b/tests/ui/lint/lint-ctypes-73251.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Foo { +trait Foo { type Assoc; } @@ -16,7 +16,7 @@ type Bar = impl Foo<Assoc = u32>; fn assign() -> Bar {} extern "C" { - pub fn lint_me() -> <Bar as Foo>::Assoc; + fn lint_me() -> <Bar as Foo>::Assoc; } fn main() {} diff --git a/tests/ui/lint/opaque-ty-ffi-unsafe.rs b/tests/ui/lint/opaque-ty-ffi-unsafe.rs index b7cc38e99fc..5faeac9ed4c 100644 --- a/tests/ui/lint/opaque-ty-ffi-unsafe.rs +++ b/tests/ui/lint/opaque-ty-ffi-unsafe.rs @@ -3,12 +3,12 @@ type A = impl Fn(); -pub fn ret_closure() -> A { +pub(crate) fn ret_closure() -> A { || {} } extern "C" { - pub fn a(_: A); + pub(crate) fn a(_: A); //~^ ERROR `extern` block uses type `A`, which is not FFI-safe [improper_ctypes] } diff --git a/tests/ui/lint/opaque-ty-ffi-unsafe.stderr b/tests/ui/lint/opaque-ty-ffi-unsafe.stderr index 33aa95854e3..ba9e18bcce5 100644 --- a/tests/ui/lint/opaque-ty-ffi-unsafe.stderr +++ b/tests/ui/lint/opaque-ty-ffi-unsafe.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `A`, which is not FFI-safe - --> $DIR/opaque-ty-ffi-unsafe.rs:11:17 + --> $DIR/opaque-ty-ffi-unsafe.rs:11:24 | -LL | pub fn a(_: A); - | ^ not FFI-safe +LL | pub(crate) fn a(_: A); + | ^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/mir/mir_alignment_check.rs b/tests/ui/mir/mir_alignment_check.rs index 68a5384b30d..d1bf3d46a7c 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 00000000000..56388c1047e --- /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/parser/lit-err-in-macro.rs b/tests/ui/parser/lit-err-in-macro.rs new file mode 100644 index 00000000000..cff8ee6b40c --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.rs @@ -0,0 +1,10 @@ +macro_rules! f { + ($abi:literal) => { + extern $abi fn f() {} + } +} + +f!("Foo"__); +//~^ ERROR suffixes on string literals are invalid + +fn main() {} diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/lit-err-in-macro.stderr new file mode 100644 index 00000000000..a61fb5c85d4 --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/lit-err-in-macro.rs:7:4 + | +LL | f!("Foo"__); + | ^^^^^^^ invalid suffix `__` + +error: aborting due to previous error + diff --git a/tests/ui/traits/issue-105231.rs b/tests/ui/traits/issue-105231.rs new file mode 100644 index 00000000000..74c7afd6b9e --- /dev/null +++ b/tests/ui/traits/issue-105231.rs @@ -0,0 +1,9 @@ +//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send` +struct A<T>(B<T>); +//~^ ERROR recursive types `A` and `B` have infinite size +struct B<T>(A<A<T>>); +trait Foo {} +impl<T> Foo for T where T: Send {} +impl Foo for B<u8> {} + +fn main() {} diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr new file mode 100644 index 00000000000..fe20c47c57a --- /dev/null +++ b/tests/ui/traits/issue-105231.stderr @@ -0,0 +1,29 @@ +error[E0072]: recursive types `A` and `B` have infinite size + --> $DIR/issue-105231.rs:2:1 + | +LL | struct A<T>(B<T>); + | ^^^^^^^^^^^ ---- recursive without indirection +LL | +LL | struct B<T>(A<A<T>>); + | ^^^^^^^^^^^ ------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL ~ struct A<T>(Box<B<T>>); +LL | +LL ~ struct B<T>(Box<A<A<T>>>); + | + +error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`) +note: required because it appears within the type `B<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<u8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-105231.rs:4:8 + | +LL | struct B<T>(A<A<T>>); + | ^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0072, E0275. +For more information about an error, try `rustc --explain E0072`. diff --git a/tests/ui/traits/new-solver/closure-substs-ambiguity.rs b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs new file mode 100644 index 00000000000..48432f4020f --- /dev/null +++ b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs @@ -0,0 +1,7 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn main() { + let mut x: Vec<_> = vec![]; + x.extend(Some(1i32).into_iter().map(|x| x)); +} diff --git a/tests/ui/traits/new-solver/opportunistic-region-resolve.rs b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs new file mode 100644 index 00000000000..2610789cd48 --- /dev/null +++ b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(rustc_attrs)] + +#[rustc_coinductive] +trait Trait {} + +#[rustc_coinductive] +trait Indirect {} +impl<T: Trait + ?Sized> Indirect for T {} + +impl<'a> Trait for &'a () where &'a (): Indirect {} + +fn impls_trait<T: Trait>() {} + +fn main() { + impls_trait::<&'static ()>(); +} diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs index a1584581e6c..d9f7c7809b9 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs @@ -4,9 +4,9 @@ #![allow(dead_code)] mod m { - type Foo = impl std::fmt::Debug; + pub(crate) type Foo = impl std::fmt::Debug; - pub fn foo() -> Foo { + pub(crate) fn foo() -> Foo { 22_u32 } } diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs new file mode 100644 index 00000000000..5a9e87c0919 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +use std::fmt::{Debug, Display}; + +struct Struct<V: Display>(Option<V>); + +// Make sure that, in contrast to type aliases without opaque types, +// we actually do a wf check for the aliased type. +type Foo<T: Debug> = (impl Debug, Struct<T>); +//~^ ERROR: `T` doesn't implement `std::fmt::Display` + +fn foo<U: Debug + Display>() -> Foo<U> { + (Vec::<U>::new(), Struct(None)) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr new file mode 100644 index 00000000000..a845cba7716 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr @@ -0,0 +1,20 @@ +error[E0277]: `T` doesn't implement `std::fmt::Display` + --> $DIR/bounds-are-checked3.rs:9:35 + | +LL | type Foo<T: Debug> = (impl Debug, Struct<T>); + | ^^^^^^^^^ `T` cannot be formatted with the default formatter + | + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Struct` + --> $DIR/bounds-are-checked3.rs:5:18 + | +LL | struct Struct<V: Display>(Option<V>); + | ^^^^^^^ required by this bound in `Struct` +help: consider further restricting this bound + | +LL | type Foo<T: Debug + std::fmt::Display> = (impl Debug, Struct<T>); + | +++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/bounds.rs b/tests/ui/type-alias-impl-trait/bounds.rs new file mode 100644 index 00000000000..dc05b70c5cc --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +// check-pass + +use std::fmt::Debug; + +// No need to report the `type_alias_bounds` lint, as +// the moment an opaque type is mentioned, we actually do check +// type alias bounds. +type Foo<T: Debug> = (impl Debug, usize); + +fn foo<U: Debug>() -> Foo<U> { + (Vec::<U>::new(), 1234) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr index 00b0dbbb583..c923eb08ab3 100644 --- a/tests/ui/type-alias-impl-trait/coherence.stderr +++ b/tests/ui/type-alias-impl-trait/coherence.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate + | | `AliasOfForeignType<T>` 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 diff --git a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs index 8b51f55715e..4d84b2cbbe9 100644 --- a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs +++ b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs @@ -11,12 +11,12 @@ type Foo = impl std::fmt::Display; type Bar = impl std::fmt::Display; mod foo { - pub fn foo() -> super::Foo { + pub(crate) fn foo() -> super::Foo { "foo" } - pub mod bar { - pub fn bar() -> crate::Bar { + pub(crate) mod bar { + pub(crate) fn bar() -> crate::Bar { 1 } } diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr index c73288329b0..bc9280127ac 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -4,11 +4,11 @@ error[E0277]: the trait bound `T: Trait` is not satisfied LL | fn underconstrain<T>(_: T) -> Underconstrained<T> { | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | -note: required by a bound in `Underconstrained` +note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained.rs:6:26 | LL | type Underconstrained<T: Trait> = impl Send; - | ^^^^^ required by this bound in `Underconstrained` + | ^^^^^ required by this bound help: consider restricting type parameter `T` | LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> { diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr index d77d978aa44..fdc9ec090db 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -4,11 +4,11 @@ error[E0277]: `U` doesn't implement `Debug` LL | fn underconstrained<U>(_: U) -> Underconstrained<U> { | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` | -note: required by a bound in `Underconstrained` +note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 | LL | type Underconstrained<T: std::fmt::Debug> = impl Send; - | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained` + | ^^^^^^^^^^^^^^^ required by this bound help: consider restricting type parameter `U` | LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> { @@ -20,11 +20,11 @@ error[E0277]: `V` doesn't implement `Debug` LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | -note: required by a bound in `Underconstrained2` +note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:13:27 | LL | type Underconstrained2<T: std::fmt::Debug> = impl Send; - | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained2` + | ^^^^^^^^^^^^^^^ required by this bound help: consider restricting type parameter `V` | LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> { diff --git a/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs new file mode 100644 index 00000000000..00d1a1a226d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs @@ -0,0 +1,14 @@ +#![feature(type_alias_impl_trait)] +#![feature(auto_traits)] + +type Alias = (impl Sized, u8); + +auto trait Trait {} +impl Trait for Alias {} +//~^ ERROR traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias` + +fn _def() -> Alias { + (42, 42) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr new file mode 100644 index 00000000000..c312ee7dece --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr @@ -0,0 +1,11 @@ +error[E0321]: traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias` + --> $DIR/impl_for_weak_alias.rs:7:1 + | +LL | impl Trait for Alias {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: a trait object implements `Trait` if and only if `Trait` is one of the trait object's trait bounds + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0321`. diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs index 4a11bb5020e..b89c3e4590f 100644 --- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs +++ b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs @@ -1,9 +1,10 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl Fn() -> Foo; fn foo() -> Foo { -//~^ ERROR: overflow evaluating the requirement foo } diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr deleted file mode 100644 index 0a34e8486a5..00000000000 --- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0275]: overflow evaluating the requirement `Foo: Sized` - --> $DIR/issue-53398-cyclic-types.rs:5:13 - | -LL | fn foo() -> Foo { - | ^^^ - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`) - = note: required because it appears within the type `fn() -> Foo {foo}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/obligation_ice.rs b/tests/ui/type-alias-impl-trait/obligation_ice.rs new file mode 100644 index 00000000000..5aef04ff19c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/obligation_ice.rs @@ -0,0 +1,17 @@ +#![feature(type_alias_impl_trait)] +// check-pass + +use std::iter::{once, Chain}; + +trait Trait<'a, 'b: 'a> {} + +impl<'a, 'b: 'a, T> Trait<'a, 'b> for std::iter::Cloned<T> {} + +type I<'a, 'b: 'a, A: Trait<'a, 'b>> = Chain<A, impl Iterator<Item = &'static str>>; +fn test2<'a, 'b, A: Trait<'a, 'b> + Iterator<Item = &'static str>>(x: A) -> I<'a, 'b, A> { + x.chain(once("5")) +} + +fn main() { + assert_eq!(vec!["1", "3", "5"], test2(["1", "3"].iter().cloned()).collect::<Vec<_>>()); +} diff --git a/tests/ui/type-alias-impl-trait/privacy.rs b/tests/ui/type-alias-impl-trait/privacy.rs new file mode 100644 index 00000000000..aa092f6f8ec --- /dev/null +++ b/tests/ui/type-alias-impl-trait/privacy.rs @@ -0,0 +1,8 @@ +#![feature(type_alias_impl_trait)] + +type Foo = (impl Sized, u8); +pub fn foo() -> Foo { + //~^ ERROR private type alias `Foo` in public interface + (42, 42) +} +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/privacy.stderr b/tests/ui/type-alias-impl-trait/privacy.stderr new file mode 100644 index 00000000000..e8c6039cdc8 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/privacy.stderr @@ -0,0 +1,11 @@ +error[E0446]: private type alias `Foo` in public interface + --> $DIR/privacy.rs:4:1 + | +LL | type Foo = (impl Sized, u8); + | -------- `Foo` declared as private +LL | pub fn foo() -> Foo { + | ^^^^^^^^^^^^^^^^^^^ can't leak private type alias + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.rs b/tests/ui/type-alias-impl-trait/self-referential-3.rs index d40715717d4..18f09b54867 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-3.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-3.rs @@ -1,9 +1,9 @@ -// run-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> { + //~^ ERROR can't compare `&i32` with `Bar<'a, 'b>` i } diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.stderr b/tests/ui/type-alias-impl-trait/self-referential-3.stderr new file mode 100644 index 00000000000..4155a114b4f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/self-referential-3.stderr @@ -0,0 +1,15 @@ +error[E0277]: can't compare `&i32` with `Bar<'a, 'b>` + --> $DIR/self-referential-3.rs:5:31 + | +LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'a, 'b>` +LL | +LL | i + | - return type was inferred to be `&i32` here + | + = help: the trait `PartialEq<Bar<'a, 'b>>` is not implemented for `&i32` + = help: the trait `PartialEq` is implemented for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/self-referential.rs b/tests/ui/type-alias-impl-trait/self-referential.rs index 3ff5406a382..34b7c24df9f 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.rs +++ b/tests/ui/type-alias-impl-trait/self-referential.rs @@ -10,7 +10,7 @@ fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { type Foo<'a, 'b> = (i32, impl PartialEq<Foo<'a, 'b>> + std::fmt::Debug); fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - //~^ ERROR can't compare `&i32` with `(i32, &i32)` + //~^ ERROR can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})` (42, i) } diff --git a/tests/ui/type-alias-impl-trait/self-referential.stderr b/tests/ui/type-alias-impl-trait/self-referential.stderr index aff489d70e3..9a17d495b62 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential.stderr @@ -10,16 +10,16 @@ LL | i = help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32` = help: the trait `PartialEq` is implemented for `i32` -error[E0277]: can't compare `&i32` with `(i32, &i32)` +error[E0277]: can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})` --> $DIR/self-referential.rs:12:31 | LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - | ^^^^^^^^^^^ no implementation for `&i32 == (i32, &i32)` + | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Foo<'a, 'b>::{opaque#0})` LL | LL | (42, i) | ------- return type was inferred to be `(i32, &i32)` here | - = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` + = help: the trait `PartialEq<(i32, Foo<'a, 'b>::{opaque#0})>` is not implemented for `&i32` = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs index 07c891f0638..4e7388517a5 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs @@ -4,20 +4,20 @@ // Regression test for issue #61863 -pub trait MyTrait {} +trait MyTrait {} #[derive(Debug)] -pub struct MyStruct { +struct MyStruct { v: u64, } impl MyTrait for MyStruct {} -pub fn bla() -> TE { +fn bla() -> TE { return MyStruct { v: 1 }; } -pub fn bla2() -> TE { +fn bla2() -> TE { bla() } diff --git a/tests/ui/type-alias-impl-trait/unnameable_type.stderr b/tests/ui/type-alias-impl-trait/unnameable_type.stderr index e9032433494..24f5cc8c733 100644 --- a/tests/ui/type-alias-impl-trait/unnameable_type.stderr +++ b/tests/ui/type-alias-impl-trait/unnameable_type.stderr @@ -25,6 +25,11 @@ LL | fn dont_define_this(_private: Private) {} | ^^^^^^^ = note: expected signature `fn(Private)` found signature `fn(MyPrivate)` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/unnameable_type.rs:20:5 + | +LL | fn dont_define_this(_private: MyPrivate) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors |
