diff options
Diffstat (limited to 'tests')
87 files changed, 1315 insertions, 210 deletions
diff --git a/tests/codegen-llvm/become-musttail.rs b/tests/codegen-llvm/become-musttail.rs new file mode 100644 index 00000000000..07f33571910 --- /dev/null +++ b/tests/codegen-llvm/become-musttail.rs @@ -0,0 +1,18 @@ +//@ compile-flags: -C opt-level=0 -Cpanic=abort -C no-prepopulate-passes +//@ needs-unwind + +#![crate_type = "lib"] +#![feature(explicit_tail_calls)] + +// CHECK-LABEL: define {{.*}}@fibonacci( +#[no_mangle] +#[inline(never)] +pub fn fibonacci(n: u64, a: u64, b: u64) -> u64 { + // CHECK: musttail call {{.*}}@fibonacci( + // CHECK-NEXT: ret i64 + match n { + 0 => a, + 1 => b, + _ => become fibonacci(n - 1, b, a + b), + } +} diff --git a/tests/coverage/async_closure.cov-map b/tests/coverage/async_closure.cov-map index 9f8dc8d6cbb..53128dd7a48 100644 --- a/tests/coverage/async_closure.cov-map +++ b/tests/coverage/async_closure.cov-map @@ -37,32 +37,29 @@ Number of file 0 mappings: 8 Highest counter ID seen: c0 Function name: async_closure::main::{closure#0} -Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) -- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) Highest counter ID seen: c0 Function name: async_closure::main::{closure#0} -Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) -- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) Highest counter ID seen: c0 Function name: async_closure::main::{closure#0}::{closure#0}::<i16> -Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) -- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) Highest counter ID seen: c0 diff --git a/tests/coverage/try-in-macro.attr.cov-map b/tests/coverage/try-in-macro.attr.cov-map index 7111e89637c..1b6c97cf145 100644 --- a/tests/coverage/try-in-macro.attr.cov-map +++ b/tests/coverage/try-in-macro.attr.cov-map @@ -1,12 +1,3 @@ -Function name: <try_in_macro::MyEnum as try_in_macro::Arbitrary>::try_size_hint -Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 2a, 00, 2b] -Number of files: 1 -- file 0 => $DIR/try-in-macro.rs -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 30, 42) to (start + 0, 43) -Highest counter ID seen: (none) - Function name: try_in_macro::main Raw bytes (19): 0x[01, 01, 00, 03, 01, 29, 01, 00, 0a, 01, 01, 05, 00, 1a, 01, 01, 01, 00, 02] Number of files: 1 diff --git a/tests/coverage/try-in-macro.bang.cov-map b/tests/coverage/try-in-macro.bang.cov-map index 80bd91a993c..1b6c97cf145 100644 --- a/tests/coverage/try-in-macro.bang.cov-map +++ b/tests/coverage/try-in-macro.bang.cov-map @@ -1,12 +1,3 @@ -Function name: <try_in_macro::MyEnum as try_in_macro::Arbitrary>::try_size_hint -Raw bytes (9): 0x[01, 01, 00, 01, 00, 23, 1c, 00, 1d] -Number of files: 1 -- file 0 => $DIR/try-in-macro.rs -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 35, 28) to (start + 0, 29) -Highest counter ID seen: (none) - Function name: try_in_macro::main Raw bytes (19): 0x[01, 01, 00, 03, 01, 29, 01, 00, 0a, 01, 01, 05, 00, 1a, 01, 01, 01, 00, 02] Number of files: 1 diff --git a/tests/coverage/try-in-macro.derive.cov-map b/tests/coverage/try-in-macro.derive.cov-map index 6646b6693ba..1b6c97cf145 100644 --- a/tests/coverage/try-in-macro.derive.cov-map +++ b/tests/coverage/try-in-macro.derive.cov-map @@ -1,12 +1,3 @@ -Function name: <try_in_macro::MyEnum as try_in_macro::Arbitrary>::try_size_hint -Raw bytes (9): 0x[01, 01, 00, 01, 00, 26, 38, 00, 39] -Number of files: 1 -- file 0 => $DIR/try-in-macro.rs -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 38, 56) to (start + 0, 57) -Highest counter ID seen: (none) - Function name: try_in_macro::main Raw bytes (19): 0x[01, 01, 00, 03, 01, 29, 01, 00, 0a, 01, 01, 05, 00, 1a, 01, 01, 01, 00, 02] Number of files: 1 diff --git a/tests/crashes/139409.rs b/tests/crashes/139409.rs deleted file mode 100644 index 68cbfa153de..00000000000 --- a/tests/crashes/139409.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: #139409 -//@ compile-flags: -Znext-solver=globally - -fn main() { - trait B<C> {} - impl<C> B<C> for () {} - trait D<C, E>: B<C> + B<E> { - fn f(&self) {} - } - impl<C, E> D<C, E> for () {} - (&() as &dyn D<&(), &()>).f() -} diff --git a/tests/mir-opt/box_conditional_drop_allocator.main.ElaborateDrops.diff b/tests/mir-opt/box_conditional_drop_allocator.main.ElaborateDrops.diff new file mode 100644 index 00000000000..6f6c239d7c8 --- /dev/null +++ b/tests/mir-opt/box_conditional_drop_allocator.main.ElaborateDrops.diff @@ -0,0 +1,186 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); + let _1: std::boxed::Box<HasDrop, DropAllocator>; + let mut _2: HasDrop; + let mut _3: DropAllocator; + let mut _4: bool; + let _5: (); + let mut _6: HasDrop; + let _7: (); + let mut _8: std::boxed::Box<HasDrop, DropAllocator>; ++ let mut _9: bool; ++ let mut _10: &mut std::boxed::Box<HasDrop, DropAllocator>; ++ let mut _11: (); ++ let mut _12: &mut std::boxed::Box<HasDrop, DropAllocator>; ++ let mut _13: (); ++ let mut _14: *const HasDrop; ++ let mut _15: &mut std::boxed::Box<HasDrop, DropAllocator>; ++ let mut _16: (); ++ let mut _17: *const HasDrop; + scope 1 { + debug b => _1; + } + + bb0: { ++ _9 = const false; + StorageLive(_1); + StorageLive(_2); + _2 = HasDrop; + StorageLive(_3); + _3 = DropAllocator; + _1 = Box::<HasDrop, DropAllocator>::new_in(move _2, move _3) -> [return: bb1, unwind: bb11]; + } + + bb1: { ++ _9 = const true; + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + _4 = const true; + switchInt(move _4) -> [0: bb4, otherwise: bb2]; + } + + bb2: { + StorageLive(_5); + StorageLive(_6); + _6 = move (*_1); + _5 = std::mem::drop::<HasDrop>(move _6) -> [return: bb3, unwind: bb9]; + } + + bb3: { + StorageDead(_6); + StorageDead(_5); + _0 = const (); + goto -> bb6; + } + + bb4: { + StorageLive(_7); + StorageLive(_8); ++ _9 = const false; + _8 = move _1; + _7 = std::mem::drop::<Box<HasDrop, DropAllocator>>(move _8) -> [return: bb5, unwind: bb8]; + } + + bb5: { + StorageDead(_8); + StorageDead(_7); + _0 = const (); + goto -> bb6; + } + + bb6: { + StorageDead(_4); +- drop(_1) -> [return: bb7, unwind continue]; ++ goto -> bb23; + } + + bb7: { ++ _9 = const false; + StorageDead(_1); + return; + } + + bb8 (cleanup): { +- drop(_8) -> [return: bb10, unwind terminate(cleanup)]; ++ goto -> bb10; + } + + bb9 (cleanup): { +- drop(_6) -> [return: bb10, unwind terminate(cleanup)]; ++ goto -> bb10; + } + + bb10 (cleanup): { +- drop(_1) -> [return: bb13, unwind terminate(cleanup)]; ++ goto -> bb29; + } + + bb11 (cleanup): { +- drop(_3) -> [return: bb12, unwind terminate(cleanup)]; ++ goto -> bb12; + } + + bb12 (cleanup): { +- drop(_2) -> [return: bb13, unwind terminate(cleanup)]; ++ goto -> bb13; + } + + bb13 (cleanup): { + resume; ++ } ++ ++ bb14: { ++ _9 = const false; ++ goto -> bb7; ++ } ++ ++ bb15 (cleanup): { ++ drop((_1.1: DropAllocator)) -> [return: bb13, unwind terminate(cleanup)]; ++ } ++ ++ bb16 (cleanup): { ++ switchInt(copy _9) -> [0: bb13, otherwise: bb15]; ++ } ++ ++ bb17: { ++ drop((_1.1: DropAllocator)) -> [return: bb14, unwind: bb13]; ++ } ++ ++ bb18: { ++ switchInt(copy _9) -> [0: bb14, otherwise: bb17]; ++ } ++ ++ bb19: { ++ _10 = &mut _1; ++ _11 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _10) -> [return: bb18, unwind: bb16]; ++ } ++ ++ bb20 (cleanup): { ++ _12 = &mut _1; ++ _13 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _12) -> [return: bb16, unwind terminate(cleanup)]; ++ } ++ ++ bb21: { ++ goto -> bb19; ++ } ++ ++ bb22: { ++ _14 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute); ++ goto -> bb21; ++ } ++ ++ bb23: { ++ switchInt(copy _9) -> [0: bb18, otherwise: bb22]; ++ } ++ ++ bb24 (cleanup): { ++ drop((_1.1: DropAllocator)) -> [return: bb13, unwind terminate(cleanup)]; ++ } ++ ++ bb25 (cleanup): { ++ switchInt(copy _9) -> [0: bb13, otherwise: bb24]; ++ } ++ ++ bb26 (cleanup): { ++ _15 = &mut _1; ++ _16 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _15) -> [return: bb25, unwind terminate(cleanup)]; ++ } ++ ++ bb27 (cleanup): { ++ goto -> bb26; ++ } ++ ++ bb28 (cleanup): { ++ _17 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute); ++ goto -> bb27; ++ } ++ ++ bb29 (cleanup): { ++ switchInt(copy _9) -> [0: bb25, otherwise: bb28]; + } + } + diff --git a/tests/mir-opt/box_conditional_drop_allocator.rs b/tests/mir-opt/box_conditional_drop_allocator.rs new file mode 100644 index 00000000000..9471be14c87 --- /dev/null +++ b/tests/mir-opt/box_conditional_drop_allocator.rs @@ -0,0 +1,39 @@ +// skip-filecheck +//@ test-mir-pass: ElaborateDrops +//@ needs-unwind +#![feature(allocator_api)] + +// Regression test for #131082. +// Testing that the allocator of a Box is dropped in conditional drops + +use std::alloc::{AllocError, Allocator, Global, Layout}; +use std::ptr::NonNull; + +struct DropAllocator; + +unsafe impl Allocator for DropAllocator { + fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { + Global.allocate(layout) + } + unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { + Global.deallocate(ptr, layout); + } +} +impl Drop for DropAllocator { + fn drop(&mut self) {} +} + +struct HasDrop; +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +// EMIT_MIR box_conditional_drop_allocator.main.ElaborateDrops.diff +fn main() { + let b = Box::new_in(HasDrop, DropAllocator); + if true { + drop(*b); + } else { + drop(b); + } +} diff --git a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff index d465b8bded2..fa88211383a 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -40,7 +40,7 @@ + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:17: 19:18 (#0); + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:23: 19:30 (#0); + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:31: 19:32 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:2: 21:2 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:1: 21:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff index cf6d85abd80..9b6d2b22087 100644 --- a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff @@ -6,7 +6,7 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27:1: 27:17 (#0); + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:28:5: 28:9 (#0); -+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:2: 29:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 29:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff index 980c5e202ff..b2bb2375aee 100644 --- a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff @@ -10,8 +10,8 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:10 (#0); + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:15 (#0); + coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:16:13: 16:18 (#0); -+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:10: 17:10 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:2: 19:2 (#0); ++ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:9: 17:10 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:1: 19:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff index b707cd41788..2eb78c08ee8 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -10,8 +10,8 @@ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); - coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); - coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0); + coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0); coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); bb0: { diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff index 239b845c231..0c1bc24b6dc 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -10,8 +10,8 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); -+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0); + coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + bb0: { diff --git a/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff new file mode 100644 index 00000000000..74403247108 --- /dev/null +++ b/tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff @@ -0,0 +1,32 @@ +- // MIR for `foo` before ScalarReplacementOfAggregates ++ // MIR for `foo` after ScalarReplacementOfAggregates + + fn foo(_1: &[Simd<u8, 16>], _2: Simd<u8, 16>) -> () { + debug simds => _1; + debug _unused => _2; + let mut _0: (); + let _3: std::simd::Simd<u8, 16>; + let _4: usize; + let mut _5: usize; + let mut _6: bool; + scope 1 { + debug a => _3; + } + + bb0: { + StorageLive(_3); + StorageLive(_4); + _4 = const 0_usize; + _5 = PtrMetadata(copy _1); + _6 = Lt(copy _4, copy _5); + assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, copy _4) -> [success: bb1, unwind continue]; + } + + bb1: { + _3 = copy (*_1)[_4]; + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/sroa/simd_sroa.rs b/tests/mir-opt/sroa/simd_sroa.rs new file mode 100644 index 00000000000..1ae84d3f975 --- /dev/null +++ b/tests/mir-opt/sroa/simd_sroa.rs @@ -0,0 +1,18 @@ +//@ needs-unwind +#![feature(portable_simd)] + +// SRoA expands things even if they're unused +// <https://github.com/rust-lang/rust/issues/144621> + +use std::simd::Simd; + +// EMIT_MIR simd_sroa.foo.ScalarReplacementOfAggregates.diff +pub(crate) fn foo(simds: &[Simd<u8, 16>], _unused: Simd<u8, 16>) { + // CHECK-LABEL: fn foo + // CHECK-NOT: [u8; 16] + // CHECK: let [[SIMD:_.+]]: std::simd::Simd<u8, 16>; + // CHECK-NOT: [u8; 16] + // CHECK: [[SIMD]] = copy (*_1)[0 of 1]; + // CHECK-NOT: [u8; 16] + let a = simds[0]; +} diff --git a/tests/run-make/cross-lang-lto-clang/rmake.rs b/tests/run-make/cross-lang-lto-clang/rmake.rs index 3fed6ea2066..f209318abbc 100644 --- a/tests/run-make/cross-lang-lto-clang/rmake.rs +++ b/tests/run-make/cross-lang-lto-clang/rmake.rs @@ -28,7 +28,17 @@ static C_NEVER_INLINED_PATTERN: &'static str = "bl.*<c_never_inlined>"; static C_NEVER_INLINED_PATTERN: &'static str = "call.*c_never_inlined"; fn main() { + test_lto(false); + test_lto(true); +} + +fn test_lto(fat_lto: bool) { + let lto = if fat_lto { "fat" } else { "thin" }; + let clang_lto = if fat_lto { "full" } else { "thin" }; + println!("Running {lto} lto"); + rustc() + .lto(lto) .linker_plugin_lto("on") .output(static_lib_name("rustlib-xlto")) .opt_level("2") @@ -36,30 +46,36 @@ fn main() { .input("rustlib.rs") .run(); clang() - .lto("thin") + .lto(clang_lto) .use_ld("lld") .arg("-lrustlib-xlto") .out_exe("cmain") .input("cmain.c") .arg("-O3") .run(); + + let dump = llvm_objdump().disassemble().input("cmain").run(); // Make sure we don't find a call instruction to the function we expect to // always be inlined. - llvm_objdump() - .disassemble() - .input("cmain") - .run() - .assert_stdout_not_contains_regex(RUST_ALWAYS_INLINED_PATTERN); + dump.assert_stdout_not_contains_regex(RUST_ALWAYS_INLINED_PATTERN); // As a sanity check, make sure we do find a call instruction to a // non-inlined function - llvm_objdump() - .disassemble() - .input("cmain") - .run() - .assert_stdout_contains_regex(RUST_NEVER_INLINED_PATTERN); - clang().input("clib.c").lto("thin").arg("-c").out_exe("clib.o").arg("-O2").run(); + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + dump.assert_stdout_contains_regex(RUST_NEVER_INLINED_PATTERN); + #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] + { + if fat_lto { + // fat lto inlines this anyway + dump.assert_stdout_not_contains_regex(RUST_NEVER_INLINED_PATTERN); + } else { + dump.assert_stdout_contains_regex(RUST_NEVER_INLINED_PATTERN); + } + } + + clang().input("clib.c").lto(clang_lto).arg("-c").out_exe("clib.o").arg("-O2").run(); llvm_ar().obj_to_ar().output_input(static_lib_name("xyz"), "clib.o").run(); rustc() + .lto(lto) .linker_plugin_lto("on") .opt_level("2") .linker(&env_var("CLANG")) @@ -67,14 +83,13 @@ fn main() { .input("main.rs") .output("rsmain") .run(); - llvm_objdump() - .disassemble() - .input("rsmain") - .run() - .assert_stdout_not_contains_regex(C_ALWAYS_INLINED_PATTERN); - llvm_objdump() - .disassemble() - .input("rsmain") - .run() - .assert_stdout_contains_regex(C_NEVER_INLINED_PATTERN); + + let dump = llvm_objdump().disassemble().input("rsmain").run(); + dump.assert_stdout_not_contains_regex(C_ALWAYS_INLINED_PATTERN); + if fat_lto { + // fat lto inlines this anyway + dump.assert_stdout_not_contains_regex(C_NEVER_INLINED_PATTERN); + } else { + dump.assert_stdout_contains_regex(C_NEVER_INLINED_PATTERN); + } } diff --git a/tests/run-make/fat-then-thin-lto/lib.rs b/tests/run-make/fat-then-thin-lto/lib.rs new file mode 100644 index 00000000000..c675dcb6e8a --- /dev/null +++ b/tests/run-make/fat-then-thin-lto/lib.rs @@ -0,0 +1,13 @@ +#![allow(internal_features)] +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "rlib"] + +#[lang = "pointee_sized"] +trait PointeeSized {} +#[lang = "meta_sized"] +trait MetaSized: PointeeSized {} +#[lang = "sized"] +trait Sized: MetaSized {} + +pub fn foo() {} diff --git a/tests/run-make/fat-then-thin-lto/main.rs b/tests/run-make/fat-then-thin-lto/main.rs new file mode 100644 index 00000000000..a3f2e18158b --- /dev/null +++ b/tests/run-make/fat-then-thin-lto/main.rs @@ -0,0 +1,11 @@ +#![allow(internal_features)] +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "cdylib"] + +extern crate lib; + +#[unsafe(no_mangle)] +pub fn bar() { + lib::foo(); +} diff --git a/tests/run-make/fat-then-thin-lto/rmake.rs b/tests/run-make/fat-then-thin-lto/rmake.rs new file mode 100644 index 00000000000..ef4f26689d4 --- /dev/null +++ b/tests/run-make/fat-then-thin-lto/rmake.rs @@ -0,0 +1,25 @@ +// Compile a library with lto=fat, then compile a binary with lto=thin +// and check that lto is applied with the library. +// The goal is to mimic the standard library being build with lto=fat +// and allowing users to build with lto=thin. + +//@ only-x86_64-unknown-linux-gnu + +use run_make_support::{dynamic_lib_name, llvm_objdump, rustc}; + +fn main() { + rustc().input("lib.rs").opt_level("3").lto("fat").run(); + rustc().input("main.rs").panic("abort").opt_level("3").lto("thin").run(); + + llvm_objdump() + .input(dynamic_lib_name("main")) + .arg("--disassemble-symbols=bar") + .run() + // The called function should be inlined. + // Check that we have a ret (to detect tail + // calls with a jmp) and no call. + .assert_stdout_contains("bar") + .assert_stdout_contains("ret") + .assert_stdout_not_contains("foo") + .assert_stdout_not_contains("call"); +} diff --git a/tests/run-make/linker-plugin-lto-fat/ir.ll b/tests/run-make/linker-plugin-lto-fat/ir.ll new file mode 100644 index 00000000000..fa3dbdd4e08 --- /dev/null +++ b/tests/run-make/linker-plugin-lto-fat/ir.ll @@ -0,0 +1,6 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @ir_callee() { + ret void +} diff --git a/tests/run-make/linker-plugin-lto-fat/main.rs b/tests/run-make/linker-plugin-lto-fat/main.rs new file mode 100644 index 00000000000..ad2a90bc801 --- /dev/null +++ b/tests/run-make/linker-plugin-lto-fat/main.rs @@ -0,0 +1,22 @@ +#![allow(internal_features)] +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "cdylib"] + +#[lang = "pointee_sized"] +trait PointeeSized {} +#[lang = "meta_sized"] +trait MetaSized: PointeeSized {} +#[lang = "sized"] +trait Sized: MetaSized {} + +extern "C" { + fn ir_callee(); +} + +#[no_mangle] +extern "C" fn rs_foo() { + unsafe { + ir_callee(); + } +} diff --git a/tests/run-make/linker-plugin-lto-fat/rmake.rs b/tests/run-make/linker-plugin-lto-fat/rmake.rs new file mode 100644 index 00000000000..ff5b647a594 --- /dev/null +++ b/tests/run-make/linker-plugin-lto-fat/rmake.rs @@ -0,0 +1,33 @@ +// Check that -C lto=fat with -C linker-plugin-lto actually works and can inline functions. +// A library is created from LLVM IR, defining a single function. Then a dylib is compiled, +// linking to the library and calling the function from the library. +// The function from the library should end up inlined and disappear from the output. + +//@ only-x86_64-unknown-linux-gnu +//@ needs-rust-lld + +use run_make_support::{dynamic_lib_name, llvm_as, llvm_objdump, rustc}; + +fn main() { + llvm_as().input("ir.ll").run(); + rustc() + .input("main.rs") + .opt_level("3") + .lto("fat") + .linker_plugin_lto("on") + .link_arg("ir.bc") + .arg("-Zunstable-options") + .arg("-Clinker-features=+lld") + .run(); + + llvm_objdump() + .input(dynamic_lib_name("main")) + .arg("--disassemble-symbols=rs_foo") + .run() + // The called function should be inlined. + // Check that we have a ret (to detect tail + // calls with a jmp) and no call. + .assert_stdout_contains("foo") + .assert_stdout_contains("ret") + .assert_stdout_not_contains("call"); +} diff --git a/tests/rustdoc-ui/2024-doctests-checks.rs b/tests/rustdoc-ui/2024-doctests-checks.rs index 0c3a11771f3..61f90fe6231 100644 --- a/tests/rustdoc-ui/2024-doctests-checks.rs +++ b/tests/rustdoc-ui/2024-doctests-checks.rs @@ -3,6 +3,8 @@ //@ compile-flags: --test --test-args=--test-threads=1 //@ normalize-stdout: "tests/rustdoc-ui" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ normalize-stdout: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" /// ``` diff --git a/tests/rustdoc-ui/2024-doctests-checks.stdout b/tests/rustdoc-ui/2024-doctests-checks.stdout index 534fe466fe7..c86eafd61b9 100644 --- a/tests/rustdoc-ui/2024-doctests-checks.stdout +++ b/tests/rustdoc-ui/2024-doctests-checks.stdout @@ -1,12 +1,13 @@ running 1 test -test $DIR/2024-doctests-checks.rs - Foo (line 8) ... ok +test $DIR/2024-doctests-checks.rs - Foo (line 10) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME running 1 test -test $DIR/2024-doctests-checks.rs - Foo (line 15) ... ok +test $DIR/2024-doctests-checks.rs - Foo (line 17) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/2024-doctests-crate-attribute.rs b/tests/rustdoc-ui/2024-doctests-crate-attribute.rs index c9887cbc63b..416d50cb070 100644 --- a/tests/rustdoc-ui/2024-doctests-crate-attribute.rs +++ b/tests/rustdoc-ui/2024-doctests-crate-attribute.rs @@ -4,6 +4,8 @@ //@ normalize-stdout: "tests/rustdoc-ui" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ normalize-stdout: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" /// This doctest is used to ensure that if a crate attribute is present, /// it will not be part of the merged doctests. diff --git a/tests/rustdoc-ui/2024-doctests-crate-attribute.stdout b/tests/rustdoc-ui/2024-doctests-crate-attribute.stdout index c084ac4522e..20618426312 100644 --- a/tests/rustdoc-ui/2024-doctests-crate-attribute.stdout +++ b/tests/rustdoc-ui/2024-doctests-crate-attribute.stdout @@ -1,12 +1,13 @@ running 1 test -test $DIR/2024-doctests-crate-attribute.rs - Foo (line 20) ... ok +test $DIR/2024-doctests-crate-attribute.rs - Foo (line 22) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME running 1 test -test $DIR/2024-doctests-crate-attribute.rs - Foo (line 11) ... ok +test $DIR/2024-doctests-crate-attribute.rs - Foo (line 13) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/dead-code-2024.rs b/tests/rustdoc-ui/doctest/dead-code-2024.rs index 079d44570bb..e02d2601c58 100644 --- a/tests/rustdoc-ui/doctest/dead-code-2024.rs +++ b/tests/rustdoc-ui/doctest/dead-code-2024.rs @@ -4,6 +4,8 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 #![doc(test(attr(allow(unused_variables), deny(warnings))))] diff --git a/tests/rustdoc-ui/doctest/dead-code-2024.stdout b/tests/rustdoc-ui/doctest/dead-code-2024.stdout index a943a177e10..bf9cd65200b 100644 --- a/tests/rustdoc-ui/doctest/dead-code-2024.stdout +++ b/tests/rustdoc-ui/doctest/dead-code-2024.stdout @@ -1,18 +1,18 @@ running 1 test -test $DIR/dead-code-2024.rs - f (line 13) - compile ... FAILED +test $DIR/dead-code-2024.rs - f (line 15) - compile ... FAILED failures: ----- $DIR/dead-code-2024.rs - f (line 13) stdout ---- +---- $DIR/dead-code-2024.rs - f (line 15) stdout ---- error: trait `T` is never used - --> $DIR/dead-code-2024.rs:14:7 + --> $DIR/dead-code-2024.rs:16:7 | LL | trait T { fn f(); } | ^ | note: the lint level is defined here - --> $DIR/dead-code-2024.rs:12:9 + --> $DIR/dead-code-2024.rs:14:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -23,7 +23,8 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/dead-code-2024.rs - f (line 13) + $DIR/dead-code-2024.rs - f (line 15) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/dead-code-items.rs b/tests/rustdoc-ui/doctest/dead-code-items.rs index 015504cbced..ff59bfaabc4 100644 --- a/tests/rustdoc-ui/doctest/dead-code-items.rs +++ b/tests/rustdoc-ui/doctest/dead-code-items.rs @@ -4,6 +4,8 @@ //@ compile-flags:--test --test-args=--test-threads=1 //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 #![doc(test(attr(deny(warnings))))] diff --git a/tests/rustdoc-ui/doctest/dead-code-items.stdout b/tests/rustdoc-ui/doctest/dead-code-items.stdout index 4b9d8be94dd..ecfe09f09ce 100644 --- a/tests/rustdoc-ui/doctest/dead-code-items.stdout +++ b/tests/rustdoc-ui/doctest/dead-code-items.stdout @@ -1,30 +1,30 @@ running 13 tests -test $DIR/dead-code-items.rs - A (line 32) - compile ... ok -test $DIR/dead-code-items.rs - A (line 88) - compile ... ok -test $DIR/dead-code-items.rs - A::field (line 39) - compile ... FAILED -test $DIR/dead-code-items.rs - A::method (line 94) - compile ... ok -test $DIR/dead-code-items.rs - C (line 22) - compile ... FAILED -test $DIR/dead-code-items.rs - Enum (line 70) - compile ... FAILED -test $DIR/dead-code-items.rs - Enum::Variant1 (line 77) - compile ... FAILED -test $DIR/dead-code-items.rs - MyTrait (line 103) - compile ... FAILED -test $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) - compile ... FAILED -test $DIR/dead-code-items.rs - S (line 14) - compile ... ok -test $DIR/dead-code-items.rs - U (line 48) - compile ... ok -test $DIR/dead-code-items.rs - U::field (line 55) - compile ... FAILED -test $DIR/dead-code-items.rs - U::field2 (line 61) - compile ... ok +test $DIR/dead-code-items.rs - A (line 34) - compile ... ok +test $DIR/dead-code-items.rs - A (line 90) - compile ... ok +test $DIR/dead-code-items.rs - A::field (line 41) - compile ... FAILED +test $DIR/dead-code-items.rs - A::method (line 96) - compile ... ok +test $DIR/dead-code-items.rs - C (line 24) - compile ... FAILED +test $DIR/dead-code-items.rs - Enum (line 72) - compile ... FAILED +test $DIR/dead-code-items.rs - Enum::Variant1 (line 79) - compile ... FAILED +test $DIR/dead-code-items.rs - MyTrait (line 105) - compile ... FAILED +test $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 112) - compile ... FAILED +test $DIR/dead-code-items.rs - S (line 16) - compile ... ok +test $DIR/dead-code-items.rs - U (line 50) - compile ... ok +test $DIR/dead-code-items.rs - U::field (line 57) - compile ... FAILED +test $DIR/dead-code-items.rs - U::field2 (line 63) - compile ... ok failures: ----- $DIR/dead-code-items.rs - A::field (line 39) stdout ---- +---- $DIR/dead-code-items.rs - A::field (line 41) stdout ---- error: trait `DeadCodeInField` is never used - --> $DIR/dead-code-items.rs:40:7 + --> $DIR/dead-code-items.rs:42:7 | LL | trait DeadCodeInField {} | ^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/dead-code-items.rs:38:9 + --> $DIR/dead-code-items.rs:40:9 | LL | #![deny(dead_code)] | ^^^^^^^^^ @@ -32,15 +32,15 @@ LL | #![deny(dead_code)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - C (line 22) stdout ---- +---- $DIR/dead-code-items.rs - C (line 24) stdout ---- error: unused variable: `unused_error` - --> $DIR/dead-code-items.rs:23:5 + --> $DIR/dead-code-items.rs:25:5 | LL | let unused_error = 5; | ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_error` | note: the lint level is defined here - --> $DIR/dead-code-items.rs:20:9 + --> $DIR/dead-code-items.rs:22:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -49,15 +49,15 @@ LL | #![deny(warnings)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - Enum (line 70) stdout ---- +---- $DIR/dead-code-items.rs - Enum (line 72) stdout ---- error: unused variable: `not_dead_code_but_unused` - --> $DIR/dead-code-items.rs:71:5 + --> $DIR/dead-code-items.rs:73:5 | LL | let not_dead_code_but_unused = 5; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_not_dead_code_but_unused` | note: the lint level is defined here - --> $DIR/dead-code-items.rs:68:9 + --> $DIR/dead-code-items.rs:70:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -66,15 +66,15 @@ LL | #![deny(warnings)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - Enum::Variant1 (line 77) stdout ---- +---- $DIR/dead-code-items.rs - Enum::Variant1 (line 79) stdout ---- error: unused variable: `unused_in_variant` - --> $DIR/dead-code-items.rs:80:17 + --> $DIR/dead-code-items.rs:82:17 | LL | fn main() { let unused_in_variant = 5; } | ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_variant` | note: the lint level is defined here - --> $DIR/dead-code-items.rs:75:9 + --> $DIR/dead-code-items.rs:77:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -83,15 +83,15 @@ LL | #![deny(warnings)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - MyTrait (line 103) stdout ---- +---- $DIR/dead-code-items.rs - MyTrait (line 105) stdout ---- error: trait `StillDeadCodeAtMyTrait` is never used - --> $DIR/dead-code-items.rs:104:7 + --> $DIR/dead-code-items.rs:106:7 | LL | trait StillDeadCodeAtMyTrait { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/dead-code-items.rs:102:9 + --> $DIR/dead-code-items.rs:104:9 | LL | #![deny(dead_code)] | ^^^^^^^^^ @@ -99,15 +99,15 @@ LL | #![deny(dead_code)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) stdout ---- +---- $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 112) stdout ---- error: unused variable: `unused_in_impl` - --> $DIR/dead-code-items.rs:113:17 + --> $DIR/dead-code-items.rs:115:17 | LL | fn main() { let unused_in_impl = 5; } | ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_impl` | note: the lint level is defined here - --> $DIR/dead-code-items.rs:108:9 + --> $DIR/dead-code-items.rs:110:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -116,15 +116,15 @@ LL | #![deny(warnings)] error: aborting due to 1 previous error Couldn't compile the test. ----- $DIR/dead-code-items.rs - U::field (line 55) stdout ---- +---- $DIR/dead-code-items.rs - U::field (line 57) stdout ---- error: trait `DeadCodeInUnionField` is never used - --> $DIR/dead-code-items.rs:56:7 + --> $DIR/dead-code-items.rs:58:7 | LL | trait DeadCodeInUnionField {} | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/dead-code-items.rs:54:9 + --> $DIR/dead-code-items.rs:56:9 | LL | #![deny(dead_code)] | ^^^^^^^^^ @@ -134,13 +134,14 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/dead-code-items.rs - A::field (line 39) - $DIR/dead-code-items.rs - C (line 22) - $DIR/dead-code-items.rs - Enum (line 70) - $DIR/dead-code-items.rs - Enum::Variant1 (line 77) - $DIR/dead-code-items.rs - MyTrait (line 103) - $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) - $DIR/dead-code-items.rs - U::field (line 55) + $DIR/dead-code-items.rs - A::field (line 41) + $DIR/dead-code-items.rs - C (line 24) + $DIR/dead-code-items.rs - Enum (line 72) + $DIR/dead-code-items.rs - Enum::Variant1 (line 79) + $DIR/dead-code-items.rs - MyTrait (line 105) + $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 112) + $DIR/dead-code-items.rs - U::field (line 57) test result: FAILED. 6 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/dead-code-module-2.rs b/tests/rustdoc-ui/doctest/dead-code-module-2.rs index de7b11b91ec..fd9c313ec9a 100644 --- a/tests/rustdoc-ui/doctest/dead-code-module-2.rs +++ b/tests/rustdoc-ui/doctest/dead-code-module-2.rs @@ -4,6 +4,8 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 #![doc(test(attr(allow(unused_variables))))] diff --git a/tests/rustdoc-ui/doctest/dead-code-module-2.stdout b/tests/rustdoc-ui/doctest/dead-code-module-2.stdout index d44068dcbf5..cf737996d5c 100644 --- a/tests/rustdoc-ui/doctest/dead-code-module-2.stdout +++ b/tests/rustdoc-ui/doctest/dead-code-module-2.stdout @@ -1,24 +1,24 @@ running 1 test -test $DIR/dead-code-module-2.rs - g (line 24) - compile ... ok +test $DIR/dead-code-module-2.rs - g (line 26) - compile ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME running 1 test -test $DIR/dead-code-module-2.rs - my_mod::f (line 16) - compile ... FAILED +test $DIR/dead-code-module-2.rs - my_mod::f (line 18) - compile ... FAILED failures: ----- $DIR/dead-code-module-2.rs - my_mod::f (line 16) stdout ---- +---- $DIR/dead-code-module-2.rs - my_mod::f (line 18) stdout ---- error: trait `T` is never used - --> $DIR/dead-code-module-2.rs:17:7 + --> $DIR/dead-code-module-2.rs:19:7 | LL | trait T { fn f(); } | ^ | note: the lint level is defined here - --> $DIR/dead-code-module-2.rs:15:9 + --> $DIR/dead-code-module-2.rs:17:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -29,7 +29,8 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/dead-code-module-2.rs - my_mod::f (line 16) + $DIR/dead-code-module-2.rs - my_mod::f (line 18) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/dead-code-module.rs b/tests/rustdoc-ui/doctest/dead-code-module.rs index f825749a6a2..d3103ad28e9 100644 --- a/tests/rustdoc-ui/doctest/dead-code-module.rs +++ b/tests/rustdoc-ui/doctest/dead-code-module.rs @@ -4,6 +4,8 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 mod my_mod { diff --git a/tests/rustdoc-ui/doctest/dead-code-module.stdout b/tests/rustdoc-ui/doctest/dead-code-module.stdout index b5ccf225d25..83c6af3775e 100644 --- a/tests/rustdoc-ui/doctest/dead-code-module.stdout +++ b/tests/rustdoc-ui/doctest/dead-code-module.stdout @@ -1,18 +1,18 @@ running 1 test -test $DIR/dead-code-module.rs - my_mod::f (line 14) - compile ... FAILED +test $DIR/dead-code-module.rs - my_mod::f (line 16) - compile ... FAILED failures: ----- $DIR/dead-code-module.rs - my_mod::f (line 14) stdout ---- +---- $DIR/dead-code-module.rs - my_mod::f (line 16) stdout ---- error: trait `T` is never used - --> $DIR/dead-code-module.rs:15:7 + --> $DIR/dead-code-module.rs:17:7 | LL | trait T { fn f(); } | ^ | note: the lint level is defined here - --> $DIR/dead-code-module.rs:13:9 + --> $DIR/dead-code-module.rs:15:9 | LL | #![deny(warnings)] | ^^^^^^^^ @@ -23,7 +23,8 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/dead-code-module.rs - my_mod::f (line 14) + $DIR/dead-code-module.rs - my_mod::f (line 16) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/doctest-output-include-fail.rs b/tests/rustdoc-ui/doctest/doctest-output-include-fail.rs index a47bac3daef..2f0d6756b27 100644 --- a/tests/rustdoc-ui/doctest/doctest-output-include-fail.rs +++ b/tests/rustdoc-ui/doctest/doctest-output-include-fail.rs @@ -2,6 +2,8 @@ //@ compile-flags:--test --test-args=--test-threads=1 //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 // https://github.com/rust-lang/rust/issues/130470 diff --git a/tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout b/tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout index 22d15f8743c..ceaf60b1201 100644 --- a/tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout +++ b/tests/rustdoc-ui/doctest/doctest-output-include-fail.stdout @@ -22,3 +22,4 @@ failures: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/edition-2024-error-output.rs b/tests/rustdoc-ui/doctest/edition-2024-error-output.rs index 82a85debcd1..e1e57ad01cd 100644 --- a/tests/rustdoc-ui/doctest/edition-2024-error-output.rs +++ b/tests/rustdoc-ui/doctest/edition-2024-error-output.rs @@ -6,6 +6,8 @@ //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "panicked at .+rs:" -> "panicked at $$TMP:" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ rustc-env:RUST_BACKTRACE=0 //@ failure-status: 101 diff --git a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout index 273d7071237..ab6aca239af 100644 --- a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout +++ b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout @@ -1,10 +1,10 @@ running 1 test -test $DIR/edition-2024-error-output.rs - (line 12) ... FAILED +test $DIR/edition-2024-error-output.rs - (line 14) ... FAILED failures: ----- $DIR/edition-2024-error-output.rs - (line 12) stdout ---- +---- $DIR/edition-2024-error-output.rs - (line 14) stdout ---- Test executable failed (exit status: 101). stderr: @@ -18,7 +18,8 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: - $DIR/edition-2024-error-output.rs - (line 12) + $DIR/edition-2024-error-output.rs - (line 14) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs index 793f8654661..0504c3dc730 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs @@ -5,6 +5,8 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 /// ```should_panic diff --git a/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout index 2b04b77c9dc..9047fe0dcdd 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout @@ -1,14 +1,15 @@ running 1 test -test $DIR/failed-doctest-should-panic.rs - Foo (line 10) - should panic ... FAILED +test $DIR/failed-doctest-should-panic.rs - Foo (line 12) - should panic ... FAILED failures: ----- $DIR/failed-doctest-should-panic.rs - Foo (line 10) stdout ---- -note: test did not panic as expected at $DIR/failed-doctest-should-panic.rs:10:0 +---- $DIR/failed-doctest-should-panic.rs - Foo (line 12) stdout ---- +note: test did not panic as expected at $DIR/failed-doctest-should-panic.rs:12:0 failures: - $DIR/failed-doctest-should-panic.rs - Foo (line 10) + $DIR/failed-doctest-should-panic.rs - Foo (line 12) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2015.stdout b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2015.stdout index ce767fb8443..d80c0da323d 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2015.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2015.stdout @@ -1,12 +1,12 @@ running 1 test -test $DIR/failed-doctest-test-crate.rs - m (line 14) ... FAILED +test $DIR/failed-doctest-test-crate.rs - m (line 16) ... FAILED failures: ----- $DIR/failed-doctest-test-crate.rs - m (line 14) stdout ---- +---- $DIR/failed-doctest-test-crate.rs - m (line 16) stdout ---- error[E0432]: unresolved import `test` - --> $DIR/failed-doctest-test-crate.rs:15:5 + --> $DIR/failed-doctest-test-crate.rs:17:5 | LL | use test::*; | ^^^^ use of unresolved module or unlinked crate `test` @@ -22,7 +22,7 @@ For more information about this error, try `rustc --explain E0432`. Couldn't compile the test. failures: - $DIR/failed-doctest-test-crate.rs - m (line 14) + $DIR/failed-doctest-test-crate.rs - m (line 16) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2024.stdout b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2024.stdout index 80642e93bbd..724bb9bee62 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2024.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.edition2024.stdout @@ -1,12 +1,12 @@ running 1 test -test $DIR/failed-doctest-test-crate.rs - m (line 14) ... FAILED +test $DIR/failed-doctest-test-crate.rs - m (line 16) ... FAILED failures: ----- $DIR/failed-doctest-test-crate.rs - m (line 14) stdout ---- +---- $DIR/failed-doctest-test-crate.rs - m (line 16) stdout ---- error[E0432]: unresolved import `test` - --> $DIR/failed-doctest-test-crate.rs:15:5 + --> $DIR/failed-doctest-test-crate.rs:17:5 | LL | use test::*; | ^^^^ use of unresolved module or unlinked crate `test` @@ -19,7 +19,8 @@ For more information about this error, try `rustc --explain E0432`. Couldn't compile the test. failures: - $DIR/failed-doctest-test-crate.rs - m (line 14) + $DIR/failed-doctest-test-crate.rs - m (line 16) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.rs b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.rs index 6966d3df11c..75f7ac396f5 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-test-crate.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-test-crate.rs @@ -7,6 +7,8 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 /// <https://github.com/rust-lang/rust/pull/137899#discussion_r1976743383> diff --git a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2015.stdout b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2015.stdout index ff26e7e3231..0d00a9fc9c4 100644 --- a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2015.stdout +++ b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2015.stdout @@ -1,12 +1,12 @@ running 1 test -test $DIR/relative-path-include-bytes-132203.rs - (line 18) ... FAILED +test $DIR/relative-path-include-bytes-132203.rs - (line 20) ... FAILED failures: ----- $DIR/relative-path-include-bytes-132203.rs - (line 18) stdout ---- +---- $DIR/relative-path-include-bytes-132203.rs - (line 20) stdout ---- error: couldn't read `$DIR/relative-dir-empty-file`: $FILE_NOT_FOUND_MSG (os error 2) - --> $DIR/relative-path-include-bytes-132203.rs:19:9 + --> $DIR/relative-path-include-bytes-132203.rs:21:9 | LL | let x = include_bytes!("relative-dir-empty-file"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/relative-path-include-bytes-132203.rs - (line 18) + $DIR/relative-path-include-bytes-132203.rs - (line 20) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2024.stdout b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2024.stdout index e4c65703081..fa5bd7c93fa 100644 --- a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2024.stdout +++ b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.edition2024.stdout @@ -4,3 +4,4 @@ test $DIR/auxiliary/relative-dir.md - (line 1) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs index ceacd69a5fd..321edc3ee84 100644 --- a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs +++ b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs @@ -9,6 +9,8 @@ //@ normalize-stdout: "tests.rustdoc-ui.doctest." -> "$$DIR/" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ normalize-stdout: "`: .* \(os error 2\)" -> "`: $$FILE_NOT_FOUND_MSG (os error 2)" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" // https://github.com/rust-lang/rust/issues/132203 // This version, because it's edition2024, passes thanks to the new diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.rs b/tests/rustdoc-ui/doctest/stdout-and-stderr.rs index 9b0c69d8839..a4eda8c7f83 100644 --- a/tests/rustdoc-ui/doctest/stdout-and-stderr.rs +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.rs @@ -9,6 +9,8 @@ //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ normalize-stdout: "panicked at .+rs:" -> "panicked at $$TMP:" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout index b2febe1344f..a35a4d7c3cb 100644 --- a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout @@ -1,12 +1,12 @@ running 3 tests -test $DIR/stdout-and-stderr.rs - (line 15) ... FAILED -test $DIR/stdout-and-stderr.rs - (line 20) ... FAILED -test $DIR/stdout-and-stderr.rs - (line 24) ... FAILED +test $DIR/stdout-and-stderr.rs - (line 17) ... FAILED +test $DIR/stdout-and-stderr.rs - (line 22) ... FAILED +test $DIR/stdout-and-stderr.rs - (line 26) ... FAILED failures: ----- $DIR/stdout-and-stderr.rs - (line 15) stdout ---- +---- $DIR/stdout-and-stderr.rs - (line 17) stdout ---- Test executable failed (exit status: 101). stdout: @@ -21,7 +21,7 @@ assertion `left == right` failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ----- $DIR/stdout-and-stderr.rs - (line 20) stdout ---- +---- $DIR/stdout-and-stderr.rs - (line 22) stdout ---- Test executable failed (exit status: 101). stderr: @@ -33,14 +33,15 @@ assertion `left == right` failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ----- $DIR/stdout-and-stderr.rs - (line 24) stdout ---- +---- $DIR/stdout-and-stderr.rs - (line 26) stdout ---- Test executable failed (exit status: 1). failures: - $DIR/stdout-and-stderr.rs - (line 15) - $DIR/stdout-and-stderr.rs - (line 20) - $DIR/stdout-and-stderr.rs - (line 24) + $DIR/stdout-and-stderr.rs - (line 17) + $DIR/stdout-and-stderr.rs - (line 22) + $DIR/stdout-and-stderr.rs - (line 26) test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc-ui/doctest/wrong-ast-2024.rs b/tests/rustdoc-ui/doctest/wrong-ast-2024.rs index 3b4fb3f3443..df30e01b25e 100644 --- a/tests/rustdoc-ui/doctest/wrong-ast-2024.rs +++ b/tests/rustdoc-ui/doctest/wrong-ast-2024.rs @@ -3,6 +3,8 @@ //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ normalize-stdout: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" +//@ normalize-stdout: "ran in \d+\.\d+s" -> "ran in $$TIME" +//@ normalize-stdout: "compilation took \d+\.\d+s" -> "compilation took $$TIME" //@ failure-status: 101 /// ``` diff --git a/tests/rustdoc-ui/doctest/wrong-ast-2024.stdout b/tests/rustdoc-ui/doctest/wrong-ast-2024.stdout index 62e1fb10b9f..13567b41e51 100644 --- a/tests/rustdoc-ui/doctest/wrong-ast-2024.stdout +++ b/tests/rustdoc-ui/doctest/wrong-ast-2024.stdout @@ -1,17 +1,17 @@ running 1 test -test $DIR/wrong-ast-2024.rs - three (line 18) - should panic ... ok +test $DIR/wrong-ast-2024.rs - three (line 20) - should panic ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME running 2 tests -test $DIR/wrong-ast-2024.rs - one (line 8) ... FAILED -test $DIR/wrong-ast-2024.rs - two (line 13) ... FAILED +test $DIR/wrong-ast-2024.rs - one (line 10) ... FAILED +test $DIR/wrong-ast-2024.rs - two (line 15) ... FAILED failures: ----- $DIR/wrong-ast-2024.rs - one (line 8) stdout ---- +---- $DIR/wrong-ast-2024.rs - one (line 10) stdout ---- error[E0758]: unterminated block comment --> $DIR/wrong-ast-2024.rs:$LINE:$COL | @@ -22,7 +22,7 @@ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0758`. Couldn't compile the test. ----- $DIR/wrong-ast-2024.rs - two (line 13) stdout ---- +---- $DIR/wrong-ast-2024.rs - two (line 15) stdout ---- error: unexpected closing delimiter: `}` --> $DIR/wrong-ast-2024.rs:$LINE:$COL | @@ -34,8 +34,9 @@ error: aborting due to 1 previous error Couldn't compile the test. failures: - $DIR/wrong-ast-2024.rs - one (line 8) - $DIR/wrong-ast-2024.rs - two (line 13) + $DIR/wrong-ast-2024.rs - one (line 10) + $DIR/wrong-ast-2024.rs - two (line 15) test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/rustdoc/extern/extern-html-alias.rs b/tests/rustdoc/extern/extern-html-alias.rs new file mode 100644 index 00000000000..3ff782d3963 --- /dev/null +++ b/tests/rustdoc/extern/extern-html-alias.rs @@ -0,0 +1,9 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url externs_name=https://renamed.example.com --extern-html-root-url empty=https://bad.invalid +//@ aux-crate:externs_name=empty.rs +//@ edition: 2018 + +extern crate externs_name as renamed; + +//@ has extern_html_alias/index.html +//@ has - '//a/@href' 'https://renamed.example.com/empty/index.html' +pub use renamed as yet_different_name; diff --git a/tests/rustdoc/extern/extern-html-fallback.rs b/tests/rustdoc/extern/extern-html-fallback.rs new file mode 100644 index 00000000000..ddac9bf713c --- /dev/null +++ b/tests/rustdoc/extern/extern-html-fallback.rs @@ -0,0 +1,14 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url yet_another_name=https://bad.invalid --extern-html-root-url renamed_privately=https://bad.invalid --extern-html-root-url renamed_locally=https://bad.invalid --extern-html-root-url empty=https://localhost +//@ aux-crate:externs_name=empty.rs +//@ edition: 2018 + +mod m { + pub extern crate externs_name as renamed_privately; +} + +// renaming within the crate's source code is not supposed to affect CLI flags +extern crate externs_name as renamed_locally; + +//@ has extern_html_fallback/index.html +//@ has - '//a/@href' 'https://localhost/empty/index.html' +pub use crate::renamed_locally as yet_another_name; diff --git a/tests/rustdoc/reexport/auxiliary/wrap-unnamable-type.rs b/tests/rustdoc/reexport/auxiliary/wrap-unnamable-type.rs new file mode 100644 index 00000000000..7f8e346c8be --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/wrap-unnamable-type.rs @@ -0,0 +1,12 @@ +pub trait Assoc { + type Ty; +} + +pub struct Foo(<Foo as crate::Assoc>::Ty); + +const _X: () = { + impl crate::Assoc for Foo { + type Ty = Bar; + } + pub struct Bar; +}; diff --git a/tests/rustdoc/reexport/wrapped-unnamble-type-143222.rs b/tests/rustdoc/reexport/wrapped-unnamble-type-143222.rs new file mode 100644 index 00000000000..9a8893786f5 --- /dev/null +++ b/tests/rustdoc/reexport/wrapped-unnamble-type-143222.rs @@ -0,0 +1,16 @@ +//@ compile-flags: -Z normalize-docs --document-private-items -Zunstable-options --show-type-layout +//@ aux-build:wrap-unnamable-type.rs +//@ build-aux-docs + +// regression test for https://github.com/rust-lang/rust/issues/143222 +// makes sure normalizing docs does not cause us to link to unnamable types +// in cross-crate reexports. + +#![crate_name = "foo"] + +extern crate wrap_unnamable_type as helper; + +//@ has 'foo/struct.Foo.html' +//@ !hasraw - 'struct.Bar.html' +#[doc(inline)] +pub use helper::Foo; diff --git a/tests/ui/async-await/async-drop/async-drop-box-allocator.rs b/tests/ui/async-await/async-drop/async-drop-box-allocator.rs new file mode 100644 index 00000000000..86ebf8a0ffd --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-box-allocator.rs @@ -0,0 +1,134 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// It's used as the allocator of a `Box` which is conditionally moved out of. +// Sync version is called in sync context, async version is called in async function. + +#![feature(async_drop, allocator_api)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, + alloc::{AllocError, Allocator, Global, Layout}, + ptr::NonNull, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +unsafe impl Allocator for Foo { + fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { + Global.allocate(layout) + } + unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { + Global.deallocate(ptr, layout); + } +} + +struct HasDrop; +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +fn main() { + { + let b = Box::new_in(HasDrop, Foo::new(7)); + + if true { + let _x = *b; + } else { + let _y = b; + } + } + println!("Middle"); + block_on(bar(10)); + println!("Done") +} + +async fn bar(ident_base: usize) { + let b = Box::new_in(HasDrop, Foo::new(ident_base)); + + if true { + let _x = *b; + } else { + let _y = b; + } +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-box-allocator.run.stdout b/tests/ui/async-await/async-drop/async-drop-box-allocator.run.stdout new file mode 100644 index 00000000000..cb7d0b0fea5 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-box-allocator.run.stdout @@ -0,0 +1,6 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Foo::new() : 10 +Foo::async drop() : 10 +Done diff --git a/tests/ui/async-await/async-drop/async-drop-box.rs b/tests/ui/async-await/async-drop/async-drop-box.rs new file mode 100644 index 00000000000..0a6ed412863 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-box.rs @@ -0,0 +1,109 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// `Foo` is always inside `Box` +// Sync version is called in sync context, async version is called in async function. + +//@ known-bug: #143658 +// async version is never actually called + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Box::new(Foo::new(7)); + } + println!("Middle"); + block_on(bar(10)); + println!("Done") +} + +async fn bar(ident_base: usize) { + let _first = Box::new(Foo::new(ident_base)); +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-box.run.stdout b/tests/ui/async-await/async-drop/async-drop-box.run.stdout new file mode 100644 index 00000000000..a2dab2ba992 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-box.run.stdout @@ -0,0 +1,6 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Foo::new() : 10 +Foo::drop() : 10 +Done diff --git a/tests/ui/drop/box-conditional-drop-allocator.rs b/tests/ui/drop/box-conditional-drop-allocator.rs new file mode 100644 index 00000000000..8f78da16473 --- /dev/null +++ b/tests/ui/drop/box-conditional-drop-allocator.rs @@ -0,0 +1,43 @@ +//@ run-pass +#![feature(allocator_api)] + +// Regression test for #131082. +// Testing that the allocator of a Box is dropped in conditional drops + +use std::alloc::{AllocError, Allocator, Global, Layout}; +use std::cell::Cell; +use std::ptr::NonNull; + +struct DropCheckingAllocator<'a>(&'a Cell<bool>); + +unsafe impl Allocator for DropCheckingAllocator<'_> { + fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { + Global.allocate(layout) + } + unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { + Global.deallocate(ptr, layout); + } +} +impl Drop for DropCheckingAllocator<'_> { + fn drop(&mut self) { + self.0.set(true); + } +} + +struct HasDrop; +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +fn main() { + let dropped = Cell::new(false); + { + let b = Box::new_in(HasDrop, DropCheckingAllocator(&dropped)); + if true { + drop(*b); + } else { + drop(b); + } + } + assert!(dropped.get()); +} diff --git a/tests/ui/error-codes/E0423.stderr b/tests/ui/error-codes/E0423.stderr index e50b8bd820c..b699e53fb48 100644 --- a/tests/ui/error-codes/E0423.stderr +++ b/tests/ui/error-codes/E0423.stderr @@ -54,7 +54,7 @@ help: use struct literal syntax instead LL - let f = Foo(); LL + let f = Foo { a: val }; | -help: a function with a similar name exists (notice the capitalization difference) +help: a function with a similar name exists (notice the capitalization) | LL - let f = Foo(); LL + let f = foo(); diff --git a/tests/ui/error-emitter/auxiliary/close_window.rs b/tests/ui/error-emitter/auxiliary/close_window.rs new file mode 100644 index 00000000000..e41313b6ab3 --- /dev/null +++ b/tests/ui/error-emitter/auxiliary/close_window.rs @@ -0,0 +1,4 @@ +pub struct S; +impl S { + fn method(&self) {} +} diff --git a/tests/ui/error-emitter/close_window.ascii.stderr b/tests/ui/error-emitter/close_window.ascii.stderr new file mode 100644 index 00000000000..e208b709393 --- /dev/null +++ b/tests/ui/error-emitter/close_window.ascii.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + --> $DIR/close_window.rs:9:7 + | +LL | s.method(); + | ^^^^^^ private method + | + ::: $DIR/auxiliary/close_window.rs:3:5 + | +LL | fn method(&self) {} + | ---------------- private method defined here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/error-emitter/close_window.rs b/tests/ui/error-emitter/close_window.rs new file mode 100644 index 00000000000..879507c287a --- /dev/null +++ b/tests/ui/error-emitter/close_window.rs @@ -0,0 +1,11 @@ +//@ aux-build:close_window.rs +//@ revisions: ascii unicode +//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode + +extern crate close_window; + +fn main() { + let s = close_window::S; + s.method(); + //[ascii]~^ ERROR method `method` is private +} diff --git a/tests/ui/error-emitter/close_window.unicode.stderr b/tests/ui/error-emitter/close_window.unicode.stderr new file mode 100644 index 00000000000..b4aa78a5ac9 --- /dev/null +++ b/tests/ui/error-emitter/close_window.unicode.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + ╭▸ $DIR/close_window.rs:9:7 + │ +LL │ s.method(); + │ ━━━━━━ private method + │ + ⸬ $DIR/auxiliary/close_window.rs:3:5 + │ +LL │ fn method(&self) {} + ╰╴ ──────────────── private method defined here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/explicit-tail-calls/recursion-etc.rs b/tests/ui/explicit-tail-calls/recursion-etc.rs new file mode 100644 index 00000000000..8c89ceb7869 --- /dev/null +++ b/tests/ui/explicit-tail-calls/recursion-etc.rs @@ -0,0 +1,17 @@ +//@ run-pass +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +use std::hint::black_box; + +pub fn count(curr: u64, top: u64) -> u64 { + if black_box(curr) >= top { + curr + } else { + become count(curr + 1, top) + } +} + +fn main() { + println!("{}", count(0, black_box(1000000))); +} diff --git a/tests/ui/lint/lint-non-uppercase-usages.stderr b/tests/ui/lint/lint-non-uppercase-usages.stderr index 7c7e573a88e..b34be31216d 100644 --- a/tests/ui/lint/lint-non-uppercase-usages.stderr +++ b/tests/ui/lint/lint-non-uppercase-usages.stderr @@ -29,7 +29,7 @@ warning: const parameter `foo` should have an upper case name LL | fn foo<const foo: u32>() { | ^^^ | -help: convert the identifier to upper case (notice the capitalization difference) +help: convert the identifier to upper case (notice the capitalization) | LL - fn foo<const foo: u32>() { LL + fn foo<const FOO: u32>() { diff --git a/tests/ui/lint/wide_pointer_comparisons.rs b/tests/ui/lint/wide_pointer_comparisons.rs index 05097cbf1e3..a5e3f4754b8 100644 --- a/tests/ui/lint/wide_pointer_comparisons.rs +++ b/tests/ui/lint/wide_pointer_comparisons.rs @@ -146,12 +146,10 @@ fn main() { { macro_rules! cmp { ($a:tt, $b:tt) => { $a == $b } + //~^ WARN ambiguous wide pointer comparison } - // FIXME: This lint uses some custom span combination logic. - // Rewrite it to adapt to the new metavariable span rules. cmp!(a, b); - //~^ WARN ambiguous wide pointer comparison } { diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 4f5238e8252..4199ff62e2a 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -720,18 +720,20 @@ LL + std::ptr::eq(*a, *b) | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected - --> $DIR/wide_pointer_comparisons.rs:153:14 + --> $DIR/wide_pointer_comparisons.rs:148:33 | +LL | ($a:tt, $b:tt) => { $a == $b } + | ^^^^^^^^ +... LL | cmp!(a, b); - | ^^^^ - | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses + | ---------- in this macro invocation | -LL | cmp!(std::ptr::addr_eq(a, b)); - | ++++++++++++++++++ + + = help: use explicit `std::ptr::eq` method to compare metadata and addresses + = help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses + = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected - --> $DIR/wide_pointer_comparisons.rs:159:39 + --> $DIR/wide_pointer_comparisons.rs:157:39 | LL | ($a:ident, $b:ident) => { $a == $b } | ^^^^^^^^ @@ -747,7 +749,7 @@ LL + ($a:ident, $b:ident) => { std::ptr::addr_eq($a, $b) } | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected - --> $DIR/wide_pointer_comparisons.rs:169:37 + --> $DIR/wide_pointer_comparisons.rs:167:37 | LL | ($a:expr, $b:expr) => { $a == $b } | ^^^^^^^^ diff --git a/tests/ui/parser/item-kw-case-mismatch.stderr b/tests/ui/parser/item-kw-case-mismatch.stderr index df39eb10fdb..d2a1eb7f2f5 100644 --- a/tests/ui/parser/item-kw-case-mismatch.stderr +++ b/tests/ui/parser/item-kw-case-mismatch.stderr @@ -4,7 +4,7 @@ error: keyword `use` is written in the wrong case LL | Use std::ptr::read; | ^^^ | -help: write it in the correct case (notice the capitalization difference) +help: write it in the correct case (notice the capitalization) | LL - Use std::ptr::read; LL + use std::ptr::read; @@ -28,7 +28,7 @@ error: keyword `fn` is written in the wrong case LL | async Fn _a() {} | ^^ | -help: write it in the correct case (notice the capitalization difference) +help: write it in the correct case (notice the capitalization) | LL - async Fn _a() {} LL + async fn _a() {} @@ -40,7 +40,7 @@ error: keyword `fn` is written in the wrong case LL | Fn _b() {} | ^^ | -help: write it in the correct case (notice the capitalization difference) +help: write it in the correct case (notice the capitalization) | LL - Fn _b() {} LL + fn _b() {} diff --git a/tests/ui/parser/kw-in-trait-bounds.stderr b/tests/ui/parser/kw-in-trait-bounds.stderr index 1892d0b6226..5a4adf3e37b 100644 --- a/tests/ui/parser/kw-in-trait-bounds.stderr +++ b/tests/ui/parser/kw-in-trait-bounds.stderr @@ -4,7 +4,7 @@ error: expected identifier, found keyword `fn` LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) LL + fn _f<F: Fn(), G>(_: impl fn(), _: &dyn fn()) @@ -16,7 +16,7 @@ error: expected identifier, found keyword `fn` LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) LL + fn _f<F: fn(), G>(_: impl Fn(), _: &dyn fn()) @@ -28,7 +28,7 @@ error: expected identifier, found keyword `fn` LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) LL + fn _f<F: fn(), G>(_: impl fn(), _: &dyn Fn()) @@ -40,7 +40,7 @@ error: expected identifier, found keyword `fn` LL | G: fn(), | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - G: fn(), LL + G: Fn(), diff --git a/tests/ui/parser/misspelled-keywords/hrdt.stderr b/tests/ui/parser/misspelled-keywords/hrdt.stderr index e5fc1a50382..497bd613bf4 100644 --- a/tests/ui/parser/misspelled-keywords/hrdt.stderr +++ b/tests/ui/parser/misspelled-keywords/hrdt.stderr @@ -4,7 +4,7 @@ error: expected one of `!`, `(`, `+`, `::`, `<`, `where`, or `{`, found keyword LL | Where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8, | ^^^ expected one of 7 possible tokens | -help: write keyword `where` in lowercase (notice the capitalization difference) +help: write keyword `where` in lowercase (notice the capitalization) | LL - Where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8, LL + where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8, diff --git a/tests/ui/parser/misspelled-keywords/impl-return.stderr b/tests/ui/parser/misspelled-keywords/impl-return.stderr index ff5391461a9..d49d962d7e9 100644 --- a/tests/ui/parser/misspelled-keywords/impl-return.stderr +++ b/tests/ui/parser/misspelled-keywords/impl-return.stderr @@ -4,7 +4,7 @@ error: expected one of `!`, `(`, `+`, `::`, `<`, `where`, or `{`, found `Display LL | fn code() -> Impl Display {} | ^^^^^^^ expected one of 7 possible tokens | -help: write keyword `impl` in lowercase (notice the capitalization difference) +help: write keyword `impl` in lowercase (notice the capitalization) | LL - fn code() -> Impl Display {} LL + fn code() -> impl Display {} diff --git a/tests/ui/parser/misspelled-keywords/static.stderr b/tests/ui/parser/misspelled-keywords/static.stderr index e559f2be109..0df40bcdc33 100644 --- a/tests/ui/parser/misspelled-keywords/static.stderr +++ b/tests/ui/parser/misspelled-keywords/static.stderr @@ -4,7 +4,7 @@ error: expected one of `!` or `::`, found `a` LL | Static a = 0; | ^ expected one of `!` or `::` | -help: write keyword `static` in lowercase (notice the capitalization difference) +help: write keyword `static` in lowercase (notice the capitalization) | LL - Static a = 0; LL + static a = 0; diff --git a/tests/ui/parser/misspelled-keywords/struct.stderr b/tests/ui/parser/misspelled-keywords/struct.stderr index edbec3b9456..af8614ef14b 100644 --- a/tests/ui/parser/misspelled-keywords/struct.stderr +++ b/tests/ui/parser/misspelled-keywords/struct.stderr @@ -4,7 +4,7 @@ error: expected one of `!` or `::`, found `Foor` LL | Struct Foor { | ^^^^ expected one of `!` or `::` | -help: write keyword `struct` in lowercase (notice the capitalization difference) +help: write keyword `struct` in lowercase (notice the capitalization) | LL - Struct Foor { LL + struct Foor { diff --git a/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr b/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr index 4e1fcaf4936..bd809e77a8f 100644 --- a/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr +++ b/tests/ui/parser/recover/recover-fn-trait-from-fn-kw.stderr @@ -4,7 +4,7 @@ error: expected identifier, found keyword `fn` LL | fn foo(_: impl fn() -> i32) {} | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - fn foo(_: impl fn() -> i32) {} LL + fn foo(_: impl Fn() -> i32) {} @@ -16,7 +16,7 @@ error: expected identifier, found keyword `fn` LL | fn foo2<T: fn(i32)>(_: T) {} | ^^ | -help: use `Fn` to refer to the trait (notice the capitalization difference) +help: use `Fn` to refer to the trait (notice the capitalization) | LL - fn foo2<T: fn(i32)>(_: T) {} LL + fn foo2<T: Fn(i32)>(_: T) {} diff --git a/tests/ui/parser/typod-const-in-const-param-def.stderr b/tests/ui/parser/typod-const-in-const-param-def.stderr index bf7168a0157..cc1600fe5cb 100644 --- a/tests/ui/parser/typod-const-in-const-param-def.stderr +++ b/tests/ui/parser/typod-const-in-const-param-def.stderr @@ -4,7 +4,7 @@ error: `const` keyword was mistyped as `Const` LL | pub fn foo<Const N: u8>() {} | ^^^^^ | -help: use the `const` keyword (notice the capitalization difference) +help: use the `const` keyword (notice the capitalization) | LL - pub fn foo<Const N: u8>() {} LL + pub fn foo<const N: u8>() {} @@ -16,7 +16,7 @@ error: `const` keyword was mistyped as `Const` LL | pub fn baz<Const N: u8, T>() {} | ^^^^^ | -help: use the `const` keyword (notice the capitalization difference) +help: use the `const` keyword (notice the capitalization) | LL - pub fn baz<Const N: u8, T>() {} LL + pub fn baz<const N: u8, T>() {} @@ -28,7 +28,7 @@ error: `const` keyword was mistyped as `Const` LL | pub fn qux<T, Const N: u8>() {} | ^^^^^ | -help: use the `const` keyword (notice the capitalization difference) +help: use the `const` keyword (notice the capitalization) | LL - pub fn qux<T, Const N: u8>() {} LL + pub fn qux<T, const N: u8>() {} @@ -40,7 +40,7 @@ error: `const` keyword was mistyped as `Const` LL | pub fn quux<T, Const N: u8, U>() {} | ^^^^^ | -help: use the `const` keyword (notice the capitalization difference) +help: use the `const` keyword (notice the capitalization) | LL - pub fn quux<T, Const N: u8, U>() {} LL + pub fn quux<T, const N: u8, U>() {} diff --git a/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr b/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr index 6d6fd983038..47efe69cfc2 100644 --- a/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr +++ b/tests/ui/suggestions/assoc-ct-for-assoc-method.stderr @@ -8,7 +8,7 @@ LL | let x: i32 = MyS::foo; | = note: expected type `i32` found fn item `fn() -> MyS {MyS::foo}` -help: try referring to the associated const `FOO` instead (notice the capitalization difference) +help: try referring to the associated const `FOO` instead (notice the capitalization) | LL - let x: i32 = MyS::foo; LL + let x: i32 = MyS::FOO; diff --git a/tests/ui/suggestions/bool_typo_err_suggest.stderr b/tests/ui/suggestions/bool_typo_err_suggest.stderr index faf799d0fda..d46ce1ad8a9 100644 --- a/tests/ui/suggestions/bool_typo_err_suggest.stderr +++ b/tests/ui/suggestions/bool_typo_err_suggest.stderr @@ -16,7 +16,7 @@ error[E0425]: cannot find value `False` in this scope LL | let y = False; | ^^^^^ not found in this scope | -help: you may want to use a bool value instead (notice the capitalization difference) +help: you may want to use a bool value instead (notice the capitalization) | LL - let y = False; LL + let y = false; diff --git a/tests/ui/suggestions/case-difference-suggestions.rs b/tests/ui/suggestions/case-difference-suggestions.rs new file mode 100644 index 00000000000..d554b6e9367 --- /dev/null +++ b/tests/ui/suggestions/case-difference-suggestions.rs @@ -0,0 +1,57 @@ +fn main() { + + // Simple case difference, no hit + let hello = "hello"; + println!("{}", Hello); //~ ERROR cannot find value `Hello` in this scope + + // Multiple case differences, hit + let myVariable = 10; + println!("{}", myvariable); //~ ERROR cannot find value `myvariable` in this scope + + // Case difference with special characters, hit + let user_name = "john"; + println!("{}", User_Name); //~ ERROR cannot find value `User_Name` in this scope + + // All uppercase vs all lowercase, hit + let FOO = 42; + println!("{}", foo); //~ ERROR cannot find value `foo` in this scope + + + // 0 vs O + let FFO0 = 100; + println!("{}", FFOO); //~ ERROR cannot find value `FFOO` in this scope + + let l1st = vec![1, 2, 3]; + println!("{}", list); //~ ERROR cannot find value `list` in this scope + + let S5 = "test"; + println!("{}", SS); //~ ERROR cannot find value `SS` in this scope + + let aS5 = "test"; + println!("{}", a55); //~ ERROR cannot find value `a55` in this scope + + let B8 = 8; + println!("{}", BB); //~ ERROR cannot find value `BB` in this scope + + let g9 = 9; + println!("{}", gg); //~ ERROR cannot find value `gg` in this scope + + let o1d = "old"; + println!("{}", old); //~ ERROR cannot find value `old` in this scope + + let new1 = "new"; + println!("{}", newl); //~ ERROR cannot find value `newl` in this scope + + let apple = "apple"; + println!("{}", app1e); //~ ERROR cannot find value `app1e` in this scope + + let a = 1; + println!("{}", A); //~ ERROR cannot find value `A` in this scope + + let worldlu = "world"; + println!("{}", world1U); //~ ERROR cannot find value `world1U` in this scope + + let myV4rlable = 42; + println!("{}", myv4r1able); //~ ERROR cannot find value `myv4r1able` in this scope + +} diff --git a/tests/ui/suggestions/case-difference-suggestions.stderr b/tests/ui/suggestions/case-difference-suggestions.stderr new file mode 100644 index 00000000000..c3d2410a6eb --- /dev/null +++ b/tests/ui/suggestions/case-difference-suggestions.stderr @@ -0,0 +1,99 @@ +error[E0425]: cannot find value `Hello` in this scope + --> $DIR/case-difference-suggestions.rs:5:20 + | +LL | println!("{}", Hello); + | ^^^^^ help: a local variable with a similar name exists: `hello` + +error[E0425]: cannot find value `myvariable` in this scope + --> $DIR/case-difference-suggestions.rs:9:20 + | +LL | println!("{}", myvariable); + | ^^^^^^^^^^ help: a local variable with a similar name exists (notice the capitalization): `myVariable` + +error[E0425]: cannot find value `User_Name` in this scope + --> $DIR/case-difference-suggestions.rs:13:20 + | +LL | println!("{}", User_Name); + | ^^^^^^^^^ help: a local variable with a similar name exists: `user_name` + +error[E0425]: cannot find value `foo` in this scope + --> $DIR/case-difference-suggestions.rs:17:20 + | +LL | println!("{}", foo); + | ^^^ help: a local variable with a similar name exists (notice the capitalization): `FOO` + +error[E0425]: cannot find value `FFOO` in this scope + --> $DIR/case-difference-suggestions.rs:22:20 + | +LL | println!("{}", FFOO); + | ^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `FFO0` + +error[E0425]: cannot find value `list` in this scope + --> $DIR/case-difference-suggestions.rs:25:20 + | +LL | println!("{}", list); + | ^^^^ help: a local variable with a similar name exists: `l1st` + +error[E0425]: cannot find value `SS` in this scope + --> $DIR/case-difference-suggestions.rs:28:20 + | +LL | println!("{}", SS); + | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `S5` + +error[E0425]: cannot find value `a55` in this scope + --> $DIR/case-difference-suggestions.rs:31:20 + | +LL | println!("{}", a55); + | ^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `aS5` + +error[E0425]: cannot find value `BB` in this scope + --> $DIR/case-difference-suggestions.rs:34:20 + | +LL | println!("{}", BB); + | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `B8` + +error[E0425]: cannot find value `gg` in this scope + --> $DIR/case-difference-suggestions.rs:37:20 + | +LL | println!("{}", gg); + | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `g9` + +error[E0425]: cannot find value `old` in this scope + --> $DIR/case-difference-suggestions.rs:40:20 + | +LL | println!("{}", old); + | ^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `o1d` + +error[E0425]: cannot find value `newl` in this scope + --> $DIR/case-difference-suggestions.rs:43:20 + | +LL | println!("{}", newl); + | ^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `new1` + +error[E0425]: cannot find value `app1e` in this scope + --> $DIR/case-difference-suggestions.rs:46:20 + | +LL | println!("{}", app1e); + | ^^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `apple` + +error[E0425]: cannot find value `A` in this scope + --> $DIR/case-difference-suggestions.rs:49:20 + | +LL | println!("{}", A); + | ^ help: a local variable with a similar name exists: `a` + +error[E0425]: cannot find value `world1U` in this scope + --> $DIR/case-difference-suggestions.rs:52:20 + | +LL | println!("{}", world1U); + | ^^^^^^^ help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion): `worldlu` + +error[E0425]: cannot find value `myv4r1able` in this scope + --> $DIR/case-difference-suggestions.rs:55:20 + | +LL | println!("{}", myv4r1able); + | ^^^^^^^^^^ help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion): `myV4rlable` + +error: aborting due to 16 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/suggestions/incorrect-variant-literal.svg b/tests/ui/suggestions/incorrect-variant-literal.svg index 279fd30f216..2cab1f4b60f 100644 --- a/tests/ui/suggestions/incorrect-variant-literal.svg +++ b/tests/ui/suggestions/incorrect-variant-literal.svg @@ -455,7 +455,7 @@ </tspan> <tspan x="10px" y="3916px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3934px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name (notice the capitalization difference)</tspan> + <tspan x="10px" y="3934px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name (notice the capitalization)</tspan> </tspan> <tspan x="10px" y="3952px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.next.stderr b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.next.stderr new file mode 100644 index 00000000000..141a07b4be7 --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.next.stderr @@ -0,0 +1,19 @@ +error[E0283]: type annotations needed: cannot satisfy `dyn D<&(), &()>: B<&()>` + --> $DIR/ambiguity-due-to-uniquification-1.rs:15:31 + | +LL | (&() as &dyn D<&(), &()>).f() + | ^ + | + = note: cannot satisfy `dyn D<&(), &()>: B<&()>` + = help: the trait `B<C>` is implemented for `()` +note: required by a bound in `D::f` + --> $DIR/ambiguity-due-to-uniquification-1.rs:10:16 + | +LL | trait D<C, E>: B<C> + B<E> { + | ^^^^ required by this bound in `D::f` +LL | fn f(&self) {} + | - required by a bound in this associated function + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.rs b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.rs new file mode 100644 index 00000000000..cfdf74046fb --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-1.rs @@ -0,0 +1,17 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-pass + +// Regression test for #139409 and trait-system-refactor-initiative#27. + +trait B<C> {} +impl<C> B<C> for () {} +trait D<C, E>: B<C> + B<E> { + fn f(&self) {} +} +impl<C, E> D<C, E> for () {} +fn main() { + (&() as &dyn D<&(), &()>).f() + //[next]~^ ERROR type annotations needed: cannot satisfy `dyn D<&(), &()>: B<&()>` +} diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.next.stderr b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.next.stderr new file mode 100644 index 00000000000..3b478889996 --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.next.stderr @@ -0,0 +1,17 @@ +error[E0283]: type annotations needed: cannot satisfy `impl Trait<'x> + Trait<'y>: Trait<'y>` + --> $DIR/ambiguity-due-to-uniquification-2.rs:16:23 + | +LL | impls_trait::<'y, _>(foo::<'x, 'y>()); + | ^ + | + = note: cannot satisfy `impl Trait<'x> + Trait<'y>: Trait<'y>` + = help: the trait `Trait<'t>` is implemented for `()` +note: required by a bound in `impls_trait` + --> $DIR/ambiguity-due-to-uniquification-2.rs:13:23 + | +LL | fn impls_trait<'x, T: Trait<'x>>(_: T) {} + | ^^^^^^^^^ required by this bound in `impls_trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.rs b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.rs new file mode 100644 index 00000000000..2a9a8b80cc0 --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-2.rs @@ -0,0 +1,20 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-pass + +// Regression test from trait-system-refactor-initiative#27. + +trait Trait<'t> {} +impl<'t> Trait<'t> for () {} + +fn foo<'x, 'y>() -> impl Trait<'x> + Trait<'y> {} + +fn impls_trait<'x, T: Trait<'x>>(_: T) {} + +fn bar<'x, 'y>() { + impls_trait::<'y, _>(foo::<'x, 'y>()); + //[next]~^ ERROR type annotations needed: cannot satisfy `impl Trait<'x> + Trait<'y>: Trait<'y>` +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.next.stderr b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.next.stderr new file mode 100644 index 00000000000..e25f892b365 --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.next.stderr @@ -0,0 +1,19 @@ +error[E0283]: type annotations needed: cannot satisfy `(dyn Object<&(), &()> + 'static): Trait<&()>` + --> $DIR/ambiguity-due-to-uniquification-3.rs:28:17 + | +LL | impls_trait(obj, t); + | ----------- ^^^ + | | + | required by a bound introduced by this call + | + = note: cannot satisfy `(dyn Object<&(), &()> + 'static): Trait<&()>` + = help: the trait `Trait<T>` is implemented for `()` +note: required by a bound in `impls_trait` + --> $DIR/ambiguity-due-to-uniquification-3.rs:24:19 + | +LL | fn impls_trait<T: Trait<U>, U>(_: Inv<T>, _: Inv<U>) {} + | ^^^^^^^^ required by this bound in `impls_trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.rs b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.rs new file mode 100644 index 00000000000..6dcd9d5bdf4 --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-3.rs @@ -0,0 +1,33 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[current] check-pass + +// Regression test from trait-system-refactor-initiative#27. +// +// Unlike in the previous two tests, `dyn Object<?x, ?y>: Trait<?x>` relies +// on structural identity of type inference variables. This inference variable +// gets constrained to a type containing a region later on. To prevent this +// from causing an ICE during MIR borrowck, we stash goals which depend on +// inference variables and then reprove them at the end of HIR typeck. + +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] +trait Trait<T> {} +impl<T> Trait<T> for () {} + +trait Object<T, U>: Trait<T> + Trait<U> {} + +#[derive(Clone, Copy)] +struct Inv<T>(*mut T); +fn foo<T: Sized, U: Sized>() -> (Inv<dyn Object<T, U>>, Inv<T>) { todo!() } +fn impls_trait<T: Trait<U>, U>(_: Inv<T>, _: Inv<U>) {} + +fn bar() { + let (obj, t) = foo(); + impls_trait(obj, t); + //[next]~^ ERROR type annotations needed + let _: Inv<dyn Object<&(), &()>> = obj; +} + +fn main() {} |
