From 9f06585c0e93f835c9e0ceb199d71b8f5679d9d1 Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 12 Mar 2025 22:22:20 -0600 Subject: [PATCH 1/3] improves outer mod attribute test --- .../outer-mod-attr-applies-only-to-first.rs | 16 ++++++++++++ tests/ui/dupe-first-attr.rs | 25 ------------------- 2 files changed, 16 insertions(+), 25 deletions(-) create mode 100644 tests/ui/attributes/outer-mod-attr-applies-only-to-first.rs delete mode 100644 tests/ui/dupe-first-attr.rs 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 0000000000000..ec521c1afb518 --- /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: + +//@ 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/dupe-first-attr.rs b/tests/ui/dupe-first-attr.rs deleted file mode 100644 index c254df050c153..0000000000000 --- 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() {} From 62075593a8077ef7fb123ab6f36522b526b93e47 Mon Sep 17 00:00:00 2001 From: Spencer Date: Thu, 13 Mar 2025 18:07:37 -0600 Subject: [PATCH 2/3] improves duplicate label test --- .../E0381-duplicated-label.rs} | 3 +++ .../E0381-duplicated-label.stderr} | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) rename tests/ui/{duplicate-label-E0381-issue-129274.rs => error-codes/E0381-duplicated-label.rs} (68%) rename tests/ui/{duplicate-label-E0381-issue-129274.stderr => error-codes/E0381-duplicated-label.stderr} (91%) diff --git a/tests/ui/duplicate-label-E0381-issue-129274.rs b/tests/ui/error-codes/E0381-duplicated-label.rs similarity index 68% rename from tests/ui/duplicate-label-E0381-issue-129274.rs rename to tests/ui/error-codes/E0381-duplicated-label.rs index b2156e630c87f..84a85caa65df3 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: 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 similarity index 91% rename from tests/ui/duplicate-label-E0381-issue-129274.stderr rename to tests/ui/error-codes/E0381-duplicated-label.stderr index 7f8bddb17c5a8..36e6d966f09d1 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; | ---- binding declared here but left uninitialized From 27077b94c2f3653151ad7a22e4e77b2efe43be14 Mon Sep 17 00:00:00 2001 From: Spencer Date: Thu, 13 Mar 2025 17:30:30 -0600 Subject: [PATCH 3/3] improves duplicate lang item test --- tests/ui/duplicate_entry_error.rs | 18 ----------------- .../error-codes/E0152-duplicate-lang-items.rs | 20 +++++++++++++++++++ .../E0152-duplicate-lang-items.stderr} | 6 +++--- 3 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 tests/ui/duplicate_entry_error.rs create mode 100644 tests/ui/error-codes/E0152-duplicate-lang-items.rs rename tests/ui/{duplicate_entry_error.stderr => error-codes/E0152-duplicate-lang-items.stderr} (70%) diff --git a/tests/ui/duplicate_entry_error.rs b/tests/ui/duplicate_entry_error.rs deleted file mode 100644 index 5a25802c6e789..0000000000000 --- 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 0000000000000..089810b1ad249 --- /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: + +//@ 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 similarity index 70% rename from tests/ui/duplicate_entry_error.stderr rename to tests/ui/error-codes/E0152-duplicate-lang-items.stderr index 958e9c7527d8c..3c3d64322f3cd 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