diff options
| author | Spencer <spencer3035@gmail.com> | 2025-03-13 17:30:30 -0600 |
|---|---|---|
| committer | Spencer <spencer3035@gmail.com> | 2025-03-15 10:52:08 -0600 |
| commit | 27077b94c2f3653151ad7a22e4e77b2efe43be14 (patch) | |
| tree | 5e637f4b1b35b5ec88fd571de3a5676f4dbdaec0 /tests/ui/error-codes | |
| parent | 62075593a8077ef7fb123ab6f36522b526b93e47 (diff) | |
| download | rust-27077b94c2f3653151ad7a22e4e77b2efe43be14.tar.gz rust-27077b94c2f3653151ad7a22e4e77b2efe43be14.zip | |
improves duplicate lang item test
Diffstat (limited to 'tests/ui/error-codes')
| -rw-r--r-- | tests/ui/error-codes/E0152-duplicate-lang-items.rs | 20 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0152-duplicate-lang-items.stderr | 16 |
2 files changed, 36 insertions, 0 deletions
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/error-codes/E0152-duplicate-lang-items.stderr b/tests/ui/error-codes/E0152-duplicate-lang-items.stderr new file mode 100644 index 00000000000..3c3d64322f3 --- /dev/null +++ b/tests/ui/error-codes/E0152-duplicate-lang-items.stderr @@ -0,0 +1,16 @@ +error[E0152]: found duplicate lang item `panic_impl` + --> $DIR/E0152-duplicate-lang-items.rs:15:1 + | +LL | / fn panic_impl(info: &PanicInfo) -> ! { +LL | | +LL | | loop {} +LL | | } + | |_^ + | + = 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 (`E0152_duplicate_lang_items`) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0152`. |
