diff options
Diffstat (limited to 'tests')
54 files changed, 984 insertions, 77 deletions
diff --git a/tests/codegen/consts.rs b/tests/codegen/consts.rs index dd22fd0f7e8..8a135039c06 100644 --- a/tests/codegen/consts.rs +++ b/tests/codegen/consts.rs @@ -9,7 +9,7 @@ // CHECK: @STATIC = {{.*}}, align 4 // This checks the constants from inline_enum_const -// CHECK: @alloc_76bfe2f13a3e3b01074971d122eac57e = {{.*}}, align 2 +// CHECK: @alloc_701ed935fbda2002838d0a2cbbc171e5 = {{.*}}, align 2 // This checks the constants from {low,high}_align_const, they share the same // constant, but the alignment differs, so the higher one should be used diff --git a/tests/codegen/remap_path_prefix/main.rs b/tests/codegen/remap_path_prefix/main.rs index 6c0cd6997d0..85523d053b5 100644 --- a/tests/codegen/remap_path_prefix/main.rs +++ b/tests/codegen/remap_path_prefix/main.rs @@ -12,7 +12,7 @@ mod aux_mod; include!("aux_mod.rs"); // Here we check that the expansion of the file!() macro is mapped. -// CHECK: @alloc_92a59126a55aa3c0019b6c8a007fe001 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }> +// CHECK: @alloc_af9d0c7bc6ca3c31bb051d2862714536 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }> pub static FILE_PATH: &'static str = file!(); fn main() { diff --git a/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff new file mode 100644 index 00000000000..c44a14075ef --- /dev/null +++ b/tests/mir-opt/combine_transmutes.adt_transmutes.InstCombine.diff @@ -0,0 +1,158 @@ +- // MIR for `adt_transmutes` before InstCombine ++ // MIR for `adt_transmutes` after InstCombine + + fn adt_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:32: +0:32 + let _1: u8; // in scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let mut _2: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + let mut _4: EnumNoRepr; // in scope 0 at $DIR/combine_transmutes.rs:+2:28: +2:41 + let mut _6: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+3:31: +3:47 + let mut _8: EnumReprIsize; // in scope 0 at $DIR/combine_transmutes.rs:+4:31: +4:47 + let mut _10: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+5:28: +5:52 + let mut _12: std::cmp::Ordering; // in scope 0 at $DIR/combine_transmutes.rs:+6:28: +6:52 + let mut _14: std::option::Option<std::num::NonZeroU8>; // in scope 0 at $DIR/combine_transmutes.rs:+7:28: +7:58 + let mut _16: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+8:29: +8:54 + let mut _18: std::num::Wrapping<i16>; // in scope 0 at $DIR/combine_transmutes.rs:+9:29: +9:54 + let mut _20: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+10:29: +10:47 + let mut _22: Union32; // in scope 0 at $DIR/combine_transmutes.rs:+11:29: +11:47 + let mut _24: std::mem::MaybeUninit<std::string::String>; // in scope 0 at $DIR/combine_transmutes.rs:+12:46: +12:77 + scope 1 { + debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+1:9: +1:11 + let _3: i8; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + scope 2 { + debug _a => _3; // in scope 2 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let _5: usize; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + scope 3 { + debug _a => _5; // in scope 3 at $DIR/combine_transmutes.rs:+3:9: +3:11 + let _7: isize; // in scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + scope 4 { + debug _a => _7; // in scope 4 at $DIR/combine_transmutes.rs:+4:9: +4:11 + let _9: u8; // in scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + scope 5 { + debug _a => _9; // in scope 5 at $DIR/combine_transmutes.rs:+5:9: +5:11 + let _11: i8; // in scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + scope 6 { + debug _a => _11; // in scope 6 at $DIR/combine_transmutes.rs:+6:9: +6:11 + let _13: u8; // in scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 + scope 7 { + debug _a => _13; // in scope 7 at $DIR/combine_transmutes.rs:+7:9: +7:11 + let _15: i16; // in scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 + scope 8 { + debug _a => _15; // in scope 8 at $DIR/combine_transmutes.rs:+8:9: +8:11 + let _17: u16; // in scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 + scope 9 { + debug _a => _17; // in scope 9 at $DIR/combine_transmutes.rs:+9:9: +9:11 + let _19: u32; // in scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 + scope 10 { + debug _a => _19; // in scope 10 at $DIR/combine_transmutes.rs:+10:9: +10:11 + let _21: i32; // in scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 + scope 11 { + debug _a => _21; // in scope 11 at $DIR/combine_transmutes.rs:+11:9: +11:11 + let _23: std::mem::ManuallyDrop<std::string::String>; // in scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 + scope 12 { + debug _a => _23; // in scope 12 at $DIR/combine_transmutes.rs:+12:9: +12:11 + } + } + } + } + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+1:9: +1:11 + StorageLive(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + _2 = EnumNoRepr::A; // scope 0 at $DIR/combine_transmutes.rs:+1:28: +1:41 + _1 = move _2 as u8 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+1:18: +1:42 + StorageDead(_2); // scope 0 at $DIR/combine_transmutes.rs:+1:41: +1:42 + StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + StorageLive(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 + _4 = EnumNoRepr::B; // scope 1 at $DIR/combine_transmutes.rs:+2:28: +2:41 + _3 = move _4 as i8 (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+2:18: +2:42 + StorageDead(_4); // scope 1 at $DIR/combine_transmutes.rs:+2:41: +2:42 + StorageLive(_5); // scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + StorageLive(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 + _6 = EnumReprIsize::A; // scope 2 at $DIR/combine_transmutes.rs:+3:31: +3:47 + _5 = move _6 as usize (Transmute); // scope 2 at $DIR/combine_transmutes.rs:+3:21: +3:48 + StorageDead(_6); // scope 2 at $DIR/combine_transmutes.rs:+3:47: +3:48 + StorageLive(_7); // scope 3 at $DIR/combine_transmutes.rs:+4:9: +4:11 + StorageLive(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 + _8 = EnumReprIsize::B; // scope 3 at $DIR/combine_transmutes.rs:+4:31: +4:47 +- _7 = move _8 as isize (Transmute); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 ++ _7 = discriminant(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:21: +4:48 + StorageDead(_8); // scope 3 at $DIR/combine_transmutes.rs:+4:47: +4:48 + StorageLive(_9); // scope 4 at $DIR/combine_transmutes.rs:+5:9: +5:11 + StorageLive(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 + _10 = Less; // scope 4 at $DIR/combine_transmutes.rs:+5:28: +5:52 + _9 = move _10 as u8 (Transmute); // scope 4 at $DIR/combine_transmutes.rs:+5:18: +5:53 + StorageDead(_10); // scope 4 at $DIR/combine_transmutes.rs:+5:52: +5:53 + StorageLive(_11); // scope 5 at $DIR/combine_transmutes.rs:+6:9: +6:11 + StorageLive(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 + _12 = Less; // scope 5 at $DIR/combine_transmutes.rs:+6:28: +6:52 +- _11 = move _12 as i8 (Transmute); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 ++ _11 = discriminant(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:18: +6:53 + StorageDead(_12); // scope 5 at $DIR/combine_transmutes.rs:+6:52: +6:53 + StorageLive(_13); // scope 6 at $DIR/combine_transmutes.rs:+7:9: +7:11 + StorageLive(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 + _14 = Option::<NonZeroU8>::Some(const _); // scope 6 at $DIR/combine_transmutes.rs:+7:28: +7:58 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:41:33: 41:57 + // + literal: Const { ty: NonZeroU8, val: Unevaluated(NonZeroU8::MAX, [], None) } + _13 = move _14 as u8 (Transmute); // scope 6 at $DIR/combine_transmutes.rs:+7:18: +7:59 + StorageDead(_14); // scope 6 at $DIR/combine_transmutes.rs:+7:58: +7:59 + StorageLive(_15); // scope 7 at $DIR/combine_transmutes.rs:+8:9: +8:11 + StorageLive(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 + _16 = Wrapping::<i16>(const 0_i16); // scope 7 at $DIR/combine_transmutes.rs:+8:29: +8:54 +- _15 = move _16 as i16 (Transmute); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 ++ _15 = move (_16.0: i16); // scope 7 at $DIR/combine_transmutes.rs:+8:19: +8:55 + StorageDead(_16); // scope 7 at $DIR/combine_transmutes.rs:+8:54: +8:55 + StorageLive(_17); // scope 8 at $DIR/combine_transmutes.rs:+9:9: +9:11 + StorageLive(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 + _18 = Wrapping::<i16>(const 0_i16); // scope 8 at $DIR/combine_transmutes.rs:+9:29: +9:54 + _17 = move _18 as u16 (Transmute); // scope 8 at $DIR/combine_transmutes.rs:+9:19: +9:55 + StorageDead(_18); // scope 8 at $DIR/combine_transmutes.rs:+9:54: +9:55 + StorageLive(_19); // scope 9 at $DIR/combine_transmutes.rs:+10:9: +10:11 + StorageLive(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 + _20 = Union32 { u32: const 0_i32 }; // scope 9 at $DIR/combine_transmutes.rs:+10:29: +10:47 + _19 = move _20 as u32 (Transmute); // scope 9 at $DIR/combine_transmutes.rs:+10:19: +10:48 + StorageDead(_20); // scope 9 at $DIR/combine_transmutes.rs:+10:47: +10:48 + StorageLive(_21); // scope 10 at $DIR/combine_transmutes.rs:+11:9: +11:11 + StorageLive(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 + _22 = Union32 { u32: const 0_u32 }; // scope 10 at $DIR/combine_transmutes.rs:+11:29: +11:47 + _21 = move _22 as i32 (Transmute); // scope 10 at $DIR/combine_transmutes.rs:+11:19: +11:48 + StorageDead(_22); // scope 10 at $DIR/combine_transmutes.rs:+11:47: +11:48 + StorageLive(_23); // scope 11 at $DIR/combine_transmutes.rs:+12:9: +12:11 + StorageLive(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 + _24 = MaybeUninit::<String>::uninit() -> bb1; // scope 11 at $DIR/combine_transmutes.rs:+12:46: +12:77 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:46:46: 46:75 + // + user_ty: UserType(23) + // + literal: Const { ty: fn() -> MaybeUninit<String> {MaybeUninit::<String>::uninit}, val: Value(<ZST>) } + } + + bb1: { +- _23 = move _24 as std::mem::ManuallyDrop<std::string::String> (Transmute); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 ++ _23 = move (_24.1: std::mem::ManuallyDrop<std::string::String>); // scope 11 at $DIR/combine_transmutes.rs:+12:36: +12:78 + StorageDead(_24); // scope 11 at $DIR/combine_transmutes.rs:+12:77: +12:78 + _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:32: +13:2 + StorageDead(_23); // scope 11 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_21); // scope 10 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_19); // scope 9 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_17); // scope 8 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_15); // scope 7 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_13); // scope 6 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_11); // scope 5 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_9); // scope 4 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_7); // scope 3 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_5); // scope 2 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+13:1: +13:2 + StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+13:1: +13:2 + return; // scope 0 at $DIR/combine_transmutes.rs:+13:2: +13:2 + } + } + diff --git a/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff new file mode 100644 index 00000000000..c83c9f5acf4 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.identity_transmutes.InstCombine.diff @@ -0,0 +1,43 @@ +- // MIR for `identity_transmutes` before InstCombine ++ // MIR for `identity_transmutes` after InstCombine + + fn identity_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:37: +0:37 + let _1: i32; // in scope 0 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let mut _3: std::vec::Vec<i32>; // in scope 0 at $DIR/combine_transmutes.rs:+3:46: +3:56 + scope 1 { + debug _a => _1; // in scope 1 at $DIR/combine_transmutes.rs:+2:9: +2:11 + let _2: std::vec::Vec<i32>; // in scope 1 at $DIR/combine_transmutes.rs:+3:9: +3:11 + scope 2 { + debug _a => _2; // in scope 2 at $DIR/combine_transmutes.rs:+3:9: +3:11 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/combine_transmutes.rs:+2:9: +2:11 +- _1 = const 1_i32 as i32 (Transmute); // scope 0 at $DIR/combine_transmutes.rs:+2:14: +2:38 ++ _1 = const 1_i32; // scope 0 at $DIR/combine_transmutes.rs:+2:14: +2:38 + StorageLive(_2); // scope 1 at $DIR/combine_transmutes.rs:+3:9: +3:11 + StorageLive(_3); // scope 1 at $DIR/combine_transmutes.rs:+3:46: +3:56 + _3 = Vec::<i32>::new() -> bb1; // scope 1 at $DIR/combine_transmutes.rs:+3:46: +3:56 + // mir::Constant + // + span: $DIR/combine_transmutes.rs:15:46: 15:54 + // + user_ty: UserType(0) + // + literal: Const { ty: fn() -> Vec<i32> {Vec::<i32>::new}, val: Value(<ZST>) } + } + + bb1: { +- _2 = move _3 as std::vec::Vec<i32> (Transmute); // scope 1 at $DIR/combine_transmutes.rs:+3:14: +3:57 ++ _2 = move _3; // scope 1 at $DIR/combine_transmutes.rs:+3:14: +3:57 + StorageDead(_3); // scope 1 at $DIR/combine_transmutes.rs:+3:56: +3:57 + _0 = const (); // scope 0 at $DIR/combine_transmutes.rs:+0:37: +4:2 + drop(_2) -> bb2; // scope 1 at $DIR/combine_transmutes.rs:+4:1: +4:2 + } + + bb2: { + StorageDead(_2); // scope 1 at $DIR/combine_transmutes.rs:+4:1: +4:2 + StorageDead(_1); // scope 0 at $DIR/combine_transmutes.rs:+4:1: +4:2 + return; // scope 0 at $DIR/combine_transmutes.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff b/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff new file mode 100644 index 00000000000..8de7c34e6b2 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.integer_transmutes.InstCombine.diff @@ -0,0 +1,24 @@ +- // MIR for `integer_transmutes` before InstCombine ++ // MIR for `integer_transmutes` after InstCombine + + fn integer_transmutes() -> () { + let mut _0: (); // return place in scope 0 at $DIR/combine_transmutes.rs:+0:36: +0:36 + let mut _1: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: i64; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i64; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _1 = const 1_i32 as u32 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _1 = const 1_i32 as u32 (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _2 = const 1_i32 as i64 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _3 = const 1_u64 as i64 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _3 = const 1_u64 as i64 (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _4 = const 1_u64 as u32 (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _5 = const 1_isize as usize (Transmute); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _5 = const 1_isize as usize (IntToInt); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + return; // scope 0 at $DIR/combine_transmutes.rs:+8:13: +8:21 + } + } + diff --git a/tests/mir-opt/combine_transmutes.rs b/tests/mir-opt/combine_transmutes.rs new file mode 100644 index 00000000000..de9b9c35c03 --- /dev/null +++ b/tests/mir-opt/combine_transmutes.rs @@ -0,0 +1,65 @@ +// unit-test: InstCombine +// compile-flags: -C panic=abort + +#![crate_type = "lib"] +#![feature(core_intrinsics)] +#![feature(custom_mir)] + +use std::intrinsics::mir::*; +use std::mem::{MaybeUninit, ManuallyDrop, transmute}; + +// EMIT_MIR combine_transmutes.identity_transmutes.InstCombine.diff +pub unsafe fn identity_transmutes() { + // These are nops and should be removed + let _a = transmute::<i32, i32>(1); + let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new()); +} + +#[custom_mir(dialect = "runtime", phase = "initial")] +// EMIT_MIR combine_transmutes.integer_transmutes.InstCombine.diff +pub unsafe fn integer_transmutes() { + mir! { + { + let A = CastTransmute::<i32, u32>(1); // Can be a cast + let B = CastTransmute::<i32, i64>(1); // UB + let C = CastTransmute::<u64, i64>(1); // Can be a cast + let D = CastTransmute::<u64, u32>(1); // UB + let E = CastTransmute::<isize, usize>(1); // Can be a cast + Return() + } + } +} + +// EMIT_MIR combine_transmutes.adt_transmutes.InstCombine.diff +pub unsafe fn adt_transmutes() { + let _a: u8 = transmute(EnumNoRepr::A); + let _a: i8 = transmute(EnumNoRepr::B); + let _a: usize = transmute(EnumReprIsize::A); + let _a: isize = transmute(EnumReprIsize::B); + let _a: u8 = transmute(std::cmp::Ordering::Less); + let _a: i8 = transmute(std::cmp::Ordering::Less); + let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX)); + let _a: i16 = transmute(std::num::Wrapping(0_i16)); + let _a: u16 = transmute(std::num::Wrapping(0_i16)); + let _a: u32 = transmute(Union32 { i32: 0 }); + let _a: i32 = transmute(Union32 { u32: 0 }); + let _a: ManuallyDrop<String> = transmute(MaybeUninit::<String>::uninit()); +} + +#[inline(always)] +#[custom_mir(dialect = "runtime", phase = "initial")] +const unsafe fn mir_transmute<T, U>(x: T) -> U { + mir!{ + { + RET = CastTransmute(x); + Return() + } + } +} + +pub enum EnumNoRepr { A, B, C } + +#[repr(isize)] +pub enum EnumReprIsize { A, B, C } + +pub union Union32 { u32: u32, i32: i32 } diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 225f80ed41b..f6f2344e82f 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -19,12 +19,12 @@ let mut _17: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let _18: &[core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL let _19: [core::fmt::ArgumentV1<'_>; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _20: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:21: +10:22 - let mut _21: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:21: +10:22 - let _22: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:21: +10:22 - let mut _23: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:25: +10:26 - let mut _24: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:25: +10:26 - let _25: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:25: +10:26 + let mut _20: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let mut _21: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let _22: &std::boxed::Box<dyn std::fmt::Display>; // in scope 0 at $DIR/lifetimes.rs:+10:20: +10:23 + let mut _23: core::fmt::ArgumentV1<'_>; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let mut _24: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 + let _25: &u32; // in scope 0 at $DIR/lifetimes.rs:+10:24: +10:27 let mut _27: bool; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 let mut _28: isize; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 let mut _29: isize; // in scope 0 at $DIR/lifetimes.rs:+12:1: +12:2 @@ -108,34 +108,34 @@ StorageLive(_17); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_20); // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - StorageLive(_21); // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - StorageLive(_22); // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - _22 = &_8; // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - _21 = &(*_22); // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - _20 = core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _21) -> bb3; // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 + StorageLive(_20); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + StorageLive(_21); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + StorageLive(_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _22 = &_8; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _21 = &(*_22); // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 + _20 = core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>(move _21) -> bb3; // scope 4 at $DIR/lifetimes.rs:+10:20: +10:23 // mir::Constant - // + span: $DIR/lifetimes.rs:27:21: 27:22 + // + span: $DIR/lifetimes.rs:27:20: 27:23 // + user_ty: UserType(4) // + literal: Const { ty: for<'b> fn(&'b Box<dyn std::fmt::Display>) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<Box<dyn std::fmt::Display>>}, val: Value(<ZST>) } } bb3: { - StorageDead(_21); // scope 4 at $DIR/lifetimes.rs:+10:21: +10:22 - StorageLive(_23); // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 - StorageLive(_24); // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 - StorageLive(_25); // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 - _25 = &_6; // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 - _24 = &(*_25); // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 - _23 = core::fmt::ArgumentV1::<'_>::new_display::<u32>(move _24) -> bb4; // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 + StorageDead(_21); // scope 4 at $DIR/lifetimes.rs:+10:22: +10:23 + StorageLive(_23); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + StorageLive(_24); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + StorageLive(_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _25 = &_6; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _24 = &(*_25); // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 + _23 = core::fmt::ArgumentV1::<'_>::new_display::<u32>(move _24) -> bb4; // scope 4 at $DIR/lifetimes.rs:+10:24: +10:27 // mir::Constant - // + span: $DIR/lifetimes.rs:27:25: 27:26 + // + span: $DIR/lifetimes.rs:27:24: 27:27 // + user_ty: UserType(5) // + literal: Const { ty: for<'b> fn(&'b u32) -> core::fmt::ArgumentV1<'b> {core::fmt::ArgumentV1::<'_>::new_display::<u32>}, val: Value(<ZST>) } } bb4: { - StorageDead(_24); // scope 4 at $DIR/lifetimes.rs:+10:25: +10:26 + StorageDead(_24); // scope 4 at $DIR/lifetimes.rs:+10:26: +10:27 _19 = [move _20, move _23]; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL StorageDead(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL diff --git a/tests/run-make/jobserver-error/Makefile b/tests/run-make/jobserver-error/Makefile new file mode 100644 index 00000000000..3b9104fc354 --- /dev/null +++ b/tests/run-make/jobserver-error/Makefile @@ -0,0 +1,8 @@ +include ../../run-make-fulldeps/tools.mk + +# only-linux + +# Test compiler behavior in case: `jobserver-auth` points to correct pipe which is not jobserver. + +all: + bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC) - 3</dev/null' 2>&1 | diff jobserver.stderr - diff --git a/tests/run-make/jobserver-error/jobserver.stderr b/tests/run-make/jobserver-error/jobserver.stderr new file mode 100644 index 00000000000..d18e15a2628 --- /dev/null +++ b/tests/run-make/jobserver-error/jobserver.stderr @@ -0,0 +1,4 @@ +error: failed to acquire jobserver token: early EOF on jobserver pipe + +error: aborting due to previous error + diff --git a/tests/rustdoc-json/non_lifetime_binders.rs b/tests/rustdoc-json/non_lifetime_binders.rs new file mode 100644 index 00000000000..ca5a008344a --- /dev/null +++ b/tests/rustdoc-json/non_lifetime_binders.rs @@ -0,0 +1,24 @@ +// ignore-tidy-linelength + +#![feature(non_lifetime_binders)] +#![allow(incomplete_features)] + +#![no_core] +#![feature(lang_items, no_core)] + +#[lang = "sized"] +pub trait Sized {} + +pub trait Trait {} + +#[lang = "phantom_data"] +struct PhantomData<T_>; + +pub struct Wrapper<T_>(PhantomData<T_>); + +// @count "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[*]" 2 +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].name" \"\'a\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].name" \"T\" +// @is "$.index[*][?(@.name=='foo')].inner.generics.where_predicates[0].bound_predicate.generic_params[1].kind" '{ "type": { "bounds": [], "default": null, "synthetic": false } }' +pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/rustdoc/issue-15318-2.rs b/tests/rustdoc/issue-15318-2.rs index f7f5052a36d..614f2c1c08e 100644 --- a/tests/rustdoc/issue-15318-2.rs +++ b/tests/rustdoc/issue-15318-2.rs @@ -6,7 +6,7 @@ extern crate issue_15318; pub use issue_15318::ptr; -// @has issue_15318_2/fn.bar.html \ +// @!has issue_15318_2/fn.bar.html \ // '//*[@href="primitive.pointer.html"]' \ // '*mut T' pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/non_lifetime_binders.rs b/tests/rustdoc/non_lifetime_binders.rs new file mode 100644 index 00000000000..da9a4e6a84d --- /dev/null +++ b/tests/rustdoc/non_lifetime_binders.rs @@ -0,0 +1,9 @@ +#![feature(non_lifetime_binders)] +#![allow(incomplete_features)] + +pub trait Trait {} + +pub struct Wrapper<T: ?Sized>(Box<T>); + +// @has non_lifetime_binders/fn.foo.html '//pre' "fn foo()where for<'a, T> &'a Wrapper<T>: Trait" +pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl b/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl new file mode 100644 index 00000000000..e28852ea005 --- /dev/null +++ b/tests/ui-fulldeps/fluent-messages/invalid-escape.ftl @@ -0,0 +1 @@ +no_crate_bad_escape = don't use \n, \', or \" diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs index 66575eb8e30..1ee7227a8e9 100644 --- a/tests/ui-fulldeps/fluent-messages/test.rs +++ b/tests/ui-fulldeps/fluent-messages/test.rs @@ -92,3 +92,12 @@ mod missing_message_ref { fluent_messages! { "./missing-message-ref.ftl" } //~^ ERROR referenced message `message` does not exist } + +mod bad_escape { + use super::fluent_messages; + + fluent_messages! { "./invalid-escape.ftl" } + //~^ ERROR invalid escape `\n` + //~| ERROR invalid escape `\"` + //~| ERROR invalid escape `\'` +} diff --git a/tests/ui-fulldeps/fluent-messages/test.stderr b/tests/ui-fulldeps/fluent-messages/test.stderr index c7961ed22f2..8a6a4a91cc2 100644 --- a/tests/ui-fulldeps/fluent-messages/test.stderr +++ b/tests/ui-fulldeps/fluent-messages/test.stderr @@ -83,5 +83,29 @@ LL | fluent_messages! { "./missing-message-ref.ftl" } | = help: you may have meant to use a variable reference (`{$message}`) -error: aborting due to 10 previous errors +error: invalid escape `\n` in Fluent resource + --> $DIR/test.rs:99:24 + | +LL | fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: os-specific message + +error: invalid escape `\"` in Fluent resource + --> $DIR/test.rs:99:24 + | +LL | fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: os-specific message + +error: invalid escape `\'` in Fluent resource + --> $DIR/test.rs:99:24 + | +LL | fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: os-specific message + +error: aborting due to 13 previous errors diff --git a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr b/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr index 4e296fff6d0..5110b9be08a 100644 --- a/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr +++ b/tests/ui-fulldeps/internal-lints/existing_doc_keyword.stderr @@ -1,4 +1,4 @@ -error: found non-existing keyword `tadam` used in `#[doc(keyword = \"...\")]` +error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]` --> $DIR/existing_doc_keyword.rs:10:1 | LL | #[doc(keyword = "tadam")] diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr index f71fd9980a2..1e67cdca248 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:4:12 + --> $DIR/dont-project-to-specializable-projection.rs:6:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:14:5 + --> $DIR/dont-project-to-specializable-projection.rs:16:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr new file mode 100644 index 00000000000..fa89c6b77e0 --- /dev/null +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr @@ -0,0 +1,34 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-project-to-specializable-projection.rs:6:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/dont-project-to-specializable-projection.rs:16:35 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^ expected associated type, found future + | +note: type in trait + --> $DIR/dont-project-to-specializable-projection.rs:12:27 + | +LL | async fn foo(_: T) -> &'static str; + | ^^^^^^^^^^^^ + = note: expected signature `fn(_) -> impl Future<Output = &'static str>` + found signature `fn(_) -> impl Future<Output = &'static str>` + +error: async associated function in trait cannot be specialized + --> $DIR/dont-project-to-specializable-projection.rs:16:5 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs index afd3db5e052..7183eaccc93 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs @@ -1,5 +1,7 @@ // edition: 2021 // known-bug: #108309 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(min_specialization)] diff --git a/tests/ui/codegen/mono-impossible-2.rs b/tests/ui/codegen/mono-impossible-2.rs new file mode 100644 index 00000000000..21eb2c9b2f2 --- /dev/null +++ b/tests/ui/codegen/mono-impossible-2.rs @@ -0,0 +1,19 @@ +//compile-flags: --crate-type=lib -Clink-dead-code=on +// build-pass + +// Make sure that we don't monomorphize the impossible method `<() as Visit>::visit`, +// which does not hold under a reveal-all param env. + +pub trait Visit { + fn visit() {} +} + +pub trait Array { + type Element; +} + +impl<'a> Visit for () where (): Array<Element = &'a ()> {} + +impl Array for () { + type Element = (); +} diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index c39920d444d..70a1abb0a95 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -1,8 +1,8 @@ error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:2:20 + --> $DIR/format.rs:2:13 | LL | panic!("{:?}", 0); - | ^ + | ^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -17,10 +17,10 @@ LL | panic!("{:?}", 0); = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:8:22 + --> $DIR/format.rs:8:15 | LL | println!("{:?}", 0); - | ^ + | ^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs b/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs new file mode 100644 index 00000000000..93418b7651c --- /dev/null +++ b/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs @@ -0,0 +1,6 @@ +// ignore-tidy-tab + +pub struct S; +impl S { + fn method(&self) {} +} diff --git a/tests/ui/diagnostic-width/tab-column-numbers.rs b/tests/ui/diagnostic-width/tab-column-numbers.rs new file mode 100644 index 00000000000..2abb0bcde95 --- /dev/null +++ b/tests/ui/diagnostic-width/tab-column-numbers.rs @@ -0,0 +1,12 @@ +// Test for #109537: ensure that column numbers are correctly generated when using hard tabs. +// aux-build:tab_column_numbers.rs + +// ignore-tidy-tab + +extern crate tab_column_numbers; + +fn main() { + let s = tab_column_numbers::S; + s.method(); + //~^ ERROR method `method` is private +} diff --git a/tests/ui/diagnostic-width/tab-column-numbers.stderr b/tests/ui/diagnostic-width/tab-column-numbers.stderr new file mode 100644 index 00000000000..ea4e1ff52a9 --- /dev/null +++ b/tests/ui/diagnostic-width/tab-column-numbers.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + --> $DIR/tab-column-numbers.rs:10:4 + | +LL | s.method(); + | ^^^^^^ private method + | + ::: $DIR/auxiliary/tab_column_numbers.rs:5:3 + | +LL | fn method(&self) {} + | ---------------- private method defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/fmt/format-args-argument-span.rs b/tests/ui/fmt/format-args-argument-span.rs new file mode 100644 index 00000000000..c7acb08f84b --- /dev/null +++ b/tests/ui/fmt/format-args-argument-span.rs @@ -0,0 +1,22 @@ +// check-compile + +struct DisplayOnly; + +impl std::fmt::Display for DisplayOnly { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + unimplemented!() + } +} + +fn main() { + let x = Some(1); + println!("{x:?} {x} {x:?}"); + //~^ ERROR: `Option<{integer}>` doesn't implement `std::fmt::Display` + println!("{x:?} {x} {x:?}", x = Some(1)); + //~^ ERROR: `Option<{integer}>` doesn't implement `std::fmt::Display` + let x = DisplayOnly; + println!("{x} {x:?} {x}"); + //~^ ERROR: `DisplayOnly` doesn't implement `Debug` + println!("{x} {x:?} {x}", x = DisplayOnly); + //~^ ERROR: `DisplayOnly` doesn't implement `Debug` +} diff --git a/tests/ui/fmt/format-args-argument-span.stderr b/tests/ui/fmt/format-args-argument-span.stderr new file mode 100644 index 00000000000..b060b2cd339 --- /dev/null +++ b/tests/ui/fmt/format-args-argument-span.stderr @@ -0,0 +1,51 @@ +error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` + --> $DIR/format-args-argument-span.rs:13:21 + | +LL | println!("{x:?} {x} {x:?}"); + | ^^^ `Option<{integer}>` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` + --> $DIR/format-args-argument-span.rs:15:37 + | +LL | println!("{x:?} {x} {x:?}", x = Some(1)); + | ^^^^^^^ `Option<{integer}>` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `DisplayOnly` doesn't implement `Debug` + --> $DIR/format-args-argument-span.rs:18:19 + | +LL | println!("{x} {x:?} {x}"); + | ^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `DisplayOnly` + = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `DisplayOnly` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | + +error[E0277]: `DisplayOnly` doesn't implement `Debug` + --> $DIR/format-args-argument-span.rs:20:35 + | +LL | println!("{x} {x:?} {x}", x = DisplayOnly); + | ^^^^^^^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `DisplayOnly` + = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `DisplayOnly` with `#[derive(Debug)]` + | +LL | #[derive(Debug)] + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr index d716bbe51af..bf18fb315c9 100644 --- a/tests/ui/fmt/ifmt-bad-arg.stderr +++ b/tests/ui/fmt/ifmt-bad-arg.stderr @@ -300,10 +300,9 @@ error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:78:32 | LL | println!("{} {:.*} {}", 1, 3.2, 4); - | ^^^ - | | - | expected `&usize`, found `&{float}` - | arguments to this function are incorrect + | -- ^^^ expected `&usize`, found `&{float}` + | | + | arguments to this function are incorrect | = note: expected reference `&usize` found reference `&{float}` @@ -315,10 +314,9 @@ error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:81:35 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); - | ^^^ - | | - | expected `&usize`, found `&{float}` - | arguments to this function are incorrect + | -- ^^^ expected `&usize`, found `&{float}` + | | + | arguments to this function are incorrect | = note: expected reference `&usize` found reference `&{float}` diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index 3480a2ec815..dc2dee3f341 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -2,7 +2,9 @@ error[E0277]: the trait bound `str: UpperHex` is not satisfied --> $DIR/ifmt-unimpl.rs:2:21 | LL | format!("{:X}", "3"); - | ^^^ the trait `UpperHex` is not implemented for `str` + | ---- ^^^ the trait `UpperHex` is not implemented for `str` + | | + | required by a bound introduced by this call | = help: the following other types implement trait `UpperHex`: &T diff --git a/tests/ui/fn/fn-ptr-trait.rs b/tests/ui/fn/fn-ptr-trait.rs new file mode 100644 index 00000000000..45918ae5b61 --- /dev/null +++ b/tests/ui/fn/fn-ptr-trait.rs @@ -0,0 +1,9 @@ +#![feature(fn_ptr_trait)] +// check-pass + +use std::marker::FnPtr; + +trait Foo {} +impl<T> Foo for Vec<T> where T: FnPtr {} + +fn main() {} diff --git a/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs new file mode 100644 index 00000000000..b43f982283b --- /dev/null +++ b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Foo { + type Assoc<T>: PartialEq<Self::Assoc<i32>>; +} + +impl Foo for () { + type Assoc<T> = Wrapper<T>; +} + +struct Wrapper<T>(T); + +impl<T> PartialEq<Wrapper<i32>> for Wrapper<T> { + fn eq(&self, _other: &Wrapper<i32>) -> bool { true } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/ice-unbound-region-vars.rs b/tests/ui/implied-bounds/ice-unbound-region-vars.rs new file mode 100644 index 00000000000..9e1e3feaeec --- /dev/null +++ b/tests/ui/implied-bounds/ice-unbound-region-vars.rs @@ -0,0 +1,24 @@ +// Because of #109628, we can have unbounded region vars in implied bounds. +// Make sure we don't ICE in this case! +// +// check-pass + +pub trait MapAccess { + type Error; + fn next_key_seed(&mut self) -> Option<Self::Error>; +} + +struct Access<'a> { + _marker: std::marker::PhantomData<&'a ()>, +} + +// implied_bounds(Option<Self::Error>) = ['?1: 'a, ] +// where '?1 is a fresh region var. +impl<'a, 'b: 'a> MapAccess for Access<'a> { + type Error = (); + fn next_key_seed(&mut self) -> Option<Self::Error> { + unimplemented!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/normalization.rs b/tests/ui/implied-bounds/normalization.rs new file mode 100644 index 00000000000..f776fc98a9e --- /dev/null +++ b/tests/ui/implied-bounds/normalization.rs @@ -0,0 +1,58 @@ +// Test that we get implied bounds from complex projections after normalization. + +// check-pass + +// implementations wil ensure that +// WF(<T as Combine<'a>>::Ty) implies T: 'a +trait Combine<'a> { + type Ty; +} + +impl<'a, T: 'a> Combine<'a> for Box<T> { + type Ty = &'a T; +} + +// ======= Wrappers ====== + +// normalizes to a projection +struct WrapA<T>(T); +impl<'a, T> Combine<'a> for WrapA<T> +where + T: Combine<'a>, +{ + type Ty = T::Ty; +} + +// <WrapB<T> as Combine<'a>>::Ty normalizes to a type variable ?X +// with constraint `<T as Combine<'a>>::Ty == ?X` +struct WrapB<T>(T); +impl<'a, X, T> Combine<'a> for WrapB<T> +where + T: Combine<'a, Ty = X>, +{ + type Ty = X; +} + +// <WrapC<T> as Combine<'a>>::Ty normalizes to `&'a &'?x ()` +// with constraint `<T as Combine<'a>>::Ty == &'a &'?x ()` +struct WrapC<T>(T); +impl<'a, 'x: 'a, T> Combine<'a> for WrapC<T> +where + T: Combine<'a, Ty = &'a &'x ()>, +{ + type Ty = &'a &'x (); +} + +//==== Test implied bounds ====== + +fn test_wrap<'a, 'b, 'c1, 'c2, A, B>( + _: <WrapA<Box<A>> as Combine<'a>>::Ty, // normalized: &'a A + _: <WrapB<Box<B>> as Combine<'b>>::Ty, // normalized: &'b B + _: <WrapC<Box<&'c1 ()>> as Combine<'c2>>::Ty, // normalized: &'c2 &'c1 () +) { + None::<&'a A>; + None::<&'b B>; + None::<&'c2 &'c1 ()>; +} + +fn main() {} diff --git a/tests/ui/issues/issue-59488.stderr b/tests/ui/issues/issue-59488.stderr index d45beefa420..ac8862716c0 100644 --- a/tests/ui/issues/issue-59488.stderr +++ b/tests/ui/issues/issue-59488.stderr @@ -90,16 +90,6 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` - = help: the following other types implement trait `Debug`: - extern "C" fn() -> Ret - extern "C" fn(A, B) -> Ret - extern "C" fn(A, B, ...) -> Ret - extern "C" fn(A, B, C) -> Ret - extern "C" fn(A, B, C, ...) -> Ret - extern "C" fn(A, B, C, D) -> Ret - extern "C" fn(A, B, C, D, ...) -> Ret - extern "C" fn(A, B, C, D, E) -> Ret - and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` @@ -109,16 +99,6 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` - = help: the following other types implement trait `Debug`: - extern "C" fn() -> Ret - extern "C" fn(A, B) -> Ret - extern "C" fn(A, B, ...) -> Ret - extern "C" fn(A, B, C) -> Ret - extern "C" fn(A, B, C, ...) -> Ret - extern "C" fn(A, B, C, D) -> Ret - extern "C" fn(A, B, C, D, ...) -> Ret - extern "C" fn(A, B, C, D, E) -> Ret - and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/lint/issue-109529.fixed b/tests/ui/lint/issue-109529.fixed new file mode 100644 index 00000000000..5ad489073ee --- /dev/null +++ b/tests/ui/lint/issue-109529.fixed @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + for _ in 0..=255 as u8 {} //~ ERROR range endpoint is out of range + for _ in 0..=(255 as u8) {} //~ ERROR range endpoint is out of range +} diff --git a/tests/ui/lint/issue-109529.rs b/tests/ui/lint/issue-109529.rs new file mode 100644 index 00000000000..383d7bc4cf3 --- /dev/null +++ b/tests/ui/lint/issue-109529.rs @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + for _ in 0..256 as u8 {} //~ ERROR range endpoint is out of range + for _ in 0..(256 as u8) {} //~ ERROR range endpoint is out of range +} diff --git a/tests/ui/lint/issue-109529.stderr b/tests/ui/lint/issue-109529.stderr new file mode 100644 index 00000000000..9e857d1b0ab --- /dev/null +++ b/tests/ui/lint/issue-109529.stderr @@ -0,0 +1,23 @@ +error: range endpoint is out of range for `u8` + --> $DIR/issue-109529.rs:4:14 + | +LL | for _ in 0..256 as u8 {} + | ------^^^^^^ + | | + | help: use an inclusive range instead: `0..=255` + | + = note: `#[deny(overflowing_literals)]` on by default + +error: range endpoint is out of range for `u8` + --> $DIR/issue-109529.rs:5:14 + | +LL | for _ in 0..(256 as u8) {} + | ^^^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL | for _ in 0..=(255 as u8) {} + | + ~~~ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/missing-writer.rs b/tests/ui/macros/missing-writer.rs new file mode 100644 index 00000000000..7df965c3684 --- /dev/null +++ b/tests/ui/macros/missing-writer.rs @@ -0,0 +1,17 @@ +// Check error for missing writer in writeln! and write! macro +fn main() { + let x = 1; + let y = 2; + write!("{}_{}", x, y); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + //~| ERROR cannot write into `&'static str` + //~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + //~| HELP a writer is needed before this format string + writeln!("{}_{}", x, y); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + //~| ERROR cannot write into `&'static str` + //~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + //~| HELP a writer is needed before this format string +} diff --git a/tests/ui/macros/missing-writer.stderr b/tests/ui/macros/missing-writer.stderr new file mode 100644 index 00000000000..86dfe7d65ea --- /dev/null +++ b/tests/ui/macros/missing-writer.stderr @@ -0,0 +1,59 @@ +error: format argument must be a string literal + --> $DIR/missing-writer.rs:5:21 + | +LL | write!("{}_{}", x, y); + | ^ + | +help: you might be missing a string literal to format with + | +LL | write!("{}_{}", "{} {}", x, y); + | ++++++++ + +error: format argument must be a string literal + --> $DIR/missing-writer.rs:11:23 + | +LL | writeln!("{}_{}", x, y); + | ^ + | +help: you might be missing a string literal to format with + | +LL | writeln!("{}_{}", "{} {}", x, y); + | ++++++++ + +error[E0599]: cannot write into `&'static str` + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | -------^^^^^^^------- method not found in `&str` + | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | ^^^^^^^ +help: a writer is needed before this format string + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | ^ + +error[E0599]: cannot write into `&'static str` + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ---------^^^^^^^------- method not found in `&str` + | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ^^^^^^^ +help: a writer is needed before this format string + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs index 62aa22d41ed..b9f1de7ec13 100644 --- a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs +++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs @@ -1,4 +1,8 @@ -// check-pass +// known-bug: #89515 +// +// The trait solver cannot deal with ambiguous marker trait impls +// if there are lifetimes involved. As we must not special-case any +// regions this does not work, even with 'static #![feature(marker_trait_attr)] #[marker] diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr new file mode 100644 index 00000000000..fe4de540b51 --- /dev/null +++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr @@ -0,0 +1,31 @@ +error[E0283]: type annotations needed: cannot satisfy `&'static (): Marker` + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:17 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^ + | +note: multiple `impl`s satisfying `&'static (): Marker` found + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:1 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed: cannot satisfy `&'static (): Marker` + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:12:17 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^ + | +note: multiple `impl`s satisfying `&'static (): Marker` found + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:1 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs index a8f3db5f5b2..97a814f51ee 100644 --- a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs +++ b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs @@ -1,9 +1,17 @@ -// check-pass +// known-bug: #109481 +// +// While the `T: Copy` is always applicable when checking +// that the impl `impl<T: Copy> F for T {}` is well formed, +// the old trait solver can only approximate this by checking +// that there are no inference variables in the obligation and +// no region constraints in the evaluation result. +// +// Because of this we end up with ambiguity here. #![feature(marker_trait_attr)] #[marker] pub trait F {} -impl<T> F for T where T: Copy {} -impl<T> F for T where T: 'static {} +impl<T: Copy> F for T {} +impl<T: 'static> F for T {} fn main() {} diff --git a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr new file mode 100644 index 00000000000..e713d1451cf --- /dev/null +++ b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr @@ -0,0 +1,14 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/overlapping-impl-1-modulo-regions.rs:14:21 + | +LL | impl<T: Copy> F for T {} + | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | impl<T: Copy + 'static> F for T {} + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr index bbcc3693fff..5415c247c8f 100644 --- a/tests/ui/suggestions/issue-97760.stderr +++ b/tests/ui/suggestions/issue-97760.stderr @@ -1,8 +1,8 @@ error[E0277]: `<impl IntoIterator as IntoIterator>::Item` doesn't implement `std::fmt::Display` - --> $DIR/issue-97760.rs:4:20 + --> $DIR/issue-97760.rs:4:19 | LL | println!("{x}"); - | ^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter + | ^^^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `<impl IntoIterator as IntoIterator>::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index 6910b77d9bc..94710f4503f 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -21,18 +21,22 @@ note: required by a bound in `BufWriter` --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn Write>`, but its trait bounds were not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:21:5 + --> $DIR/mut-borrow-needed-by-trait.rs:21:14 | LL | writeln!(fp, "hello world").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds + | ---------^^---------------- method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL | = note: doesn't satisfy `BufWriter<&dyn std::io::Write>: std::io::Write` | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + | +LL | writeln!(fp, "hello world").unwrap(); + | ^^ = note: the following trait bounds were not satisfied: `&dyn std::io::Write: std::io::Write` which is required by `BufWriter<&dyn std::io::Write>: std::io::Write` - = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/thread-local/auxiliary/tls-export.rs b/tests/ui/thread-local/auxiliary/tls-export.rs new file mode 100644 index 00000000000..027213bc033 --- /dev/null +++ b/tests/ui/thread-local/auxiliary/tls-export.rs @@ -0,0 +1,17 @@ +#![crate_type = "dylib"] +#![feature(thread_local)] +#![feature(cfg_target_thread_local)] + +extern crate tls_rlib; + +pub use tls_rlib::*; + +#[cfg(target_thread_local)] +#[thread_local] +pub static FOO: bool = true; + +#[cfg(target_thread_local)] +#[inline(never)] +pub fn foo_addr() -> usize { + &FOO as *const bool as usize +} diff --git a/tests/ui/thread-local/auxiliary/tls-rlib.rs b/tests/ui/thread-local/auxiliary/tls-rlib.rs new file mode 100644 index 00000000000..20bc998ec11 --- /dev/null +++ b/tests/ui/thread-local/auxiliary/tls-rlib.rs @@ -0,0 +1,15 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![feature(thread_local)] +#![feature(cfg_target_thread_local)] + +#[cfg(target_thread_local)] +#[thread_local] +pub static BAR: bool = true; + +#[cfg(target_thread_local)] +#[inline(never)] +pub fn bar_addr() -> usize { + &BAR as *const bool as usize +} diff --git a/tests/ui/thread-local/tls-dylib-access.rs b/tests/ui/thread-local/tls-dylib-access.rs new file mode 100644 index 00000000000..12c46113cea --- /dev/null +++ b/tests/ui/thread-local/tls-dylib-access.rs @@ -0,0 +1,19 @@ +// aux-build: tls-rlib.rs +// aux-build: tls-export.rs +// run-pass + +#![feature(cfg_target_thread_local)] + +#[cfg(target_thread_local)] +extern crate tls_export; + +fn main() { + #[cfg(target_thread_local)] + { + // Check that we get the real address of the `FOO` TLS in the dylib + assert_eq!(&tls_export::FOO as *const bool as usize, tls_export::foo_addr()); + + // Check that we get the real address of the `BAR` TLS in the rlib linked into the dylib + assert_eq!(&tls_export::BAR as *const bool as usize, tls_export::bar_addr()); + } +} diff --git a/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs b/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs new file mode 100644 index 00000000000..e608250063c --- /dev/null +++ b/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs @@ -0,0 +1,12 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Iter<'a, I: 'a>: Iterator<Item = &'a I> {} + +fn needs_iter<'a, T: Iter<'a, I> + ?Sized, I: 'a>(_: &T) {} + +fn test(x: &dyn Iter<'_, ()>) { + needs_iter(x); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/more-object-bound.rs b/tests/ui/traits/new-solver/more-object-bound.rs index 712759ef0e6..bb730b18ef7 100644 --- a/tests/ui/traits/new-solver/more-object-bound.rs +++ b/tests/ui/traits/new-solver/more-object-bound.rs @@ -10,7 +10,7 @@ trait Trait: SuperTrait<A = <Self as SuperTrait>::B> {} fn transmute<A, B>(x: A) -> B { foo::<A, B, dyn Trait<A = A, B = B>>(x) - //~^ ERROR type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait` + //~^ ERROR the trait bound `dyn Trait<A = A, B = B>: Trait` is not satisfied } fn foo<A, B, T: ?Sized>(x: T::A) -> B diff --git a/tests/ui/traits/new-solver/more-object-bound.stderr b/tests/ui/traits/new-solver/more-object-bound.stderr index 208fdecb08f..4554b8c7473 100644 --- a/tests/ui/traits/new-solver/more-object-bound.stderr +++ b/tests/ui/traits/new-solver/more-object-bound.stderr @@ -1,10 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait` - --> $DIR/more-object-bound.rs:12:5 +error[E0277]: the trait bound `dyn Trait<A = A, B = B>: Trait` is not satisfied + --> $DIR/more-object-bound.rs:12:17 | LL | foo::<A, B, dyn Trait<A = A, B = B>>(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Trait<A = A, B = B>` | - = note: cannot satisfy `dyn Trait<A = A, B = B>: Trait` note: required by a bound in `foo` --> $DIR/more-object-bound.rs:18:8 | @@ -13,7 +12,11 @@ LL | fn foo<A, B, T: ?Sized>(x: T::A) -> B LL | where LL | T: Trait<B = B>, | ^^^^^^^^^^^^ required by this bound in `foo` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn transmute<A, B>(x: A) -> B where dyn Trait<A = A, B = B>: Trait { + | ++++++++++++++++++++++++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs new file mode 100644 index 00000000000..7417d6018a1 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next + +trait Foo1 { + type Assoc1; +} + +trait Foo2 { + type Assoc2; +} + +trait Bar {} +fn needs_bar<S: Bar>() {} + +fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() { + needs_bar::<T::Assoc1>(); + //~^ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr new file mode 100644 index 00000000000..29cfa47a105 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/recursive-self-normalization-2.rs:15:5 + | +LL | needs_bar::<T::Assoc1>(); + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `S` declared on the function `needs_bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs new file mode 100644 index 00000000000..f3e3d71d813 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs @@ -0,0 +1,15 @@ +// compile-flags: -Ztrait-solver=next + +trait Foo { + type Assoc; +} + +trait Bar {} +fn needs_bar<S: Bar>() {} + +fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() { + needs_bar::<T::Assoc>(); + //~^ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr new file mode 100644 index 00000000000..ba39981893d --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/recursive-self-normalization.rs:11:5 + | +LL | needs_bar::<T::Assoc>(); + | ^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `S` declared on the function `needs_bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. |
