diff options
Diffstat (limited to 'tests')
270 files changed, 3990 insertions, 928 deletions
diff --git a/tests/codegen/asm-maybe-uninit.rs b/tests/codegen/asm-maybe-uninit.rs new file mode 100644 index 00000000000..d7e4a948954 --- /dev/null +++ b/tests/codegen/asm-maybe-uninit.rs @@ -0,0 +1,27 @@ +// compile-flags: -O +// only-x86_64 + +#![crate_type = "rlib"] +#![allow(asm_sub_register)] + +use std::mem::MaybeUninit; +use std::arch::asm; + +// CHECK-LABEL: @int +#[no_mangle] +pub unsafe fn int(x: MaybeUninit<i32>) -> MaybeUninit<i32> { + let y: MaybeUninit<i32>; + asm!("/*{}{}*/", in(reg) x, out(reg) y); + y +} + +// CHECK-LABEL: @inout +#[no_mangle] +pub unsafe fn inout(mut x: i32) -> MaybeUninit<u32> { + let mut y: MaybeUninit<u32>; + asm!("/*{}*/", inout(reg) x => y); + asm!("/*{}*/", inout(reg) y => x); + asm!("/*{}*/", inlateout(reg) x => y); + asm!("/*{}*/", inlateout(reg) y => x); + y +} diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-uninit-bytes.rs index 282af99b067..732da0a1794 100644 --- a/tests/codegen/box-maybe-uninit.rs +++ b/tests/codegen/box-uninit-bytes.rs @@ -25,6 +25,20 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { Box::new(MaybeUninit::uninit()) } +#[repr(align(1024))] +pub struct LotsaPadding(usize); + +// Boxing a value with padding should not copy junk from the stack +#[no_mangle] +pub fn box_lotsa_padding() -> Box<LotsaPadding> { + // CHECK-LABEL: @box_lotsa_padding + // CHECK-NOT: alloca + // CHECK-NOT: getelementptr + // CHECK-NOT: memcpy + // CHECK-NOT: memset + Box::new(LotsaPadding(42)) +} + // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. // CHECK: declare {{(dso_local )?}}noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 174ac608e01..be3af989ef0 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -33,12 +33,21 @@ pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str { } #[no_mangle] -// CHECK-LABEL: @replace_short_array( -pub fn replace_short_array(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] { +// CHECK-LABEL: @replace_short_array_3( +pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] { // CHECK-NOT: alloca - // CHECK: %[[R:.+]] = load <3 x i32>, ptr %r, align 4 - // CHECK: store <3 x i32> %[[R]], ptr %result - // CHECK: %[[V:.+]] = load <3 x i32>, ptr %v, align 4 - // CHECK: store <3 x i32> %[[V]], ptr %r + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 12, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 12, i1 false) + std::mem::replace(r, v) +} + +#[no_mangle] +// CHECK-LABEL: @replace_short_array_4( +pub fn replace_short_array_4(r: &mut [u32; 4], v: [u32; 4]) -> [u32; 4] { + // CHECK-NOT: alloca + // CHECK: %[[R:.+]] = load <4 x i32>, ptr %r, align 4 + // CHECK: store <4 x i32> %[[R]], ptr %result + // CHECK: %[[V:.+]] = load <4 x i32>, ptr %v, align 4 + // CHECK: store <4 x i32> %[[V]], ptr %r std::mem::replace(r, v) } diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs index da608e180c5..2d8b13e2080 100644 --- a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -500,12 +500,12 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { } // CHECK: ![[TYPE45]] = !{i64 0, !"_ZTSFvu5usizeE"} // CHECK: ![[TYPE46]] = !{i64 0, !"_ZTSFvu5usizeS_E"} // CHECK: ![[TYPE47]] = !{i64 0, !"_ZTSFvu5usizeS_S_E"} -// CHECK: ![[TYPE48]] = !{i64 0, !"_ZTSFvu3f32E"} -// CHECK: ![[TYPE49]] = !{i64 0, !"_ZTSFvu3f32S_E"} -// CHECK: ![[TYPE50]] = !{i64 0, !"_ZTSFvu3f32S_S_E"} -// CHECK: ![[TYPE51]] = !{i64 0, !"_ZTSFvu3f64E"} -// CHECK: ![[TYPE52]] = !{i64 0, !"_ZTSFvu3f64S_E"} -// CHECK: ![[TYPE53]] = !{i64 0, !"_ZTSFvu3f64S_S_E"} +// CHECK: ![[TYPE48]] = !{i64 0, !"_ZTSFvfE"} +// CHECK: ![[TYPE49]] = !{i64 0, !"_ZTSFvffE"} +// CHECK: ![[TYPE50]] = !{i64 0, !"_ZTSFvfffE"} +// CHECK: ![[TYPE51]] = !{i64 0, !"_ZTSFvdE"} +// CHECK: ![[TYPE52]] = !{i64 0, !"_ZTSFvddE"} +// CHECK: ![[TYPE53]] = !{i64 0, !"_ZTSFvdddE"} // CHECK: ![[TYPE54]] = !{i64 0, !"_ZTSFvu4charE"} // CHECK: ![[TYPE55]] = !{i64 0, !"_ZTSFvu4charS_E"} // CHECK: ![[TYPE56]] = !{i64 0, !"_ZTSFvu4charS_S_E"} diff --git a/tests/codegen/swap-small-types.rs b/tests/codegen/swap-small-types.rs index 419645a3fc6..27bc00bc3ab 100644 --- a/tests/codegen/swap-small-types.rs +++ b/tests/codegen/swap-small-types.rs @@ -11,11 +11,12 @@ type RGB48 = [u16; 3]; // CHECK-LABEL: @swap_rgb48_manually( #[no_mangle] pub fn swap_rgb48_manually(x: &mut RGB48, y: &mut RGB48) { - // CHECK-NOT: alloca - // CHECK: %[[TEMP0:.+]] = load <3 x i16>, ptr %x, align 2 - // CHECK: %[[TEMP1:.+]] = load <3 x i16>, ptr %y, align 2 - // CHECK: store <3 x i16> %[[TEMP1]], ptr %x, align 2 - // CHECK: store <3 x i16> %[[TEMP0]], ptr %y, align 2 + // FIXME: See #115212 for why this has an alloca again + + // CHECK: alloca [3 x i16], align 2 + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) let temp = *x; *x = *y; @@ -25,11 +26,25 @@ pub fn swap_rgb48_manually(x: &mut RGB48, y: &mut RGB48) { // CHECK-LABEL: @swap_rgb48 #[no_mangle] pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) { + // FIXME: See #115212 for why this has an alloca again + + // CHECK: alloca [3 x i16], align 2 + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64({{.+}}, i64 6, i1 false) + swap(x, y) +} + +type RGBA64 = [u16; 4]; + +// CHECK-LABEL: @swap_rgba64 +#[no_mangle] +pub fn swap_rgba64(x: &mut RGBA64, y: &mut RGBA64) { // CHECK-NOT: alloca - // CHECK: load <3 x i16> - // CHECK: load <3 x i16> - // CHECK: store <3 x i16> - // CHECK: store <3 x i16> + // CHECK-DAG: %[[XVAL:.+]] = load <4 x i16>, ptr %x, align 2 + // CHECK-DAG: %[[YVAL:.+]] = load <4 x i16>, ptr %y, align 2 + // CHECK-DAG: store <4 x i16> %[[YVAL]], ptr %x, align 2 + // CHECK-DAG: store <4 x i16> %[[XVAL]], ptr %y, align 2 swap(x, y) } diff --git a/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir b/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir index a59ffe97bf0..6c3128f8c36 100644 --- a/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir +++ b/tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir @@ -9,7 +9,7 @@ fn main() -> () { bb0: { StorageLive(_1); _1 = const (); - asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind terminate]; + asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind terminate(abi)]; } bb1: { diff --git a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff index 15269fb8f6c..f187f959727 100644 --- a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff +++ b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff @@ -47,7 +47,7 @@ bb2 (cleanup): { _5 = move _6; -- drop(_6) -> [return: bb6, unwind terminate]; +- drop(_6) -> [return: bb6, unwind terminate(cleanup)]; + goto -> bb6; } @@ -71,12 +71,12 @@ } bb6 (cleanup): { -- drop(_5) -> [return: bb7, unwind terminate]; +- drop(_5) -> [return: bb7, unwind terminate(cleanup)]; + goto -> bb7; } bb7 (cleanup): { -- drop(_4) -> [return: bb8, unwind terminate]; +- drop(_4) -> [return: bb8, unwind terminate(cleanup)]; + goto -> bb8; } diff --git a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir index a9bc2e89034..75070ffda11 100644 --- a/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir @@ -51,7 +51,7 @@ fn main() -> () { bb2 (cleanup): { _5 = move _6; - drop(_6) -> [return: bb6, unwind terminate]; + drop(_6) -> [return: bb6, unwind terminate(cleanup)]; } bb3: { @@ -73,11 +73,11 @@ fn main() -> () { } bb6 (cleanup): { - drop(_5) -> [return: bb7, unwind terminate]; + drop(_5) -> [return: bb7, unwind terminate(cleanup)]; } bb7 (cleanup): { - drop(_4) -> [return: bb8, unwind terminate]; + drop(_4) -> [return: bb8, unwind terminate(cleanup)]; } bb8 (cleanup): { diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir index d196b045a1b..1c7ef7f8345 100644 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir @@ -54,15 +54,15 @@ fn main() -> () { } bb6 (cleanup): { - drop(_7) -> [return: bb7, unwind terminate]; + drop(_7) -> [return: bb7, unwind terminate(cleanup)]; } bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate]; + drop(_1) -> [return: bb9, unwind terminate(cleanup)]; } bb8 (cleanup): { - drop(_5) -> [return: bb9, unwind terminate]; + drop(_5) -> [return: bb9, unwind terminate(cleanup)]; } bb9 (cleanup): { diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir index a72d22a9c9f..4ad1c2de129 100644 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir @@ -54,15 +54,15 @@ fn main() -> () { } bb6 (cleanup): { - drop(_7) -> [return: bb7, unwind terminate]; + drop(_7) -> [return: bb7, unwind terminate(cleanup)]; } bb7 (cleanup): { - drop(_1) -> [return: bb9, unwind terminate]; + drop(_1) -> [return: bb9, unwind terminate(cleanup)]; } bb8 (cleanup): { - drop(_5) -> [return: bb9, unwind terminate]; + drop(_5) -> [return: bb9, unwind terminate(cleanup)]; } bb9 (cleanup): { diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index 074ebddf78b..9be5b8509c7 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -30,7 +30,7 @@ fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]> } bb2: { - assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind continue]; + assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index f774f32eb23..80ac92d59f3 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -310,7 +310,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb28: { - assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind continue]; + assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind unreachable]; } bb29: { diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs index f1240566168..123118f654e 100644 --- a/tests/mir-opt/building/custom/terminators.rs +++ b/tests/mir-opt/building/custom/terminators.rs @@ -12,7 +12,7 @@ fn ident<T>(t: T) -> T { fn direct_call(x: i32) -> i32 { mir!( { - Call(RET, retblock, ident(x)) + Call(RET = ident(x), retblock) } retblock = { @@ -26,7 +26,7 @@ fn direct_call(x: i32) -> i32 { fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 { mir!( { - Call(RET, retblock, f(x)) + Call(RET = f(x), retblock) } retblock = { diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir index 1caf9e4a523..ea0edb610f5 100644 --- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir +++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir @@ -62,7 +62,7 @@ fn droppy() -> () { } bb4 (cleanup): { - drop(_2) -> [return: bb5, unwind terminate]; + drop(_2) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir index fea1138ba8d..82424de0392 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -89,15 +89,15 @@ fn move_out_by_subslice() -> () { } bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate]; + drop(_1) -> [return: bb12, unwind terminate(cleanup)]; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate]; + drop(_7) -> [return: bb11, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate]; + drop(_2) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir index 3def40a8578..0872d1b6ac0 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -89,15 +89,15 @@ fn move_out_from_end() -> () { } bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate]; + drop(_1) -> [return: bb12, unwind terminate(cleanup)]; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate]; + drop(_7) -> [return: bb11, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate]; + drop(_2) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff index 1a4372afe69..f2b87221f2b 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff @@ -63,7 +63,7 @@ } bb4 (cleanup): { - drop(_2) -> [return: bb5, unwind terminate]; + drop(_2) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index a89b64441d0..bf94dc57d33 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -21,11 +21,11 @@ fn f() -> bool { let b = a; // We cannot propagate the place `a`. let r2 = &b; - Call(RET, next, cmp_ref(r1, r2)) + Call(RET = cmp_ref(r1, r2), next) } next = { // But we can propagate the value `a`. - Call(RET, ret, opaque(b)) + Call(RET = opaque(b), ret) } ret = { Return() diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs index a90db08fa51..d1c5ffdff0d 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.rs +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -13,11 +13,11 @@ struct NotCopy(bool); fn f(_1: NotCopy) { mir!({ let _2 = _1; - Call(RET, bb1, opaque(Move(_1))) + Call(RET = opaque(Move(_1)), bb1) } bb1 = { let _3 = Move(_2); - Call(RET, bb2, opaque(_3)) + Call(RET = opaque(_3), bb2) } bb2 = { Return() diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs index 40f51ce8406..f94addb5629 100644 --- a/tests/mir-opt/copy-prop/move_projection.rs +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -17,10 +17,10 @@ fn f(a: Foo) -> bool { let b = a; // This is a move out of a copy, so must become a copy of `a.0`. let c = Move(b.0); - Call(RET, bb1, opaque(Move(a))) + Call(RET = opaque(Move(a)), bb1) } bb1 = { - Call(RET, ret, opaque(Move(c))) + Call(RET = opaque(Move(c)), ret) } ret = { Return() diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-abort.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-abort.diff new file mode 100644 index 00000000000..dc0f9073416 --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-abort.diff @@ -0,0 +1,15 @@ +- // MIR for `move_packed` before DeadStoreElimination ++ // MIR for `move_packed` after DeadStoreElimination + + fn move_packed(_1: Packed) -> () { + let mut _0: (); + + bb0: { + _0 = use_both(const 0_i32, (_1.1: i32)) -> [return: bb1, unwind unreachable]; + } + + bb1: { + return; + } + } + diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-unwind.diff new file mode 100644 index 00000000000..86ef026ec5c --- /dev/null +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-unwind.diff @@ -0,0 +1,15 @@ +- // MIR for `move_packed` before DeadStoreElimination ++ // MIR for `move_packed` after DeadStoreElimination + + fn move_packed(_1: Packed) -> () { + let mut _0: (); + + bb0: { + _0 = use_both(const 0_i32, (_1.1: i32)) -> [return: bb1, unwind continue]; + } + + bb1: { + return; + } + } + diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs index 41f91fc1306..f09cdee1482 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -2,6 +2,12 @@ // unit-test: DeadStoreElimination // compile-flags: -Zmir-enable-passes=+CopyProp +#![feature(core_intrinsics)] +#![feature(custom_mir)] +#![allow(internal_features)] + +use std::intrinsics::mir::*; + #[inline(never)] fn use_both(_: i32, _: i32) {} @@ -10,6 +16,26 @@ fn move_simple(x: i32) { use_both(x, x); } +#[repr(packed)] +struct Packed { + x: u8, + y: i32, +} + +// EMIT_MIR call_arg_copy.move_packed.DeadStoreElimination.diff +#[custom_mir(dialect = "analysis")] +fn move_packed(packed: Packed) { + mir!( + { + Call(RET = use_both(0, packed.y), ret) + } + ret = { + Return() + } + ) +} + fn main() { move_simple(1); + move_packed(Packed { x: 0, y: 1 }); } diff --git a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-abort.diff b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-abort.diff index 024d9bc7f51..8ac6acd0e4a 100644 --- a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-abort.diff +++ b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-abort.diff @@ -28,7 +28,7 @@ } bb4 (cleanup): { - drop(_2) -> [return: bb5, unwind terminate]; + drop(_2) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff index 2ada087b4bd..aa9fcb505e6 100644 --- a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff @@ -28,7 +28,7 @@ } bb4 (cleanup): { - drop(_2) -> [return: bb5, unwind terminate]; + drop(_2) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir b/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir index 6a4c5436fce..6fcceb6c66b 100644 --- a/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir +++ b/tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir @@ -104,7 +104,7 @@ yields () bb13 (cleanup): { StorageDead(_3); - drop(_1) -> [return: bb14, unwind terminate]; + drop(_1) -> [return: bb14, unwind terminate(cleanup)]; } bb14 (cleanup): { @@ -113,6 +113,6 @@ yields () bb15 (cleanup): { StorageDead(_3); - drop(_1) -> [return: bb14, unwind terminate]; + drop(_1) -> [return: bb14, unwind terminate(cleanup)]; } } diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff index 503dc5beb19..aa9429c46d8 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff @@ -17,7 +17,7 @@ StorageLive(_1); - _1 = foo() -> [return: bb1, unwind unreachable]; + StorageLive(_2); -+ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind terminate]; ++ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind terminate(abi)]; } bb1: { diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff index 684211b53b3..ea9c360aa7b 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff @@ -32,7 +32,7 @@ + } + + bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate]; ++ drop(_2) -> [return: bb4, unwind terminate(cleanup)]; + } + + bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff index f3a6ee22c20..b7fea4f2e14 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff @@ -30,7 +30,7 @@ } bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate]; + drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff index ad801fd280a..1fd1014ba1d 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff @@ -36,7 +36,7 @@ + } + + bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate]; ++ drop(_2) -> [return: bb4, unwind terminate(cleanup)]; + } + + bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff index 99dc64115a9..e8299db47db 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff @@ -36,7 +36,7 @@ + } + + bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate]; ++ drop(_2) -> [return: bb4, unwind terminate(cleanup)]; + } + + bb4 (cleanup): { diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff index ef85e075eeb..b82961c2815 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff @@ -27,7 +27,7 @@ } bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate]; + drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff index 5df730a9930..47fd0ed0799 100644 --- a/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff @@ -30,7 +30,7 @@ } bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate]; + drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index 073ddeff7ca..9f8c5806c90 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -54,11 +54,11 @@ + } + + bb4 (cleanup): { -+ drop(_4) -> [return: bb5, unwind terminate]; ++ drop(_4) -> [return: bb5, unwind terminate(cleanup)]; + } + + bb5 (cleanup): { -+ drop(_2) -> [return: bb6, unwind terminate]; ++ drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + } + + bb6 (cleanup): { 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 54c33aac9e8..675292f06d6 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 @@ -155,7 +155,7 @@ - StorageDead(_1); - return; + bb3 (cleanup): { -+ drop(_2) -> [return: bb2, unwind terminate]; ++ drop(_2) -> [return: bb2, unwind terminate(cleanup)]; } - bb4 (cleanup): { diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff index b750330df92..5a946712ea4 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -37,7 +37,7 @@ } bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate]; + drop(_1) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff index 7765e491d89..cbfb39115b3 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff @@ -40,7 +40,7 @@ } bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate]; + drop(_1) -> [return: bb5, unwind terminate(cleanup)]; } bb5 (cleanup): { diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff index 6ee6a0ffe4c..ab81f707148 100644 --- a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -40,7 +40,7 @@ bb4 (cleanup): { _8 = &mut _3; - _9 = <Box<[i32]> as Drop>::drop(move _8) -> [return: bb1, unwind terminate]; + _9 = <Box<[i32]> as Drop>::drop(move _8) -> [return: bb1, unwind terminate(cleanup)]; } } diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-abort.diff b/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-abort.diff index 11501907b88..4469270a9b2 100644 --- a/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-abort.diff +++ b/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-abort.diff @@ -40,17 +40,17 @@ } bb3 (cleanup): { -- drop(_3) -> [return: bb5, unwind terminate]; +- drop(_3) -> [return: bb5, unwind terminate(cleanup)]; + goto -> bb5; } bb4 (cleanup): { -- drop(_4) -> [return: bb5, unwind terminate]; +- drop(_4) -> [return: bb5, unwind terminate(cleanup)]; + goto -> bb5; } bb5 (cleanup): { -- drop(_2) -> [return: bb6, unwind terminate]; +- drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + goto -> bb8; } @@ -59,7 +59,7 @@ + } + + bb7 (cleanup): { -+ drop(_2) -> [return: bb6, unwind terminate]; ++ drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + } + + bb8 (cleanup): { diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-unwind.diff index 11501907b88..4469270a9b2 100644 --- a/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41110.main.ElaborateDrops.panic-unwind.diff @@ -40,17 +40,17 @@ } bb3 (cleanup): { -- drop(_3) -> [return: bb5, unwind terminate]; +- drop(_3) -> [return: bb5, unwind terminate(cleanup)]; + goto -> bb5; } bb4 (cleanup): { -- drop(_4) -> [return: bb5, unwind terminate]; +- drop(_4) -> [return: bb5, unwind terminate(cleanup)]; + goto -> bb5; } bb5 (cleanup): { -- drop(_2) -> [return: bb6, unwind terminate]; +- drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + goto -> bb8; } @@ -59,7 +59,7 @@ + } + + bb7 (cleanup): { -+ drop(_2) -> [return: bb6, unwind terminate]; ++ drop(_2) -> [return: bb6, unwind terminate(cleanup)]; + } + + bb8 (cleanup): { diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff index 65f4806aaf7..78184f6aeeb 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-abort.diff @@ -47,7 +47,7 @@ bb3 (cleanup): { _2 = move _5; -- drop(_5) -> [return: bb8, unwind terminate]; +- drop(_5) -> [return: bb8, unwind terminate(cleanup)]; + goto -> bb8; } @@ -70,17 +70,17 @@ } bb7 (cleanup): { -- drop(_4) -> [return: bb8, unwind terminate]; +- drop(_4) -> [return: bb8, unwind terminate(cleanup)]; + goto -> bb8; } bb8 (cleanup): { -- drop(_2) -> [return: bb9, unwind terminate]; +- drop(_2) -> [return: bb9, unwind terminate(cleanup)]; + goto -> bb9; } bb9 (cleanup): { -- drop(_1) -> [return: bb10, unwind terminate]; +- drop(_1) -> [return: bb10, unwind terminate(cleanup)]; + goto -> bb12; } @@ -89,7 +89,7 @@ + } + + bb11 (cleanup): { -+ drop(_1) -> [return: bb10, unwind terminate]; ++ drop(_1) -> [return: bb10, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff index 4845fc732aa..688887c3c1f 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff @@ -47,7 +47,7 @@ bb3 (cleanup): { _2 = move _5; -- drop(_5) -> [return: bb8, unwind terminate]; +- drop(_5) -> [return: bb8, unwind terminate(cleanup)]; + goto -> bb8; } @@ -70,17 +70,17 @@ } bb7 (cleanup): { -- drop(_4) -> [return: bb8, unwind terminate]; +- drop(_4) -> [return: bb8, unwind terminate(cleanup)]; + goto -> bb8; } bb8 (cleanup): { -- drop(_2) -> [return: bb9, unwind terminate]; +- drop(_2) -> [return: bb9, unwind terminate(cleanup)]; + goto -> bb9; } bb9 (cleanup): { -- drop(_1) -> [return: bb10, unwind terminate]; +- drop(_1) -> [return: bb10, unwind terminate(cleanup)]; + goto -> bb12; } @@ -89,7 +89,7 @@ + } + + bb11 (cleanup): { -+ drop(_1) -> [return: bb10, unwind terminate]; ++ drop(_1) -> [return: bb10, unwind terminate(cleanup)]; + } + + bb12 (cleanup): { diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff index aca7fe95c18..b57fe348c2d 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-abort.diff @@ -58,7 +58,7 @@ + _8 = const true; + _9 = const true; _1 = move _3; -- drop(_3) -> [return: bb11, unwind terminate]; +- drop(_3) -> [return: bb11, unwind terminate(cleanup)]; + goto -> bb11; } @@ -102,7 +102,7 @@ } bb11 (cleanup): { -- drop(_1) -> [return: bb12, unwind terminate]; +- drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + goto -> bb12; } @@ -124,7 +124,7 @@ + } + + bb16 (cleanup): { -+ drop(_1) -> [return: bb12, unwind terminate]; ++ drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + } + + bb17: { diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff index 60ce9cd8ad9..2156850e38c 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff @@ -58,7 +58,7 @@ + _8 = const true; + _9 = const true; _1 = move _3; -- drop(_3) -> [return: bb11, unwind terminate]; +- drop(_3) -> [return: bb11, unwind terminate(cleanup)]; + goto -> bb11; } @@ -102,7 +102,7 @@ } bb11 (cleanup): { -- drop(_1) -> [return: bb12, unwind terminate]; +- drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + goto -> bb12; } @@ -124,7 +124,7 @@ + } + + bb16 (cleanup): { -+ drop(_1) -> [return: bb12, unwind terminate]; ++ drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + } + + bb17: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir index ae0beffae18..73462967850 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir @@ -100,11 +100,11 @@ fn test() -> Option<Box<u32>> { } bb11 (cleanup): { - drop(_1) -> [return: bb13, unwind terminate]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb12 (cleanup): { - drop(_5) -> [return: bb13, unwind terminate]; + drop(_5) -> [return: bb13, unwind terminate(cleanup)]; } bb13 (cleanup): { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir index 7ecdc428e59..8264e2cabbc 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -100,11 +100,11 @@ fn test() -> Option<Box<u32>> { } bb11 (cleanup): { - drop(_1) -> [return: bb13, unwind terminate]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb12 (cleanup): { - drop(_5) -> [return: bb13, unwind terminate]; + drop(_5) -> [return: bb13, unwind terminate(cleanup)]; } bb13 (cleanup): { diff --git a/tests/mir-opt/issue_91633.bar.built.after.mir b/tests/mir-opt/issue_91633.bar.built.after.mir index 92f52e138a5..cce1a1fd2ef 100644 --- a/tests/mir-opt/issue_91633.bar.built.after.mir +++ b/tests/mir-opt/issue_91633.bar.built.after.mir @@ -28,7 +28,7 @@ fn bar(_1: Box<[T]>) -> () { } bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate]; + drop(_1) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/issue_91633.foo.built.after.mir b/tests/mir-opt/issue_91633.foo.built.after.mir index 4529c58a137..a66769f0d11 100644 --- a/tests/mir-opt/issue_91633.foo.built.after.mir +++ b/tests/mir-opt/issue_91633.foo.built.after.mir @@ -45,7 +45,7 @@ fn foo(_1: Box<[T]>) -> T { } bb5 (cleanup): { - drop(_1) -> [return: bb6, unwind terminate]; + drop(_1) -> [return: bb6, unwind terminate(cleanup)]; } bb6 (cleanup): { diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index be09ed641b8..3e817ff433b 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -243,7 +243,7 @@ } - bb25 (cleanup): { -- drop(_2) -> [return: bb26, unwind terminate]; +- drop(_2) -> [return: bb26, unwind terminate(cleanup)]; + bb22 (cleanup): { + goto -> bb27; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index be09ed641b8..3e817ff433b 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -243,7 +243,7 @@ } - bb25 (cleanup): { -- drop(_2) -> [return: bb26, unwind terminate]; +- drop(_2) -> [return: bb26, unwind terminate(cleanup)]; + bb22 (cleanup): { + goto -> bb27; } diff --git a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-abort.mir index e22fc7d54bc..99a7a6b6154 100644 --- a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-abort.mir @@ -31,7 +31,7 @@ fn main() -> () { } bb3 (cleanup): { - drop(_2) -> [return: bb4, unwind terminate]; + drop(_2) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir index 6fb107929e6..7364b329e12 100644 --- a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir @@ -31,7 +31,7 @@ fn main() -> () { } bb3 (cleanup): { - drop(_2) -> [return: bb4, unwind terminate]; + drop(_2) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index bc04790028d..0ef19180459 100644 --- a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -33,7 +33,7 @@ fn main() -> () { bb1 (cleanup): { (_1.0: Aligned) = move _4; - drop(_1) -> [return: bb3, unwind terminate]; + drop(_1) -> [return: bb3, unwind terminate(cleanup)]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/chained_comparison.rs b/tests/mir-opt/pre-codegen/chained_comparison.rs index f7879140f81..43030041983 100644 --- a/tests/mir-opt/pre-codegen/chained_comparison.rs +++ b/tests/mir-opt/pre-codegen/chained_comparison.rs @@ -1,5 +1,4 @@ // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 -// ignore-debug #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs index dee43b0c6f8..23d78e98777 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.rs +++ b/tests/mir-opt/pre-codegen/checked_ops.rs @@ -1,6 +1,5 @@ // compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 // needs-unwind -// ignore-debug // only-x86_64 #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/intrinsics.rs b/tests/mir-opt/pre-codegen/intrinsics.rs index ecdb656cb85..e32e04384c4 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.rs +++ b/tests/mir-opt/pre-codegen/intrinsics.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug // Checks that we do not have any branches in the MIR for the two tested functions. diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir index 940b9ae1156..4db829a5ec3 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -83,7 +83,7 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> () } bb9 (cleanup): { - drop(_5) -> [return: bb10, unwind terminate]; + drop(_5) -> [return: bb10, unwind terminate(cleanup)]; } bb10 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index 2614160363e..c30df7425d2 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -75,7 +75,7 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () { } bb9 (cleanup): { - drop(_5) -> [return: bb10, unwind terminate]; + drop(_5) -> [return: bb10, unwind terminate(cleanup)]; } bb10 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs index 67f549a511c..f3ba409229d 100644 --- a/tests/mir-opt/pre-codegen/loops.rs +++ b/tests/mir-opt/pre-codegen/loops.rs @@ -1,6 +1,5 @@ // compile-flags: -O -Zmir-opt-level=2 -g // needs-unwind -// ignore-debug #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index 8eff46fb931..cb29473d762 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -67,7 +67,7 @@ fn vec_move(_1: Vec<impl Sized>) -> () { } bb9 (cleanup): { - drop(_3) -> [return: bb10, unwind terminate]; + drop(_3) -> [return: bb10, unwind terminate(cleanup)]; } bb10 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/mem_replace.rs b/tests/mir-opt/pre-codegen/mem_replace.rs index e5066c38b96..a139848bab2 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.rs +++ b/tests/mir-opt/pre-codegen/mem_replace.rs @@ -1,6 +1,6 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug +// ignore-debug the standard library debug assertions leak into this test #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 4d7c017dad4..35f7356d47a 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -127,7 +127,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb11 (cleanup): { - drop(_3) -> [return: bb12, unwind terminate]; + drop(_3) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index bbab4e47a3a..a677e8b439f 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -82,7 +82,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb8 (cleanup): { - drop(_3) -> [return: bb9, unwind terminate]; + drop(_3) -> [return: bb9, unwind terminate(cleanup)]; } bb9 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/range_iter.rs b/tests/mir-opt/pre-codegen/range_iter.rs index cabd9419e92..9552144787d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.rs +++ b/tests/mir-opt/pre-codegen/range_iter.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index 68d78f74328..312565e45c3 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -3,9 +3,9 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { debug x => _1; let mut _0: std::option::Option<i32>; - scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:18:12: 18:15]>) { + scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:17:12: 17:15]>) { debug slf => _1; - debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; + debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:17:12: 17:15]; let mut _2: isize; let _3: i32; let mut _4: i32; diff --git a/tests/mir-opt/pre-codegen/simple_option_map.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index fb3da68e4af..d4f28dda6c6 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug #[inline(always)] fn map<T, U, F>(slf: Option<T>, f: F) -> Option<U> diff --git a/tests/mir-opt/pre-codegen/slice_index.rs b/tests/mir-opt/pre-codegen/slice_index.rs index d80bff50c31..57ffb07e294 100644 --- a/tests/mir-opt/pre-codegen/slice_index.rs +++ b/tests/mir-opt/pre-codegen/slice_index.rs @@ -1,6 +1,6 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug +// ignore-debug the standard library debug assertions leak into this test // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 836fa2677b1..3d76bab7ce7 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -195,7 +195,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate]; + drop(_2) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 65baaf64a9e..e8586cec981 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -182,7 +182,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate]; + drop(_2) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index f7b19e80e44..8bd072fd625 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -143,7 +143,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12 (cleanup): { - drop(_2) -> [return: bb13, unwind terminate]; + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; } bb13 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index 43f8806e165..3cdc49f6056 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -196,7 +196,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate]; + drop(_2) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs index 4e954aa3433..1790056369c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.rs +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -1,6 +1,6 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug +// ignore-debug the standard library debug assertions leak into this test // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/try_identity.rs b/tests/mir-opt/pre-codegen/try_identity.rs index 079ecccab28..a227c82d6a3 100644 --- a/tests/mir-opt/pre-codegen/try_identity.rs +++ b/tests/mir-opt/pre-codegen/try_identity.rs @@ -1,6 +1,5 @@ // compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 // only-64bit -// ignore-debug // Track the status of MIR optimizations simplifying `Ok(res?)` for both the old and new desugarings // of that syntax. diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 4083b45470b..610660131b1 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -426,7 +426,7 @@ fn multiple_storage() { // As there are multiple `StorageLive` statements for `x`, we cannot know if this `z`'s // pointer address is the address of `x`, so do nothing. let y = *z; - Call(RET, retblock, opaque(y)) + Call(RET = opaque(y), retblock) } retblock = { @@ -452,7 +452,7 @@ fn dominate_storage() { } bb1 = { let c = *r; - Call(RET, bb2, opaque(c)) + Call(RET = opaque(c), bb2) } bb2 = { StorageDead(x); @@ -486,18 +486,18 @@ fn maybe_dead(m: bool) { bb1 = { StorageDead(x); StorageDead(y); - Call(RET, bb2, opaque(u)) + Call(RET = opaque(u), bb2) } bb2 = { // As `x` may be `StorageDead`, `a` may be dangling, so we do nothing. let z = *a; - Call(RET, bb3, opaque(z)) + Call(RET = opaque(z), bb3) } bb3 = { // As `y` may be `StorageDead`, `b` may be dangling, so we do nothing. // This implies that we also do not substitute `b` in `bb0`. let t = *b; - Call(RET, retblock, opaque(t)) + Call(RET = opaque(t), retblock) } retblock = { Return() diff --git a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 508f964099a..7d3346faba6 100644 --- a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -167,11 +167,11 @@ fn main() -> () { } bb7 (cleanup): { - drop(_21) -> [return: bb9, unwind terminate]; + drop(_21) -> [return: bb9, unwind terminate(cleanup)]; } bb8 (cleanup): { - drop(_5) -> [return: bb9, unwind terminate]; + drop(_5) -> [return: bb9, unwind terminate(cleanup)]; } bb9 (cleanup): { diff --git a/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir b/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir index 9bf69acd356..3a8b457a7a1 100644 --- a/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir @@ -24,7 +24,7 @@ fn std::ptr::drop_in_place(_1: *mut [String]) -> () { bb3 (cleanup): { _4 = &raw mut (*_1)[_3]; _3 = Add(move _3, const 1_usize); - drop((*_4)) -> [return: bb4, unwind terminate]; + drop((*_4)) -> [return: bb4, unwind terminate(cleanup)]; } bb4 (cleanup): { diff --git a/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir b/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir index ee90a540720..b5879418355 100644 --- a/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir @@ -22,7 +22,7 @@ fn std::ptr::drop_in_place(_1: *mut Vec<i32>) -> () { } bb4 (cleanup): { - drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb2, unwind terminate]; + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb2, unwind terminate(cleanup)]; } bb5: { diff --git a/tests/run-make/issue-88756-default-output/output-default.stdout b/tests/run-make/issue-88756-default-output/output-default.stdout index b280698230d..de8ff0e5f89 100644 --- a/tests/run-make/issue-88756-default-output/output-default.stdout +++ b/tests/run-make/issue-88756-default-output/output-default.stdout @@ -191,6 +191,8 @@ Options: removed, see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information + --html-no-source + Disable HTML source code pages generation @path Read newline separated options from `path` diff --git a/tests/run-make/optimization-remarks-dir-pgo/Makefile b/tests/run-make/optimization-remarks-dir-pgo/Makefile index c88ec1e6cb3..3bc3d7d1428 100644 --- a/tests/run-make/optimization-remarks-dir-pgo/Makefile +++ b/tests/run-make/optimization-remarks-dir-pgo/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-cross-compile # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. diff --git a/tests/run-make/panic-abort-eh_frame/Makefile b/tests/run-make/panic-abort-eh_frame/Makefile index 1cb7bf575cb..7020455b742 100644 --- a/tests/run-make/panic-abort-eh_frame/Makefile +++ b/tests/run-make/panic-abort-eh_frame/Makefile @@ -6,5 +6,5 @@ include ../tools.mk all: - $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort + $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort --edition 2021 -Z validate-mir objdump --dwarf=frames $(TMPDIR)/foo.o | $(CGREP) -v 'DW_CFA' diff --git a/tests/run-make/panic-abort-eh_frame/foo.rs b/tests/run-make/panic-abort-eh_frame/foo.rs index e1853529455..e2274d469e7 100644 --- a/tests/run-make/panic-abort-eh_frame/foo.rs +++ b/tests/run-make/panic-abort-eh_frame/foo.rs @@ -1,5 +1,13 @@ #![no_std] +use core::future::Future; + +pub struct NeedsDrop; + +impl Drop for NeedsDrop { + fn drop(&mut self) {} +} + #[panic_handler] fn handler(_: &core::panic::PanicInfo<'_>) -> ! { loop {} @@ -8,3 +16,19 @@ fn handler(_: &core::panic::PanicInfo<'_>) -> ! { pub unsafe fn oops(x: *const u32) -> u32 { *x } + +pub async fn foo(_: NeedsDrop) { + async fn bar() {} + bar().await; +} + +pub fn poll_foo(x: &mut core::task::Context<'_>) { + let _g = NeedsDrop; + let mut p = core::pin::pin!(foo(NeedsDrop)); + let _ = p.as_mut().poll(x); + let _ = p.as_mut().poll(x); +} + +pub fn drop_foo() { + drop(foo(NeedsDrop)); +} diff --git a/tests/rustdoc-gui/docblock-table.goml b/tests/rustdoc-gui/docblock-table.goml index 011451ef4f3..678b302f22e 100644 --- a/tests/rustdoc-gui/docblock-table.goml +++ b/tests/rustdoc-gui/docblock-table.goml @@ -36,17 +36,17 @@ define-function: ( ) call-function: ("check-colors", { - "theme": "dark", - "border_color": "rgb(224, 224, 224)", - "zebra_stripe_color": "rgb(42, 42, 42)", + "theme": "ayu", + "border_color": "#5c6773", + "zebra_stripe_color": "#191f26", }) call-function: ("check-colors", { - "theme": "ayu", - "border_color": "rgb(92, 103, 115)", - "zebra_stripe_color": "rgb(25, 31, 38)", + "theme": "dark", + "border_color": "#e0e0e0", + "zebra_stripe_color": "#2a2a2a", }) call-function: ("check-colors", { "theme": "light", - "border_color": "rgb(224, 224, 224)", - "zebra_stripe_color": "rgb(245, 245, 245)", + "border_color": "#e0e0e0", + "zebra_stripe_color": "#f5f5f5", }) diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index 83c6980909c..a4e22364859 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -2,262 +2,138 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" show-text: true -// Ayu theme -set-local-storage: { - "rustdoc-theme": "ayu", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - "color": "rgb(255, 255, 255)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(255, 255, 255)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(57, 175, 215)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(197, 197, 197)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(92, 103, 115)", - "background-color": "rgb(20, 25, 32)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(197, 197, 197)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(20, 25, 32)", - }, -) - -// Dark theme -set-local-storage: { - "rustdoc-theme": "dark", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) -focus: ".search-input" -// Only "border-color" should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(0, 141, 253)", - "background-color": "rgb(240, 240, 240)", - "color": "rgb(17, 17, 17)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(210, 153, 29)", +define-function: ( + "check-search-colors", + ( + theme, border, background, search_input_color, search_input_border_focus, + menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color, + ), + block { + set-local-storage: { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + } + reload: + assert-css: ( + ".search-input", + { + "border-color": |border|, + "background-color": |background|, + "color": |search_input_color|, + }, + ) + // Focus on search input. + focus: ".search-input" + assert-css: ( + ".search-input", + { + "border-color": |search_input_border_focus|, + "background-color": |background|, + "color": |search_input_color|, + }, + ) + assert-css: ( + "#help-button", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_color|, + "border-color": |border|, + "background-color": |background|, + }, + ) + // Hover help button. + move-cursor-to: "#help-button" + assert-css: ( + "#help-button:hover", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#help-button > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border_hover|, + "background-color": |background|, + }, + ) + // Link color inside + click: "#help-button" + assert-css: ( + "#help a", + { + "color": |menu_a_color|, + }, + ) + assert-css: ( + "#settings-menu", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu > a", + { + "color": |menu_button_a_color|, + "border-color": |border|, + "background-color": |background|, + }, + ) + // Hover settings menu. + move-cursor-to: "#settings-menu" + assert-css: ( + "#settings-menu:hover", + {"border-color": |menu_button_border|}, + ) + assert-css: ( + "#settings-menu:hover > a", + { + "color": |menu_button_a_color|, + "border-color": |menu_button_a_border_hover|, + "background-color": |background|, + }, + ) }, ) -assert-css: ( - "#settings-menu", - {"border-color": "rgb(221, 221, 221)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(240, 240, 240)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(221, 221, 221)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(255, 185, 0)", - "background-color": "rgb(240, 240, 240)", - }, -) - -// Light theme -set-local-storage: { - "rustdoc-theme": "light", - "rustdoc-use-system-theme": "false", -} -reload: - -assert-css: ( - ".search-input", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) -focus: ".search-input" -// Nothing should change. -assert-css: ( - ".search-input", - { - "border-color": "rgb(102, 175, 233)", - "background-color": "rgb(255, 255, 255)", - "color": "rgb(0, 0, 0)", - }, -) - -assert-css: ( - "#help-button", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#help-button > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#help-button" -assert-css: ( - "#help-button:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#help-button:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, -) -// Link color inside -click: "#help-button" -assert-css: ( - "#help a", - { - "color": "rgb(56, 115, 173)", - }, -) - -assert-css: ( - "#settings-menu", - {"border-color": "rgb(0, 0, 0)"}, -) -assert-css: ( - "#settings-menu > a", - { - "border-color": "rgb(224, 224, 224)", - "background-color": "rgb(255, 255, 255)", - }, -) -move-cursor-to: "#settings-menu" -assert-css: ( - "#settings-menu:hover", - {"border-color": "rgb(0, 0, 0)"}, -) -// Only "border-color" should change. -assert-css: ( - "#settings-menu:hover > a", - { - "color": "rgb(0, 0, 0)", - "border-color": "rgb(113, 113, 113)", - "background-color": "rgb(255, 255, 255)", - }, +call-function: ( + "check-search-colors", + { + "theme": "ayu", + "border": "#5c6773", + "background": "#141920", + "search_input_color": "#fff", + "search_input_border_focus": "#5c6773", + "menu_button_border": "#c5c5c5", + "menu_button_a_color": "#fff", + "menu_button_a_border_hover": "#e0e0e0", + "menu_a_color": "#39afd7", + } +) +call-function: ( + "check-search-colors", + { + "theme": "dark", + "border": "#e0e0e0", + "background": "#f0f0f0", + "search_input_color": "#111", + "search_input_border_focus": "#008dfd", + "menu_button_border": "#ddd", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#ffb900", + "menu_a_color": "#d2991d", + } +) +call-function: ( + "check-search-colors", + { + "theme": "light", + "border": "#e0e0e0", + "background": "#fff", + "search_input_color": "#000", + "search_input_border_focus": "#66afe9", + "menu_button_border": "#000", + "menu_button_a_color": "#000", + "menu_button_a_border_hover": "#717171", + "menu_a_color": "#3873ad", + } ) diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 574cc629a04..913d72932b9 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -67,7 +67,7 @@ assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums") assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants") assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits") assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions") -assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions") +assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Aliases") assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions") assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords") assert-text: ("#structs + .item-table .item-name > a", "Foo") @@ -102,7 +102,7 @@ assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules") assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs") assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits") assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions") -assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Definitions") +assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Aliases") assert-text: ("#functions + .item-table .item-name > a", "foobar") click: "#functions + .item-table .item-name > a" diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 49484ee0869..38180aef762 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -65,6 +65,18 @@ impl Foo { pub fn must_use(&self) -> bool { true } + + /// hello + /// + /// <div id="doc-warning-1" class="warning">this is a warning</div> + /// + /// done + pub fn warning1() {} + + /// Checking there is no bottom margin if "warning" is the last element. + /// + /// <div id="doc-warning-2" class="warning">this is a warning</div> + pub fn warning2() {} } impl AsRef<str> for Foo { diff --git a/tests/rustdoc-gui/warning-block.goml b/tests/rustdoc-gui/warning-block.goml new file mode 100644 index 00000000000..8832b65c4d8 --- /dev/null +++ b/tests/rustdoc-gui/warning-block.goml @@ -0,0 +1,42 @@ +// Test to check that the "warning blocks" are displayed as expected. +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +show-text: true + +define-function: ( + "check-warning", + (theme, color, border_color), + block { + set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} + reload: + + // The IDs are added directly into the DOM to make writing this test easier. + assert-css: ("#doc-warning-1", { + "margin-bottom": "12px", + "color": |color|, + "border-left": "2px solid " + |border_color|, + "background-color": "transparent", + }) + assert-css: ("#doc-warning-2", { + "margin-bottom": "0px", + "color": |color|, + "border-left": "2px solid " + |border_color|, + "background-color": "transparent", + }) + }, +) + +call-function: ("check-warning", { + "theme": "ayu", + "color": "#c5c5c5", + "border_color": "#ff8e00", +}) +call-function: ("check-warning", { + "theme": "dark", + "color": "#ddd", + "border_color": "#ff8e00", +}) +call-function: ("check-warning", { + "theme": "light", + "color": "black", + "border_color": "#ff8e00", +}) diff --git a/tests/rustdoc-json/fn_pointer/abi.rs b/tests/rustdoc-json/fn_pointer/abi.rs index 77c0e82330f..dbe316f573d 100644 --- a/tests/rustdoc-json/fn_pointer/abi.rs +++ b/tests/rustdoc-json/fn_pointer/abi.rs @@ -2,23 +2,23 @@ #![feature(abi_vectorcall)] -// @is "$.index[*][?(@.name=='AbiRust')].inner.typedef.type.function_pointer.header.abi" \"Rust\" +// @is "$.index[*][?(@.name=='AbiRust')].inner.type_alias.type.function_pointer.header.abi" \"Rust\" pub type AbiRust = fn(); -// @is "$.index[*][?(@.name=='AbiC')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiC')].inner.type_alias.type.function_pointer.header.abi" '{"C": {"unwind": false}}' pub type AbiC = extern "C" fn(); -// @is "$.index[*][?(@.name=='AbiSystem')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": false}}' +// @is "$.index[*][?(@.name=='AbiSystem')].inner.type_alias.type.function_pointer.header.abi" '{"System": {"unwind": false}}' pub type AbiSystem = extern "system" fn(); -// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.typedef.type.function_pointer.header.abi" '{"C": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiCUnwind')].inner.type_alias.type.function_pointer.header.abi" '{"C": {"unwind": true}}' pub type AbiCUnwind = extern "C-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.typedef.type.function_pointer.header.abi" '{"System": {"unwind": true}}' +// @is "$.index[*][?(@.name=='AbiSystemUnwind')].inner.type_alias.type.function_pointer.header.abi" '{"System": {"unwind": true}}' pub type AbiSystemUnwind = extern "system-unwind" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall\""' +// @is "$.index[*][?(@.name=='AbiVecorcall')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall\""' pub type AbiVecorcall = extern "vectorcall" fn(); -// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.typedef.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' +// @is "$.index[*][?(@.name=='AbiVecorcallUnwind')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""' pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn(); diff --git a/tests/rustdoc-json/fn_pointer/generics.rs b/tests/rustdoc-json/fn_pointer/generics.rs index 48672f12da1..3b82561ec7d 100644 --- a/tests/rustdoc-json/fn_pointer/generics.rs +++ b/tests/rustdoc-json/fn_pointer/generics.rs @@ -3,11 +3,11 @@ #![feature(no_core)] #![no_core] -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][0]" '"val"' -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.decl.output.primitive" \"i32\" -// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].name" \"\'c\" -// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.typedef.type.function_pointer.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][0]" '"val"' +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.inputs[0][1].borrowed_ref.lifetime" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.decl.output.primitive" \"i32\" +// @count "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[0].name" \"\'c\" +// @is "$.index[*][?(@.name=='WithHigherRankTraitBounds')].inner.type_alias.type.function_pointer.generic_params[0].kind" '{ "lifetime": { "outlives": [] } }' pub type WithHigherRankTraitBounds = for<'c> fn(val: &'c i32) -> i32; diff --git a/tests/rustdoc-json/fn_pointer/qualifiers.rs b/tests/rustdoc-json/fn_pointer/qualifiers.rs index 0ab776c21ed..1a62eb2bae8 100644 --- a/tests/rustdoc-json/fn_pointer/qualifiers.rs +++ b/tests/rustdoc-json/fn_pointer/qualifiers.rs @@ -1,11 +1,11 @@ // ignore-tidy-linelength -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.unsafe" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.const" false -// @is "$.index[*][?(@.name=='FnPointer')].inner.typedef.type.function_pointer.header.async" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.unsafe" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='FnPointer')].inner.type_alias.type.function_pointer.header.async" false pub type FnPointer = fn(); -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.unsafe" true -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.const" false -// @is "$.index[*][?(@.name=='UnsafePointer')].inner.typedef.type.function_pointer.header.async" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.unsafe" true +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.const" false +// @is "$.index[*][?(@.name=='UnsafePointer')].inner.type_alias.type.function_pointer.header.async" false pub type UnsafePointer = unsafe fn(); diff --git a/tests/rustdoc-json/primitives/primitive_type.rs b/tests/rustdoc-json/primitives/primitive_type.rs index 5f251b3b890..89c5d06c0b2 100644 --- a/tests/rustdoc-json/primitives/primitive_type.rs +++ b/tests/rustdoc-json/primitives/primitive_type.rs @@ -1,17 +1,17 @@ #![feature(never_type)] // @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" -// @is "$.index[*][?(@.name=='PrimNever')].inner.typedef.type.primitive" \"never\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type_alias.type.primitive" \"never\" pub type PrimNever = !; -// @is "$.index[*][?(@.name=='PrimStr')].inner.typedef.type.primitive" \"str\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type_alias.type.primitive" \"str\" pub type PrimStr = str; -// @is "$.index[*][?(@.name=='PrimBool')].inner.typedef.type.primitive" \"bool\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type_alias.type.primitive" \"bool\" pub type PrimBool = bool; -// @is "$.index[*][?(@.name=='PrimChar')].inner.typedef.type.primitive" \"char\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type_alias.type.primitive" \"char\" pub type PrimChar = char; -// @is "$.index[*][?(@.name=='PrimU8')].inner.typedef.type.primitive" \"u8\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type_alias.type.primitive" \"u8\" pub type PrimU8 = u8; diff --git a/tests/rustdoc-json/type/dyn.rs b/tests/rustdoc-json/type/dyn.rs index e5ee60fad59..4db65b61dc6 100644 --- a/tests/rustdoc-json/type/dyn.rs +++ b/tests/rustdoc-json/type/dyn.rs @@ -7,40 +7,40 @@ use std::fmt::Debug; // @set weird_order = "$.index[*][?(@.name=='WeirdOrder')].id" // @ismany "$.index[*][?(@.name=='dyn')].inner.module.items[*]" $sync_int_gen $ref_fn $weird_order -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.generics" '{"params": [], "where_predicates": []}' -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.name" \"Box\" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args" 1 -// @has "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait" -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.lifetime" \"\'static\" -// @count "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[*]" 3 -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].generic_params" [] -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Fn"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].trait.name" '"Sync"' -// @is "$.index[*][?(@.name=='SyncIntGen')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"primitive": "i32"}}}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.generics" '{"params": [], "where_predicates": []}' +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.name" \"Box\" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.bindings" [] +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args" 1 +// @has "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait" +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.lifetime" \"\'static\" +// @count "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[*]" 3 +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].generic_params" [] +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Fn"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[2].trait.name" '"Sync"' +// @is "$.index[*][?(@.name=='SyncIntGen')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.args" '{"parenthesized": {"inputs": [],"output": {"primitive": "i32"}}}' pub type SyncIntGen = Box<dyn Fn() -> i32 + Send + Sync + 'static>; -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.mutable" 'false' -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.lifetime" "\"'a\"" -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.lifetime" null -// @count "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[*]" 1 -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref.lifetime" "\"'b\"" -// @has "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref" -// @is "$.index[*][?(@.name=='RefFn')].inner.typedef.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.generics" '{"params": [{"kind": {"lifetime": {"outlives": []}},"name": "'\''a"}],"where_predicates": []}' +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.mutable" 'false' +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.lifetime" "\"'a\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.lifetime" null +// @count "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[*]" 1 +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].generic_params" '[{"kind": {"lifetime": {"outlives": []}},"name": "'\''b"}]' +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.name" '"Fn"' +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.inputs[0].borrowed_ref.lifetime" "\"'b\"" +// @has "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref" +// @is "$.index[*][?(@.name=='RefFn')].inner.type_alias.type.borrowed_ref.type.dyn_trait.traits[0].trait.args.parenthesized.output.borrowed_ref.lifetime" "\"'b\"" pub type RefFn<'a> = &'a dyn for<'b> Fn(&'b i32) -> &'b i32; -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Send"' -// @is "$.index[*][?(@.name=='WeirdOrder')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Debug"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[0].trait.name" '"Send"' +// @is "$.index[*][?(@.name=='WeirdOrder')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.dyn_trait.traits[1].trait.name" '"Debug"' pub type WeirdOrder = Box<dyn Send + Debug>; diff --git a/tests/rustdoc-json/type/fn_lifetime.rs b/tests/rustdoc-json/type/fn_lifetime.rs index 424c5dce273..4aca303e6dc 100644 --- a/tests/rustdoc-json/type/fn_lifetime.rs +++ b/tests/rustdoc-json/type/fn_lifetime.rs @@ -1,26 +1,26 @@ // ignore-tidy-linelength -// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef" +// @has "$.index[*][?(@.name=='GenericFn')].inner.type_alias" -// @ismany "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.generic_params[*]" 0 -// @count "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='GenericFn')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" +// @ismany "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.generic_params[*]" 0 +// @count "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='GenericFn')].inner.type_alias.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type GenericFn<'a> = fn(&'a i32) -> &'a i32; -// @has "$.index[*][?(@.name=='ForAll')].inner.typedef" -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.params[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].name" \"\'a\" -// @has "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime" -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.generic_params[*].kind.lifetime.outlives[*]" 0 -// @count "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*]" 1 -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" -// @is "$.index[*][?(@.name=='ForAll')].inner.typedef.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type_alias" +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.generics.params[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].name" \"\'a\" +// @has "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].kind.lifetime" +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.generic_params[*].kind.lifetime.outlives[*]" 0 +// @count "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.inputs[*]" 1 +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.inputs[*][1].borrowed_ref.lifetime" \"\'a\" +// @is "$.index[*][?(@.name=='ForAll')].inner.type_alias.type.function_pointer.decl.output.borrowed_ref.lifetime" \"\'a\" pub type ForAll = for<'a> fn(&'a i32) -> &'a i32; diff --git a/tests/rustdoc-json/type/generic_default.rs b/tests/rustdoc-json/type/generic_default.rs index b4642874532..30817a42e8a 100644 --- a/tests/rustdoc-json/type/generic_default.rs +++ b/tests/rustdoc-json/type/generic_default.rs @@ -9,25 +9,25 @@ pub enum Result<T, E> { // @set my_error = "$.index[*][?(@.name=='MyError')].id" pub struct MyError {} -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef" -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.where_predicates[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[*]" 2 -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].name" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].name" \"E\" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type" -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.bounds[*]" 0 -// @count "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.bounds[*]" 0 -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[0].kind.type.default" null -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.id" $my_error -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.generics.params[1].kind.type.default.resolved_path.name" \"MyError\" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.id" $result -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.name" \"Result\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.bindings" [] -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" -// @has "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[0].type.generic" \"T\" -// @is "$.index[*][?(@.name=='MyResult')].inner.typedef.type.resolved_path.args.angle_bracketed.args[1].type.generic" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias" +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.where_predicates[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[*]" 2 +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].name" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].name" \"E\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type" +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type.bounds[*]" 0 +// @count "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.bounds[*]" 0 +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[0].kind.type.default" null +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path.id" $my_error +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.generics.params[1].kind.type.default.resolved_path.name" \"MyError\" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.id" $result +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.name" \"Result\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.bindings" [] +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.generic" +// @has "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[1].type.generic" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[0].type.generic" \"T\" +// @is "$.index[*][?(@.name=='MyResult')].inner.type_alias.type.resolved_path.args.angle_bracketed.args[1].type.generic" \"E\" pub type MyResult<T, E = MyError> = Result<T, E>; diff --git a/tests/rustdoc-ui/lints/inline-doc-link.rs b/tests/rustdoc-ui/lints/inline-doc-link.rs new file mode 100644 index 00000000000..596f89be3d6 --- /dev/null +++ b/tests/rustdoc-ui/lints/inline-doc-link.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/pull/113167> + +// check-pass +#![deny(rustdoc::redundant_explicit_links)] + +mod m { + pub enum ValueEnum {} +} +mod m2 { + /// [`ValueEnum`] + pub use crate::m::ValueEnum; +} +pub use m2::ValueEnum; diff --git a/tests/rustdoc-ui/lints/no-redundancy.rs b/tests/rustdoc-ui/lints/no-redundancy.rs new file mode 100644 index 00000000000..e3358728b1b --- /dev/null +++ b/tests/rustdoc-ui/lints/no-redundancy.rs @@ -0,0 +1,7 @@ +// check-pass + +#![deny(rustdoc::redundant_explicit_links)] + +/// [Vec][std::vec::Vec#examples] should not warn, because it's not actually redundant! +/// [This is just an `Option`][std::option::Option] has different display content to actual link! +pub fn func() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs new file mode 100644 index 00000000000..fecefb7b25f --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-utf8.rs @@ -0,0 +1,18 @@ +// check-pass + +/// [`…foo`] [`…bar`] [`Err`] +pub struct Broken {} + +/// [`…`] [`…`] [`Err`] +pub struct Broken2 {} + +/// [`…`][…] [`…`][…] [`Err`] +pub struct Broken3 {} + +/// […………………………][Broken3] +pub struct Broken4 {} + +/// [Broken3][…………………………] +pub struct Broken5 {} + +pub struct Err; diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.fixed b/tests/rustdoc-ui/lints/redundant_explicit_links.fixed new file mode 100644 index 00000000000..900234e31e9 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.fixed @@ -0,0 +1,158 @@ +// run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +pub fn dummy_target() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_inline() {} + +/// [`Vec<T>`](Vec) +/// [`Vec<T>`](std::vec::Vec) +pub fn should_not_warn_inline() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_reference_unknown() {} + +/// [`Vec<T>`][Vec] +/// [`Vec<T>`][std::vec::Vec] +pub fn should_not_warn_reference_unknown() {} + +/// [dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`] +//~^ ERROR redundant explicit link target +/// +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`] +//~^ ERROR redundant explicit link target +/// +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [usize] +//~^ ERROR redundant explicit link target +/// [`usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`] TEXT +//~^ ERROR redundant explicit link target +/// +/// [dummy_target]: dummy_target +/// [Vec]: Vec +/// [std::vec::Vec]: Vec +/// [usize]: usize +/// [std::primitive::usize]: usize +pub fn should_warn_reference() {} + +/// [`Vec<T>`]: Vec +/// [`Vec<T>`]: std::vec::Vec +pub fn should_not_warn_reference() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.rs b/tests/rustdoc-ui/lints/redundant_explicit_links.rs new file mode 100644 index 00000000000..13feb85e051 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.rs @@ -0,0 +1,158 @@ +// run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +pub fn dummy_target() {} + +/// [dummy_target](dummy_target) +//~^ ERROR redundant explicit link target +/// [`dummy_target`](dummy_target) +//~^ ERROR redundant explicit link target +/// +/// [Vec](Vec) +//~^ ERROR redundant explicit link target +/// [`Vec`](Vec) +//~^ ERROR redundant explicit link target +/// [Vec](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [`Vec`](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [std::vec::Vec](Vec) +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`](Vec) +//~^ ERROR redundant explicit link target +/// [std::vec::Vec](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`](std::vec::Vec) +//~^ ERROR redundant explicit link target +/// +/// [usize](usize) +//~^ ERROR redundant explicit link target +/// [`usize`](usize) +//~^ ERROR redundant explicit link target +/// [usize](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [`usize`](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [std::primitive::usize](usize) +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`](usize) +//~^ ERROR redundant explicit link target +/// [std::primitive::usize](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`](std::primitive::usize) +//~^ ERROR redundant explicit link target +/// +/// [dummy_target](dummy_target) TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`](dummy_target) TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_inline() {} + +/// [`Vec<T>`](Vec) +/// [`Vec<T>`](std::vec::Vec) +pub fn should_not_warn_inline() {} + +/// [dummy_target][dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] +//~^ ERROR redundant explicit link target +/// +/// [Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// +/// [usize][usize] +//~^ ERROR redundant explicit link target +/// [`usize`][usize] +//~^ ERROR redundant explicit link target +/// [usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] TEXT +//~^ ERROR redundant explicit link target +pub fn should_warn_reference_unknown() {} + +/// [`Vec<T>`][Vec] +/// [`Vec<T>`][std::vec::Vec] +pub fn should_not_warn_reference_unknown() {} + +/// [dummy_target][dummy_target] +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] +//~^ ERROR redundant explicit link target +/// +/// [Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][Vec] +//~^ ERROR redundant explicit link target +/// [std::vec::Vec][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// [`std::vec::Vec`][std::vec::Vec] +//~^ ERROR redundant explicit link target +/// +/// [usize][usize] +//~^ ERROR redundant explicit link target +/// [`usize`][usize] +//~^ ERROR redundant explicit link target +/// [usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][usize] +//~^ ERROR redundant explicit link target +/// [std::primitive::usize][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// [`std::primitive::usize`][std::primitive::usize] +//~^ ERROR redundant explicit link target +/// +/// [dummy_target][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// [`dummy_target`][dummy_target] TEXT +//~^ ERROR redundant explicit link target +/// +/// [dummy_target]: dummy_target +/// [Vec]: Vec +/// [std::vec::Vec]: Vec +/// [usize]: usize +/// [std::primitive::usize]: usize +pub fn should_warn_reference() {} + +/// [`Vec<T>`]: Vec +/// [`Vec<T>`]: std::vec::Vec +pub fn should_not_warn_reference() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links.stderr b/tests/rustdoc-ui/lints/redundant_explicit_links.stderr new file mode 100644 index 00000000000..34ec9be6646 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links.stderr @@ -0,0 +1,1007 @@ +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:7:20 + | +LL | /// [dummy_target](dummy_target) + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +note: the lint level is defined here + --> $DIR/redundant_explicit_links.rs:3:9 + | +LL | #![deny(rustdoc::redundant_explicit_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:9:22 + | +LL | /// [`dummy_target`](dummy_target) + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:12:11 + | +LL | /// [Vec](Vec) + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:14:13 + | +LL | /// [`Vec`](Vec) + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:16:11 + | +LL | /// [Vec](std::vec::Vec) + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:18:13 + | +LL | /// [`Vec`](std::vec::Vec) + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:20:21 + | +LL | /// [std::vec::Vec](Vec) + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:22:23 + | +LL | /// [`std::vec::Vec`](Vec) + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:24:21 + | +LL | /// [std::vec::Vec](std::vec::Vec) + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:26:23 + | +LL | /// [`std::vec::Vec`](std::vec::Vec) + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:29:13 + | +LL | /// [usize](usize) + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:31:15 + | +LL | /// [`usize`](usize) + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:33:13 + | +LL | /// [usize](std::primitive::usize) + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:35:15 + | +LL | /// [`usize`](std::primitive::usize) + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:37:29 + | +LL | /// [std::primitive::usize](usize) + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:39:31 + | +LL | /// [`std::primitive::usize`](usize) + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:41:29 + | +LL | /// [std::primitive::usize](std::primitive::usize) + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:43:31 + | +LL | /// [`std::primitive::usize`](std::primitive::usize) + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:46:20 + | +LL | /// [dummy_target](dummy_target) TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:48:22 + | +LL | /// [`dummy_target`](dummy_target) TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:56:20 + | +LL | /// [dummy_target][dummy_target] + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:58:22 + | +LL | /// [`dummy_target`][dummy_target] + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:61:11 + | +LL | /// [Vec][Vec] + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:63:13 + | +LL | /// [`Vec`][Vec] + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:65:11 + | +LL | /// [Vec][std::vec::Vec] + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:67:13 + | +LL | /// [`Vec`][std::vec::Vec] + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:69:21 + | +LL | /// [std::vec::Vec][Vec] + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:71:23 + | +LL | /// [`std::vec::Vec`][Vec] + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:73:21 + | +LL | /// [std::vec::Vec][std::vec::Vec] + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:75:23 + | +LL | /// [`std::vec::Vec`][std::vec::Vec] + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:78:13 + | +LL | /// [usize][usize] + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:80:15 + | +LL | /// [`usize`][usize] + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:82:13 + | +LL | /// [usize][std::primitive::usize] + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:84:15 + | +LL | /// [`usize`][std::primitive::usize] + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:86:29 + | +LL | /// [std::primitive::usize][usize] + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:88:31 + | +LL | /// [`std::primitive::usize`][usize] + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:90:29 + | +LL | /// [std::primitive::usize][std::primitive::usize] + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:92:31 + | +LL | /// [`std::primitive::usize`][std::primitive::usize] + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:95:20 + | +LL | /// [dummy_target][dummy_target] TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:97:22 + | +LL | /// [`dummy_target`][dummy_target] TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:105:20 + | +LL | /// [dummy_target][dummy_target] + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:107:22 + | +LL | /// [`dummy_target`][dummy_target] + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] + | ~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:110:11 + | +LL | /// [Vec][Vec] + | --- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:112:13 + | +LL | /// [`Vec`][Vec] + | ----- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:114:11 + | +LL | /// [Vec][std::vec::Vec] + | --- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [Vec] + | ~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:116:13 + | +LL | /// [`Vec`][std::vec::Vec] + | ----- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`Vec`] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:118:21 + | +LL | /// [std::vec::Vec][Vec] + | ------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:120:23 + | +LL | /// [`std::vec::Vec`][Vec] + | --------------- ^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:150:12 + | +LL | /// [Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:122:21 + | +LL | /// [std::vec::Vec][std::vec::Vec] + | ------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::vec::Vec] + | ~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:124:23 + | +LL | /// [`std::vec::Vec`][std::vec::Vec] + | --------------- ^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:151:22 + | +LL | /// [std::vec::Vec]: Vec + | ^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::vec::Vec`] + | ~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:127:13 + | +LL | /// [usize][usize] + | ----- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:129:15 + | +LL | /// [`usize`][usize] + | ------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:131:13 + | +LL | /// [usize][std::primitive::usize] + | ----- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [usize] + | ~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:133:15 + | +LL | /// [`usize`][std::primitive::usize] + | ------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`usize`] + | ~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:135:29 + | +LL | /// [std::primitive::usize][usize] + | --------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:137:31 + | +LL | /// [`std::primitive::usize`][usize] + | ----------------------- ^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:152:14 + | +LL | /// [usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:139:29 + | +LL | /// [std::primitive::usize][std::primitive::usize] + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [std::primitive::usize] + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:141:31 + | +LL | /// [`std::primitive::usize`][std::primitive::usize] + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:153:30 + | +LL | /// [std::primitive::usize]: usize + | ^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`std::primitive::usize`] + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:144:20 + | +LL | /// [dummy_target][dummy_target] TEXT + | ------------ ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [dummy_target] TEXT + | ~~~~~~~~~~~~~~ + +error: redundant explicit link target + --> $DIR/redundant_explicit_links.rs:146:22 + | +LL | /// [`dummy_target`][dummy_target] TEXT + | -------------- ^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | +note: referenced explicit link target defined here + --> $DIR/redundant_explicit_links.rs:149:21 + | +LL | /// [dummy_target]: dummy_target + | ^^^^^^^^^^^^ + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL | /// [`dummy_target`] TEXT + | ~~~~~~~~~~~~~~~~ + +error: aborting due to 60 previous errors + diff --git a/tests/rustdoc-ui/unescaped_backticks.rs b/tests/rustdoc-ui/unescaped_backticks.rs index e99cd1f3d58..e960e9f59e9 100644 --- a/tests/rustdoc-ui/unescaped_backticks.rs +++ b/tests/rustdoc-ui/unescaped_backticks.rs @@ -1,6 +1,7 @@ #![deny(rustdoc::unescaped_backticks)] #![allow(rustdoc::broken_intra_doc_links)] #![allow(rustdoc::invalid_html_tags)] +#![allow(rustdoc::redundant_explicit_links)] /// pub fn empty() {} diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr index bf1f18889c4..83822f778d0 100644 --- a/tests/rustdoc-ui/unescaped_backticks.stderr +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -1,5 +1,5 @@ error: unescaped backtick - --> $DIR/unescaped_backticks.rs:186:70 + --> $DIR/unescaped_backticks.rs:187:70 | LL | /// if you want your MIR to be modified by the full MIR pipeline, or `#![custom_mir(dialect = | ^ @@ -19,7 +19,7 @@ LL | /// if you want your MIR to be modified by the full MIR pipeline, or \`#![c | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:231:13 + --> $DIR/unescaped_backticks.rs:232:13 | LL | //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] | ^ @@ -34,7 +34,7 @@ LL | //! \`#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kin | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:236:13 + --> $DIR/unescaped_backticks.rs:237:13 | LL | /// `cfg=... | ^ @@ -49,7 +49,7 @@ LL | /// \`cfg=... | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:240:42 + --> $DIR/unescaped_backticks.rs:241:42 | LL | /// `cfg=... and not `#[cfg_attr]` | ^ @@ -64,7 +64,7 @@ LL | /// `cfg=... and not `#[cfg_attr]\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:192:91 + --> $DIR/unescaped_backticks.rs:193:91 | LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to | ^ @@ -79,7 +79,7 @@ LL | /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:201:34 + --> $DIR/unescaped_backticks.rs:202:34 | LL | /// in `nt_to_tokenstream` | ^ @@ -94,7 +94,7 @@ LL | /// in `nt_to_tokenstream\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:207:62 + --> $DIR/unescaped_backticks.rs:208:62 | LL | /// that `Option<Symbol>` only takes up 4 bytes, because `newtype_index! reserves | ^ @@ -109,7 +109,7 @@ LL | /// that `Option<Symbol>` only takes up 4 bytes, because \`newtype_inde | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:215:52 + --> $DIR/unescaped_backticks.rs:216:52 | LL | /// also avoids the need to import `OpenOptions`. | ^ @@ -124,7 +124,7 @@ LL | /// also avoids the need to import `OpenOptions\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:220:46 + --> $DIR/unescaped_backticks.rs:221:46 | LL | /// `HybridBitSet`. Has no effect if `row` does not exist. | ^ @@ -139,7 +139,7 @@ LL | /// `HybridBitSet`. Has no effect if `row\` does not exist. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:246:12 + --> $DIR/unescaped_backticks.rs:247:12 | LL | /// RWU`s can get very large, so it uses a more compact representation. | ^ @@ -154,7 +154,7 @@ LL | /// RWU\`s can get very large, so it uses a more compact representation | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:253:15 + --> $DIR/unescaped_backticks.rs:254:15 | LL | /// in `U2`. | ^ @@ -169,7 +169,7 @@ LL | /// in `U2\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:270:42 + --> $DIR/unescaped_backticks.rs:271:42 | LL | /// because it contains `[type error]`. Yuck! (See issue #29857 for | ^ @@ -184,7 +184,7 @@ LL | /// because it contains `[type error]\`. Yuck! (See issue #29857 for | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:280:53 + --> $DIR/unescaped_backticks.rs:281:53 | LL | /// well as the second instance of `A: AutoTrait`) to suppress | ^ @@ -199,7 +199,7 @@ LL | /// well as the second instance of `A: AutoTrait\`) to suppress | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:290:40 + --> $DIR/unescaped_backticks.rs:291:40 | LL | /// `'a` with `'b` and not `'static`. But it will have to do for | ^ @@ -211,7 +211,7 @@ LL | /// `'a` with `'b` and not `'static\`. But it will have to do for | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:299:54 + --> $DIR/unescaped_backticks.rs:300:54 | LL | /// `None`. Otherwise, it will return `Some(Dispatch)`. | ^ @@ -226,7 +226,7 @@ LL | /// `None`. Otherwise, it will return `Some(Dispatch)\`. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:303:13 + --> $DIR/unescaped_backticks.rs:304:13 | LL | /// or `None` if it isn't. | ^ @@ -238,7 +238,7 @@ LL | /// or `None\` if it isn't. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:307:14 + --> $DIR/unescaped_backticks.rs:308:14 | LL | /// `on_event` should be called. | ^ @@ -253,7 +253,7 @@ LL | /// `on_event\` should be called. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:312:29 + --> $DIR/unescaped_backticks.rs:313:29 | LL | /// [`rebuild_interest_cache`][rebuild] is called after the value of the max | ^ @@ -268,7 +268,7 @@ LL | /// [`rebuild_interest_cache\`][rebuild] is called after the value of the m | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -287,7 +287,7 @@ LL | | /// level changes. to this: `None`. Otherwise, it will return `Some(Dispatch)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -304,7 +304,7 @@ LL | | /// level changes. to this: or `None\` if it isn't. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -323,7 +323,7 @@ LL | | /// level changes. to this: `on_event\` should be called. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:322:5 + --> $DIR/unescaped_backticks.rs:323:5 | LL | / /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`], LL | | @@ -342,7 +342,7 @@ LL | | /// level changes. to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max error: unescaped backtick - --> $DIR/unescaped_backticks.rs:348:56 + --> $DIR/unescaped_backticks.rs:349:56 | LL | /// instead and use [`CloneCounterObserver::counter`] to increment. | ^ @@ -354,7 +354,7 @@ LL | /// instead and use [`CloneCounterObserver::counter\`] to increment. | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:11:5 + --> $DIR/unescaped_backticks.rs:12:5 | LL | /// ` | ^ @@ -366,7 +366,7 @@ LL | /// \` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:18:7 + --> $DIR/unescaped_backticks.rs:19:7 | LL | /// \` | ^ @@ -381,7 +381,7 @@ LL | /// \\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:25:6 + --> $DIR/unescaped_backticks.rs:26:6 | LL | /// [`link1] | ^ @@ -396,7 +396,7 @@ LL | /// [\`link1] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:29:11 + --> $DIR/unescaped_backticks.rs:30:11 | LL | /// [link2`] | ^ @@ -411,7 +411,7 @@ LL | /// [link2\`] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:33:6 + --> $DIR/unescaped_backticks.rs:34:6 | LL | /// [`link_long](link_long) | ^ @@ -426,7 +426,7 @@ LL | /// [\`link_long](link_long) | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:37:6 + --> $DIR/unescaped_backticks.rs:38:6 | LL | /// [`broken-link] | ^ @@ -441,7 +441,7 @@ LL | /// [\`broken-link] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:44:8 + --> $DIR/unescaped_backticks.rs:45:8 | LL | /// <x:`> | ^ @@ -456,7 +456,7 @@ LL | /// <x:\`> | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:54:6 + --> $DIR/unescaped_backticks.rs:55:6 | LL | /// 🦀`🦀 | ^ @@ -475,7 +475,7 @@ LL | /// 🦀\`🦀 | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:58:5 + --> $DIR/unescaped_backticks.rs:59:5 | LL | /// `foo( | ^ @@ -490,7 +490,7 @@ LL | /// \`foo( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:64:14 + --> $DIR/unescaped_backticks.rs:65:14 | LL | /// `foo `bar` | ^ @@ -505,7 +505,7 @@ LL | /// `foo `bar\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:70:5 + --> $DIR/unescaped_backticks.rs:71:5 | LL | /// `foo( | ^ @@ -520,7 +520,7 @@ LL | /// \`foo( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:75:83 + --> $DIR/unescaped_backticks.rs:76:83 | LL | /// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`. | ^ @@ -535,7 +535,7 @@ LL | /// Addition is commutative, which means that add(a, b)` is the same as `ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:79:51 + --> $DIR/unescaped_backticks.rs:80:51 | LL | /// or even to add a number `n` to 42 (`add(42, b)`)! | ^ @@ -550,7 +550,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, b)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:83:83 + --> $DIR/unescaped_backticks.rs:84:83 | LL | /// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`. | ^ @@ -565,7 +565,7 @@ LL | /// Addition is commutative, which means that `add(a, b) is the same as `ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:87:51 + --> $DIR/unescaped_backticks.rs:88:51 | LL | /// or even to add a number `n` to 42 (`add(42, n)`)! | ^ @@ -580,7 +580,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:91:83 + --> $DIR/unescaped_backticks.rs:92:83 | LL | /// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`. | ^ @@ -595,7 +595,7 @@ LL | /// Addition is commutative, which means that `add(a, b)` is the same as ad | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:95:50 + --> $DIR/unescaped_backticks.rs:96:50 | LL | /// or even to add a number `n` to 42 (add(42, n)`)! | ^ @@ -610,7 +610,7 @@ LL | /// or even to add a number `n` to 42 (add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:99:74 + --> $DIR/unescaped_backticks.rs:100:74 | LL | /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a). | ^ @@ -625,7 +625,7 @@ LL | /// Addition is commutative, which means that `add(a, b)` is the same as \` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:103:51 + --> $DIR/unescaped_backticks.rs:104:51 | LL | /// or even to add a number `n` to 42 (`add(42, n)`)! | ^ @@ -640,7 +640,7 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:107:1 + --> $DIR/unescaped_backticks.rs:108:1 | LL | #[doc = "`"] | ^^^^^^^^^^^^ @@ -651,7 +651,7 @@ LL | #[doc = "`"] to this: \` error: unescaped backtick - --> $DIR/unescaped_backticks.rs:114:1 + --> $DIR/unescaped_backticks.rs:115:1 | LL | #[doc = concat!("\\", "`")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -664,7 +664,7 @@ LL | #[doc = concat!("\\", "`")] to this: \\` error: unescaped backtick - --> $DIR/unescaped_backticks.rs:118:1 + --> $DIR/unescaped_backticks.rs:119:1 | LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -677,7 +677,7 @@ LL | #[doc = "Addition is commutative, which means that add(a, b)` is the same a to this: Addition is commutative, which means that add(a, b)` is the same as `add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:122:1 + --> $DIR/unescaped_backticks.rs:123:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -690,7 +690,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b) is the same a to this: Addition is commutative, which means that `add(a, b) is the same as `add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:126:1 + --> $DIR/unescaped_backticks.rs:127:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -703,7 +703,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same to this: Addition is commutative, which means that `add(a, b)` is the same as add(b, a)\`. error: unescaped backtick - --> $DIR/unescaped_backticks.rs:130:1 + --> $DIR/unescaped_backticks.rs:131:1 | LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)."] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -716,7 +716,7 @@ LL | #[doc = "Addition is commutative, which means that `add(a, b)` is the same to this: Addition is commutative, which means that `add(a, b)` is the same as \`add(b, a). error: unescaped backtick - --> $DIR/unescaped_backticks.rs:135:5 + --> $DIR/unescaped_backticks.rs:136:5 | LL | /// `foo | ^ @@ -731,7 +731,7 @@ LL | /// \`foo | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:139:7 + --> $DIR/unescaped_backticks.rs:140:7 | LL | /// # `(heading | ^ @@ -746,7 +746,7 @@ LL | /// # \`(heading | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:141:17 + --> $DIR/unescaped_backticks.rs:142:17 | LL | /// ## heading2)` | ^ @@ -761,7 +761,7 @@ LL | /// ## heading2)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:144:11 + --> $DIR/unescaped_backticks.rs:145:11 | LL | /// multi `( | ^ @@ -776,7 +776,7 @@ LL | /// multi \`( | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:150:10 + --> $DIR/unescaped_backticks.rs:151:10 | LL | /// para)`(graph | ^ @@ -795,7 +795,7 @@ LL | /// para)\`(graph | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:153:10 + --> $DIR/unescaped_backticks.rs:154:10 | LL | /// para)`(graph2 | ^ @@ -814,7 +814,7 @@ LL | /// para)\`(graph2 | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:156:12 + --> $DIR/unescaped_backticks.rs:157:12 | LL | /// 1. foo)` | ^ @@ -829,7 +829,7 @@ LL | /// 1. foo)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:158:8 + --> $DIR/unescaped_backticks.rs:159:8 | LL | /// 2. `(bar | ^ @@ -844,7 +844,7 @@ LL | /// 2. \`(bar | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:160:11 + --> $DIR/unescaped_backticks.rs:161:11 | LL | /// * baz)` | ^ @@ -859,7 +859,7 @@ LL | /// * baz)\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:162:7 + --> $DIR/unescaped_backticks.rs:163:7 | LL | /// * `(quux | ^ @@ -874,7 +874,7 @@ LL | /// * \`(quux | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:165:5 + --> $DIR/unescaped_backticks.rs:166:5 | LL | /// `#![this_is_actually_an_image(and(not), an = "attribute")] | ^ @@ -889,7 +889,7 @@ LL | /// \`#![this_is_actually_an_image(and(not), an = "attribute")] | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:168:62 + --> $DIR/unescaped_backticks.rs:169:62 | LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]` | ^ @@ -904,7 +904,7 @@ LL | /// #![this_is_actually_an_image(and(not), an = "attribute")]\` | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:173:7 + --> $DIR/unescaped_backticks.rs:174:7 | LL | /// | `table( | )head` | | ^ @@ -919,7 +919,7 @@ LL | /// | \`table( | )head` | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:173:22 + --> $DIR/unescaped_backticks.rs:174:22 | LL | /// | `table( | )head` | | ^ @@ -934,7 +934,7 @@ LL | /// | `table( | )head\` | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:177:12 + --> $DIR/unescaped_backticks.rs:178:12 | LL | /// | table`( | )`body | | ^ @@ -949,7 +949,7 @@ LL | /// | table\`( | )`body | | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:177:18 + --> $DIR/unescaped_backticks.rs:178:18 | LL | /// | table`( | )`body | | ^ diff --git a/tests/rustdoc/description.rs b/tests/rustdoc/description.rs index 43cd59ebd09..aabbb4c4c8f 100644 --- a/tests/rustdoc/description.rs +++ b/tests/rustdoc/description.rs @@ -1,4 +1,5 @@ #![crate_name = "foo"] +#![allow(rustdoc::redundant_explicit_links)] //! # Description test crate //! //! This is the contents of the test crate docstring. diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs new file mode 100644 index 00000000000..25615a73c3f --- /dev/null +++ b/tests/rustdoc/html-no-source.rs @@ -0,0 +1,30 @@ +// compile-flags: -Zunstable-options --html-no-source + +// This test ensures that the `--html-no-source` flag disables +// the creation of the `src` folder. + +#![feature(staged_api)] +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] + +// Ensures that there is no items in the corresponding "src" folder. +// @files 'src/foo' '[]' + +// @has foo/fn.foo.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +// @has foo/struct.Bar.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0' + // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +} diff --git a/tests/rustdoc/intra-doc/basic.rs b/tests/rustdoc/intra-doc/basic.rs index 96e21137b2d..c88a7887f11 100644 --- a/tests/rustdoc/intra-doc/basic.rs +++ b/tests/rustdoc/intra-doc/basic.rs @@ -1,3 +1,5 @@ +#![allow(rustdoc::redundant_explicit_links)] + // @has basic/index.html // @has - '//a/@href' 'struct.ThisType.html' // @has - '//a/@title' 'struct basic::ThisType' diff --git a/tests/rustdoc/intra-doc/generic-params.rs b/tests/rustdoc/intra-doc/generic-params.rs index fbc9fc6a9bc..359f775f97f 100644 --- a/tests/rustdoc/intra-doc/generic-params.rs +++ b/tests/rustdoc/intra-doc/generic-params.rs @@ -1,6 +1,7 @@ // ignore-tidy-linelength #![crate_name = "foo"] +#![allow(rustdoc::redundant_explicit_links)] //! Here's a link to [`Vec<T>`] and one to [`Box<Vec<Option<T>>>`]. //! Here's a link to [`Iterator<Box<T>>::Item`]. diff --git a/tests/rustdoc/intra-doc/issue-108459.rs b/tests/rustdoc/intra-doc/issue-108459.rs index eb1c7a05e54..b8cd478b4df 100644 --- a/tests/rustdoc/intra-doc/issue-108459.rs +++ b/tests/rustdoc/intra-doc/issue-108459.rs @@ -1,4 +1,5 @@ #![deny(rustdoc::broken_intra_doc_links)] +#![allow(rustdoc::redundant_explicit_links)] pub struct S; pub mod char {} diff --git a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs index 91082483948..5d2c553d8a5 100644 --- a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs +++ b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs @@ -8,7 +8,7 @@ // @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' // We also ensure we don't have another item displayed. // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 2 -// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' +// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants' mod other { diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs index b0c22540180..3b836a21931 100644 --- a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs +++ b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs @@ -104,7 +104,7 @@ pub mod glob_reexport { // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3 // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Re-exports' // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs' - // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Definitions' + // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Type Aliases' // Now we check we have 1 re-export and 2 inlined items. // If not item from a glob re-export is visible, we don't show the re-export. @@ -135,9 +135,9 @@ pub mod doc_hidden_reexport { // @has - '//a[@class="struct"]' 'Reexport' // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. // @has - '//*[@class="desc docblock-short"]' 'Visible. Original.' + /// Visible. + pub use self::Bar3 as Reexport; /// Hidden. #[doc(hidden)] pub use crate::private::Bar3; - /// Visible. - pub use self::Bar3 as Reexport; } diff --git a/tests/rustdoc/sidebar-all-page.rs b/tests/rustdoc/sidebar-all-page.rs index 45a6ba8ed2e..4c8a0f543a5 100644 --- a/tests/rustdoc/sidebar-all-page.rs +++ b/tests/rustdoc/sidebar-all-page.rs @@ -1,5 +1,4 @@ #![crate_name = "foo"] - #![feature(rustc_attrs)] // @has 'foo/all.html' @@ -9,7 +8,7 @@ // @has - '//*[@class="sidebar-elems"]//li' 'Functions' // @has - '//*[@class="sidebar-elems"]//li' 'Traits' // @has - '//*[@class="sidebar-elems"]//li' 'Macros' -// @has - '//*[@class="sidebar-elems"]//li' 'Type Definitions' +// @has - '//*[@class="sidebar-elems"]//li' 'Type Aliases' // @has - '//*[@class="sidebar-elems"]//li' 'Constants' // @has - '//*[@class="sidebar-elems"]//li' 'Statics' // @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' @@ -26,7 +25,7 @@ pub fn foo() {} pub trait Trait {} #[macro_export] macro_rules! foo { - () => {} + () => {}; } pub type Type = u8; pub const FOO: u8 = 0; diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index e1feb1cd64f..f6a059de620 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -30,7 +30,7 @@ pub struct FooStruct; // @matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum' pub enum FooEnum {} -// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType' +// @matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType' // @matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType' pub type FooType = FooStruct; diff --git a/tests/ui/abi/explicit_repr_rust.rs b/tests/ui/abi/explicit_repr_rust.rs new file mode 100644 index 00000000000..4f8cab3bf0e --- /dev/null +++ b/tests/ui/abi/explicit_repr_rust.rs @@ -0,0 +1,12 @@ +// check-pass + +#[repr(Rust)] +struct A; + +#[repr(Rust, align(16))] +struct B; + +#[repr(Rust, packed)] +struct C; + +fn main() {} diff --git a/tests/ui/abi/relocation_model_pic.rs b/tests/ui/abi/relocation_model_pic.rs new file mode 100644 index 00000000000..0cfc44cd09d --- /dev/null +++ b/tests/ui/abi/relocation_model_pic.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -C relocation-model=pic +// ignore-emscripten no pic +// ignore-wasm + +#![feature(cfg_relocation_model)] + +#[cfg(relocation_model = "pic")] +fn main() {} diff --git a/tests/ui/argument-suggestions/issue-100154.stderr b/tests/ui/argument-suggestions/issue-100154.stderr index 2504f616fb7..966f56e2a15 100644 --- a/tests/ui/argument-suggestions/issue-100154.stderr +++ b/tests/ui/argument-suggestions/issue-100154.stderr @@ -14,12 +14,10 @@ LL | fn foo(i: impl std::fmt::Display) {} = note: `impl Trait` cannot be explicitly specified as a generic argument error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-100154.rs:4:15 + --> $DIR/issue-100154.rs:4:11 | LL | foo::<()>(()); - | --------- ^^ `()` cannot be formatted with the default formatter - | | - | required by a bound introduced by this call + | ^^ `()` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/associated-consts/associated-const-array-len.stderr b/tests/ui/associated-consts/associated-const-array-len.stderr index 86c62e7b7f1..0e0dec35b53 100644 --- a/tests/ui/associated-consts/associated-const-array-len.stderr +++ b/tests/ui/associated-consts/associated-const-array-len.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/associated-const-array-len.rs:5:16 + --> $DIR/associated-const-array-len.rs:5:17 | LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2]; - | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | ^^^ the trait `Foo` is not implemented for `i32` error: aborting due to previous error diff --git a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs index 40896c32e11..1e0b77b0d3b 100644 --- a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs +++ b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs @@ -5,6 +5,8 @@ trait Trait { impl Trait for () { const ASSOC: &dyn Fn(_) = 1i32; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants + //~| WARN `&` without an explicit lifetime name cannot be used here + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } fn main() {} diff --git a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr index 993a08faba9..f8c02420f96 100644 --- a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr +++ b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr @@ -1,9 +1,23 @@ +warning: `&` without an explicit lifetime name cannot be used here + --> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:18 + | +LL | const ASSOC: &dyn Fn(_) = 1i32; + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> + = note: `#[warn(elided_lifetimes_in_associated_constant)]` on by default +help: use the `'static` lifetime + | +LL | const ASSOC: &'static dyn Fn(_) = 1i32; + | +++++++ + error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26 | LL | const ASSOC: &dyn Fn(_) = 1i32; | ^ not allowed in type signatures -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.rs b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.rs new file mode 100644 index 00000000000..3853bc8594f --- /dev/null +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.rs @@ -0,0 +1,12 @@ +#![allow(bare_trait_objects)] +#![feature(associated_type_bounds)] +trait Item { + type Core; +} +pub struct Flatten<I> { + inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core, + //~^ ERROR E0191 + //~| ERROR E0223 +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr new file mode 100644 index 00000000000..61299550e98 --- /dev/null +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr @@ -0,0 +1,24 @@ +error[E0191]: the value of the associated types `IntoIter` (from trait `IntoIterator`), `IntoIter` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`) must be specified + --> $DIR/overlaping-bound-suggestion.rs:7:13 + | +LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | associated types `Item`, `IntoIter` must be specified + | associated types `Item`, `IntoIter` must be specified + +error[E0223]: ambiguous associated type + --> $DIR/overlaping-bound-suggestion.rs:7:13 + | +LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `IntoIterator` implemented for `(dyn IntoIterator + 'static)`, you could use the fully-qualified path + | +LL | inner: <<(dyn IntoIterator + 'static) as Example>::IntoIterator as Item>::Core, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0191, E0223. +For more information about an error, try `rustc --explain E0191`. diff --git a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr index 8fecfdf7b93..676d6353d98 100644 --- a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr +++ b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Foo<usize>` is not satisfied - --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:12 + --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:13 | LL | let u: <T as Foo<usize>>::Bar = t.get_bar(); - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo<usize>` is not implemented for `T` + | ^ the trait `Foo<usize>` is not implemented for `T` | help: consider further restricting this bound | diff --git a/tests/ui/associated-types/issue-44153.stderr b/tests/ui/associated-types/issue-44153.stderr index 8bddcd95568..73365d64d56 100644 --- a/tests/ui/associated-types/issue-44153.stderr +++ b/tests/ui/associated-types/issue-44153.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving `<() as Array>::Element == &()` - --> $DIR/issue-44153.rs:18:5 + --> $DIR/issue-44153.rs:18:6 | LL | <() as Visit>::visit(); - | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array>::Element == &()` + | ^^ type mismatch resolving `<() as Array>::Element == &()` | note: expected this to be `&()` --> $DIR/issue-44153.rs:10:20 diff --git a/tests/ui/associated-types/substs-ppaux.normal.stderr b/tests/ui/associated-types/substs-ppaux.normal.stderr index acdc3be8c67..015b22f790f 100644 --- a/tests/ui/associated-types/substs-ppaux.normal.stderr +++ b/tests/ui/associated-types/substs-ppaux.normal.stderr @@ -71,10 +71,10 @@ LL | let x: () = foo::<'static>(); | ++ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/substs-ppaux.rs:49:5 + --> $DIR/substs-ppaux.rs:49:6 | LL | <str as Foo<u8>>::bar; - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` note: required for `str` to implement `Foo<'_, '_, u8>` diff --git a/tests/ui/associated-types/substs-ppaux.verbose.stderr b/tests/ui/associated-types/substs-ppaux.verbose.stderr index ad67899e6da..484581b1028 100644 --- a/tests/ui/associated-types/substs-ppaux.verbose.stderr +++ b/tests/ui/associated-types/substs-ppaux.verbose.stderr @@ -71,10 +71,10 @@ LL | let x: () = foo::<'static>(); | ++ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/substs-ppaux.rs:49:5 + --> $DIR/substs-ppaux.rs:49:6 | LL | <str as Foo<u8>>::bar; - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` note: required for `str` to implement `Foo<'?0, '?1, u8>` diff --git a/tests/ui/async-await/normalize-output-in-signature-deduction.rs b/tests/ui/async-await/normalize-output-in-signature-deduction.rs new file mode 100644 index 00000000000..960065a83a4 --- /dev/null +++ b/tests/ui/async-await/normalize-output-in-signature-deduction.rs @@ -0,0 +1,19 @@ +// edition:2021 +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(type_alias_impl_trait)] + +struct Foo; + +impl Trait for Foo {} +pub trait Trait {} + +pub type TAIT<T> = impl Trait; + +async fn foo<T>() -> TAIT<T> { + Foo +} + +fn main() {} diff --git a/tests/ui/backtrace.rs b/tests/ui/backtrace.rs index 66b378f62d6..95783945529 100644 --- a/tests/ui/backtrace.rs +++ b/tests/ui/backtrace.rs @@ -100,14 +100,17 @@ fn runtest(me: &str) { let s = str::from_utf8(&out.stderr).unwrap(); // loosened the following from double::h to double:: due to // spurious failures on mac, 32bit, optimized - assert!(s.contains("stack backtrace") && contains_verbose_expected(s, "double"), - "bad output3: {}", s); + assert!( + s.contains("stack backtrace") && + s.contains("panic in a destructor during cleanup") && + contains_verbose_expected(s, "double"), + "bad output3: {}", s + ); // Make sure a stack trace isn't printed too many times // - // Currently it is printed 3 times ("once", "twice" and "panic in a - // function that cannot unwind") but in the future the last one may be - // removed. + // Currently it is printed 3 times ("once", "twice" and "panic in a destructor during + // cleanup") but in the future the last one may be removed. let p = template(me).arg("double-fail") .env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); diff --git a/tests/ui/borrowck/suggest-mut-iterator.fixed b/tests/ui/borrowck/suggest-mut-iterator.fixed new file mode 100644 index 00000000000..16512b8a3cd --- /dev/null +++ b/tests/ui/borrowck/suggest-mut-iterator.fixed @@ -0,0 +1,30 @@ +// run-rustfix +struct Test { + a: u32 +} + +impl Test { + pub fn add(&mut self, value: u32) { + self.a += value; + } + + pub fn print_value(&self) { + println!("Value of a is: {}", self.a); + } +} + +fn main() { + let mut tests = Vec::new(); + for i in 0..=10 { + tests.push(Test {a: i}); + } + for test in &mut tests { + test.add(2); //~ ERROR cannot borrow `*test` as mutable, as it is behind a `&` reference + } + for test in &mut tests { + test.add(2); + } + for test in &tests { + test.print_value(); + } +} diff --git a/tests/ui/borrowck/suggest-mut-iterator.rs b/tests/ui/borrowck/suggest-mut-iterator.rs new file mode 100644 index 00000000000..276edeccb22 --- /dev/null +++ b/tests/ui/borrowck/suggest-mut-iterator.rs @@ -0,0 +1,30 @@ +// run-rustfix +struct Test { + a: u32 +} + +impl Test { + pub fn add(&mut self, value: u32) { + self.a += value; + } + + pub fn print_value(&self) { + println!("Value of a is: {}", self.a); + } +} + +fn main() { + let mut tests = Vec::new(); + for i in 0..=10 { + tests.push(Test {a: i}); + } + for test in &tests { + test.add(2); //~ ERROR cannot borrow `*test` as mutable, as it is behind a `&` reference + } + for test in &mut tests { + test.add(2); + } + for test in &tests { + test.print_value(); + } +} diff --git a/tests/ui/borrowck/suggest-mut-iterator.stderr b/tests/ui/borrowck/suggest-mut-iterator.stderr new file mode 100644 index 00000000000..77f991a9a61 --- /dev/null +++ b/tests/ui/borrowck/suggest-mut-iterator.stderr @@ -0,0 +1,16 @@ +error[E0596]: cannot borrow `*test` as mutable, as it is behind a `&` reference + --> $DIR/suggest-mut-iterator.rs:22:9 + | +LL | for test in &tests { + | ------ this iterator yields `&` references +LL | test.add(2); + | ^^^^ `test` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: use a mutable iterator instead + | +LL | for test in &mut tests { + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr b/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr index d8eebeb0d21..cb51d9b1ea5 100644 --- a/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr +++ b/tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `[Adt; std::mem::size_of::<Self::Assoc>()]: Foo` is not satisfied - --> $DIR/dont-evaluate-array-len-on-err-1.rs:15:9 + --> $DIR/dont-evaluate-array-len-on-err-1.rs:15:10 | LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::<Self::Assoc>()]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::<Self::Assoc>()]` error: aborting due to previous error diff --git a/tests/ui/const-generics/exhaustive-value.stderr b/tests/ui/const-generics/exhaustive-value.stderr index 4a26e09772d..deb65ddba70 100644 --- a/tests/ui/const-generics/exhaustive-value.stderr +++ b/tests/ui/const-generics/exhaustive-value.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `(): Foo<N>` is not satisfied - --> $DIR/exhaustive-value.rs:262:5 + --> $DIR/exhaustive-value.rs:262:6 | LL | <() as Foo<N>>::test() - | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo<N>` is not implemented for `()` + | ^^ the trait `Foo<N>` is not implemented for `()` | = help: the following other types implement trait `Foo<N>`: <() as Foo<0>> diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 42ad4d61c8e..796966b22d5 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -4,6 +4,7 @@ error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> = note: `#[deny(invalid_reference_casting)]` on by default error[E0080]: evaluation of constant value failed diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 70aec91e226..3c03b03deee 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -2,19 +2,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:12:9 | LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to instantiate uninhabited type `!`', $DIR/assert-type-intrinsics.rs:12:36 error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:16:9 | LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `&i32` uninitialized, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to leave type `&i32` uninitialized, which is invalid', $DIR/assert-type-intrinsics.rs:16:9 error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:20:9 | LL | intrinsics::assert_zero_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to zero-initialize type `&i32`, which is invalid', $DIR/assert-type-intrinsics.rs:20:9 error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assoc-const-elided-lifetime.rs b/tests/ui/consts/assoc-const-elided-lifetime.rs new file mode 100644 index 00000000000..10cd33a8fed --- /dev/null +++ b/tests/ui/consts/assoc-const-elided-lifetime.rs @@ -0,0 +1,19 @@ +#![deny(elided_lifetimes_in_associated_constant)] + +use std::marker::PhantomData; + +struct Foo<'a> { + x: PhantomData<&'a ()>, +} + +impl<'a> Foo<'a> { + const FOO: Foo<'_> = Foo { x: PhantomData::<&()> }; + //~^ ERROR `'_` cannot be used here + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + + const BAR: &() = &(); + //~^ ERROR `&` without an explicit lifetime name cannot be used here + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +fn main() {} diff --git a/tests/ui/consts/assoc-const-elided-lifetime.stderr b/tests/ui/consts/assoc-const-elided-lifetime.stderr new file mode 100644 index 00000000000..a1eeaff4ba8 --- /dev/null +++ b/tests/ui/consts/assoc-const-elided-lifetime.stderr @@ -0,0 +1,33 @@ +error: `'_` cannot be used here + --> $DIR/assoc-const-elided-lifetime.rs:10:20 + | +LL | const FOO: Foo<'_> = Foo { x: PhantomData::<&()> }; + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> +note: the lint level is defined here + --> $DIR/assoc-const-elided-lifetime.rs:1:9 + | +LL | #![deny(elided_lifetimes_in_associated_constant)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: use the `'static` lifetime + | +LL | const FOO: Foo<'static> = Foo { x: PhantomData::<&()> }; + | ~~~~~~~ + +error: `&` without an explicit lifetime name cannot be used here + --> $DIR/assoc-const-elided-lifetime.rs:14:16 + | +LL | const BAR: &() = &(); + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> +help: use the `'static` lifetime + | +LL | const BAR: &'static () = &(); + | +++++++ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr b/tests/ui/consts/const-eval/ub-int-array.64bit.stderr deleted file mode 100644 index b3df41304ac..00000000000 --- a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:19:1 - | -LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:24:1 - | -LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:42:1 - | -LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ - } - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index adcf376b9c7..cde0749dc5f 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -1,4 +1,3 @@ -// stderr-per-bitwidth //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. @@ -19,7 +18,12 @@ impl<T: Copy> MaybeUninit<T> { const UNINIT_INT_0: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value //~| invalid value at [0] - mem::transmute([MaybeUninit { uninit: () }, MaybeUninit::new(1), MaybeUninit::new(2)]) + mem::transmute([ + MaybeUninit { uninit: () }, + // Constants chosen to achieve endianness-independent hex dump. + MaybeUninit::new(0x11111111), + MaybeUninit::new(0x22222222), + ]) }; const UNINIT_INT_1: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value diff --git a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index b3df41304ac..c8efd7e1bd3 100644 --- a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,16 +1,16 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:19:1 + --> $DIR/ub-int-array.rs:18:1 | LL | const UNINIT_INT_0: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ + __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:24:1 + --> $DIR/ub-int-array.rs:28:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer @@ -21,7 +21,7 @@ LL | const UNINIT_INT_1: [u32; 3] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:42:1 + --> $DIR/ub-int-array.rs:46:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr index b8f6cb5ef97..fe9d0f6e6ed 100644 --- a/tests/ui/consts/missing-larger-array-impl.stderr +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `[X; 35]: Default` is not satisfied - --> $DIR/missing-larger-array-impl.rs:7:5 + --> $DIR/missing-larger-array-impl.rs:7:6 | LL | <[X; 35] as Default>::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` + | ^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: [T; 0] diff --git a/tests/ui/consts/std/alloc.32bit.stderr b/tests/ui/consts/std/alloc.32bit.stderr index 8c83df53dad..da805de451c 100644 --- a/tests/ui/consts/std/alloc.32bit.stderr +++ b/tests/ui/consts/std/alloc.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 + --> $DIR/alloc.rs:11:1 | LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec } error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 + --> $DIR/alloc.rs:15:1 | LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag diff --git a/tests/ui/consts/std/alloc.64bit.stderr b/tests/ui/consts/std/alloc.64bit.stderr index addedad1704..094503e1039 100644 --- a/tests/ui/consts/std/alloc.64bit.stderr +++ b/tests/ui/consts/std/alloc.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 + --> $DIR/alloc.rs:11:1 | LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec } error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 + --> $DIR/alloc.rs:15:1 | LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag diff --git a/tests/ui/consts/std/alloc.rs b/tests/ui/consts/std/alloc.rs index 9abf35d63d3..0a2c2f4dec8 100644 --- a/tests/ui/consts/std/alloc.rs +++ b/tests/ui/consts/std/alloc.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -// ignore-debug (the debug assertions change the error) // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" diff --git a/tests/ui/cross-crate/auxiliary/static_init_aux.rs b/tests/ui/cross-crate/auxiliary/static_init_aux.rs index 3b664f43654..5e172ef3198 100644 --- a/tests/ui/cross-crate/auxiliary/static_init_aux.rs +++ b/tests/ui/cross-crate/auxiliary/static_init_aux.rs @@ -1,10 +1,14 @@ pub static V: &u32 = &X; pub static F: fn() = f; +pub static G: fn() = G0; static X: u32 = 42; +static G0: fn() = g; pub fn v() -> *const u32 { V } fn f() {} + +fn g() {} diff --git a/tests/ui/cross-crate/static-init.rs b/tests/ui/cross-crate/static-init.rs index 2e893c5d9bf..0b50c41fc5e 100644 --- a/tests/ui/cross-crate/static-init.rs +++ b/tests/ui/cross-crate/static-init.rs @@ -1,9 +1,11 @@ +// Regression test for #84455 and #115052. // run-pass // aux-build:static_init_aux.rs extern crate static_init_aux as aux; static V: &u32 = aux::V; static F: fn() = aux::F; +static G: fn() = aux::G; fn v() -> *const u32 { V @@ -12,4 +14,5 @@ fn v() -> *const u32 { fn main() { assert_eq!(aux::v(), crate::v()); F(); + G(); } diff --git a/tests/ui/deprecation/issue-84637-deprecated-associated-function.fixed b/tests/ui/deprecation/issue-84637-deprecated-associated-function.fixed index 85e88287094..659b5465522 100644 --- a/tests/ui/deprecation/issue-84637-deprecated-associated-function.fixed +++ b/tests/ui/deprecation/issue-84637-deprecated-associated-function.fixed @@ -6,4 +6,6 @@ fn main() { let _foo = str::trim_start(" aoeu"); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated] let _bar = " aoeu".trim_start(); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated] + + let _baz = ["a", "b"].join(" "); //~ ERROR use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join [deprecated] } diff --git a/tests/ui/deprecation/issue-84637-deprecated-associated-function.rs b/tests/ui/deprecation/issue-84637-deprecated-associated-function.rs index 246de2f5e4b..cfc6c4450b4 100644 --- a/tests/ui/deprecation/issue-84637-deprecated-associated-function.rs +++ b/tests/ui/deprecation/issue-84637-deprecated-associated-function.rs @@ -6,4 +6,6 @@ fn main() { let _foo = str::trim_left(" aoeu"); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated] let _bar = " aoeu".trim_left(); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated] + + let _baz = ["a", "b"].connect(" "); //~ ERROR use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join [deprecated] } diff --git a/tests/ui/deprecation/issue-84637-deprecated-associated-function.stderr b/tests/ui/deprecation/issue-84637-deprecated-associated-function.stderr index 3b518d1802b..d1f5ea3602a 100644 --- a/tests/ui/deprecation/issue-84637-deprecated-associated-function.stderr +++ b/tests/ui/deprecation/issue-84637-deprecated-associated-function.stderr @@ -25,5 +25,16 @@ help: replace the use of the deprecated method LL | let _bar = " aoeu".trim_start(); | ~~~~~~~~~~ -error: aborting due to 2 previous errors +error: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join + --> $DIR/issue-84637-deprecated-associated-function.rs:10:27 + | +LL | let _baz = ["a", "b"].connect(" "); + | ^^^^^^^ + | +help: replace the use of the deprecated method + | +LL | let _baz = ["a", "b"].join(" "); + | ~~~~ + +error: aborting due to 3 previous errors diff --git a/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs new file mode 100644 index 00000000000..7529014ece2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.rs @@ -0,0 +1,4 @@ +#[cfg(relocation_model = "pic")] //~ ERROR +fn _foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr new file mode 100644 index 00000000000..592768a4203 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-relocation-model.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(relocation_model)` is experimental and subject to change + --> $DIR/feature-gate-cfg-relocation-model.rs:1:7 + | +LL | #[cfg(relocation_model = "pic")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #114929 <https://github.com/rust-lang/rust/issues/114929> for more information + = help: add `#![feature(cfg_relocation_model)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unnamed_fields.rs b/tests/ui/feature-gates/feature-gate-unnamed_fields.rs new file mode 100644 index 00000000000..4bbd0c83bfb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unnamed_fields.rs @@ -0,0 +1,26 @@ +struct Foo { + foo: u8, + _: union { //~ ERROR unnamed fields are not yet fully implemented [E0658] + //~^ ERROR unnamed fields are not yet fully implemented [E0658] + //~| ERROR anonymous unions are unimplemented + bar: u8, + baz: u16 + } +} + +union Bar { + foobar: u8, + _: struct { //~ ERROR unnamed fields are not yet fully implemented [E0658] + //~^ ERROR unnamed fields are not yet fully implemented [E0658] + //~| ERROR anonymous structs are unimplemented + foobaz: u8, + barbaz: u16 + } +} + +struct S; +struct Baz { + _: S //~ ERROR unnamed fields are not yet fully implemented [E0658] +} + +fn main(){} diff --git a/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr b/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr new file mode 100644 index 00000000000..f026f2c3600 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr @@ -0,0 +1,84 @@ +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:3:5 + | +LL | _: union { + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:3:8 + | +LL | _: union { + | ________^ +LL | | +LL | | +LL | | bar: u8, +LL | | baz: u16 +LL | | } + | |_____^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:13:5 + | +LL | _: struct { + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:13:8 + | +LL | _: struct { + | ________^ +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:23:5 + | +LL | _: S + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error: anonymous unions are unimplemented + --> $DIR/feature-gate-unnamed_fields.rs:3:8 + | +LL | _: union { + | ________^ +LL | | +LL | | +LL | | bar: u8, +LL | | baz: u16 +LL | | } + | |_____^ + +error: anonymous structs are unimplemented + --> $DIR/feature-gate-unnamed_fields.rs:13:8 + | +LL | _: struct { + | ________^ +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/function-pointer/unsized-ret.stderr b/tests/ui/function-pointer/unsized-ret.stderr index 870f1805b58..dcfec53eeb9 100644 --- a/tests/ui/function-pointer/unsized-ret.stderr +++ b/tests/ui/function-pointer/unsized-ret.stderr @@ -1,10 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-ret.rs:10:27 + --> $DIR/unsized-ret.rs:10:11 | LL | foo::<fn() -> str, _>(None, ()); - | --------------------- ^^^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `fn() -> str`, the trait `Sized` is not implemented for `str` = note: required because it appears within the type `fn() -> str` @@ -15,12 +13,10 @@ LL | fn foo<F: Fn<T>, T:std::marker::Tuple>(f: Option<F>, t: T) { | ^^^^^ required by this bound in `foo` error[E0277]: the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time - --> $DIR/unsized-ret.rs:13:66 + --> $DIR/unsized-ret.rs:13:11 | LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),)); - | ------------------------------------------------------------ ^^^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)` = note: required because it appears within the type `fn(&()) -> dyn Display` diff --git a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs new file mode 100644 index 00000000000..b127b3f6e1f --- /dev/null +++ b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs @@ -0,0 +1,10 @@ +trait Trait { + type P<T: Copy, U: Copy>; +} +impl Trait for () { + type P<T: Copy, U: Copy> = (); +} +fn main() { + let _: <() as Trait>::P<String, String>; + //~^ ERROR the trait bound `String: Copy` is not satisfied +} diff --git a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr new file mode 100644 index 00000000000..72a987b4a1d --- /dev/null +++ b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/multiple-type-params-with-unmet-bounds.rs:8:29 + | +LL | let _: <() as Trait>::P<String, String>; + | ^^^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `Trait::P` + --> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 + | +LL | type P<T: Copy, U: Copy>; + | ^^^^ required by this bound in `Trait::P` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-associated-types/own-bound-span.stderr b/tests/ui/generic-associated-types/own-bound-span.stderr index 8ab8ea623b2..4a0566ca7b5 100644 --- a/tests/ui/generic-associated-types/own-bound-span.stderr +++ b/tests/ui/generic-associated-types/own-bound-span.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/own-bound-span.rs:14:12 + --> $DIR/own-bound-span.rs:14:24 | LL | let _: <S as D>::P<String>; - | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ^^^^^^ the trait `Copy` is not implemented for `String` | note: required by a bound in `D::P` --> $DIR/own-bound-span.rs:4:15 diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-bounds.stderr index 1fda460372a..2cee53431a4 100644 --- a/tests/ui/generic-const-items/unsatisfied-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-bounds.stderr @@ -27,10 +27,10 @@ LL | Infallible: From<T>; | ^^^^^^^ required by this bound in `K` error[E0277]: the trait bound `Vec<u8>: Copy` is not satisfied - --> $DIR/unsatisfied-bounds.rs:32:13 + --> $DIR/unsatisfied-bounds.rs:32:26 | LL | let _ = <() as Trait<Vec<u8>>>::A; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<u8>` + | ^^^^^^^ the trait `Copy` is not implemented for `Vec<u8>` | note: required by a bound in `Trait::A` --> $DIR/unsatisfied-bounds.rs:17:12 diff --git a/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs b/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs new file mode 100644 index 00000000000..e0df96b0de8 --- /dev/null +++ b/tests/ui/implied-bounds/implied_bounds_entailment_alias_var.rs @@ -0,0 +1,32 @@ +// check-pass + +trait Data { + type Elem; +} + +impl<F, S: Data<Elem = F>> Data for ArrayBase<S> { + type Elem = F; +} + +struct DatasetIter<'a, R: Data> { + data: &'a R::Elem, +} + +pub struct ArrayBase<S> { + data: S, +} + +trait Trait { + type Item; + fn next() -> Option<Self::Item>; +} + +impl<'a, D: Data> Trait for DatasetIter<'a, ArrayBase<D>> { + type Item = (); + + fn next() -> Option<Self::Item> { + None + } +} + +fn main() {} diff --git a/tests/ui/inference/issue-72690.stderr b/tests/ui/inference/issue-72690.stderr index 8eda71ec09b..9b96e6dd89b 100644 --- a/tests/ui/inference/issue-72690.stderr +++ b/tests/ui/inference/issue-72690.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:7:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -71,7 +71,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:21:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -97,7 +97,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:28:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -123,7 +123,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:37:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -149,7 +149,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:46:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -175,7 +175,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:53:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; @@ -201,7 +201,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:62:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | ^^^^^^ cannot infer type for reference `&_` | = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: - impl<> From<&String> for String; diff --git a/tests/ui/inline-const/required-const.rs b/tests/ui/inline-const/required-const.rs new file mode 100644 index 00000000000..0483410662b --- /dev/null +++ b/tests/ui/inline-const/required-const.rs @@ -0,0 +1,13 @@ +// build-fail +// compile-flags: -Zmir-opt-level=3 +#![feature(inline_const)] + +fn foo<T>() { + if false { + const { panic!() } //~ ERROR E0080 + } +} + +fn main() { + foo::<i32>(); +} diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr new file mode 100644 index 00000000000..d6948e7acc0 --- /dev/null +++ b/tests/ui/inline-const/required-const.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed + --> $DIR/required-const.rs:7:17 + | +LL | const { panic!() } + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/required-const.rs:7:17 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/issues/issue-29147.stderr b/tests/ui/issues/issue-29147.stderr index 138d477dc6b..d0d9485310b 100644 --- a/tests/ui/issues/issue-29147.stderr +++ b/tests/ui/issues/issue-29147.stderr @@ -1,8 +1,8 @@ error[E0283]: type annotations needed - --> $DIR/issue-29147.rs:22:13 + --> $DIR/issue-29147.rs:22:14 | LL | let _ = <S5<_>>::xxx; - | ^^^^^^^^^^^^ cannot infer type for struct `S5<_>` + | ^^^^^ cannot infer type for struct `S5<_>` | note: multiple `impl`s satisfying `S5<_>: Foo` found --> $DIR/issue-29147.rs:18:1 diff --git a/tests/ui/issues/issue-39970.stderr b/tests/ui/issues/issue-39970.stderr index 8344b88c3be..713bc404f67 100644 --- a/tests/ui/issues/issue-39970.stderr +++ b/tests/ui/issues/issue-39970.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving `<() as Array<'a>>::Element == ()` - --> $DIR/issue-39970.rs:19:5 + --> $DIR/issue-39970.rs:19:6 | LL | <() as Visit>::visit(); - | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array<'a>>::Element == ()` + | ^^ type mismatch resolving `<() as Array<'a>>::Element == ()` | note: expected this to be `()` --> $DIR/issue-39970.rs:10:20 diff --git a/tests/ui/issues/issue-43988.stderr b/tests/ui/issues/issue-43988.stderr index 02c5dd5bfb7..7bbb8ed2ca9 100644 --- a/tests/ui/issues/issue-43988.stderr +++ b/tests/ui/issues/issue-43988.stderr @@ -32,7 +32,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(nothing)] | ^^^^^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0552]: unrecognized representation hint --> $DIR/issue-43988.rs:18:12 @@ -40,7 +40,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(something_not_real)] | ^^^^^^^^^^^^^^^^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43988.rs:30:5 diff --git a/tests/ui/issues/issue-66353.stderr b/tests/ui/issues/issue-66353.stderr index 3356180974f..71530f58220 100644 --- a/tests/ui/issues/issue-66353.stderr +++ b/tests/ui/issues/issue-66353.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `(): _A` is not satisfied - --> $DIR/issue-66353.rs:12:14 + --> $DIR/issue-66353.rs:12:15 | LL | _Func::< <() as _A>::AssocT >::func(()); - | ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()` + | ^^ the trait `_A` is not implemented for `()` error[E0277]: the trait bound `(): _Func<_>` is not satisfied --> $DIR/issue-66353.rs:12:41 diff --git a/tests/ui/issues/issue-66923-show-error-for-correct-call.stderr b/tests/ui/issues/issue-66923-show-error-for-correct-call.stderr index cec482a53ba..22b1da64cb3 100644 --- a/tests/ui/issues/issue-66923-show-error-for-correct-call.stderr +++ b/tests/ui/issues/issue-66923-show-error-for-correct-call.stderr @@ -17,10 +17,12 @@ note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64` - --> $DIR/issue-66923-show-error-for-correct-call.rs:12:29 + --> $DIR/issue-66923-show-error-for-correct-call.rs:12:39 | LL | let x3 = x1.into_iter().collect::<Vec<f64>>(); - | ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>` + | ------- ^^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>` + | | + | required by a bound introduced by this call | = help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>` = help: the trait `FromIterator<T>` is implemented for `Vec<T>` diff --git a/tests/ui/issues/issue-87199.stderr b/tests/ui/issues/issue-87199.stderr index 0ec5e73f39a..67949b37d40 100644 --- a/tests/ui/issues/issue-87199.stderr +++ b/tests/ui/issues/issue-87199.stderr @@ -17,12 +17,10 @@ LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/issue-87199.rs:18:22 + --> $DIR/issue-87199.rs:18:15 | LL | ref_arg::<[i32]>(&[5]); - | ---------------- ^^^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` note: required by a bound in `ref_arg` diff --git a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr index 7f1b9c38e67..e728fec2910 100644 --- a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr @@ -1,8 +1,10 @@ error[E0277]: a value of type `f32` cannot be made by summing an iterator over elements of type `{integer}` - --> $DIR/invalid-iterator-chain-with-int-infer.rs:2:41 + --> $DIR/invalid-iterator-chain-with-int-infer.rs:2:47 | LL | let x = Some(()).iter().map(|()| 1).sum::<f32>(); - | ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>` + | --- ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sum<A>`: diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index a2688107d10..b355da5cb76 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -17,10 +17,12 @@ note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` - --> $DIR/invalid-iterator-chain.rs:15:27 + --> $DIR/invalid-iterator-chain.rs:15:33 | LL | println!("{}", scores.sum::<i32>()); - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: @@ -42,10 +44,12 @@ note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` - --> $DIR/invalid-iterator-chain.rs:26:14 + --> $DIR/invalid-iterator-chain.rs:26:20 | LL | .sum::<i32>(), - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: @@ -74,10 +78,12 @@ note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64` - --> $DIR/invalid-iterator-chain.rs:36:14 + --> $DIR/invalid-iterator-chain.rs:36:20 | LL | .sum::<i32>(), - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<f64>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: @@ -102,10 +108,12 @@ note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()` - --> $DIR/invalid-iterator-chain.rs:38:54 + --> $DIR/invalid-iterator-chain.rs:38:60 | LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: @@ -123,10 +131,12 @@ note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()` - --> $DIR/invalid-iterator-chain.rs:39:40 + --> $DIR/invalid-iterator-chain.rs:39:46 | LL | println!("{}", vec![(), ()].iter().sum::<i32>()); - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr index 9e0e2bfa872..3b216ac1581 100644 --- a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12 + --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24 | LL | let _: lazy::Alias<String>; - | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ^^^^^^ the trait `Copy` is not implemented for `String` | -note: required by a bound on the type alias `Alias` +note: required by a bound in `lazy::Alias` --> $DIR/auxiliary/lazy.rs:4:19 | LL | pub type Alias<T: Copy> = Option<T>; - | ^^^^ required by this bound + | ^^^^ required by this bound in `Alias` error: aborting due to previous error diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr index 9e0e2bfa872..3b216ac1581 100644 --- a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr +++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12 + --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24 | LL | let _: lazy::Alias<String>; - | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ^^^^^^ the trait `Copy` is not implemented for `String` | -note: required by a bound on the type alias `Alias` +note: required by a bound in `lazy::Alias` --> $DIR/auxiliary/lazy.rs:4:19 | LL | pub type Alias<T: Copy> = Option<T>; - | ^^^^ required by this bound + | ^^^^ required by this bound in `Alias` error: aborting due to previous error diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.stderr b/tests/ui/lazy-type-alias/trailing-where-clause.stderr index d7606ba6b2a..193f80b23d3 100644 --- a/tests/ui/lazy-type-alias/trailing-where-clause.stderr +++ b/tests/ui/lazy-type-alias/trailing-where-clause.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `String: From<()>` is not satisfied - --> $DIR/trailing-where-clause.rs:12:12 + --> $DIR/trailing-where-clause.rs:12:18 | LL | let _: Alias<()>; - | ^^^^^^^^^ the trait `From<()>` is not implemented for `String` + | ^^ the trait `From<()>` is not implemented for `String` | = help: the following other types implement trait `From<T>`: <String as From<char>> @@ -11,11 +11,14 @@ LL | let _: Alias<()>; <String as From<&str>> <String as From<&mut str>> <String as From<&String>> -note: required by a bound on the type alias `Alias` +note: required by a bound in `Alias` --> $DIR/trailing-where-clause.rs:8:13 | +LL | type Alias<T> = T + | ----- required by a bound in this type alias +LL | where LL | String: From<T>; - | ^^^^^^^ required by this bound + | ^^^^^^^ required by this bound in `Alias` error: aborting due to previous error diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 6c38bca3daa..92d985948ec 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -71,6 +71,11 @@ unsafe fn assign_to_ref() { //~^ ERROR assigning to `&T` is undefined behavior *std::mem::transmute::<_, *mut i32>(num) += 1; //~^ ERROR assigning to `&T` is undefined behavior + std::ptr::write( + //~^ ERROR assigning to `&T` is undefined behavior + std::mem::transmute::<*const i32, *mut i32>(num), + -1i32, + ); let value = num as *const i32 as *mut i32; *value = 1; @@ -79,6 +84,12 @@ unsafe fn assign_to_ref() { //~^ ERROR assigning to `&T` is undefined behavior *(num as *const _ as usize as *mut i32) = 2; //~^ ERROR assigning to `&T` is undefined behavior + std::ptr::write(value, 2); + //~^ ERROR assigning to `&T` is undefined behavior + std::ptr::write_unaligned(value, 2); + //~^ ERROR assigning to `&T` is undefined behavior + std::ptr::write_volatile(value, 2); + //~^ ERROR assigning to `&T` is undefined behavior unsafe fn generic_assign_to_ref<T>(this: &T, a: T) { *(this as *const _ as *mut _) = a; diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index 7ff9b76a85e..47b95460ec3 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -4,6 +4,7 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is LL | let _num = &mut *(num as *const i32 as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> = note: `#[deny(invalid_reference_casting)]` on by default error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` @@ -11,54 +12,72 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is | LL | let _num = &mut *(num as *const i32).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:23:16 | LL | let _num = &mut *std::ptr::from_ref(num).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:25:16 | LL | let _num = &mut *std::ptr::from_ref({ num }).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:27:16 | LL | let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:29:16 | LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:31:16 | LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:33:16 | LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_const().cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:35:16 | LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:37:16 | LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:41:16 @@ -67,6 +86,8 @@ LL | let deferred = num as *const i32 as *mut i32; | ----------------------------- casting happend here LL | let _num = &mut *deferred; | ^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:44:16 @@ -75,86 +96,159 @@ LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).ca | ---------------------------------------------------------------------------- casting happend here LL | let _num = &mut *deferred; | ^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:46:16 | LL | let _num = &mut *(num as *const _ as usize as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:50:9 | LL | &mut *((this as *const _) as *mut _) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:60:5 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:62:5 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:64:5 | LL | *std::ptr::from_ref(num).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:66:5 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:68:5 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:70:5 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` --> $DIR/reference_casting.rs:72:5 | LL | *std::mem::transmute::<_, *mut i32>(num) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:74:5 + | +LL | / std::ptr::write( +LL | | +LL | | std::mem::transmute::<*const i32, *mut i32>(num), +LL | | -1i32, +LL | | ); + | |_____^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:76:5 + --> $DIR/reference_casting.rs:81:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here LL | *value = 1; | ^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:78:5 + --> $DIR/reference_casting.rs:83:5 | LL | *(num as *const i32).cast::<i32>().cast_mut() = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:80:5 + --> $DIR/reference_casting.rs:85:5 | LL | *(num as *const _ as usize as *mut i32) = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:87:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +... +LL | std::ptr::write(value, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:84:9 + --> $DIR/reference_casting.rs:89:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +... +LL | std::ptr::write_unaligned(value, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:91:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +... +LL | std::ptr::write_volatile(value, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:95:9 | LL | *(this as *const _ as *mut _) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> -error: aborting due to 25 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/issue-2804.rs b/tests/ui/macros/issue-2804.rs index 571028c5e40..571028c5e40 100644 --- a/tests/ui/issue-2804.rs +++ b/tests/ui/macros/issue-2804.rs diff --git a/tests/ui/macros/macro-interpolation.rs b/tests/ui/macros/macro-interpolation.rs index 35003a79ad7..48c1f19e777 100644 --- a/tests/ui/macros/macro-interpolation.rs +++ b/tests/ui/macros/macro-interpolation.rs @@ -1,5 +1,3 @@ -// run-pass - macro_rules! overly_complicated { ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) => ({ @@ -21,12 +19,14 @@ macro_rules! qpath { (ty, <$type:ty as $trait:ty>::$name:ident) => { <$type as $trait>::$name + //~^ ERROR expected identifier, found `!` }; } pub fn main() { let _: qpath!(path, <str as ToOwned>::Owned); let _: qpath!(ty, <str as ToOwned>::Owned); + let _: qpath!(ty, <str as !>::Owned); assert!(overly_complicated!(f, x, Option<usize>, { return Some(x); }, Some(8), Some(y), y) == 8) diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr new file mode 100644 index 00000000000..7ef1fcbbce3 --- /dev/null +++ b/tests/ui/macros/macro-interpolation.stderr @@ -0,0 +1,16 @@ +error: expected identifier, found `!` + --> $DIR/macro-interpolation.rs:21:19 + | +LL | <$type as $trait>::$name + | ^^^^^^ expected identifier +... +LL | let _: qpath!(ty, <str as !>::Owned); + | ----------------------------- + | | + | this macro call doesn't expand to a type + | in this macro invocation + | + = note: this error originates in the macro `qpath` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/methods/issues/issue-61525.stderr b/tests/ui/methods/issues/issue-61525.stderr index a8afdeb8401..a329b52e373 100644 --- a/tests/ui/methods/issues/issue-61525.stderr +++ b/tests/ui/methods/issues/issue-61525.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time - --> $DIR/issue-61525.rs:14:33 + --> $DIR/issue-61525.rs:14:19 | LL | 1.query::<dyn ToString>("") - | ----- ^^ doesn't have a size known at compile-time + | ----- ^^^^^^^^^^^^ doesn't have a size known at compile-time | | | required by a bound introduced by this call | diff --git a/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr b/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr index 06e902bca70..54c16230fe6 100644 --- a/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr +++ b/tests/ui/never_type/never-value-fallback-issue-66757.nofallback.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `E: From<()>` is not satisfied - --> $DIR/never-value-fallback-issue-66757.rs:28:26 + --> $DIR/never-value-fallback-issue-66757.rs:28:6 | LL | <E as From<_>>::from(never); - | -------------------- ^^^^^ the trait `From<()>` is not implemented for `E` - | | - | required by a bound introduced by this call + | ^ the trait `From<()>` is not implemented for `E` | = help: the trait `From<!>` is implemented for `E` diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr index f8488d842e2..6b5bc360349 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr @@ -13,12 +13,12 @@ LL | fn bop<T: Bop + ?Sized>() where T: Sized { | ++++++++++++++ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:12:13 + --> $DIR/assoc_type_bounds_sized_used.rs:12:14 | LL | fn bop<T: Bop + ?Sized>() { | - this type parameter needs to be `Sized` LL | let _ = <T as Bop>::Bar::default(); - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | note: required by a bound in `Bop::Bar` --> $DIR/assoc_type_bounds_sized_used.rs:8:15 diff --git a/tests/ui/on-unimplemented/sum.stderr b/tests/ui/on-unimplemented/sum.stderr index a2357e49b07..257dec20074 100644 --- a/tests/ui/on-unimplemented/sum.stderr +++ b/tests/ui/on-unimplemented/sum.stderr @@ -1,8 +1,10 @@ error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()` - --> $DIR/sum.rs:4:25 + --> $DIR/sum.rs:4:31 | LL | vec![(), ()].iter().sum::<i32>(); - | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>` + | --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>` + | | + | required by a bound introduced by this call | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: @@ -19,10 +21,12 @@ note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0277]: a value of type `i32` cannot be made by multiplying all elements of type `&()` from an iterator - --> $DIR/sum.rs:7:25 + --> $DIR/sum.rs:7:35 | LL | vec![(), ()].iter().product::<i32>(); - | ^^^^^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>` + | ------- ^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>` + | | + | required by a bound introduced by this call | = help: the trait `Product<&()>` is not implemented for `i32` = help: the following other types implement trait `Product<A>`: diff --git a/tests/ui/or-patterns/missing-bindings.stderr b/tests/ui/or-patterns/missing-bindings.stderr index 8fafa275b5c..4457b7893d5 100644 --- a/tests/ui/or-patterns/missing-bindings.stderr +++ b/tests/ui/or-patterns/missing-bindings.stderr @@ -79,6 +79,14 @@ LL | let (A(A(..) | B(a), _) | B(A(a, _) | B(a))) = Y; | | | pattern doesn't bind `a` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:12 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | ^^^^^^^ - variable not in all patterns + | | + | pattern doesn't bind `c` + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:45:22 | @@ -96,12 +104,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:12 + --> $DIR/missing-bindings.rs:45:33 | LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | ^^^^^^^ - variable not in all patterns - | | - | pattern doesn't bind `c` + | - ^^^^ pattern doesn't bind `c` + | | + | variable not in all patterns error[E0408]: variable `d` is not bound in all patterns --> $DIR/missing-bindings.rs:45:33 @@ -135,14 +143,6 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | variable not in all patterns -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:33 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | - ^^^^ pattern doesn't bind `c` - | | - | variable not in all patterns - error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:61:29 | @@ -185,6 +185,28 @@ LL | B(b), LL | B(_) | ^^^^ pattern doesn't bind `b` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/missing-bindings.rs:57:13 + | +LL | / V1( +LL | | +LL | | +LL | | A( +... | +LL | | B(Ok(a) | Err(a)) +LL | | ) | + | |_____________^ pattern doesn't bind `c` +LL | / V2( +LL | | A( +LL | | A(_, a) | +LL | | B(b), +... | +LL | | +LL | | ) | + | |_____________^ pattern doesn't bind `c` +LL | V3(c), + | - variable not in all patterns + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:76:13 | @@ -215,28 +237,6 @@ LL | B(b), LL | V3(c), | ^^^^^ pattern doesn't bind `b` -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/missing-bindings.rs:57:13 - | -LL | / V1( -LL | | -LL | | -LL | | A( -... | -LL | | B(Ok(a) | Err(a)) -LL | | ) | - | |_____________^ pattern doesn't bind `c` -LL | / V2( -LL | | A( -LL | | A(_, a) | -LL | | B(b), -... | -LL | | -LL | | ) | - | |_____________^ pattern doesn't bind `c` -LL | V3(c), - | - variable not in all patterns - error: aborting due to 26 previous errors For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/panics/panic-in-cleanup.rs b/tests/ui/panics/panic-in-cleanup.rs new file mode 100644 index 00000000000..a1c797268d1 --- /dev/null +++ b/tests/ui/panics/panic-in-cleanup.rs @@ -0,0 +1,22 @@ +// run-fail +// exec-env:RUST_BACKTRACE=0 +// check-run-results +// error-pattern: panic in a destructor during cleanup +// normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" +// normalize-stderr-test: "\n +at [^\n]+" -> "" +// needs-unwind +// ignore-emscripten "RuntimeError" junk in output +// ignore-msvc SEH doesn't do panic-during-cleanup the same way as everyone else + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + panic!("BOOM"); + } +} + +fn main() { + let _b = Bomb; + panic!(); +} diff --git a/tests/ui/panics/panic-in-cleanup.run.stderr b/tests/ui/panics/panic-in-cleanup.run.stderr new file mode 100644 index 00000000000..923bac69c50 --- /dev/null +++ b/tests/ui/panics/panic-in-cleanup.run.stderr @@ -0,0 +1,10 @@ +thread 'main' panicked at $DIR/panic-in-cleanup.rs:21:5: +explicit panic +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread 'main' panicked at $DIR/panic-in-cleanup.rs:15:9: +BOOM +stack backtrace: +thread 'main' panicked at library/core/src/panicking.rs:126:5: +panic in a destructor during cleanup +stack backtrace: +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-in-ffi.rs b/tests/ui/panics/panic-in-ffi.rs new file mode 100644 index 00000000000..da2b24945be --- /dev/null +++ b/tests/ui/panics/panic-in-ffi.rs @@ -0,0 +1,17 @@ +// run-fail +// exec-env:RUST_BACKTRACE=0 +// check-run-results +// error-pattern: panic in a function that cannot unwind +// normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" +// normalize-stderr-test: "\n +at [^\n]+" -> "" +// needs-unwind +// ignore-emscripten "RuntimeError" junk in output +#![feature(c_unwind)] + +extern "C" fn panic_in_ffi() { + panic!("Test"); +} + +fn main() { + panic_in_ffi(); +} diff --git a/tests/ui/panics/panic-in-ffi.run.stderr b/tests/ui/panics/panic-in-ffi.run.stderr new file mode 100644 index 00000000000..3422f5ccc4d --- /dev/null +++ b/tests/ui/panics/panic-in-ffi.run.stderr @@ -0,0 +1,7 @@ +thread 'main' panicked at $DIR/panic-in-ffi.rs:12:5: +Test +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread 'main' panicked at library/core/src/panicking.rs:126:5: +panic in a function that cannot unwind +stack backtrace: +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/parser/keyword-union-as-identifier.rs b/tests/ui/parser/keyword-union-as-identifier.rs new file mode 100644 index 00000000000..7062557d731 --- /dev/null +++ b/tests/ui/parser/keyword-union-as-identifier.rs @@ -0,0 +1,72 @@ +// check-pass + +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +mod union { + type union = i32; + + pub struct Bar { + pub union: union, + } + + pub fn union() -> Bar { + Bar { + union: 5 + } + } +} + +mod struct_union { + pub struct union { + pub union: u32 + } + static union: union = union { union: 0 }; + + impl union { + pub fn union<'union>() -> &'union union { + &union + } + } + impl union {} + trait Foo {} + impl Foo for union {} + trait Bar { + fn bar() {} + } + impl Bar for union {} +} + +mod union_union { + pub union union { + pub union: u32 + } + const union: union = union { union: 0 }; + impl union { + pub fn union() -> union { + union + } + } +} + +mod trait_union { + pub trait union { + fn union() {} + } + impl union for () {} +} + +macro_rules! ty { + ($ty:ty { $($field:ident:$field_ty:ty)* }) => {}; +} + +fn main() { + let union = union::union(); + let _ = union.union; + let _ = struct_union::union::union().union; + let union = union_union::union::union(); + let _ = unsafe { union.union }; + <() as trait_union::union>::union(); + ty!(union {}); + ty!(union { union: union }); +} diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index 0e0f0c3e11e..df330c60b1e 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -77,6 +77,8 @@ LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize:: | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered | = note: the matched value is of type `(usize, bool)` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | match $s { $($t)+ => {}, (_, _) => todo!() } @@ -131,6 +133,8 @@ LL | m!((0isize, true), (isize::MIN..5, true) | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered | = note: the matched value is of type `(isize, bool)` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | match $s { $($t)+ => {}, (_, _) => todo!() } diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs new file mode 100644 index 00000000000..8f58227ee2c --- /dev/null +++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs @@ -0,0 +1,67 @@ +struct A<T> { + a: T, +} + +struct B<T, U>(T, U); + +fn main() { + match 0 { + //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] + 0 => (), + 1..=usize::MAX => (), + } + + match (0usize, 0usize) { + //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004] + (0, 0) => (), + (1..=usize::MAX, 1..=usize::MAX) => (), + } + + match (0isize, 0usize) { + //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004] + (isize::MIN..=isize::MAX, 0) => (), + (isize::MIN..=isize::MAX, 1..=usize::MAX) => (), + } + + // Should not report note about usize not having fixed max value + match Some(1usize) { + //~^ ERROR non-exhaustive patterns: `Some(_)` not covered + None => {} + } + + match Some(4) { + //~^ ERROR non-exhaustive patterns: `Some(_)` not covered + Some(0) => (), + Some(1..=usize::MAX) => (), + None => (), + } + + match Some(Some(Some(0))) { + //~^ ERROR non-exhaustive patterns: `Some(Some(Some(_)))` not covered + Some(Some(Some(0))) => (), + Some(Some(Some(1..=usize::MAX))) => (), + Some(Some(None)) => (), + Some(None) => (), + None => (), + } + + match (A { a: 0usize }) { + //~^ ERROR non-exhaustive patterns: `A { .. }` not covered [E0004] + A { a: 0 } => (), + A { a: 1..=usize::MAX } => (), + } + + match B(0isize, 0usize) { + //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004] + B(isize::MIN..=isize::MAX, 0) => (), + B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (), + } + + // Should report only the note about usize not having fixed max value and not report + // report the note about isize + match B(0isize, 0usize) { + //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004] + B(_, 0) => (), + B(_, 1..=usize::MAX) => (), + } +} diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr new file mode 100644 index 00000000000..ea1d99e20ae --- /dev/null +++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr @@ -0,0 +1,170 @@ +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:8:11 + | +LL | match 0 { + | ^ pattern `_` not covered + | + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 1..=usize::MAX => (), +LL ~ _ => todo!(), + | + +error[E0004]: non-exhaustive patterns: `(_, _)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:14:11 + | +LL | match (0usize, 0usize) { + | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | + = note: the matched value is of type `(usize, usize)` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (1..=usize::MAX, 1..=usize::MAX) => (), +LL ~ (_, _) => todo!(), + | + +error[E0004]: non-exhaustive patterns: `(_, _)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:20:11 + | +LL | match (0isize, 0usize) { + | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | + = note: the matched value is of type `(isize, usize)` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ (isize::MIN..=isize::MAX, 1..=usize::MAX) => (), +LL ~ (_, _) => todo!(), + | + +error[E0004]: non-exhaustive patterns: `Some(_)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:27:11 + | +LL | match Some(1usize) { + | ^^^^^^^^^^^^ pattern `Some(_)` not covered + | +note: `Option<usize>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Option<usize>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None => {}, +LL + Some(_) => todo!() + | + +error[E0004]: non-exhaustive patterns: `Some(_)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:32:11 + | +LL | match Some(4) { + | ^^^^^^^ pattern `Some(_)` not covered + | +note: `Option<usize>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Option<usize>` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None => (), +LL ~ Some(_) => todo!(), + | + +error[E0004]: non-exhaustive patterns: `Some(Some(Some(_)))` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:39:11 + | +LL | match Some(Some(Some(0))) { + | ^^^^^^^^^^^^^^^^^^^ pattern `Some(Some(Some(_)))` not covered + | +note: `Option<Option<Option<usize>>>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + | + = note: not covered + | + = note: not covered + = note: the matched value is of type `Option<Option<Option<usize>>>` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None => (), +LL ~ Some(Some(Some(_))) => todo!(), + | + +error[E0004]: non-exhaustive patterns: `A { .. }` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:48:11 + | +LL | match (A { a: 0usize }) { + | ^^^^^^^^^^^^^^^^^ pattern `A { .. }` not covered + | +note: `A<usize>` defined here + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:1:8 + | +LL | struct A<T> { + | ^ + = note: the matched value is of type `A<usize>` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ A { a: 1..=usize::MAX } => (), +LL ~ A { .. } => todo!(), + | + +error[E0004]: non-exhaustive patterns: `B(_, _)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:54:11 + | +LL | match B(0isize, 0usize) { + | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered + | +note: `B<isize, usize>` defined here + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8 + | +LL | struct B<T, U>(T, U); + | ^ + = note: the matched value is of type `B<isize, usize>` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (), +LL ~ B(_, _) => todo!(), + | + +error[E0004]: non-exhaustive patterns: `B(_, _)` not covered + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:62:11 + | +LL | match B(0isize, 0usize) { + | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered + | +note: `B<isize, usize>` defined here + --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8 + | +LL | struct B<T, U>(T, U); + | ^ + = note: the matched value is of type `B<isize, usize>` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ B(_, 1..=usize::MAX) => (), +LL ~ B(_, _) => todo!(), + | + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr index b8af566de7c..d798ec722dd 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr @@ -10,6 +10,8 @@ note: `Foo` defined here LL | struct Foo { | ^^^ = note: the matched value is of type `Foo` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ Foo { first: false, second: Some([1, 2, 3, 4]) } => (), diff --git a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr index e2a65ff8524..50c7fc889f4 100644 --- a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr +++ b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr @@ -10,6 +10,8 @@ note: `Foo` defined here LL | struct Foo(isize, isize); | ^^^ = note: the matched value is of type `Foo` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ Foo(2, b) => println!("{}", b), diff --git a/tests/ui/repr/invalid_repr_list_help.stderr b/tests/ui/repr/invalid_repr_list_help.stderr index 48a6af3dd4c..7ffe1287eb3 100644 --- a/tests/ui/repr/invalid_repr_list_help.stderr +++ b/tests/ui/repr/invalid_repr_list_help.stderr @@ -4,7 +4,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(uwu)] | ^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:6:8 @@ -12,7 +12,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(uwu = "a")] | ^^^^^^^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:9:8 @@ -20,7 +20,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(uwu(4))] | ^^^^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:14:8 @@ -28,7 +28,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(uwu, u8)] | ^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` warning: unknown `doc` attribute `owo` --> $DIR/invalid_repr_list_help.rs:20:7 @@ -46,7 +46,7 @@ error[E0552]: unrecognized representation hint LL | #[repr(uwu)] | ^^^ | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error: aborting due to 5 previous errors; 1 warning emitted diff --git a/tests/ui/resolve/resolve-inconsistent-names.stderr b/tests/ui/resolve/resolve-inconsistent-names.stderr index 023db303dd0..42b7281d7b0 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.stderr +++ b/tests/ui/resolve/resolve-inconsistent-names.stderr @@ -14,6 +14,15 @@ LL | a | b => {} | | | pattern doesn't bind `b` +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/resolve-inconsistent-names.rs:19:9 + | +LL | (A, B) | (ref B, c) | (c, A) => () + | ^^^^^^ - - variable not in all patterns + | | | + | | variable not in all patterns + | pattern doesn't bind `c` + error[E0408]: variable `A` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:18 | @@ -37,15 +46,6 @@ LL | (A, B) | (ref B, c) | (c, A) => () | | variable not in all patterns | variable not in all patterns -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:19:9 - | -LL | (A, B) | (ref B, c) | (c, A) => () - | ^^^^^^ - - variable not in all patterns - | | | - | | variable not in all patterns - | pattern doesn't bind `c` - error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|` --> $DIR/resolve-inconsistent-names.rs:19:23 | diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs new file mode 100644 index 00000000000..b4eb541398c --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs @@ -0,0 +1,18 @@ +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +fn match_option(x: Option<u32>) { + match x { + //~^ ERROR non-exhaustive patterns: `None` not covered + Some(_) => {} + None if let y = x => {} + } +} + +fn main() { + let x = (); + match x { + //~^ ERROR non-exhaustive patterns: `()` not covered + y if let z = y => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr new file mode 100644 index 00000000000..ddd08854ff7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr @@ -0,0 +1,35 @@ +error[E0004]: non-exhaustive patterns: `None` not covered + --> $DIR/exhaustive.rs:5:11 + | +LL | match x { + | ^ pattern `None` not covered + | +note: `Option<u32>` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Option<u32>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None if let y = x => {}, +LL + None => todo!() + | + +error[E0004]: non-exhaustive patterns: `()` not covered + --> $DIR/exhaustive.rs:14:11 + | +LL | match x { + | ^ pattern `()` not covered + | + = note: the matched value is of type `()` + = note: match arms with guards don't count towards exhaustivity +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ y if let z = y => {}, +LL + () => todo!() + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs new file mode 100644 index 00000000000..792225e656f --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs @@ -0,0 +1,15 @@ +// References to by-move bindings in an if-let guard *cannot* be used after the guard. + +#![feature(if_let_guard)] + +fn main() { + let x: Option<Option<String>> = Some(Some(String::new())); + match x { + Some(mut y) if let Some(ref z) = y => { + //~^ ERROR: cannot move out of `x.0` because it is borrowed + let _z: &String = z; + let _y: Option<String> = y; + } + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr new file mode 100644 index 00000000000..b8e1bb324b1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr @@ -0,0 +1,15 @@ +error[E0505]: cannot move out of `x.0` because it is borrowed + --> $DIR/guard-lifetime-1.rs:8:14 + | +LL | Some(mut y) if let Some(ref z) = y => { + | ^^^^^ + | | + | move out of `x.0` occurs here + | borrow of `x.0` occurs here +LL | +LL | let _z: &String = z; + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs new file mode 100644 index 00000000000..aa2154e3e9e --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs @@ -0,0 +1,16 @@ +// References to by-mutable-ref bindings in an if-let guard *can* be used after the guard. + +// check-pass + +#![feature(if_let_guard)] + +fn main() { + let mut x: Option<Option<String>> = Some(Some(String::new())); + match x { + Some(ref mut y) if let Some(ref z) = *y => { + let _z: &String = z; + let _y: &mut Option<String> = y; + } + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs new file mode 100644 index 00000000000..9353c9d92f8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs @@ -0,0 +1,14 @@ +// Check mutable bindings cannot be mutated by an if-let guard. + +#![feature(if_let_guard)] + +fn main() { + let x: Option<Option<i32>> = Some(Some(6)); + match x { + Some(mut y) if let Some(ref mut z) = y => { + //~^ ERROR cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + let _: &mut i32 = z; + } + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr new file mode 100644 index 00000000000..009d153387e --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + --> $DIR/guard-mutability-1.rs:8:33 + | +LL | Some(mut y) if let Some(ref mut z) = y => { + | ^^^^^^^^^ cannot borrow as mutable + | + = note: variables bound in patterns are immutable until the end of the pattern guard + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs new file mode 100644 index 00000000000..4efa02f57a6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs @@ -0,0 +1,14 @@ +// Check mutable reference bindings cannot be mutated by an if-let guard. + +#![feature(if_let_guard)] + +fn main() { + let mut x: Option<Option<i32>> = Some(Some(6)); + match x { + Some(ref mut y) if let Some(ref mut z) = *y => { + //~^ ERROR cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + let _: &mut i32 = z; + } + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr new file mode 100644 index 00000000000..07e7c6a2c07 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + --> $DIR/guard-mutability-2.rs:8:37 + | +LL | Some(ref mut y) if let Some(ref mut z) = *y => { + | ^^^^^^^^^ cannot borrow as mutable + | + = note: variables bound in patterns are immutable until the end of the pattern guard + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs new file mode 100644 index 00000000000..423a2cd53fc --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs @@ -0,0 +1,16 @@ +// Expression macros can't expand to a let match guard. + +#![feature(if_let_guard)] +#![feature(let_chains)] + +macro_rules! m { + ($e:expr) => { let Some(x) = $e } + //~^ ERROR expected expression, found `let` statement +} + +fn main() { + match () { + () if m!(Some(5)) => {} + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr new file mode 100644 index 00000000000..41a20bf8ae1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr @@ -0,0 +1,13 @@ +error: expected expression, found `let` statement + --> $DIR/macro-expanded.rs:7:20 + | +LL | ($e:expr) => { let Some(x) = $e } + | ^^^ +... +LL | () if m!(Some(5)) => {} + | ----------- in this macro invocation + | + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs new file mode 100644 index 00000000000..9cb27c73b14 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs @@ -0,0 +1,27 @@ +// Parenthesised let "expressions" are not allowed in guards + +#![feature(if_let_guard)] +#![feature(let_chains)] + +#[cfg(FALSE)] +fn un_cfged() { + match () { + () if let 0 = 1 => {} + () if (let 0 = 1) => {} + //~^ ERROR expected expression, found `let` statement + () if (((let 0 = 1))) => {} + //~^ ERROR expected expression, found `let` statement + } +} + +fn main() { + match () { + () if let 0 = 1 => {} + () if (let 0 = 1) => {} + //~^ ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + () if (((let 0 = 1))) => {} + //~^ ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr new file mode 100644 index 00000000000..85df360daab --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr @@ -0,0 +1,52 @@ +error: expected expression, found `let` statement + --> $DIR/parens.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:12:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:20:16 + | +LL | () if (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:23:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^ + +error: `let` expressions are not supported here + --> $DIR/parens.rs:20:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:20:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/parens.rs:23:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:23:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs new file mode 100644 index 00000000000..d91b3a358da --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs @@ -0,0 +1,18 @@ +// Macros can be used for (parts of) the pattern and expression in an if let guard +// check-pass + +#![feature(if_let_guard)] +#![feature(let_chains)] + +macro_rules! m { + (pattern $i:ident) => { Some($i) }; + (expression $e:expr) => { $e }; +} + +fn main() { + match () { + () if let m!(pattern x) = m!(expression Some(4)) => {} + () if let [m!(pattern y)] = [Some(8 + m!(expression 4))] => {} + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs new file mode 100644 index 00000000000..dba292ef9e2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs @@ -0,0 +1,23 @@ +// Check shadowing in if let guards works as expected. +// check-pass + +#![feature(if_let_guard)] +#![feature(let_chains)] + +fn main() { + let x: Option<Option<i32>> = Some(Some(6)); + match x { + Some(x) if let Some(x) = x => { + let _: i32 = x; + } + _ => {} + } + + let y: Option<Option<Option<i32>>> = Some(Some(Some(-24))); + match y { + Some(y) if let Some(y) = y && let Some(y) = y => { + let _: i32 = y; + } + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr index 4fcfe9d4769..ad11c090f12 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/assoc-type-const-bound-usage.rs:12:5 + --> $DIR/assoc-type-const-bound-usage.rs:12:6 | LL | <T as Foo>::Assoc::foo(); - | ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | ^ the trait `Foo` is not implemented for `T` | help: consider further restricting this bound | diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr index 2d9c49af85a..452bf757df7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `u32: ~const Plus` is not satisfied - --> $DIR/call-const-trait-method-fail.rs:25:7 + --> $DIR/call-const-trait-method-fail.rs:25:5 | LL | a.plus(b) - | ^^^^ the trait `Plus` is not implemented for `u32` + | ^ the trait `Plus` is not implemented for `u32` | = help: the trait `Plus` is implemented for `u32` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr index e8d0eec020f..c94563d3591 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: ~const Bar` is not satisfied --> $DIR/trait-where-clause-const.rs:21:5 | LL | T::b(); - | ^^^^ the trait `Bar` is not implemented for `T` + | ^ the trait `Bar` is not implemented for `T` | note: required by a bound in `Foo::b` --> $DIR/trait-where-clause-const.rs:15:24 diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr index 11f0c40160d..255878e1775 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Bar` is not satisfied --> $DIR/trait-where-clause.rs:14:5 | LL | T::b(); - | ^^^^ the trait `Bar` is not implemented for `T` + | ^ the trait `Bar` is not implemented for `T` | note: required by a bound in `Foo::b` --> $DIR/trait-where-clause.rs:8:24 diff --git a/tests/ui/span/issue-39698.stderr b/tests/ui/span/issue-39698.stderr index 25c35fd5479..81211b20a01 100644 --- a/tests/ui/span/issue-39698.stderr +++ b/tests/ui/span/issue-39698.stderr @@ -1,3 +1,13 @@ +error[E0408]: variable `c` is not bound in all patterns + --> $DIR/issue-39698.rs:10:9 + | +LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` + | | | | + | | | variable not in all patterns + | | pattern doesn't bind `c` + | pattern doesn't bind `c` + error[E0408]: variable `d` is not bound in all patterns --> $DIR/issue-39698.rs:10:37 | @@ -28,16 +38,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | variable not in all patterns | pattern doesn't bind `b` -error[E0408]: variable `c` is not bound in all patterns - --> $DIR/issue-39698.rs:10:9 - | -LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } - | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` - | | | | - | | | variable not in all patterns - | | pattern doesn't bind `c` - | pattern doesn't bind `c` - error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/issues/issue-17431-6.rs b/tests/ui/structs-enums/enum-rec/issue-17431-6.rs index b7e49873da8..b7e49873da8 100644 --- a/tests/ui/issues/issue-17431-6.rs +++ b/tests/ui/structs-enums/enum-rec/issue-17431-6.rs diff --git a/tests/ui/issues/issue-17431-6.stderr b/tests/ui/structs-enums/enum-rec/issue-17431-6.stderr index e0a8225507e..e0a8225507e 100644 --- a/tests/ui/issues/issue-17431-6.stderr +++ b/tests/ui/structs-enums/enum-rec/issue-17431-6.stderr diff --git a/tests/ui/issues/issue-17431-7.rs b/tests/ui/structs-enums/enum-rec/issue-17431-7.rs index 4fd7862781b..4fd7862781b 100644 --- a/tests/ui/issues/issue-17431-7.rs +++ b/tests/ui/structs-enums/enum-rec/issue-17431-7.rs diff --git a/tests/ui/issues/issue-17431-7.stderr b/tests/ui/structs-enums/enum-rec/issue-17431-7.stderr index ecf072b8e8a..ecf072b8e8a 100644 --- a/tests/ui/issues/issue-17431-7.stderr +++ b/tests/ui/structs-enums/enum-rec/issue-17431-7.stderr diff --git a/tests/ui/issues/issue-17431-1.rs b/tests/ui/structs-enums/struct-rec/issue-17431-1.rs index 3b692cc0eeb..3b692cc0eeb 100644 --- a/tests/ui/issues/issue-17431-1.rs +++ b/tests/ui/structs-enums/struct-rec/issue-17431-1.rs diff --git a/tests/ui/issues/issue-17431-1.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-1.stderr index e3af8976cee..e3af8976cee 100644 --- a/tests/ui/issues/issue-17431-1.stderr +++ b/tests/ui/structs-enums/struct-rec/issue-17431-1.stderr diff --git a/tests/ui/issues/issue-17431-2.rs b/tests/ui/structs-enums/struct-rec/issue-17431-2.rs index f7b9c6a55dd..f7b9c6a55dd 100644 --- a/tests/ui/issues/issue-17431-2.rs +++ b/tests/ui/structs-enums/struct-rec/issue-17431-2.rs diff --git a/tests/ui/issues/issue-17431-2.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-2.stderr index 39a99ec1ef7..39a99ec1ef7 100644 --- a/tests/ui/issues/issue-17431-2.stderr +++ b/tests/ui/structs-enums/struct-rec/issue-17431-2.stderr diff --git a/tests/ui/issues/issue-17431-3.rs b/tests/ui/structs-enums/struct-rec/issue-17431-3.rs index 83a63a88b72..83a63a88b72 100644 --- a/tests/ui/issues/issue-17431-3.rs +++ b/tests/ui/structs-enums/struct-rec/issue-17431-3.rs diff --git a/tests/ui/issues/issue-17431-3.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-3.stderr index 394134c7855..394134c7855 100644 --- a/tests/ui/issues/issue-17431-3.stderr +++ b/tests/ui/structs-enums/struct-rec/issue-17431-3.stderr diff --git a/tests/ui/issues/issue-17431-4.rs b/tests/ui/structs-enums/struct-rec/issue-17431-4.rs index 48f0dba2aec..48f0dba2aec 100644 --- a/tests/ui/issues/issue-17431-4.rs +++ b/tests/ui/structs-enums/struct-rec/issue-17431-4.rs diff --git a/tests/ui/issues/issue-17431-4.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-4.stderr index 3d141e44bab..3d141e44bab 100644 --- a/tests/ui/issues/issue-17431-4.stderr +++ b/tests/ui/structs-enums/struct-rec/issue-17431-4.stderr diff --git a/tests/ui/issues/issue-17431-5.rs b/tests/ui/structs-enums/struct-rec/issue-17431-5.rs index 0fd6ee61156..0fd6ee61156 100644 --- a/tests/ui/issues/issue-17431-5.rs +++ b/tests/ui/structs-enums/struct-rec/issue-17431-5.rs diff --git a/tests/ui/issues/issue-17431-5.stderr b/tests/ui/structs-enums/struct-rec/issue-17431-5.stderr index 44a90a6fe38..44a90a6fe38 100644 --- a/tests/ui/issues/issue-17431-5.stderr +++ b/tests/ui/structs-enums/struct-rec/issue-17431-5.stderr diff --git a/tests/ui/suggestions/assoc-const-as-fn.stderr b/tests/ui/suggestions/assoc-const-as-fn.stderr index 3b6e947c59f..d55d968b600 100644 --- a/tests/ui/suggestions/assoc-const-as-fn.stderr +++ b/tests/ui/suggestions/assoc-const-as-fn.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied - --> $DIR/assoc-const-as-fn.rs:14:40 + --> $DIR/assoc-const-as-fn.rs:14:6 | LL | <T as GlUniformScalar>::FACTORY(1, value); - | ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T` - | | - | required by a bound introduced by this call + | ^ the trait `GlUniformScalar` is not implemented for `T` | help: consider further restricting this bound | diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 61b9137eadd..97bd7789a63 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -6,6 +6,11 @@ // normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" // normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET" +// The test becomes too flaky if we care about exact args. If `-Z ui-testing` +// from compiletest and `-Z track-diagnostics` from `// compile-flags` at the +// top of this file are present, then assume all args are present. +// normalize-stderr-test "note: compiler flags: .*-Z ui-testing.*-Z track-diagnostics" -> "note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics" + fn main() { break rust } diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index 8256c1f5f0f..60254dc475b 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -20,6 +20,8 @@ note: we would appreciate a joke overview: https://github.com/rust-lang/rust/iss note: rustc $VERSION running on $TARGET +note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics + error: aborting due to 3 previous errors Some errors have detailed explanations: E0268, E0425. diff --git a/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs new file mode 100644 index 00000000000..91525bc90c4 --- /dev/null +++ b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.rs @@ -0,0 +1,6 @@ +// Regression test for one part of issue #105306. + +fn main() { + let _ = Option::<[u8]>::None; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +} diff --git a/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr new file mode 100644 index 00000000000..32f6b00b20c --- /dev/null +++ b/tests/ui/trait-bounds/enum-unit-variant-trait-bound.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/enum-unit-variant-trait-bound.rs:4:22 + | +LL | let _ = Option::<[u8]>::None; + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `None` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/bad-method-typaram-kind.stderr b/tests/ui/traits/bad-method-typaram-kind.stderr index 074284cbdd4..bdcfbe79558 100644 --- a/tests/ui/traits/bad-method-typaram-kind.stderr +++ b/tests/ui/traits/bad-method-typaram-kind.stderr @@ -2,7 +2,9 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/bad-method-typaram-kind.rs:2:13 | LL | 1.bar::<T>(); - | ^ `T` cannot be sent between threads safely + | --- ^ `T` cannot be sent between threads safely + | | + | required by a bound introduced by this call | = note: consider using `std::sync::Arc<T>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html> note: required by a bound in `Bar::bar` diff --git a/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr index 934d20b2267..263c59ee327 100644 --- a/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr +++ b/tests/ui/traits/dont-autoderef-ty-with-escaping-var.stderr @@ -5,12 +5,10 @@ LL | <i32 as RefFoo<i32>>::ref_foo(unknown); | ^^^^^^^ not found in this scope error[E0277]: the trait bound `for<'a> &'a mut Vec<&'a u32>: Foo<'static, i32>` is not satisfied - --> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:35 + --> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:6 | LL | <i32 as RefFoo<i32>>::ref_foo(unknown); - | ----------------------------- ^^^^^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>` - | | - | required by a bound introduced by this call + | ^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>` | note: required for `i32` to implement `RefFoo<i32>` --> $DIR/dont-autoderef-ty-with-escaping-var.rs:9:9 diff --git a/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr index 656e0d0bf26..7027fa69e03 100644 --- a/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -24,12 +24,10 @@ LL | fn with_trait<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool { | ++++++++++++++++ error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied - --> $DIR/repeated-supertrait-ambig.rs:34:37 + --> $DIR/repeated-supertrait-ambig.rs:34:6 | LL | <dyn CompareToInts>::same_as(c, 22) - | ---------------------------- ^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts` | = help: the following other types implement trait `CompareTo<T>`: <i64 as CompareTo<i64>> diff --git a/tests/ui/issues/issue-66768.rs b/tests/ui/traits/issue-66768.rs index ce42c8b01cc..ce42c8b01cc 100644 --- a/tests/ui/issues/issue-66768.rs +++ b/tests/ui/traits/issue-66768.rs diff --git a/tests/ui/traits/issue-77982.stderr b/tests/ui/traits/issue-77982.stderr index d4fea05fe4b..33cc186ac0b 100644 --- a/tests/ui/traits/issue-77982.stderr +++ b/tests/ui/traits/issue-77982.stderr @@ -35,23 +35,12 @@ help: consider specifying the generic argument LL | opts.get::<Q>(opt.as_ref()); | +++++ -error[E0283]: type annotations needed +error[E0282]: type annotations needed --> $DIR/issue-77982.rs:13:59 | LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); - | --------- ^^^^ - | | - | required by a bound introduced by this call - | - = note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate: - - impl From<Ipv4Addr> for u32; - - impl From<NonZeroU32> for u32; - - impl From<bool> for u32; - - impl From<char> for u32; - - impl From<u16> for u32; - - impl From<u8> for u32; - - impl<T> From<!> for T; - - impl<T> From<T> for T; + | ^^^^ + | help: try using a fully qualified path to specify the expected types | LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect(); @@ -95,4 +84,5 @@ LL | let _: Box<T> = (&()).bar(); error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr index f7551739b13..4eaa259617b 100644 --- a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr +++ b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr @@ -1,10 +1,8 @@ error[E0277]: expected a `Fn<_>` closure, found `fn() -> str` - --> $DIR/builtin-fn-must-return-sized.rs:15:27 + --> $DIR/builtin-fn-must-return-sized.rs:15:11 | LL | foo::<fn() -> str, _>(None, ()); - | --------------------- ^^^^ expected an `Fn<_>` closure, found `fn() -> str` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^ expected an `Fn<_>` closure, found `fn() -> str` | = help: the trait `Fn<_>` is not implemented for `fn() -> str` note: required by a bound in `foo` diff --git a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr index 7d3535e1f01..a861156711d 100644 --- a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr +++ b/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr @@ -5,10 +5,10 @@ LL | impls::<W<_>>(); | ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` error[E0275]: overflow evaluating the requirement `W<_>: Trait` - --> $DIR/fixpoint-exponential-growth.rs:29:5 + --> $DIR/fixpoint-exponential-growth.rs:29:13 | LL | impls::<W<_>>(); - | ^^^^^^^^^^^^^ + | ^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`fixpoint_exponential_growth`) note: required by a bound in `impls` diff --git a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr index 4b8846da535..a3404da51f0 100644 --- a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr +++ b/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `(): Trait` - --> $DIR/double-cycle-inductive-coinductive.rs:32:5 + --> $DIR/double-cycle-inductive-coinductive.rs:32:19 | LL | impls_trait::<()>(); - | ^^^^^^^^^^^^^^^^^ + | ^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`) note: required by a bound in `impls_trait` @@ -12,10 +12,10 @@ LL | fn impls_trait<T: Trait>() {} | ^^^^^ required by this bound in `impls_trait` error[E0275]: overflow evaluating the requirement `(): TraitRev` - --> $DIR/double-cycle-inductive-coinductive.rs:35:5 + --> $DIR/double-cycle-inductive-coinductive.rs:35:23 | LL | impls_trait_rev::<()>(); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`) note: required by a bound in `impls_trait_rev` diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr index 0e1c86c1bb3..34115334063 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr +++ b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `(): AR` - --> $DIR/inductive-not-on-stack.rs:44:5 + --> $DIR/inductive-not-on-stack.rs:44:16 | LL | impls_ar::<()>(); - | ^^^^^^^^^^^^^^ + | ^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`) note: required by a bound in `impls_ar` diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr index ec1c3231abc..a31bfd9589b 100644 --- a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr +++ b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr @@ -1,8 +1,8 @@ error[E0283]: type annotations needed: cannot satisfy `Foo: Send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5 + --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:18 | LL | needs_send::<Foo>(); - | ^^^^^^^^^^^^^^^^^ + | ^^^ | = note: cannot satisfy `Foo: Send` note: required by a bound in `needs_send` diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs new file mode 100644 index 00000000000..b0b9b6bbd20 --- /dev/null +++ b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs @@ -0,0 +1,73 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// A minimization of an ambiguity when using typenum. See +// https://github.com/rust-lang/trait-system-refactor-initiative/issues/55 +// for more details. +trait Id { + type Assoc: ?Sized; +} +impl<T: ?Sized> Id for T { + type Assoc = T; +} + +trait WithAssoc<T: ?Sized> { + type Assoc: ?Sized; +} + + +struct Leaf; +struct Wrapper<U: ?Sized>(U); + +impl<U: ?Sized> WithAssoc<U> for Leaf { + type Assoc = U; +} + +impl<Ul: ?Sized, Ur: ?Sized> WithAssoc<Wrapper<Ur>> for Wrapper<Ul> +where + Ul: WithAssoc<Ur>, +{ + type Assoc = <<Ul as WithAssoc<Ur>>::Assoc as Id>::Assoc; +} + +fn bound<T: ?Sized, U: ?Sized, V: ?Sized>() +where + T: WithAssoc<U, Assoc = V>, +{ +} + +// normalize self type to `Wrapper<Leaf>` +// This succeeds, HOWEVER, instantiating the query response previously +// incremented the universe index counter. +// equate impl headers: +// <Wrapper<Leaf> as WithAssoc<<Wrapper<Leaf> as Id>::Assoc>> +// <Wrapper<?2t> as WithAssoc<Wrapper<?3t>>> +// ~> AliasRelate(<Wrapper<Leaf> as Id>::Assoc, Equate, Wrapper<?3t>) +// add where bounds: +// ~> Leaf: WithAssoc<?3t> +// equate with assoc type: +// ?0t +// <Leaf as WithAssoc<?3t>>::Assoc as Id>::Assoc +// ~> AliasRelate( +// <<Leaf as WithAssoc<?3t>>::Assoc as Id>::Assoc, +// Equate, +// <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc, +// ) +// +// We do not reuse `?3t` during generalization because `?0t` cannot name `?4t` as we created +// it after incrementing the universe index while normalizing the self type. +// +// evaluate_added_goals_and_make_query_response: +// AliasRelate(<Wrapper<Leaf> as Id>::Assoc, Equate, Wrapper<?3t>) +// YES, constrains ?3t to Leaf +// AliasRelate( +// <<Leaf as WithAssoc<Leaf>>::Assoc as Id>::Assoc, +// Equate, +// <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc, +// ) +// +// Normalizing <<Leaf as WithAssoc<?4t>>::Assoc as Id>::Assoc then *correctly* +// results in ambiguity. +fn main() { + bound::<<Wrapper<Leaf> as Id>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>() +} diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs new file mode 100644 index 00000000000..94d645a9859 --- /dev/null +++ b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs @@ -0,0 +1,75 @@ +// compile-flags: -Ztrait-solver=next +// known-bug: trait-system-refactor-initiative#60 + +// Generalizing a projection containing an inference variable +// which cannot be named by the `root_vid` can result in ambiguity. +// +// Because we do not decrement the universe index when exiting a forall, +// this can cause unexpected failures. +// +// See generalize-proj-new-universe-index-1.rs for more details. + +// For this reproduction we need: +// - an inference variable with a lower universe +// - enter a binder to increment the current universe +// - create a new inference variable which is constrained by proving a goal +// - equate a projection containing the new variable with the first variable +// - generalization creates yet another inference variable which is then +// part of an alias-relate, resulting this to fail with ambiguity. +// +// Because we need to enter the binder in-between the creation of the first +// and second inference variable, this is easiest via +// `assemble_candidates_after_normalizing_self_ty` because eagerly call +// `try_evaluate_added_goals` there before creating the inference variables +// for the impl parameters. +trait Id { + type Assoc: ?Sized; +} +impl<T: ?Sized> Id for T { + type Assoc = T; +} + +// By adding an higher ranked bound to the impl we currently +// propagate this bound to the caller, forcing us to create a new +// universe. +trait IdHigherRankedBound { + type Assoc: ?Sized; +} + +impl<T: ?Sized> IdHigherRankedBound for T +where + for<'a> T: 'a, +{ + type Assoc = T; +} + +trait WithAssoc<T: ?Sized> { + type Assoc: ?Sized; +} + + +struct Leaf; +struct Wrapper<U: ?Sized>(U); +struct Rigid; + +impl<U: ?Sized> WithAssoc<U> for Leaf { + type Assoc = U; +} + + +impl<Ur: ?Sized> WithAssoc<Wrapper<Ur>> for Rigid +where + Leaf: WithAssoc<Ur>, +{ + type Assoc = <<Leaf as WithAssoc<Ur>>::Assoc as Id>::Assoc; +} + +fn bound<T: ?Sized, U: ?Sized, V: ?Sized>() +where + T: WithAssoc<U, Assoc = V>, +{ +} + +fn main() { + bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>() +} diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr new file mode 100644 index 00000000000..9a8060133b8 --- /dev/null +++ b/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/generalize-proj-new-universe-index-2.rs:74:5 + | +LL | bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `V` declared on the function `bound` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr b/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr index 28a99cbbca6..beed40f3649 100644 --- a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr +++ b/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr @@ -5,10 +5,10 @@ LL | impls::<W<_>>(); | ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls` error[E0275]: overflow evaluating the requirement `W<_>: Trait` - --> $DIR/exponential-trait-goals.rs:17:5 + --> $DIR/exponential-trait-goals.rs:17:13 | LL | impls::<W<_>>(); - | ^^^^^^^^^^^^^ + | ^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`exponential_trait_goals`) note: required by a bound in `impls` diff --git a/tests/ui/traits/new-solver/overflow/global-cache.stderr b/tests/ui/traits/new-solver/overflow/global-cache.stderr index f3b86a083ad..ebb03d84b87 100644 --- a/tests/ui/traits/new-solver/overflow/global-cache.stderr +++ b/tests/ui/traits/new-solver/overflow/global-cache.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `Inc<Inc<Inc<Inc<Inc<Inc<Inc<...>>>>>>>: Trait` - --> $DIR/global-cache.rs:21:5 + --> $DIR/global-cache.rs:21:19 | LL | impls_trait::<Four<Four<Four<Four<()>>>>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "18"]` attribute to your crate (`global_cache`) note: required by a bound in `impls_trait` diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr index eebaf21d7df..1dc63fae98c 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr +++ b/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar` - --> $DIR/recursive-self-normalization-2.rs:16:5 + --> $DIR/recursive-self-normalization-2.rs:16:17 | LL | needs_bar::<T::Assoc1>(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) note: required by a bound in `needs_bar` diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr index 6a87fe2f121..afc5bfa54ac 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr +++ b/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar` - --> $DIR/recursive-self-normalization.rs:12:5 + --> $DIR/recursive-self-normalization.rs:12:17 | LL | needs_bar::<T::Assoc>(); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) note: required by a bound in `needs_bar` diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr index 83a0452b088..b311ac6b5a6 100644 --- a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr +++ b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr @@ -1,8 +1,8 @@ error[E0283]: type annotations needed: cannot satisfy `T: Bar` - --> $DIR/two-projection-param-candidates-are-ambiguous.rs:26:5 + --> $DIR/two-projection-param-candidates-are-ambiguous.rs:26:17 | LL | needs_bar::<T>(); - | ^^^^^^^^^^^^^^ + | ^ | = note: cannot satisfy `T: Bar` = help: the trait `Bar` is implemented for `T` diff --git a/tests/ui/traits/reservation-impl/no-use.next.stderr b/tests/ui/traits/reservation-impl/no-use.next.stderr index 542e3a28adf..632f0f81624 100644 --- a/tests/ui/traits/reservation-impl/no-use.next.stderr +++ b/tests/ui/traits/reservation-impl/no-use.next.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied - --> $DIR/no-use.rs:11:26 + --> $DIR/no-use.rs:11:6 | LL | <() as MyTrait>::foo(&()); - | -------------------- ^^^ the trait `MyTrait` is not implemented for `()` - | | - | required by a bound introduced by this call + | ^^ the trait `MyTrait` is not implemented for `()` | = help: the trait `MyTrait` is implemented for `()` diff --git a/tests/ui/traits/reservation-impl/no-use.old.stderr b/tests/ui/traits/reservation-impl/no-use.old.stderr index 542e3a28adf..632f0f81624 100644 --- a/tests/ui/traits/reservation-impl/no-use.old.stderr +++ b/tests/ui/traits/reservation-impl/no-use.old.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied - --> $DIR/no-use.rs:11:26 + --> $DIR/no-use.rs:11:6 | LL | <() as MyTrait>::foo(&()); - | -------------------- ^^^ the trait `MyTrait` is not implemented for `()` - | | - | required by a bound introduced by this call + | ^^ the trait `MyTrait` is not implemented for `()` | = help: the trait `MyTrait` is implemented for `()` diff --git a/tests/ui/traits/suggest-where-clause.stderr b/tests/ui/traits/suggest-where-clause.stderr index f3a4c689033..e3bbf768c6e 100644 --- a/tests/ui/traits/suggest-where-clause.stderr +++ b/tests/ui/traits/suggest-where-clause.stderr @@ -38,10 +38,10 @@ LL + fn check<T: Iterator, U>() { | error[E0277]: the trait bound `u64: From<T>` is not satisfied - --> $DIR/suggest-where-clause.rs:15:5 + --> $DIR/suggest-where-clause.rs:15:6 | LL | <u64 as From<T>>::from; - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `u64` + | ^^^ the trait `From<T>` is not implemented for `u64` | help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | @@ -49,10 +49,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<T> { | ++++++++++++++++++ error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfied - --> $DIR/suggest-where-clause.rs:18:5 + --> $DIR/suggest-where-clause.rs:18:6 | LL | <u64 as From<<T as Iterator>::Item>>::from; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64` + | ^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64` | help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | @@ -60,10 +60,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<<T as Iterator>::Item> { | ++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `Misc<_>: From<T>` is not satisfied - --> $DIR/suggest-where-clause.rs:23:5 + --> $DIR/suggest-where-clause.rs:23:6 | LL | <Misc<_> as From<T>>::from; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>` + | ^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>` error[E0277]: the size for values of type `[T]` cannot be known at compilation time --> $DIR/suggest-where-clause.rs:28:20 diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr index d48d9b89d1d..b612005fcb0 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr @@ -2,22 +2,8 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` --> $DIR/type-checking-test-1.rs:19:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous - | ^^^^^^^^^^^^^^^^ invalid cast - | -help: consider borrowing the value - | -LL | let _ = &x as &dyn Bar<_>; // Ambiguous - | + - -error[E0277]: the trait bound `&dyn Foo: Bar<_>` is not satisfied - --> $DIR/type-checking-test-1.rs:19:13 - | -LL | let _ = x as &dyn Bar<_>; // Ambiguous - | ^ the trait `Bar<_>` is not implemented for `&dyn Foo` - | - = note: required for the cast from `&&dyn Foo` to `&dyn Bar<_>` + | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0605. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs index 7c7beec0809..afea8521e87 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs @@ -18,7 +18,6 @@ fn test_specific(x: &dyn Foo) { fn test_unknown_version(x: &dyn Foo) { let _ = x as &dyn Bar<_>; // Ambiguous //~^ ERROR non-primitive cast - //[current]~^^ ERROR the trait bound `&dyn Foo: Bar<_>` is not satisfied } fn test_infer_version(x: &dyn Foo) { diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-2.rs b/tests/ui/traits/trait-upcasting/type-checking-test-2.rs index 36b11dffdb1..b024b27750b 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-2.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-2.rs @@ -18,13 +18,11 @@ fn test_specific2(x: &dyn Foo<u32>) { fn test_specific3(x: &dyn Foo<i32>) { let _ = x as &dyn Bar<u32>; // Error //~^ ERROR non-primitive cast - //~^^ ERROR the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied } fn test_infer_arg(x: &dyn Foo<u32>) { let a = x as &dyn Bar<_>; // Ambiguous //~^ ERROR non-primitive cast - //~^^ ERROR the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied let _ = a.bar(); } diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr index 856303ef4dd..3e59b9d3363 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr @@ -2,41 +2,14 @@ error[E0605]: non-primitive cast: `&dyn Foo<i32>` as `&dyn Bar<u32>` --> $DIR/type-checking-test-2.rs:19:13 | LL | let _ = x as &dyn Bar<u32>; // Error - | ^^^^^^^^^^^^^^^^^^ invalid cast - | -help: consider borrowing the value - | -LL | let _ = &x as &dyn Bar<u32>; // Error - | + - -error[E0277]: the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied - --> $DIR/type-checking-test-2.rs:19:13 - | -LL | let _ = x as &dyn Bar<u32>; // Error - | ^ the trait `Bar<u32>` is not implemented for `&dyn Foo<i32>` - | - = note: required for the cast from `&&dyn Foo<i32>` to `&dyn Bar<u32>` + | ^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `&dyn Foo<u32>` as `&dyn Bar<_>` - --> $DIR/type-checking-test-2.rs:25:13 + --> $DIR/type-checking-test-2.rs:24:13 | LL | let a = x as &dyn Bar<_>; // Ambiguous - | ^^^^^^^^^^^^^^^^ invalid cast - | -help: consider borrowing the value - | -LL | let a = &x as &dyn Bar<_>; // Ambiguous - | + - -error[E0277]: the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied - --> $DIR/type-checking-test-2.rs:25:13 - | -LL | let a = x as &dyn Bar<_>; // Ambiguous - | ^ the trait `Bar<_>` is not implemented for `&dyn Foo<u32>` - | - = note: required for the cast from `&&dyn Foo<u32>` to `&dyn Bar<_>` + | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0605. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs new file mode 100644 index 00000000000..54a22510066 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs @@ -0,0 +1,21 @@ +// crate foo + +#![feature(type_alias_impl_trait)] + +type Tait = impl Sized; +fn _constrain() -> Tait {} + +struct WrapperWithDrop<T>(T); +impl<T> Drop for WrapperWithDrop<T> { + fn drop(&mut self) {} +} + +pub struct Foo(WrapperWithDrop<Tait>); + +trait Id { + type Id: ?Sized; +} +impl<T: ?Sized> Id for T { + type Id = T; +} +pub struct Bar(WrapperWithDrop<<Tait as Id>::Id>); diff --git a/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs b/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs new file mode 100644 index 00000000000..51d28704972 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs @@ -0,0 +1,10 @@ +// aux-build:drop-shim-relates-opaque-aux.rs +// compile-flags: -Zvalidate-mir --crate-type=lib +// build-pass + +extern crate drop_shim_relates_opaque_aux; + +pub fn drop_foo(_: drop_shim_relates_opaque_aux::Foo) {} +pub fn drop_bar(_: drop_shim_relates_opaque_aux::Bar) {} + +fn main() {} diff --git a/tests/ui/issues/auxiliary/issue-29181.rs b/tests/ui/typeck/auxiliary/issue-29181.rs index bd1a9be4ef1..bd1a9be4ef1 100644 --- a/tests/ui/issues/auxiliary/issue-29181.rs +++ b/tests/ui/typeck/auxiliary/issue-29181.rs diff --git a/tests/ui/issues/issue-29181.rs b/tests/ui/typeck/issue-29181.rs index 70e5bc01920..70e5bc01920 100644 --- a/tests/ui/issues/issue-29181.rs +++ b/tests/ui/typeck/issue-29181.rs diff --git a/tests/ui/issues/issue-29181.stderr b/tests/ui/typeck/issue-29181.stderr index 53addf2fe4d..53addf2fe4d 100644 --- a/tests/ui/issues/issue-29181.stderr +++ b/tests/ui/typeck/issue-29181.stderr diff --git a/tests/ui/typeck/issue-90804-incorrect-reference-suggestion.stderr b/tests/ui/typeck/issue-90804-incorrect-reference-suggestion.stderr index 08eab025370..a75024aa248 100644 --- a/tests/ui/typeck/issue-90804-incorrect-reference-suggestion.stderr +++ b/tests/ui/typeck/issue-90804-incorrect-reference-suggestion.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `(): Marker<u32>` is not satisfied - --> $DIR/issue-90804-incorrect-reference-suggestion.rs:10:17 + --> $DIR/issue-90804-incorrect-reference-suggestion.rs:10:13 | LL | check::<()>(()); - | ----------- ^^ the trait `Marker<u32>` is not implemented for `()` - | | - | required by a bound introduced by this call + | ^^ the trait `Marker<u32>` is not implemented for `()` | note: required by a bound in `check` --> $DIR/issue-90804-incorrect-reference-suggestion.rs:7:17 diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 85adf775139..ae0a06e6328 100644 --- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -1,10 +1,8 @@ error[E0277]: cannot add `u32` to `i32` - --> $DIR/ufcs-qpath-self-mismatch.rs:4:31 + --> $DIR/ufcs-qpath-self-mismatch.rs:4:6 | LL | <i32 as Add<u32>>::add(1, 2); - | ---------------------- ^ no implementation for `i32 + u32` - | | - | required by a bound introduced by this call + | ^^^ no implementation for `i32 + u32` | = help: the trait `Add<u32>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: diff --git a/tests/ui/unevaluated_fixed_size_array_len.stderr b/tests/ui/unevaluated_fixed_size_array_len.stderr index 5e67b2c44f2..b04a7b7f2f1 100644 --- a/tests/ui/unevaluated_fixed_size_array_len.stderr +++ b/tests/ui/unevaluated_fixed_size_array_len.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `[(); 0]: Foo` is not satisfied - --> $DIR/unevaluated_fixed_size_array_len.rs:12:5 + --> $DIR/unevaluated_fixed_size_array_len.rs:12:6 | LL | <[(); 0] as Foo>::foo() - | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[(); 0]` + | ^^^^^^^ the trait `Foo` is not implemented for `[(); 0]` | = help: the trait `Foo` is implemented for `[(); 1]` diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs new file mode 100644 index 00000000000..192bbba5a5b --- /dev/null +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs @@ -0,0 +1,37 @@ +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + +struct F { + field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields + //~^ ERROR anonymous structs are unimplemented + _: struct { field: u8 }, + //~^ ERROR anonymous structs are unimplemented +} + +struct G { + _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types +} + +union H { + field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields + //~^ ERROR anonymous structs are unimplemented + _: struct { field: u8 }, + //~^ ERROR anonymous structs are unimplemented +} + +union I { + _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types +} + +enum K { + M { + _ : struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields + //~^ ERROR unnamed fields are not allowed outside of structs or unions + //~| ERROR anonymous structs are unimplemented + }, + N { + _ : u8, //~ ERROR unnamed fields are not allowed outside of structs or unions + } +} + +fn main() {} diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr new file mode 100644 index 00000000000..fd731766c01 --- /dev/null +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr @@ -0,0 +1,78 @@ +error: anonymous structs are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_structs.rs:5:12 + | +LL | field: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here + +error: unnamed fields can only have struct or union types + --> $DIR/restrict_anonymous_structs.rs:12:5 + | +LL | _: (u8, u8), + | ^ -------- not a struct or union + +error: anonymous structs are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_structs.rs:16:12 + | +LL | field: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here + +error: unnamed fields can only have struct or union types + --> $DIR/restrict_anonymous_structs.rs:23:5 + | +LL | _: (u8, u8), + | ^ -------- not a struct or union + +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/restrict_anonymous_structs.rs:28:9 + | +LL | _ : struct { field: u8 }, + | -^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unnamed field declared here + +error: anonymous structs are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_structs.rs:28:13 + | +LL | _ : struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here + +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/restrict_anonymous_structs.rs:33:9 + | +LL | _ : u8, + | -^^^^^ + | | + | unnamed field declared here + +error: anonymous structs are unimplemented + --> $DIR/restrict_anonymous_structs.rs:5:12 + | +LL | field: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ + +error: anonymous structs are unimplemented + --> $DIR/restrict_anonymous_structs.rs:7:8 + | +LL | _: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ + +error: anonymous structs are unimplemented + --> $DIR/restrict_anonymous_structs.rs:16:12 + | +LL | field: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ + +error: anonymous structs are unimplemented + --> $DIR/restrict_anonymous_structs.rs:18:8 + | +LL | _: struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ + +error: anonymous structs are unimplemented + --> $DIR/restrict_anonymous_structs.rs:28:13 + | +LL | _ : struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs new file mode 100644 index 00000000000..c69266089bb --- /dev/null +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs @@ -0,0 +1,37 @@ +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + +struct F { + field: union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields + //~^ ERROR anonymous unions are unimplemented + _: union { field: u8 }, + //~^ ERROR anonymous unions are unimplemented +} + +struct G { + _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types +} + +union H { + field: union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields + //~^ ERROR anonymous unions are unimplemented + _: union { field: u8 }, + //~^ ERROR anonymous unions are unimplemented +} + +union I { + _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types +} + +enum K { + M { + _ : union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields + //~^ ERROR unnamed fields are not allowed outside of structs or unions + //~| ERROR anonymous unions are unimplemented + }, + N { + _ : u8, //~ ERROR unnamed fields are not allowed outside of structs or unions + } +} + +fn main() {} diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr new file mode 100644 index 00000000000..c65cad775a9 --- /dev/null +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr @@ -0,0 +1,78 @@ +error: anonymous unions are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_unions.rs:5:12 + | +LL | field: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here + +error: unnamed fields can only have struct or union types + --> $DIR/restrict_anonymous_unions.rs:12:5 + | +LL | _: (u8, u8), + | ^ -------- not a struct or union + +error: anonymous unions are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_unions.rs:16:12 + | +LL | field: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here + +error: unnamed fields can only have struct or union types + --> $DIR/restrict_anonymous_unions.rs:23:5 + | +LL | _: (u8, u8), + | ^ -------- not a struct or union + +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/restrict_anonymous_unions.rs:28:9 + | +LL | _ : union { field: u8 }, + | -^^^^^^^^^^^^^^^^^^^^^^ + | | + | unnamed field declared here + +error: anonymous unions are not allowed outside of unnamed struct or union fields + --> $DIR/restrict_anonymous_unions.rs:28:13 + | +LL | _ : union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here + +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/restrict_anonymous_unions.rs:33:9 + | +LL | _ : u8, + | -^^^^^ + | | + | unnamed field declared here + +error: anonymous unions are unimplemented + --> $DIR/restrict_anonymous_unions.rs:5:12 + | +LL | field: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ + +error: anonymous unions are unimplemented + --> $DIR/restrict_anonymous_unions.rs:7:8 + | +LL | _: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ + +error: anonymous unions are unimplemented + --> $DIR/restrict_anonymous_unions.rs:16:12 + | +LL | field: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ + +error: anonymous unions are unimplemented + --> $DIR/restrict_anonymous_unions.rs:18:8 + | +LL | _: union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ + +error: anonymous unions are unimplemented + --> $DIR/restrict_anonymous_unions.rs:28:13 + | +LL | _ : union { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + diff --git a/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr b/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr index aa73b824a57..32f8d2f45dc 100644 --- a/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr +++ b/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr @@ -1,18 +1,18 @@ error: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable = note: requested on the command line with `-D unknown-lints` error: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable error: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable error: aborting due to 3 previous errors diff --git a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr index 82851c80064..dd9ecf02fa6 100644 --- a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr +++ b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr @@ -1,18 +1,18 @@ warning: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable = note: requested on the command line with `-W unknown-lints` warning: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable warning: unknown lint: `test_unstable_lint` | = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable warning: 3 warnings emitted diff --git a/tests/ui/unsized/unsized3.stderr b/tests/ui/unsized/unsized3.stderr index 3ef9a875358..a11243980d1 100644 --- a/tests/ui/unsized/unsized3.stderr +++ b/tests/ui/unsized/unsized3.stderr @@ -1,12 +1,10 @@ error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:7:13 + --> $DIR/unsized3.rs:7:10 | LL | fn f1<X: ?Sized>(x: &X) { | - this type parameter needs to be `Sized` LL | f2::<X>(x); - | ------- ^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^ doesn't have a size known at compile-time | note: required by a bound in `f2` --> $DIR/unsized3.rs:10:7 @@ -24,14 +22,12 @@ LL | fn f2<X: ?Sized>(x: &X) { | ++++++++ error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:18:13 + --> $DIR/unsized3.rs:18:10 | LL | fn f3<X: ?Sized + T>(x: &X) { | - this type parameter needs to be `Sized` LL | f4::<X>(x); - | ------- ^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^ doesn't have a size known at compile-time | note: required by a bound in `f4` --> $DIR/unsized3.rs:21:7 |
