diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2025-03-20 05:10:41 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2025-03-20 05:10:41 +0000 |
| commit | a6324ba7f321a326568821cc2f8c72275d426db5 (patch) | |
| tree | 0466ad7580406559e6d54e7d7573ce0d91f8f3f1 /tests | |
| parent | c2c50c62e952a1ef4f8882bdbbe503e86b1a1f69 (diff) | |
| parent | ff46ea8253d2d57882de708b281b471fb446cd1d (diff) | |
| download | rust-a6324ba7f321a326568821cc2f8c72275d426db5.tar.gz rust-a6324ba7f321a326568821cc2f8c72275d426db5.zip | |
Merge from rustc
Diffstat (limited to 'tests')
84 files changed, 1474 insertions, 226 deletions
diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs index 8abeecf8550..19f14647c1d 100644 --- a/tests/codegen/alloc-optimisation.rs +++ b/tests/codegen/alloc-optimisation.rs @@ -5,7 +5,7 @@ pub fn alloc_test(data: u32) { // CHECK-LABEL: @alloc_test // CHECK-NEXT: start: - // CHECK-NEXT: {{.*}} load volatile i8, ptr @__rust_no_alloc_shim_is_unstable, align 1 + // CHECK-NEXT: {{.*}} load volatile i8, ptr @{{.*}}__rust_no_alloc_shim_is_unstable, align 1 // CHECK-NEXT: ret void let x = Box::new(data); drop(x); diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs index 7a87bb7983b..f68c399c920 100644 --- a/tests/codegen/asm/goto.rs +++ b/tests/codegen/asm/goto.rs @@ -2,7 +2,7 @@ //@ only-x86_64 #![crate_type = "rlib"] -#![feature(asm_goto, asm_goto_with_outputs)] +#![feature(asm_goto_with_outputs)] use std::arch::asm; diff --git a/tests/codegen/box-uninit-bytes.rs b/tests/codegen/box-uninit-bytes.rs index 3b83ef3e250..0cc01148595 100644 --- a/tests/codegen/box-uninit-bytes.rs +++ b/tests/codegen/box-uninit-bytes.rs @@ -41,6 +41,6 @@ pub fn box_lotsa_padding() -> Box<LotsaPadding> { // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. -// CHECK: declare {{(dso_local )?}}noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] +// CHECK: declare {{(dso_local )?}}noalias noundef ptr @{{.*}}__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) {{(uwtable )?}}"alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen/dealloc-no-unwind.rs b/tests/codegen/dealloc-no-unwind.rs index c560d7a9932..68597817d6f 100644 --- a/tests/codegen/dealloc-no-unwind.rs +++ b/tests/codegen/dealloc-no-unwind.rs @@ -18,7 +18,7 @@ impl Drop for A { #[no_mangle] pub fn a(a: Box<i32>) { // CHECK-LABEL: define{{.*}}void @a - // CHECK: call void @__rust_dealloc + // CHECK: call void @{{.*}}__rust_dealloc // CHECK-NEXT: call void @foo let _a = A; drop(a); diff --git a/tests/codegen/issues/issue-129795.rs b/tests/codegen/issues/issue-129795.rs new file mode 100644 index 00000000000..dc64ee35c97 --- /dev/null +++ b/tests/codegen/issues/issue-129795.rs @@ -0,0 +1,17 @@ +//@ compile-flags: -Copt-level=3 +//@ min-llvm-version: 20 +#![crate_type = "lib"] + +// Ensure that a modulo operation with an operand that is known to be +// a power-of-two is properly optimized. + +// CHECK-LABEL: @modulo_with_power_of_two_divisor +// CHECK: add i64 %divisor, -1 +// CHECK-NEXT: and i64 +// CHECK-NEXT: ret i64 +#[no_mangle] +pub fn modulo_with_power_of_two_divisor(dividend: u64, divisor: u64) -> u64 { + assert!(divisor.is_power_of_two()); + // should be optimized to (dividend & (divisor - 1)) + dividend % divisor +} diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 4dab499a8a5..3bb942d11d5 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -47,7 +47,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN<NotCopy>) -> Option<NotCop #[no_mangle] // CHECK-LABEL: @vec_extend_via_iter_repeat_n pub fn vec_extend_via_iter_repeat_n() -> Vec<u8> { - // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef {{(range\(i64 1, 0\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) + // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @{{.*}}__rust_alloc(i64 noundef {{(range\(i64 1, 0\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, let n = 1234_usize; diff --git a/tests/codegen/sanitizer/cfi/external_weak_symbols.rs b/tests/codegen/sanitizer/cfi/external_weak_symbols.rs new file mode 100644 index 00000000000..00e9b5029af --- /dev/null +++ b/tests/codegen/sanitizer/cfi/external_weak_symbols.rs @@ -0,0 +1,24 @@ +// Verifies that type metadata identifiers for for weakly-linked symbols are +// emitted correctly. +// +//@ needs-sanitizer-cfi +//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +#![crate_type = "bin"] +#![feature(linkage)] + +unsafe extern "C" { + #[linkage = "extern_weak"] + static FOO: Option<unsafe extern "C" fn(f64) -> ()>; +} +// CHECK: @_rust_extern_with_linkage_FOO = internal global ptr @FOO + +fn main() { + unsafe { + if let Some(method) = FOO { + method(4.2); + // CHECK: call i1 @llvm.type.test(ptr {{%method|%0}}, metadata !"_ZTSFvdE") + } + } +} + +// CHECK: declare !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} extern_weak void @FOO(double) unnamed_addr #{{[0-9]+}} diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index 23a084c51f4..3a3453b22b4 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -63,6 +63,57 @@ pub fn result_nop_traits_32(x: Result<i32, u32>) -> Result<i32, u32> { try { x? } } +// CHECK-LABEL: @control_flow_nop_match_32 +#[no_mangle] +pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start: + // CHECK-NEXT: insertvalue { i32, i32 } + // CHECK-NEXT: insertvalue { i32, i32 } + // CHECK-NEXT: ret { i32, i32 } + match x { + Continue(x) => Continue(x), + Break(x) => Break(x), + } +} + +// CHECK-LABEL: @control_flow_nop_traits_32 +#[no_mangle] +pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { + // CHECK: start: + // CHECK-NEXT: insertvalue { i32, i32 } + // CHECK-NEXT: insertvalue { i32, i32 } + // CHECK-NEXT: ret { i32, i32 } + try { x? } +} + +// CHECK-LABEL: @option_nop_match_64 +#[no_mangle] +pub fn option_nop_match_64(x: Option<u64>) -> Option<u64> { + // CHECK: start: + // TWENTY-NEXT: %[[TRUNC:[0-9]+]] = trunc nuw i64 %0 to i1 + // TWENTY-NEXT: %[[SEL:\.[0-9]+]] = select i1 %[[TRUNC]], i64 %1, i64 undef + // CHECK-NEXT: [[REG1:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } poison, i64 %0, 0 + // NINETEEN-NEXT: [[REG2:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } [[REG1]], i64 %1, 1 + // TWENTY-NEXT: [[REG2:%[0-9a-zA-Z_.]+]] = insertvalue { i64, i64 } [[REG1]], i64 %[[SEL]], 1 + // CHECK-NEXT: ret { i64, i64 } [[REG2]] + match x { + Some(x) => Some(x), + None => None, + } +} + +// CHECK-LABEL: @option_nop_traits_64 +#[no_mangle] +pub fn option_nop_traits_64(x: Option<u64>) -> Option<u64> { + // CHECK: start: + // TWENTY-NEXT: %[[TRUNC:[0-9]+]] = trunc nuw i64 %0 to i1 + // TWENTY-NEXT: %[[SEL:\.[0-9]+]] = select i1 %[[TRUNC]], i64 %1, i64 undef + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: ret { i64, i64 } + try { x? } +} + // CHECK-LABEL: @result_nop_match_64 #[no_mangle] pub fn result_nop_match_64(x: Result<i64, u64>) -> Result<i64, u64> { @@ -86,48 +137,98 @@ pub fn result_nop_traits_64(x: Result<i64, u64>) -> Result<i64, u64> { try { x? } } -// CHECK-LABEL: @result_nop_match_ptr +// CHECK-LABEL: @control_flow_nop_match_64 #[no_mangle] -pub fn result_nop_match_ptr(x: Result<usize, Box<()>>) -> Result<usize, Box<()>> { +pub fn control_flow_nop_match_64(x: ControlFlow<i64, u64>) -> ControlFlow<i64, u64> { // CHECK: start: - // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } - // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } - // CHECK-NEXT: ret + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: ret { i64, i64 } + match x { + Continue(x) => Continue(x), + Break(x) => Break(x), + } +} + +// CHECK-LABEL: @control_flow_nop_traits_64 +#[no_mangle] +pub fn control_flow_nop_traits_64(x: ControlFlow<i64, u64>) -> ControlFlow<i64, u64> { + // CHECK: start: + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: insertvalue { i64, i64 } + // CHECK-NEXT: ret { i64, i64 } + try { x? } +} + +// CHECK-LABEL: @result_nop_match_128 +#[no_mangle] +pub fn result_nop_match_128(x: Result<i128, u128>) -> Result<i128, u128> { + // CHECK: start: + // CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8 + // CHECK-NEXT: store i128 + // CHECK-NEXT: store i128 + // CHECK-NEXT: ret void match x { Ok(x) => Ok(x), Err(x) => Err(x), } } -// CHECK-LABEL: @result_nop_traits_ptr +// CHECK-LABEL: @result_nop_traits_128 #[no_mangle] -pub fn result_nop_traits_ptr(x: Result<u64, NonNull<()>>) -> Result<u64, NonNull<()>> { +pub fn result_nop_traits_128(x: Result<i128, u128>) -> Result<i128, u128> { // CHECK: start: - // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } - // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } - // CHECK-NEXT: ret + // CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8 + // CHECK-NEXT: store i128 + // CHECK-NEXT: store i128 + // CHECK-NEXT: ret void try { x? } } -// CHECK-LABEL: @control_flow_nop_match_32 +// CHECK-LABEL: @control_flow_nop_match_128 #[no_mangle] -pub fn control_flow_nop_match_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { +pub fn control_flow_nop_match_128(x: ControlFlow<i128, u128>) -> ControlFlow<i128, u128> { // CHECK: start: - // CHECK-NEXT: insertvalue { i32, i32 } - // CHECK-NEXT: insertvalue { i32, i32 } - // CHECK-NEXT: ret { i32, i32 } + // CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8 + // CHECK-NEXT: store i128 + // CHECK-NEXT: store i128 + // CHECK-NEXT: ret void match x { Continue(x) => Continue(x), Break(x) => Break(x), } } -// CHECK-LABEL: @control_flow_nop_traits_32 +// CHECK-LABEL: @control_flow_nop_traits_128 #[no_mangle] -pub fn control_flow_nop_traits_32(x: ControlFlow<i32, u32>) -> ControlFlow<i32, u32> { +pub fn control_flow_nop_traits_128(x: ControlFlow<i128, u128>) -> ControlFlow<i128, u128> { // CHECK: start: - // CHECK-NEXT: insertvalue { i32, i32 } - // CHECK-NEXT: insertvalue { i32, i32 } - // CHECK-NEXT: ret { i32, i32 } + // CHECK-NEXT: getelementptr inbounds {{(nuw )?}}i8 + // CHECK-NEXT: store i128 + // CHECK-NEXT: store i128 + // CHECK-NEXT: ret void + try { x? } +} + +// CHECK-LABEL: @result_nop_match_ptr +#[no_mangle] +pub fn result_nop_match_ptr(x: Result<usize, Box<()>>) -> Result<usize, Box<()>> { + // CHECK: start: + // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } + // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } + // CHECK-NEXT: ret + match x { + Ok(x) => Ok(x), + Err(x) => Err(x), + } +} + +// CHECK-LABEL: @result_nop_traits_ptr +#[no_mangle] +pub fn result_nop_traits_ptr(x: Result<u64, NonNull<()>>) -> Result<u64, NonNull<()>> { + // CHECK: start: + // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } + // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } + // CHECK-NEXT: ret try { x? } } diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index 2e2769ce130..d1c320ead01 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -177,6 +177,6 @@ pub fn vec_option_i32(n: usize) -> Vec<Option<i32>> { } // Ensure that __rust_alloc_zeroed gets the right attributes for LLVM to optimize it away. -// CHECK: declare noalias noundef ptr @__rust_alloc_zeroed(i64 noundef, i64 allocalign noundef) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] +// CHECK: declare noalias noundef ptr @{{.*}}__rust_alloc_zeroed(i64 noundef, i64 allocalign noundef) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ZEROED_ATTRS]] = { {{.*}} allockind("alloc,zeroed,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs index 39d5c1614c8..f6ed2898bda 100644 --- a/tests/codegen/vec-optimizes-away.rs +++ b/tests/codegen/vec-optimizes-away.rs @@ -5,7 +5,7 @@ pub fn sum_me() -> i32 { // CHECK-LABEL: @sum_me // CHECK-NEXT: {{^.*:$}} - // CHECK-NEXT: {{.*}} load volatile i8, ptr @__rust_no_alloc_shim_is_unstable, align 1 + // CHECK-NEXT: {{.*}} load volatile i8, ptr @{{.*}}__rust_no_alloc_shim_is_unstable, align 1 // CHECK-NEXT: ret i32 6 vec![1, 2, 3].iter().sum::<i32>() } diff --git a/tests/crashes/136286.rs b/tests/crashes/136286.rs deleted file mode 100644 index f0ea14bd167..00000000000 --- a/tests/crashes/136286.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #136286 -//@ compile-flags: --edition=2024 - -#![feature(async_fn_in_dyn_trait)] -trait A { - async fn b(self: A); -} diff --git a/tests/crashes/137706.rs b/tests/crashes/137706.rs deleted file mode 100644 index 0b46f9c237a..00000000000 --- a/tests/crashes/137706.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #137706 -//@ needs-rustc-debug-assertions -trait A { - fn b() -> impl IntoIterator<Item = ()>; -} - -impl A<()> for dyn A {} diff --git a/tests/crashes/137895.rs b/tests/crashes/137895.rs deleted file mode 100644 index bb624d2e9fa..00000000000 --- a/tests/crashes/137895.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ known-bug: #137895 -trait A { - fn b() -> impl ?Sized + 'a; -} - -impl A for dyn A {} 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 e9f48a85f9c..8e1cdb7182b 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -26,7 +26,6 @@ debug a => _9; } -+ coverage body span: $DIR/branch_match_arms.rs:14:11: 21:2 (#0) + coverage Code { bcb: bcb0 } => $DIR/branch_match_arms.rs:14:1: 15:21 (#0); + coverage Code { bcb: bcb1 } => $DIR/branch_match_arms.rs:16:17: 16:33 (#0); + coverage Code { bcb: bcb3 } => $DIR/branch_match_arms.rs:17:17: 17:33 (#0); diff --git a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff index cbef6de917d..06e5f011c76 100644 --- a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff @@ -4,8 +4,7 @@ fn bar() -> bool { let mut _0: bool; -+ coverage body span: $DIR/instrument_coverage.rs:29:18: 31:2 (#0) -+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 31:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27: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 b166d79a412..1a71cb8dea7 100644 --- a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff @@ -7,12 +7,11 @@ let mut _2: bool; let mut _3: !; -+ coverage body span: $DIR/instrument_coverage.rs:14:11: 20:2 (#0) -+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:14:1: 14:11 (#0); -+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:16:12: 16:17 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:17:13: 17:18 (#0); -+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:18:10: 18:10 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:20:2: 20:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:11 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:17 (#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); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage.rs b/tests/mir-opt/coverage/instrument_coverage.rs index 48647402d0f..d4ed4b67375 100644 --- a/tests/mir-opt/coverage/instrument_coverage.rs +++ b/tests/mir-opt/coverage/instrument_coverage.rs @@ -7,7 +7,6 @@ // EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff // CHECK-LABEL: fn main() -// CHECK: coverage body span: // CHECK: coverage Code { bcb: bcb{{[0-9]+}} } => // CHECK: bb0: // CHECK: Coverage::VirtualCounter @@ -21,7 +20,6 @@ fn main() { // EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff // CHECK-LABEL: fn bar() -// CHECK: coverage body span: // CHECK: coverage Code { bcb: bcb{{[0-9]+}} } => // CHECK: bb0: // CHECK: Coverage::VirtualCounter 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 855f806aae1..1a22adeba6f 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -7,7 +7,6 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) - coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0) coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 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); 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 df1f1e8bc50..b77969a3e16 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -7,7 +7,6 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) -+ coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0) + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 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); diff --git a/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff new file mode 100644 index 00000000000..e28d04f1d58 --- /dev/null +++ b/tests/mir-opt/gvn_on_unsafe_binder.propagate.GVN.diff @@ -0,0 +1,35 @@ +- // MIR for `propagate` before GVN ++ // MIR for `propagate` after GVN + + fn propagate() -> unsafe<> i32 { + let mut _0: unsafe<> i32; + let _1: i32; + let mut _3: i32; + scope 1 { + debug x => _1; + let _2: unsafe<> i32; + scope 2 { + debug binder => _2; + } + } + + bb0: { +- StorageLive(_1); ++ nop; + _1 = const 1_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = copy _1; +- _2 = wrap_binder!(move _3; unsafe<> i32); ++ _3 = const 1_i32; ++ _2 = const {transmute(0x00000001): unsafe<> i32}; + StorageDead(_3); +- _0 = move _2; ++ _0 = const {transmute(0x00000001): unsafe<> i32}; + StorageDead(_2); +- StorageDead(_1); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn_on_unsafe_binder.rs b/tests/mir-opt/gvn_on_unsafe_binder.rs new file mode 100644 index 00000000000..b3c0576f990 --- /dev/null +++ b/tests/mir-opt/gvn_on_unsafe_binder.rs @@ -0,0 +1,29 @@ +// skip-filecheck +//@ test-mir-pass: GVN + +// EMIT_MIR gvn_on_unsafe_binder.test.GVN.diff +// EMIT_MIR gvn_on_unsafe_binder.propagate.GVN.diff + +#![feature(unsafe_binders)] + +use std::unsafe_binder::wrap_binder; + +// Test for ICE <https://github.com/rust-lang/rust/issues/137846>. +fn test() { + unsafe { + let x = 1; + let binder: unsafe<'a> &'a i32 = wrap_binder!(&x); + } +} + +// Test that GVN propagates const values through unsafe binders. +// +// The lifetime `'a` is redundant (and doesn't print when we print out the type). +// However, we need it so that rustfmt doesn't rip out the `unsafe<>` part for now. +fn propagate() -> unsafe<'a> i32 { + unsafe { + let x = 1; + let binder: unsafe<'a> i32 = wrap_binder!(x); + binder + } +} diff --git a/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff b/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff new file mode 100644 index 00000000000..33814fb34f3 --- /dev/null +++ b/tests/mir-opt/gvn_on_unsafe_binder.test.GVN.diff @@ -0,0 +1,30 @@ +- // MIR for `test` before GVN ++ // MIR for `test` after GVN + + fn test() -> () { + let mut _0: (); + let _1: i32; + let mut _3: &i32; + scope 1 { + debug x => _1; + let _2: unsafe<'a> &'a i32; + scope 2 { + debug binder => _2; + } + } + + bb0: { + StorageLive(_1); + _1 = const 1_i32; + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + _2 = wrap_binder!(move _3; unsafe<'a> &'a i32); + StorageDead(_3); + _0 = const (); + StorageDead(_2); + StorageDead(_1); + return; + } + } + diff --git a/tests/run-make/linker-warning/rmake.rs b/tests/run-make/linker-warning/rmake.rs index 73ad248b6f3..bc21739fefc 100644 --- a/tests/run-make/linker-warning/rmake.rs +++ b/tests/run-make/linker-warning/rmake.rs @@ -4,7 +4,7 @@ fn run_rustc() -> Rustc { let mut rustc = rustc(); rustc .arg("main.rs") - // NOTE: `link-self-contained` can vary depending on config.toml. + // NOTE: `link-self-contained` can vary depending on bootstrap.toml. // Make sure we use a consistent value. .arg("-Clink-self-contained=-linker") .arg("-Zunstable-options") diff --git a/tests/run-make/symbols-all-mangled/a_lib.rs b/tests/run-make/symbols-all-mangled/a_lib.rs new file mode 100644 index 00000000000..716dd3263c5 --- /dev/null +++ b/tests/run-make/symbols-all-mangled/a_lib.rs @@ -0,0 +1 @@ +pub fn public_rust_function() {} diff --git a/tests/run-make/symbols-all-mangled/an_executable.rs b/tests/run-make/symbols-all-mangled/an_executable.rs new file mode 100644 index 00000000000..db8df13b9a7 --- /dev/null +++ b/tests/run-make/symbols-all-mangled/an_executable.rs @@ -0,0 +1,3 @@ +pub fn public_rust_function_from_exe() {} + +fn main() {} diff --git a/tests/run-make/symbols-all-mangled/rmake.rs b/tests/run-make/symbols-all-mangled/rmake.rs new file mode 100644 index 00000000000..81f2678e55c --- /dev/null +++ b/tests/run-make/symbols-all-mangled/rmake.rs @@ -0,0 +1,84 @@ +// Check that all symbols in cdylibs, staticlibs and bins are mangled +//@ only-elf some object file formats create multiple symbols for each function with different names + +use run_make_support::object::read::{Object, ObjectSymbol}; +use run_make_support::{bin_name, dynamic_lib_name, object, rfs, rustc, static_lib_name}; + +fn main() { + let staticlib_name = static_lib_name("a_lib"); + let cdylib_name = dynamic_lib_name("a_lib"); + let exe_name = bin_name("an_executable"); + rustc().crate_type("cdylib").input("a_lib.rs").run(); + rustc().crate_type("staticlib").input("a_lib.rs").run(); + rustc().crate_type("bin").input("an_executable.rs").run(); + + symbols_check_archive(&staticlib_name); + symbols_check(&cdylib_name); + symbols_check(&exe_name); +} + +fn symbols_check_archive(path: &str) { + let binary_data = rfs::read(path); + let file = object::read::archive::ArchiveFile::parse(&*binary_data).unwrap(); + for symbol in file.symbols().unwrap().unwrap() { + let symbol = symbol.unwrap(); + let name = strip_underscore_if_apple(std::str::from_utf8(symbol.name()).unwrap()); + if name.starts_with("_ZN") || name.starts_with("_R") { + continue; // Correctly mangled + } + + let member_name = + std::str::from_utf8(file.member(symbol.offset()).unwrap().name()).unwrap(); + if !member_name.ends_with(".rcgu.o") || member_name.contains("compiler_builtins") { + continue; // All compiler-builtins symbols must remain unmangled + } + + if name == "__rust_no_alloc_shim_is_unstable" { + continue; // FIXME remove exception once we mangle this symbol + } + + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } + + panic!("Unmangled symbol found: {name}"); + } +} + +fn symbols_check(path: &str) { + let binary_data = rfs::read(path); + let file = object::File::parse(&*binary_data).unwrap(); + for symbol in file.symbols() { + if !symbol.is_definition() || !symbol.is_global() { + continue; + } + if symbol.is_weak() { + continue; // Likely an intrinsic from compiler-builtins + } + let name = strip_underscore_if_apple(symbol.name().unwrap()); + if name.starts_with("_ZN") || name.starts_with("_R") { + continue; // Correctly mangled + } + + if !name.contains("rust") { + // Assume that this symbol doesn't originate from rustc. This may + // be wrong, but even if so symbol_check_archive will likely + // catch it. + continue; + } + + if name == "__rust_no_alloc_shim_is_unstable" { + continue; // FIXME remove exception once we mangle this symbol + } + + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } + + panic!("Unmangled symbol found: {name}"); + } +} + +fn strip_underscore_if_apple(symbol: &str) -> &str { + if cfg!(target_vendor = "apple") { symbol.strip_prefix("_").unwrap() } else { symbol } +} diff --git a/tests/rustdoc-json/attrs/deprecated.rs b/tests/rustdoc-json/attrs/deprecated.rs new file mode 100644 index 00000000000..5cde7af841f --- /dev/null +++ b/tests/rustdoc-json/attrs/deprecated.rs @@ -0,0 +1,38 @@ +//@ is "$.index[*][?(@.name=='not')].attrs" [] +//@ is "$.index[*][?(@.name=='not')].deprecation" null +pub fn not() {} + +//@ is "$.index[*][?(@.name=='raw')].attrs" [] +//@ is "$.index[*][?(@.name=='raw')].deprecation" '{"since": null, "note": null}' +#[deprecated] +pub fn raw() {} + +//@ is "$.index[*][?(@.name=='equals_string')].attrs" [] +//@ is "$.index[*][?(@.name=='equals_string')].deprecation" '{"since": null, "note": "here is a reason"}' +#[deprecated = "here is a reason"] +pub fn equals_string() {} + +//@ is "$.index[*][?(@.name=='since')].attrs" [] +//@ is "$.index[*][?(@.name=='since')].deprecation" '{"since": "yoinks ago", "note": null}' +#[deprecated(since = "yoinks ago")] +pub fn since() {} + +//@ is "$.index[*][?(@.name=='note')].attrs" [] +//@ is "$.index[*][?(@.name=='note')].deprecation" '{"since": null, "note": "7"}' +#[deprecated(note = "7")] +pub fn note() {} + +//@ is "$.index[*][?(@.name=='since_and_note')].attrs" [] +//@ is "$.index[*][?(@.name=='since_and_note')].deprecation" '{"since": "tomorrow", "note": "sorry"}' +#[deprecated(since = "tomorrow", note = "sorry")] +pub fn since_and_note() {} + +//@ is "$.index[*][?(@.name=='note_and_since')].attrs" [] +//@ is "$.index[*][?(@.name=='note_and_since')].deprecation" '{"since": "a year from tomorrow", "note": "your welcome"}' +#[deprecated(note = "your welcome", since = "a year from tomorrow")] +pub fn note_and_since() {} + +//@ is "$.index[*][?(@.name=='neither_but_parens')].attrs" [] +//@ is "$.index[*][?(@.name=='neither_but_parens')].deprecation" '{"since": null, "note": null}' +#[deprecated()] +pub fn neither_but_parens() {} diff --git a/tests/rustdoc-json/attrs/repr_align.rs b/tests/rustdoc-json/attrs/repr_align.rs new file mode 100644 index 00000000000..bebbe1fea34 --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_align.rs @@ -0,0 +1,8 @@ +#![no_std] + +//@ is "$.index[*][?(@.name=='Aligned')].attrs" '["#[attr = Repr([ReprAlign(Align(4 bytes))])]\n"]' +#[repr(align(4))] +pub struct Aligned { + a: i8, + b: i64, +} diff --git a/tests/rustdoc-json/attrs/repr_c.rs b/tests/rustdoc-json/attrs/repr_c.rs new file mode 100644 index 00000000000..609d33d94de --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_c.rs @@ -0,0 +1,18 @@ +#![no_std] + +//@ is "$.index[*][?(@.name=='ReprCStruct')].attrs" '["#[attr = Repr([ReprC])]\n"]' +#[repr(C)] +pub struct ReprCStruct(pub i64); + +//@ is "$.index[*][?(@.name=='ReprCEnum')].attrs" '["#[attr = Repr([ReprC])]\n"]' +#[repr(C)] +pub enum ReprCEnum { + First, +} + +//@ is "$.index[*][?(@.name=='ReprCUnion')].attrs" '["#[attr = Repr([ReprC])]\n"]' +#[repr(C)] +pub union ReprCUnion { + pub left: i64, + pub right: u64, +} diff --git a/tests/rustdoc-json/attrs/repr_combination.rs b/tests/rustdoc-json/attrs/repr_combination.rs new file mode 100644 index 00000000000..662bfef67cb --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_combination.rs @@ -0,0 +1,78 @@ +#![no_std] + +// Combinations of `#[repr(..)]` attributes. + +//@ is "$.index[*][?(@.name=='ReprCI8')].attrs" '["#[attr = Repr([ReprC, ReprInt(SignedInt(I8))])]\n"]' +#[repr(C, i8)] +pub enum ReprCI8 { + First, +} + +//@ is "$.index[*][?(@.name=='SeparateReprCI16')].attrs" '["#[attr = Repr([ReprC, ReprInt(SignedInt(I16))])]\n"]' +#[repr(C)] +#[repr(i16)] +pub enum SeparateReprCI16 { + First, +} + +//@ is "$.index[*][?(@.name=='ReversedReprCUsize')].attrs" '["#[attr = Repr([ReprInt(UnsignedInt(Usize)), ReprC])]\n"]' +#[repr(usize, C)] +pub enum ReversedReprCUsize { + First, +} + +//@ is "$.index[*][?(@.name=='ReprCPacked')].attrs" '["#[attr = Repr([ReprC, ReprPacked(Align(1 bytes))])]\n"]' +#[repr(C, packed)] +pub struct ReprCPacked { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='SeparateReprCPacked')].attrs" '["#[attr = Repr([ReprC, ReprPacked(Align(2 bytes))])]\n"]' +#[repr(C)] +#[repr(packed(2))] +pub struct SeparateReprCPacked { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='ReversedReprCPacked')].attrs" '["#[attr = Repr([ReprPacked(Align(2 bytes)), ReprC])]\n"]' +#[repr(packed(2), C)] +pub struct ReversedReprCPacked { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='ReprCAlign')].attrs" '["#[attr = Repr([ReprC, ReprAlign(Align(16 bytes))])]\n"]' +#[repr(C, align(16))] +pub struct ReprCAlign { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='SeparateReprCAlign')].attrs" '["#[attr = Repr([ReprC, ReprAlign(Align(2 bytes))])]\n"]' +#[repr(C)] +#[repr(align(2))] +pub struct SeparateReprCAlign { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='ReversedReprCAlign')].attrs" '["#[attr = Repr([ReprAlign(Align(2 bytes)), ReprC])]\n"]' +#[repr(align(2), C)] +pub struct ReversedReprCAlign { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='AlignedExplicitRepr')].attrs" '["#[attr = Repr([ReprC, ReprAlign(Align(16 bytes)), ReprInt(SignedInt(Isize))])]\n"]' +#[repr(C, align(16), isize)] +pub enum AlignedExplicitRepr { + First, +} + +//@ is "$.index[*][?(@.name=='ReorderedAlignedExplicitRepr')].attrs" '["#[attr = Repr([ReprInt(SignedInt(Isize)), ReprC, ReprAlign(Align(16 bytes))])]\n"]' +#[repr(isize, C, align(16))] +pub enum ReorderedAlignedExplicitRepr { + First, +} diff --git a/tests/rustdoc-json/attrs/repr_int_enum.rs b/tests/rustdoc-json/attrs/repr_int_enum.rs new file mode 100644 index 00000000000..2ad57de2798 --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_int_enum.rs @@ -0,0 +1,19 @@ +#![no_std] + +//@ is "$.index[*][?(@.name=='I8')].attrs" '["#[attr = Repr([ReprInt(SignedInt(I8))])]\n"]' +#[repr(i8)] +pub enum I8 { + First, +} + +//@ is "$.index[*][?(@.name=='I32')].attrs" '["#[attr = Repr([ReprInt(SignedInt(I32))])]\n"]' +#[repr(i32)] +pub enum I32 { + First, +} + +//@ is "$.index[*][?(@.name=='Usize')].attrs" '["#[attr = Repr([ReprInt(UnsignedInt(Usize))])]\n"]' +#[repr(usize)] +pub enum Usize { + First, +} diff --git a/tests/rustdoc-json/attrs/repr_packed.rs b/tests/rustdoc-json/attrs/repr_packed.rs new file mode 100644 index 00000000000..33acc23b7c8 --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_packed.rs @@ -0,0 +1,18 @@ +#![no_std] + +// Note the normalization: +// `#[repr(packed)]` in has the implict "1" in rustdoc JSON. + +//@ is "$.index[*][?(@.name=='Packed')].attrs" '["#[attr = Repr([ReprPacked(Align(1 bytes))])]\n"]' +#[repr(packed)] +pub struct Packed { + a: i8, + b: i64, +} + +//@ is "$.index[*][?(@.name=='PackedAligned')].attrs" '["#[attr = Repr([ReprPacked(Align(4 bytes))])]\n"]' +#[repr(packed(4))] +pub struct PackedAligned { + a: i8, + b: i64, +} diff --git a/tests/rustdoc-json/attrs/repr_transparent.rs b/tests/rustdoc-json/attrs/repr_transparent.rs new file mode 100644 index 00000000000..ef6e69f8703 --- /dev/null +++ b/tests/rustdoc-json/attrs/repr_transparent.rs @@ -0,0 +1,22 @@ +#![no_std] + +// Rustdoc JSON currently includes `#[repr(transparent)]` +// even if the transparency is not part of the public API +// +// https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent + +//@ is "$.index[*][?(@.name=='Transparent')].attrs" '["#[attr = Repr([ReprTransparent])]\n"]' +#[repr(transparent)] +pub struct Transparent(pub i64); + +//@ is "$.index[*][?(@.name=='TransparentNonPub')].attrs" '["#[attr = Repr([ReprTransparent])]\n"]' +#[repr(transparent)] +pub struct TransparentNonPub(i64); + +//@ is "$.index[*][?(@.name=='AllZst')].attrs" '["#[attr = Repr([ReprTransparent])]\n"]' +#[repr(transparent)] +pub struct AllZst<'a>(pub core::marker::PhantomData<&'a ()>, ()); + +//@ is "$.index[*][?(@.name=='AllZstNotPublic')].attrs" '["#[attr = Repr([ReprTransparent])]\n"]' +#[repr(transparent)] +pub struct AllZstNotPublic<'a>(core::marker::PhantomData<&'a ()>, ()); diff --git a/tests/rustdoc-json/return-type-notation.rs b/tests/rustdoc-json/return-type-notation.rs new file mode 100644 index 00000000000..2219642bfc5 --- /dev/null +++ b/tests/rustdoc-json/return-type-notation.rs @@ -0,0 +1,18 @@ +//@ edition: 2021 +// ignore-tidy-linelength + +#![crate_type = "lib"] +#![feature(return_type_notation)] + +pub trait Foo { + async fn bar(); +} + +//@ is "$.index[*][?(@.name=='foo')].inner.function.generics.params[0].kind.type.bounds[0].trait_bound.trait.args.angle_bracketed.constraints[0].args" '"return_type_notation"' +//@ ismany "$.index[*][?(@.name=='foo')].inner.function.generics.where_predicates[*].bound_predicate.type.qualified_path.args" '"return_type_notation"' '"return_type_notation"' +pub fn foo<T: Foo<bar(..): Send>>() +where + <T as Foo>::bar(..): 'static, + T::bar(..): Sync, +{ +} diff --git a/tests/rustdoc-ui/remap-path-prefix-macro.rs b/tests/rustdoc-ui/remap-path-prefix-macro.rs new file mode 100644 index 00000000000..1be22694b8c --- /dev/null +++ b/tests/rustdoc-ui/remap-path-prefix-macro.rs @@ -0,0 +1,9 @@ +// Regression test for "attempted to remap an already remapped filename" ICE in rustdoc +// when using --remap-path-prefix with macro rendering. +// <https://github.com/rust-lang/rust/issues/138520> + +//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path +//@ rustc-env:RUST_BACKTRACE=0 +//@ build-pass + +macro_rules! f(() => {}); diff --git a/tests/rustdoc/return-type-notation.rs b/tests/rustdoc/return-type-notation.rs new file mode 100644 index 00000000000..405e98eb28d --- /dev/null +++ b/tests/rustdoc/return-type-notation.rs @@ -0,0 +1,18 @@ +//@ edition: 2021 + +#![crate_type = "lib"] +#![feature(return_type_notation)] + +pub trait Foo { + async fn bar(); +} + +//@ has "return_type_notation/fn.foo.html" +//@ has - '//pre[@class="rust item-decl"]' "pub fn foo<T: Foo<bar(..): Send>>()" +//@ has - '//pre[@class="rust item-decl"]' "where <T as Foo>::bar(..): 'static, T::bar(..): Sync" +pub fn foo<T: Foo<bar(..): Send>>() +where + <T as Foo>::bar(..): 'static, + T::bar(..): Sync, +{ +} diff --git a/tests/ui/asm/x86_64/bad-options.rs b/tests/ui/asm/x86_64/bad-options.rs index 6424a1b1d42..123febc06fc 100644 --- a/tests/ui/asm/x86_64/bad-options.rs +++ b/tests/ui/asm/x86_64/bad-options.rs @@ -1,6 +1,6 @@ //@ only-x86_64 -#![feature(asm_unwind, asm_goto)] +#![feature(asm_unwind)] use std::arch::{asm, global_asm}; diff --git a/tests/ui/asm/x86_64/goto-block-safe.rs b/tests/ui/asm/x86_64/goto-block-safe.rs index ee833a48a4b..b739e9f9ced 100644 --- a/tests/ui/asm/x86_64/goto-block-safe.rs +++ b/tests/ui/asm/x86_64/goto-block-safe.rs @@ -2,7 +2,6 @@ //@ needs-asm-support #![deny(unreachable_code)] -#![feature(asm_goto)] use std::arch::asm; diff --git a/tests/ui/asm/x86_64/goto-block-safe.stderr b/tests/ui/asm/x86_64/goto-block-safe.stderr index 49818db7484..ee7313bc8be 100644 --- a/tests/ui/asm/x86_64/goto-block-safe.stderr +++ b/tests/ui/asm/x86_64/goto-block-safe.stderr @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function `unreachable_unchecked` is unsafe and requires unsafe function or block - --> $DIR/goto-block-safe.rs:14:17 + --> $DIR/goto-block-safe.rs:13:17 | LL | unsafe { | ------ items do not inherit unsafety from separate enclosing items diff --git a/tests/ui/asm/x86_64/goto.rs b/tests/ui/asm/x86_64/goto.rs index 50e7441509a..00a8e588f96 100644 --- a/tests/ui/asm/x86_64/goto.rs +++ b/tests/ui/asm/x86_64/goto.rs @@ -3,7 +3,7 @@ //@ needs-asm-support #![deny(unreachable_code)] -#![feature(asm_goto, asm_goto_with_outputs)] +#![feature(asm_goto_with_outputs)] use std::arch::asm; diff --git a/tests/ui/async-await/async-closures/imm-deref-lending.rs b/tests/ui/async-await/async-closures/imm-deref-lending.rs new file mode 100644 index 00000000000..59f8d434d9c --- /dev/null +++ b/tests/ui/async-await/async-closures/imm-deref-lending.rs @@ -0,0 +1,46 @@ +//@ edition: 2021 +//@ check-pass + +#![feature(impl_trait_in_bindings)] + +struct FooS { + precise: i32, +} + +fn ref_inside_mut(f: &mut &FooS) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn mut_inside_ref(f: &&mut FooS) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn mut_ref_inside_mut(f: &mut &mut FooS) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn ref_inside_box(f: Box<&FooS>) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn box_inside_ref(f: &Box<FooS>) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn box_inside_box(f: Box<Box<FooS>>) { + let x: impl AsyncFn() = async move || { + let y = &f.precise; + }; +} + +fn main() {} diff --git a/tests/ui/async-await/async-closures/imm-deref-not-lending.rs b/tests/ui/async-await/async-closures/imm-deref-not-lending.rs new file mode 100644 index 00000000000..bd1197cc636 --- /dev/null +++ b/tests/ui/async-await/async-closures/imm-deref-not-lending.rs @@ -0,0 +1,49 @@ +//@ edition: 2021 + +#![feature(impl_trait_in_bindings)] + +struct FooS { + precise: i32, +} + +fn ref_inside_mut(f: &mut &FooS) { + let x: impl Fn() -> _ = async move || { + let y = &f.precise; + }; +} + +fn mut_inside_ref(f: &&mut FooS) { + let x: impl Fn() -> _ = async move || { + let y = &f.precise; + }; +} + +// Expected to fail, no immutable reference here. +fn mut_ref_inside_mut(f: &mut &mut FooS) { + let x: impl Fn() -> _ = async move || { + //~^ ERROR async closure does not implement `Fn` + let y = &f.precise; + }; +} + +fn ref_inside_box(f: Box<&FooS>) { + let x: impl Fn() -> _ = async move || { + let y = &f.precise; + }; +} + +fn box_inside_ref(f: &Box<FooS>) { + let x: impl Fn() -> _ = async move || { + let y = &f.precise; + }; +} + +// Expected to fail, no immutable reference here. +fn box_inside_box(f: Box<Box<FooS>>) { + let x: impl Fn() -> _ = async move || { + //~^ ERROR async closure does not implement `Fn` + let y = &f.precise; + }; +} + +fn main() {} diff --git a/tests/ui/async-await/async-closures/imm-deref-not-lending.stderr b/tests/ui/async-await/async-closures/imm-deref-not-lending.stderr new file mode 100644 index 00000000000..cd3ff55e458 --- /dev/null +++ b/tests/ui/async-await/async-closures/imm-deref-not-lending.stderr @@ -0,0 +1,14 @@ +error: async closure does not implement `Fn` because it captures state from its environment + --> $DIR/imm-deref-not-lending.rs:23:29 + | +LL | let x: impl Fn() -> _ = async move || { + | ^^^^^^^^^^^^^ + +error: async closure does not implement `Fn` because it captures state from its environment + --> $DIR/imm-deref-not-lending.rs:43:29 + | +LL | let x: impl Fn() -> _ = async move || { + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/async-await/dyn/mut-is-pointer-like.rs b/tests/ui/async-await/dyn/mut-is-pointer-like.rs index 93e8281164c..a82567e372e 100644 --- a/tests/ui/async-await/dyn/mut-is-pointer-like.rs +++ b/tests/ui/async-await/dyn/mut-is-pointer-like.rs @@ -1,11 +1,9 @@ //@ aux-build:block-on.rs //@ edition: 2021 -//@ run-pass -//@ check-run-results +//@ known-bug: #133119 #![allow(refining_impl_trait)] #![feature(async_fn_in_dyn_trait)] -//~^ WARN the feature `async_fn_in_dyn_trait` is incomplete extern crate block_on; diff --git a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr index 7c72ce43cf0..bf20473924b 100644 --- a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr +++ b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_dyn_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/mut-is-pointer-like.rs:7:12 + --> $DIR/mut-is-pointer-like.rs:6:12 | LL | #![feature(async_fn_in_dyn_trait)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,5 +7,65 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: see issue #133119 <https://github.com/rust-lang/rust/issues/133119> for more information = note: `#[warn(incomplete_features)]` on by default -warning: 1 warning emitted +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/mut-is-pointer-like.rs:35:16 + | +LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mut-is-pointer-like.rs:16:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +... +LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/mut-is-pointer-like.rs:35:56 + | +LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f; + | ^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mut-is-pointer-like.rs:16:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +... +LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait<Output = ()>>` + +error[E0277]: the trait bound `dyn AsyncTrait<Output = ()>: AsyncTrait` is not satisfied + --> $DIR/mut-is-pointer-like.rs:36:11 + | +LL | x.async_dispatch().await; + | ^^^^^^^^^^^^^^ the trait `AsyncTrait` is not implemented for `dyn AsyncTrait<Output = ()>` + +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/mut-is-pointer-like.rs:36:9 + | +LL | x.async_dispatch().await; + | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mut-is-pointer-like.rs:16:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +... +LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + +error: aborting due to 4 previous errors; 1 warning emitted +Some errors have detailed explanations: E0038, E0277. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/dyn/works.rs b/tests/ui/async-await/dyn/works.rs index 0732a3ee2f2..f406a7b593f 100644 --- a/tests/ui/async-await/dyn/works.rs +++ b/tests/ui/async-await/dyn/works.rs @@ -1,11 +1,9 @@ //@ aux-build:block-on.rs //@ edition: 2021 -//@ run-pass -//@ check-run-results +//@ known-bug: #133119 #![allow(refining_impl_trait)] #![feature(async_fn_in_dyn_trait)] -//~^ WARN the feature `async_fn_in_dyn_trait` is incomplete extern crate block_on; diff --git a/tests/ui/async-await/dyn/works.stderr b/tests/ui/async-await/dyn/works.stderr index 2c7db7c32f5..47abeab5aac 100644 --- a/tests/ui/async-await/dyn/works.stderr +++ b/tests/ui/async-await/dyn/works.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_dyn_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/works.rs:7:12 + --> $DIR/works.rs:6:12 | LL | #![feature(async_fn_in_dyn_trait)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,5 +7,75 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: see issue #133119 <https://github.com/rust-lang/rust/issues/133119> for more information = note: `#[warn(incomplete_features)]` on by default -warning: 1 warning emitted +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/works.rs:27:34 + | +LL | let x: &dyn AsyncTrait = &"hello, world!"; + | ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/works.rs:14:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. + = note: required for the cast from `&&'static str` to `&dyn AsyncTrait` + +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/works.rs:27:16 + | +LL | let x: &dyn AsyncTrait = &"hello, world!"; + | ^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/works.rs:14:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. + +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/works.rs:28:11 + | +LL | x.async_dispatch().await; + | ^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/works.rs:14:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. + +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/works.rs:28:9 + | +LL | x.async_dispatch().await; + | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/works.rs:14:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. + +error: aborting due to 4 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/dyn/wrong-size.rs b/tests/ui/async-await/dyn/wrong-size.rs index ac15dd26067..f5fce3648ac 100644 --- a/tests/ui/async-await/dyn/wrong-size.rs +++ b/tests/ui/async-await/dyn/wrong-size.rs @@ -1,7 +1,7 @@ //@ edition: 2021 +//@ known-bug: #133119 #![feature(async_fn_in_dyn_trait)] -//~^ WARN the feature `async_fn_in_dyn_trait` is incomplete use std::future::Future; @@ -19,5 +19,5 @@ impl AsyncTrait for &'static str { fn main() { let x: &dyn AsyncTrait = &"hello, world!"; - //~^ ERROR `impl Future<Output = ()>` needs to have the same ABI as a pointer + // FIXME ~^ ERROR `impl Future<Output = ()>` needs to have the same ABI as a pointer } diff --git a/tests/ui/async-await/dyn/wrong-size.stderr b/tests/ui/async-await/dyn/wrong-size.stderr index 0202b5f2409..b4684f4fc17 100644 --- a/tests/ui/async-await/dyn/wrong-size.stderr +++ b/tests/ui/async-await/dyn/wrong-size.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_dyn_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/wrong-size.rs:3:12 + --> $DIR/wrong-size.rs:4:12 | LL | #![feature(async_fn_in_dyn_trait)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,15 +7,41 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: see issue #133119 <https://github.com/rust-lang/rust/issues/133119> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0277]: `impl Future<Output = ()>` needs to have the same ABI as a pointer +error[E0038]: the trait `AsyncTrait` is not dyn compatible --> $DIR/wrong-size.rs:21:30 | LL | let x: &dyn AsyncTrait = &"hello, world!"; - | ^^^^^^^^^^^^^^^^ `impl Future<Output = ()>` needs to be a pointer-like type + | ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible | - = help: the trait `for<'a> PointerLike` is not implemented for `impl Future<Output = ()>` +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/wrong-size.rs:9:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. = note: required for the cast from `&&'static str` to `&dyn AsyncTrait` -error: aborting due to 1 previous error; 1 warning emitted +error[E0038]: the trait `AsyncTrait` is not dyn compatible + --> $DIR/wrong-size.rs:21:12 + | +LL | let x: &dyn AsyncTrait = &"hello, world!"; + | ^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/wrong-size.rs:9:14 + | +LL | trait AsyncTrait { + | ---------- this trait is not dyn compatible... +LL | async fn async_dispatch(&self); + | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` + = help: consider moving `async_dispatch` to another trait + = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. + +error: aborting due to 2 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/attributes/outer-mod-attr-applies-only-to-first.rs b/tests/ui/attributes/outer-mod-attr-applies-only-to-first.rs new file mode 100644 index 00000000000..ec521c1afb5 --- /dev/null +++ b/tests/ui/attributes/outer-mod-attr-applies-only-to-first.rs @@ -0,0 +1,16 @@ +//! Regression test to check that outer attributes applied to the first module item is applied to +//! its attached module item only, and not also to other subsequent module items +//! +//! Commit: <https://github.com/rust-lang/rust/commit/7aee9f7b56f8d96f9444ebb1d06e32e024b81974> + +//@ check-pass +//@ compile-flags: --cfg=first +//@ no-auto-check-cfg + +#[cfg(first)] +mod hello {} + +#[cfg(not_set)] +mod hello {} + +fn main() {} diff --git a/tests/ui/cast/cast_lit_suffix-issue-138392.fixed b/tests/ui/cast/cast_lit_suffix-issue-138392.fixed new file mode 100644 index 00000000000..c6fbd09f89c --- /dev/null +++ b/tests/ui/cast/cast_lit_suffix-issue-138392.fixed @@ -0,0 +1,6 @@ +//@ run-rustfix +#![allow(unused_parens)] +fn main() { + let _x: u8 = (4u8); //~ ERROR: mismatched types + let _y: u8 = (4u8); //~ ERROR: mismatched types +} diff --git a/tests/ui/cast/cast_lit_suffix-issue-138392.rs b/tests/ui/cast/cast_lit_suffix-issue-138392.rs new file mode 100644 index 00000000000..86dbbbbf126 --- /dev/null +++ b/tests/ui/cast/cast_lit_suffix-issue-138392.rs @@ -0,0 +1,6 @@ +//@ run-rustfix +#![allow(unused_parens)] +fn main() { + let _x: u8 = (4i32); //~ ERROR: mismatched types + let _y: u8 = (4.0f32); //~ ERROR: mismatched types +} diff --git a/tests/ui/cast/cast_lit_suffix-issue-138392.stderr b/tests/ui/cast/cast_lit_suffix-issue-138392.stderr new file mode 100644 index 00000000000..998fcfc36dc --- /dev/null +++ b/tests/ui/cast/cast_lit_suffix-issue-138392.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/cast_lit_suffix-issue-138392.rs:4:18 + | +LL | let _x: u8 = (4i32); + | -- ^^^^^^ expected `u8`, found `i32` + | | + | expected due to this + | +help: change the type of the numeric literal from `i32` to `u8` + | +LL - let _x: u8 = (4i32); +LL + let _x: u8 = (4u8); + | + +error[E0308]: mismatched types + --> $DIR/cast_lit_suffix-issue-138392.rs:5:18 + | +LL | let _y: u8 = (4.0f32); + | -- ^^^^^^^^ expected `u8`, found `f32` + | | + | expected due to this + | +help: change the type of the numeric literal from `f32` to `u8` + | +LL - let _y: u8 = (4.0f32); +LL + let _y: u8 = (4u8); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dupe-first-attr.rs b/tests/ui/dupe-first-attr.rs deleted file mode 100644 index c254df050c1..00000000000 --- a/tests/ui/dupe-first-attr.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass - -// Regression test for a problem with the first mod attribute -// being applied to every mod - - -#[cfg(target_os = "linux")] -mod hello {} - -#[cfg(target_os = "macos")] -mod hello {} - -#[cfg(target_os = "windows")] -mod hello {} - -#[cfg(target_os = "freebsd")] -mod hello {} - -#[cfg(target_os = "dragonfly")] -mod hello {} - -#[cfg(target_os = "android")] -mod hello {} - -fn main() {} diff --git a/tests/ui/duplicate_entry_error.rs b/tests/ui/duplicate_entry_error.rs deleted file mode 100644 index 5a25802c6e7..00000000000 --- a/tests/ui/duplicate_entry_error.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib" -// note-pattern: first defined in crate `std`. - -// Test for issue #31788 and E0152 - -#![feature(lang_items)] - -extern crate core; - -use core::panic::PanicInfo; - -#[lang = "panic_impl"] -fn panic_impl(info: &PanicInfo) -> ! { -//~^ ERROR: found duplicate lang item `panic_impl` - loop {} -} - -fn main() {} diff --git a/tests/ui/error-codes/E0152-duplicate-lang-items.rs b/tests/ui/error-codes/E0152-duplicate-lang-items.rs new file mode 100644 index 00000000000..089810b1ad2 --- /dev/null +++ b/tests/ui/error-codes/E0152-duplicate-lang-items.rs @@ -0,0 +1,20 @@ +//! Validates the correct printing of E0152 in the case of duplicate "lang_item" function +//! definitions. +//! +//! Issue: <https://github.com/rust-lang/rust/issues/31788> + +//@ error-pattern: first defined in crate `std` +//@ normalize-stderr: "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib" +#![feature(lang_items)] + +extern crate core; + +use core::panic::PanicInfo; + +#[lang = "panic_impl"] +fn panic_impl(info: &PanicInfo) -> ! { + //~^ ERROR: found duplicate lang item `panic_impl` + loop {} +} + +fn main() {} diff --git a/tests/ui/duplicate_entry_error.stderr b/tests/ui/error-codes/E0152-duplicate-lang-items.stderr index 958e9c7527d..3c3d64322f3 100644 --- a/tests/ui/duplicate_entry_error.stderr +++ b/tests/ui/error-codes/E0152-duplicate-lang-items.stderr @@ -1,5 +1,5 @@ error[E0152]: found duplicate lang item `panic_impl` - --> $DIR/duplicate_entry_error.rs:13:1 + --> $DIR/E0152-duplicate-lang-items.rs:15:1 | LL | / fn panic_impl(info: &PanicInfo) -> ! { LL | | @@ -7,9 +7,9 @@ LL | | loop {} LL | | } | |_^ | - = note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on) + = note: the lang item is first defined in crate `std` (which `E0152_duplicate_lang_items` depends on) = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib - = note: second definition in the local crate (`duplicate_entry_error`) + = note: second definition in the local crate (`E0152_duplicate_lang_items`) error: aborting due to 1 previous error diff --git a/tests/ui/duplicate-label-E0381-issue-129274.rs b/tests/ui/error-codes/E0381-duplicated-label.rs index b2156e630c8..84a85caa65d 100644 --- a/tests/ui/duplicate-label-E0381-issue-129274.rs +++ b/tests/ui/error-codes/E0381-duplicated-label.rs @@ -1,3 +1,6 @@ +//! Regression test for duplicated label in E0381 error message. +//! +//! Issue: <https://github.com/rust-lang/rust/issues/129274> fn main() { fn test() { loop { diff --git a/tests/ui/duplicate-label-E0381-issue-129274.stderr b/tests/ui/error-codes/E0381-duplicated-label.stderr index 7f8bddb17c5..36e6d966f09 100644 --- a/tests/ui/duplicate-label-E0381-issue-129274.stderr +++ b/tests/ui/error-codes/E0381-duplicated-label.stderr @@ -1,5 +1,5 @@ error[E0381]: used binding `blah` is possibly-uninitialized - --> $DIR/duplicate-label-E0381-issue-129274.rs:8:33 + --> $DIR/E0381-duplicated-label.rs:11:33 | LL | let blah: Option<String>; | ---- binding declared here but left uninitialized diff --git a/tests/ui/feature-gates/feature-gate-asm_goto.rs b/tests/ui/feature-gates/feature-gate-asm_goto.rs deleted file mode 100644 index beac4590349..00000000000 --- a/tests/ui/feature-gates/feature-gate-asm_goto.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ only-x86_64 - -use std::arch::asm; - -fn main() { - unsafe { - asm!("jmp {}", label {}); - //~^ ERROR label operands for inline assembly are unstable - } -} diff --git a/tests/ui/feature-gates/feature-gate-asm_goto.stderr b/tests/ui/feature-gates/feature-gate-asm_goto.stderr deleted file mode 100644 index 62fd1a320d3..00000000000 --- a/tests/ui/feature-gates/feature-gate-asm_goto.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: label operands for inline assembly are unstable - --> $DIR/feature-gate-asm_goto.rs:7:24 - | -LL | asm!("jmp {}", label {}); - | ^^^^^^^^ - | - = note: see issue #119364 <https://github.com/rust-lang/rust/issues/119364> for more information - = help: add `#![feature(asm_goto)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs index 294827f78d2..26b7d5d2fbf 100644 --- a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs +++ b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs @@ -1,7 +1,5 @@ //@ only-x86_64 -#![feature(asm_goto)] - use std::arch::asm; fn main() { diff --git a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr index ff7a7d5760a..06e11301565 100644 --- a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr +++ b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr @@ -1,5 +1,5 @@ error[E0658]: using both label and output operands for inline assembly is unstable - --> $DIR/feature-gate-asm_goto_with_outputs.rs:10:52 + --> $DIR/feature-gate-asm_goto_with_outputs.rs:8:52 | LL | asm!("mov {}, 1", "jmp {}", out(reg) _out, label {}); | ^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-print-check-cfg.rs b/tests/ui/feature-gates/feature-gate-print-check-cfg.rs deleted file mode 100644 index 304e0c132e5..00000000000 --- a/tests/ui/feature-gates/feature-gate-print-check-cfg.rs +++ /dev/null @@ -1,3 +0,0 @@ -//@ compile-flags: --print=check-cfg - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-print-check-cfg.stderr b/tests/ui/feature-gates/feature-gate-print-check-cfg.stderr deleted file mode 100644 index 62ee44b94a4..00000000000 --- a/tests/ui/feature-gates/feature-gate-print-check-cfg.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the `-Z unstable-options` flag must also be passed to enable the check-cfg print option - diff --git a/tests/ui/loops/label-on-block-suggest-move.rs b/tests/ui/loops/label-on-block-suggest-move.rs new file mode 100644 index 00000000000..656034cd0e9 --- /dev/null +++ b/tests/ui/loops/label-on-block-suggest-move.rs @@ -0,0 +1,90 @@ +// see https://github.com/rust-lang/rust/issues/138585 +#![allow(break_with_label_and_loop)] // doesn't work locally + +fn main() { + loop 'a: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + while false 'a: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + for i in [0] 'a: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + 'a: loop { + // first block is parsed as the break expr's value with or without parens + while break 'a 'b: {} 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + while break 'a ('b: {}) 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + + // without the parens, the first block is parsed as the while-loop's body + // (see the 'no errors' section) + // #[allow(break_with_label_and_loop)] (doesn't work locally) + while (break 'a {}) 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: if you meant to label the loop, move this label before the loop + } + + // do not suggest moving the label if there is already a label on the loop + 'a: loop 'b: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + 'a: while false 'b: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + 'a: for i in [0] 'b: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + 'a: loop { + // first block is parsed as the break expr's value with or without parens + 'd: while break 'a 'b: {} 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + 'd: while break 'a ('b: {}) 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + + // without the parens, the first block is parsed as the while-loop's body + // (see the 'no errors' section) + // #[allow(break_with_label_and_loop)] (doesn't work locally) + 'd: while (break 'a {}) 'c: {} + //~^ ERROR: block label not supported here + //~| HELP: remove this block label + } + + // no errors + loop { 'a: {} } + 'a: loop { 'b: {} } + while false { 'a: {} } + 'a: while false { 'b: {} } + for i in [0] { 'a: {} } + 'a: for i in [0] { 'b: {} } + 'a: {} + 'a: { 'b: {} } + 'a: loop { + // first block is parsed as the break expr's value if it is a labeled block + while break 'a 'b: {} {} + 'd: while break 'a 'b: {} {} + while break 'a ('b: {}) {} + 'd: while break 'a ('b: {}) {} + // first block is parsed as the while-loop's body if it has no label + // (the break expr is parsed as having no value), + // so the second block is a normal stmt-block, and the label is allowed + while break 'a {} 'c: {} + while break 'a {} {} + 'd: while break 'a {} 'c: {} + 'd: while break 'a {} {} + } + + // unrelated errors that should not be affected + 'a: 'b: {} + //~^ ERROR: expected `while`, `for`, `loop` or `{` after a label + //~| HELP: consider removing the label + loop { while break 'b: {} {} } + //~^ ERROR: parentheses are required around this expression to avoid confusion with a labeled break expression + //~| HELP: wrap the expression in parentheses + //~| ERROR: `break` or `continue` with no label in the condition of a `while` loop [E0590] +} diff --git a/tests/ui/loops/label-on-block-suggest-move.stderr b/tests/ui/loops/label-on-block-suggest-move.stderr new file mode 100644 index 00000000000..66866703ca6 --- /dev/null +++ b/tests/ui/loops/label-on-block-suggest-move.stderr @@ -0,0 +1,140 @@ +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:5:10 + | +LL | loop 'a: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - loop 'a: {} +LL + 'a: loop {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:8:17 + | +LL | while false 'a: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - while false 'a: {} +LL + 'a: while false {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:11:18 + | +LL | for i in [0] 'a: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - for i in [0] 'a: {} +LL + 'a: for i in [0] {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:16:31 + | +LL | while break 'a 'b: {} 'c: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - while break 'a 'b: {} 'c: {} +LL + 'c: while break 'a 'b: {} {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:19:33 + | +LL | while break 'a ('b: {}) 'c: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - while break 'a ('b: {}) 'c: {} +LL + 'c: while break 'a ('b: {}) {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:26:29 + | +LL | while (break 'a {}) 'c: {} + | ^^^ not supported here + | +help: if you meant to label the loop, move this label before the loop + | +LL - while (break 'a {}) 'c: {} +LL + 'c: while (break 'a {}) {} + | + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:32:14 + | +LL | 'a: loop 'b: {} + | ^^^ not supported here + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:35:21 + | +LL | 'a: while false 'b: {} + | ^^^ not supported here + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:38:22 + | +LL | 'a: for i in [0] 'b: {} + | ^^^ not supported here + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:43:35 + | +LL | 'd: while break 'a 'b: {} 'c: {} + | ^^^ not supported here + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:46:37 + | +LL | 'd: while break 'a ('b: {}) 'c: {} + | ^^^ not supported here + +error: block label not supported here + --> $DIR/label-on-block-suggest-move.rs:53:33 + | +LL | 'd: while (break 'a {}) 'c: {} + | ^^^ not supported here + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/label-on-block-suggest-move.rs:83:9 + | +LL | 'a: 'b: {} + | ^^ expected `while`, `for`, `loop` or `{` after a label + | +help: consider removing the label + | +LL - 'a: 'b: {} +LL + 'b: {} + | + +error: parentheses are required around this expression to avoid confusion with a labeled break expression + --> $DIR/label-on-block-suggest-move.rs:86:24 + | +LL | loop { while break 'b: {} {} } + | ^^^^^^ + | +help: wrap the expression in parentheses + | +LL | loop { while break ('b: {}) {} } + | + + + +error[E0590]: `break` or `continue` with no label in the condition of a `while` loop + --> $DIR/label-on-block-suggest-move.rs:86:18 + | +LL | loop { while break 'b: {} {} } + | ^^^^^^^^^^^^ unlabeled `break` in the condition of a `while` loop + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0590`. diff --git a/tests/ui/macros/duplicate-builtin.rs b/tests/ui/macros/duplicate-builtin.rs deleted file mode 100644 index c75782128f4..00000000000 --- a/tests/ui/macros/duplicate-builtin.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ compile-flags:--crate-type lib -#![feature(decl_macro)] -#![feature(rustc_attrs)] - -#[rustc_builtin_macro] -pub macro test($item:item) { -//~^ NOTE previously defined - /* compiler built-in */ -} - -mod inner { - #[rustc_builtin_macro] - pub macro test($item:item) { - //~^ ERROR attempted to define built-in macro more than once [E0773] - /* compiler built-in */ - } -} diff --git a/tests/ui/macros/duplicate-builtin.stderr b/tests/ui/macros/duplicate-builtin.stderr deleted file mode 100644 index 887a4fbbdc8..00000000000 --- a/tests/ui/macros/duplicate-builtin.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0773]: attempted to define built-in macro more than once - --> $DIR/duplicate-builtin.rs:13:5 - | -LL | / pub macro test($item:item) { -LL | | -LL | | /* compiler built-in */ -LL | | } - | |_____^ - | -note: previously defined here - --> $DIR/duplicate-builtin.rs:6:1 - | -LL | / pub macro test($item:item) { -LL | | -LL | | /* compiler built-in */ -LL | | } - | |_^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0773`. diff --git a/tests/ui/macros/unknown-builtin.rs b/tests/ui/macros/unknown-builtin.rs index 048f5d68d34..aa6e04d3fb8 100644 --- a/tests/ui/macros/unknown-builtin.rs +++ b/tests/ui/macros/unknown-builtin.rs @@ -1,12 +1,11 @@ -//@ error-pattern: attempted to define built-in macro more than once - #![feature(rustc_attrs)] #[rustc_builtin_macro] macro_rules! unknown { () => () } //~ ERROR cannot find a built-in macro with name `unknown` +// Defining another `line` builtin macro should not cause an error. #[rustc_builtin_macro] -macro_rules! line { () => () } //~ NOTE previously defined here +macro_rules! line { () => () } fn main() { line!(); diff --git a/tests/ui/macros/unknown-builtin.stderr b/tests/ui/macros/unknown-builtin.stderr index 22f54e04e54..1a83398891b 100644 --- a/tests/ui/macros/unknown-builtin.stderr +++ b/tests/ui/macros/unknown-builtin.stderr @@ -1,18 +1,8 @@ error: cannot find a built-in macro with name `unknown` - --> $DIR/unknown-builtin.rs:6:1 + --> $DIR/unknown-builtin.rs:4:1 | LL | macro_rules! unknown { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0773]: attempted to define built-in macro more than once - --> $SRC_DIR/core/src/macros/mod.rs:LL:COL - | -note: previously defined here - --> $DIR/unknown-builtin.rs:9:1 - | -LL | macro_rules! line { () => () } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0773`. diff --git a/tests/ui/match/privately-uninhabited-issue-137999.rs b/tests/ui/match/privately-uninhabited-issue-137999.rs new file mode 100644 index 00000000000..918393a0c6a --- /dev/null +++ b/tests/ui/match/privately-uninhabited-issue-137999.rs @@ -0,0 +1,44 @@ +//@ edition:2024 +//@ check-fail + +mod m { + enum Void {} + + pub struct Internal { + _v: Void, + } + + pub enum Test { + A(u32, u32), + B(Internal), + } +} + +use m::Test; + +pub fn f1(x: &mut Test) { + let r1: &mut u32 = match x { + Test::A(a, _) => a, + _ => todo!(), + }; + + let r2: &mut u32 = match x { //~ ERROR cannot use `*x` because it was mutably borrowed + Test::A(_, b) => b, + _ => todo!(), + }; + + let _ = *r1; + let _ = *r2; +} + +pub fn f2(x: &mut Test) { + let r = &mut *x; + match x { //~ ERROR cannot use `*x` because it was mutably borrowed + Test::A(_, _) => {} + _ => {} + } + + let _ = r; +} + +fn main() {} diff --git a/tests/ui/match/privately-uninhabited-issue-137999.stderr b/tests/ui/match/privately-uninhabited-issue-137999.stderr new file mode 100644 index 00000000000..6f74a75375e --- /dev/null +++ b/tests/ui/match/privately-uninhabited-issue-137999.stderr @@ -0,0 +1,26 @@ +error[E0503]: cannot use `*x` because it was mutably borrowed + --> $DIR/privately-uninhabited-issue-137999.rs:25:30 + | +LL | Test::A(a, _) => a, + | - `x.0` is borrowed here +... +LL | let r2: &mut u32 = match x { + | ^ use of borrowed `x.0` +... +LL | let _ = *r1; + | --- borrow later used here + +error[E0503]: cannot use `*x` because it was mutably borrowed + --> $DIR/privately-uninhabited-issue-137999.rs:36:11 + | +LL | let r = &mut *x; + | ------- `*x` is borrowed here +LL | match x { + | ^ use of borrowed `*x` +... +LL | let _ = r; + | - borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.fixed b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.fixed index 85b1853c23b..922c883f4f7 100644 --- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.fixed +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.fixed @@ -1,16 +1,17 @@ //@ run-rustfix +//@ revisions: current next +//@[next] compile-flags: -Znext-solver #![allow(unused_variables, dead_code)] -use std::collections::BTreeMap; -use std::collections::HashSet; +use std::collections::{BTreeMap, HashSet}; -#[derive(Debug,Eq,PartialEq,Hash)] +#[derive(Debug, Eq, PartialEq, Hash)] #[derive(Clone)] enum Day { Mon, } struct Class { - days: BTreeMap<u32, HashSet<Day>> + days: BTreeMap<u32, HashSet<Day>>, } impl Class { diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr index 6a9d76f7998..301f3c3a458 100644 --- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:18:39 + --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:19:39 | LL | let mut x: HashSet<Day> = v.clone(); | ------------ ^^^^^^^^^ expected `HashSet<Day>`, found `&HashSet<Day>` @@ -9,7 +9,7 @@ LL | let mut x: HashSet<Day> = v.clone(); = note: expected struct `HashSet<_>` found reference `&HashSet<_>` note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead - --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:18:39 + --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:19:39 | LL | let mut x: HashSet<Day> = v.clone(); | ^ diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.fixed b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.fixed new file mode 100644 index 00000000000..922c883f4f7 --- /dev/null +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.fixed @@ -0,0 +1,31 @@ +//@ run-rustfix +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +#![allow(unused_variables, dead_code)] +use std::collections::{BTreeMap, HashSet}; + +#[derive(Debug, Eq, PartialEq, Hash)] +#[derive(Clone)] +enum Day { + Mon, +} + +struct Class { + days: BTreeMap<u32, HashSet<Day>>, +} + +impl Class { + fn do_stuff(&self) { + for (_, v) in &self.days { + let mut x: HashSet<Day> = v.clone(); //~ ERROR + let y: Vec<Day> = x.drain().collect(); + println!("{:?}", x); + } + } +} + +fn fail() { + let c = Class { days: BTreeMap::new() }; + c.do_stuff(); +} +fn main() {} diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr new file mode 100644 index 00000000000..301f3c3a458 --- /dev/null +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.next.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:19:39 + | +LL | let mut x: HashSet<Day> = v.clone(); + | ------------ ^^^^^^^^^ expected `HashSet<Day>`, found `&HashSet<Day>` + | | + | expected due to this + | + = note: expected struct `HashSet<_>` + found reference `&HashSet<_>` +note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead + --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:19:39 + | +LL | let mut x: HashSet<Day> = v.clone(); + | ^ + = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied +help: consider annotating `Day` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | enum Day { + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.rs b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.rs index 740cda470d9..6f7b55be8bd 100644 --- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.rs +++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.rs @@ -1,15 +1,16 @@ //@ run-rustfix +//@ revisions: current next +//@[next] compile-flags: -Znext-solver #![allow(unused_variables, dead_code)] -use std::collections::BTreeMap; -use std::collections::HashSet; +use std::collections::{BTreeMap, HashSet}; -#[derive(Debug,Eq,PartialEq,Hash)] +#[derive(Debug, Eq, PartialEq, Hash)] enum Day { Mon, } struct Class { - days: BTreeMap<u32, HashSet<Day>> + days: BTreeMap<u32, HashSet<Day>>, } impl Class { diff --git a/tests/ui/print-request/stability.rs b/tests/ui/print-request/stability.rs new file mode 100644 index 00000000000..b205b055569 --- /dev/null +++ b/tests/ui/print-request/stability.rs @@ -0,0 +1,103 @@ +//! Check that we properly gate unstable print requests (`--print=KIND`) and require the user to +//! specify `-Z unstable-options` to use unstable print requests. + +// We don't care about the exact *stdout* output (i.e. what the print requests actually give back) +// for the purposes of this test. +//@ dont-check-compiler-stdout + +// We want to check for the core error message of the unstable print requests being `-Z +// unstable-options`-gated and not the help because the help can change with addition of a new print +// request, which is not important for the purposes of this test. +//@ dont-check-compiler-stderr + +// ======================= +// Unstable print requests +// ======================= + +//@ revisions: all_target_specs_json +//@[all_target_specs_json] compile-flags: --print=all-target-specs-json +//@[all_target_specs_json] error-pattern: the `-Z unstable-options` flag must also be passed + +//@ revisions: check_cfg +//@[check_cfg] compile-flags: --print=check-cfg +//@[check_cfg] error-pattern: the `-Z unstable-options` flag must also be passed + +//@ revisions: target_spec_json +//@[target_spec_json] compile-flags: --print=target-spec-json +//@[target_spec_json] error-pattern: the `-Z unstable-options` flag must also be passed + +// ======================= +// Stable print requests +// ======================= + +//@ revisions: calling_conventions +//@[calling_conventions] compile-flags: --print=calling-conventions +//@[calling_conventions] check-pass + +//@ revisions: cfg +//@[cfg] compile-flags: --print=cfg +//@[cfg] check-pass + +//@ revisions: code_models +//@[code_models] compile-flags: --print=code-models +//@[code_models] check-pass + +//@ revisions: crate_name +//@[crate_name] compile-flags: --print=crate-name +//@[crate_name] check-pass + +// Note: `--print=deployment_target` is only accepted on Apple targets. +//@ revisions: deployment_target +//@[deployment_target] only-apple +//@[deployment_target] compile-flags: --print=deployment-target +//@[deployment_target] check-pass + +//@ revisions: file_names +//@[file_names] compile-flags: --print=file-names +//@[file_names] check-pass + +//@ revisions: host_tuple +//@[host_tuple] compile-flags: --print=host-tuple +//@[host_tuple] check-pass + +//@ revisions: link_args +//@[link_args] compile-flags: --print=link-args +//@[link_args] check-pass + +//@ revisions: native_static_libs +//@[native_static_libs] compile-flags: --print=native-static-libs +//@[native_static_libs] check-pass + +//@ revisions: relocation_models +//@[relocation_models] compile-flags: --print=relocation-models +//@[relocation_models] check-pass + +//@ revisions: split_debuginfo +//@[split_debuginfo] compile-flags: --print=split-debuginfo +//@[split_debuginfo] check-pass + +//@ revisions: stack_protector_strategies +//@[stack_protector_strategies] compile-flags: --print=stack-protector-strategies +//@[stack_protector_strategies] check-pass + +//@ revisions: target_cpus +//@[target_cpus] compile-flags: --print=target-cpus +//@[target_cpus] check-pass + +//@ revisions: target_features +//@[target_features] compile-flags: --print=target-features +//@[target_features] check-pass + +//@ revisions: target_libdir +//@[target_libdir] compile-flags: --print=target-libdir +//@[target_libdir] check-pass + +//@ revisions: target_list +//@[target_list] compile-flags: --print=target-list +//@[target_list] check-pass + +//@ revisions: tls_models +//@[tls_models] compile-flags: --print=tls-models +//@[tls_models] check-pass + +fn main() {} diff --git a/tests/ui/tool-attributes/crate-attr.rs b/tests/ui/tool-attributes/crate-attr.rs new file mode 100644 index 00000000000..c6d7974945f --- /dev/null +++ b/tests/ui/tool-attributes/crate-attr.rs @@ -0,0 +1,5 @@ +//@ check-pass +//@ compile-flags: -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(foo) + +#[allow(foo::bar)] +fn main() {} diff --git a/tests/ui/tool-attributes/multiple-registered.rs b/tests/ui/tool-attributes/multiple-registered.rs new file mode 100644 index 00000000000..4d54c2dcb08 --- /dev/null +++ b/tests/ui/tool-attributes/multiple-registered.rs @@ -0,0 +1,7 @@ +//@ check-pass + +#![feature(register_tool)] +#![register_tool(foo, bar, baz)] + +#[allow(foo::a, bar::b, baz::c)] +fn main() {} diff --git a/tests/ui/tool-attributes/nested-disallowed.rs b/tests/ui/tool-attributes/nested-disallowed.rs new file mode 100644 index 00000000000..8e780427761 --- /dev/null +++ b/tests/ui/tool-attributes/nested-disallowed.rs @@ -0,0 +1,4 @@ +#![feature(register_tool)] +#![register_tool(foo::bar)] //~ ERROR only accepts identifiers + +fn main() {} diff --git a/tests/ui/tool-attributes/nested-disallowed.stderr b/tests/ui/tool-attributes/nested-disallowed.stderr new file mode 100644 index 00000000000..1af73fc2f19 --- /dev/null +++ b/tests/ui/tool-attributes/nested-disallowed.stderr @@ -0,0 +1,8 @@ +error: `register_tool` only accepts identifiers + --> $DIR/nested-disallowed.rs:2:18 + | +LL | #![register_tool(foo::bar)] + | ^^^^^^^^ not an identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/write-fmt-errors.rs b/tests/ui/write-fmt-errors.rs index 1dafb9a784b..b48fa3f11cc 100644 --- a/tests/ui/write-fmt-errors.rs +++ b/tests/ui/write-fmt-errors.rs @@ -4,7 +4,7 @@ #![feature(io_error_uncategorized)] use std::fmt; -use std::io::{self, Error, Write, sink}; +use std::io::{self, Error, Write}; use std::panic::catch_unwind; struct ErrorDisplay; @@ -33,7 +33,7 @@ fn main() { assert!(res.is_err(), "writer error did not propagate"); // Test that the error from the formatter is detected. - let res = catch_unwind(|| write!(sink(), "{} {} {}", 1, ErrorDisplay, "bar")); + let res = catch_unwind(|| write!(vec![], "{} {} {}", 1, ErrorDisplay, "bar")); let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap(); assert!( err.contains("formatting trait implementation returned an error"), |
