about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLorrensP-2158466 <lorrens.pantelis@student.uhasselt.be>2025-09-30 19:45:26 +0200
committerLorrensP-2158466 <lorrens.pantelis@student.uhasselt.be>2025-10-01 18:02:16 +0200
commita7eed086b913d708c9f38ce9c833e403f00fc15d (patch)
tree4bde0d8036c886a1df53d56a565267b79a7c7ea7
parenta2db9280539229a3b8a084a09886670a57bc7e9c (diff)
downloadrust-a7eed086b913d708c9f38ce9c833e403f00fc15d.tar.gz
rust-a7eed086b913d708c9f38ce9c833e403f00fc15d.zip
Add the check-pass and check-fail tests.
-rw-r--r--tests/ui/imports/auxiliary/same-res-ambigious-extern-fail.rs16
-rw-r--r--tests/ui/imports/auxiliary/same-res-ambigious-extern-macro.rs8
-rw-r--r--tests/ui/imports/auxiliary/same-res-ambigious-extern.rs11
-rw-r--r--tests/ui/imports/same-res-ambigious.fail.stderr20
-rw-r--r--tests/ui/imports/same-res-ambigious.nightly-fail.stderr20
-rw-r--r--tests/ui/imports/same-res-ambigious.rs11
6 files changed, 86 insertions, 0 deletions
diff --git a/tests/ui/imports/auxiliary/same-res-ambigious-extern-fail.rs b/tests/ui/imports/auxiliary/same-res-ambigious-extern-fail.rs
new file mode 100644
index 00000000000..61a8d8f0054
--- /dev/null
+++ b/tests/ui/imports/auxiliary/same-res-ambigious-extern-fail.rs
@@ -0,0 +1,16 @@
+//@ edition:2018
+//@ proc-macro: same-res-ambigious-extern-macro.rs
+
+macro_rules! globbing{
+    () => {
+        pub use same_res_ambigious_extern_macro::*;
+    }
+}
+
+#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility
+extern crate same_res_ambigious_extern_macro;
+globbing! {} // this imports the same `RustEmbed` macro with `pub` visibility
+
+pub trait RustEmbed {}
+
+pub use RustEmbed as Embed;
diff --git a/tests/ui/imports/auxiliary/same-res-ambigious-extern-macro.rs b/tests/ui/imports/auxiliary/same-res-ambigious-extern-macro.rs
new file mode 100644
index 00000000000..4e9b8427092
--- /dev/null
+++ b/tests/ui/imports/auxiliary/same-res-ambigious-extern-macro.rs
@@ -0,0 +1,8 @@
+//@ edition: 2018
+extern crate proc_macro;
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(RustEmbed)]
+pub fn rust_embed_derive(_input: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
diff --git a/tests/ui/imports/auxiliary/same-res-ambigious-extern.rs b/tests/ui/imports/auxiliary/same-res-ambigious-extern.rs
new file mode 100644
index 00000000000..5269dcd0b17
--- /dev/null
+++ b/tests/ui/imports/auxiliary/same-res-ambigious-extern.rs
@@ -0,0 +1,11 @@
+//@ edition:2018
+//@ proc-macro: same-res-ambigious-extern-macro.rs
+
+#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility
+extern crate same_res_ambigious_extern_macro;
+// this imports the same `RustEmbed` macro with `pub` visibility
+pub use same_res_ambigious_extern_macro::*;
+
+pub trait RustEmbed {}
+
+pub use RustEmbed as Embed;
diff --git a/tests/ui/imports/same-res-ambigious.fail.stderr b/tests/ui/imports/same-res-ambigious.fail.stderr
new file mode 100644
index 00000000000..dfd7c5a5f94
--- /dev/null
+++ b/tests/ui/imports/same-res-ambigious.fail.stderr
@@ -0,0 +1,20 @@
+error[E0603]: derive macro `Embed` is private
+  --> $DIR/same-res-ambigious.rs:8:28
+   |
+LL | #[derive(ambigious_extern::Embed)]
+   |                            ^^^^^ private derive macro
+   |
+note: the derive macro `Embed` is defined here
+  --> $DIR/auxiliary/same-res-ambigious-extern-fail.rs:16:9
+   |
+LL | pub use RustEmbed as Embed;
+   |         ^^^^^^^^^
+help: import `Embed` directly
+   |
+LL - #[derive(ambigious_extern::Embed)]
+LL + #[derive(same_res_ambigious_extern_macro::RustEmbed)]
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0603`.
diff --git a/tests/ui/imports/same-res-ambigious.nightly-fail.stderr b/tests/ui/imports/same-res-ambigious.nightly-fail.stderr
new file mode 100644
index 00000000000..dfd7c5a5f94
--- /dev/null
+++ b/tests/ui/imports/same-res-ambigious.nightly-fail.stderr
@@ -0,0 +1,20 @@
+error[E0603]: derive macro `Embed` is private
+  --> $DIR/same-res-ambigious.rs:8:28
+   |
+LL | #[derive(ambigious_extern::Embed)]
+   |                            ^^^^^ private derive macro
+   |
+note: the derive macro `Embed` is defined here
+  --> $DIR/auxiliary/same-res-ambigious-extern-fail.rs:16:9
+   |
+LL | pub use RustEmbed as Embed;
+   |         ^^^^^^^^^
+help: import `Embed` directly
+   |
+LL - #[derive(ambigious_extern::Embed)]
+LL + #[derive(same_res_ambigious_extern_macro::RustEmbed)]
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0603`.
diff --git a/tests/ui/imports/same-res-ambigious.rs b/tests/ui/imports/same-res-ambigious.rs
new file mode 100644
index 00000000000..b5c13a15b7c
--- /dev/null
+++ b/tests/ui/imports/same-res-ambigious.rs
@@ -0,0 +1,11 @@
+//@ edition: 2018
+//@ revisions: fail pass
+//@[pass] check-pass
+//@[pass] aux-crate: ambigious_extern=same-res-ambigious-extern.rs
+//@[fail] aux-crate: ambigious_extern=same-res-ambigious-extern-fail.rs
+// see https://github.com/rust-lang/rust/pull/147196
+
+#[derive(ambigious_extern::Embed)] //[fail]~ ERROR: derive macro `Embed` is private
+struct Foo{}
+
+fn main(){}