Skip to content

Commit 5c7ae0c

Browse files
committed
Auto merge of #147196 - LorrensP-2158466:same-res-ambiguity-test, r=petrochenkov
Test: Ambigious bindings in same namespace with the same res Add a test based on the discussion [here](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542316157) and related to #145575 (comment). This is the most reduced form I could create that passes on nightly but fails with #145108 (see [#gsoc > Project: Parallel Macro Expansion @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/542335131)). Also not sure about the test names. r? `@petrochenkov`
2 parents 94ecb52 + a7eed08 commit 5c7ae0c

6 files changed

+86
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ edition:2018
2+
//@ proc-macro: same-res-ambigious-extern-macro.rs
3+
4+
macro_rules! globbing{
5+
() => {
6+
pub use same_res_ambigious_extern_macro::*;
7+
}
8+
}
9+
10+
#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility
11+
extern crate same_res_ambigious_extern_macro;
12+
globbing! {} // this imports the same `RustEmbed` macro with `pub` visibility
13+
14+
pub trait RustEmbed {}
15+
16+
pub use RustEmbed as Embed;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ edition: 2018
2+
extern crate proc_macro;
3+
use proc_macro::TokenStream;
4+
5+
#[proc_macro_derive(RustEmbed)]
6+
pub fn rust_embed_derive(_input: TokenStream) -> TokenStream {
7+
TokenStream::new()
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ edition:2018
2+
//@ proc-macro: same-res-ambigious-extern-macro.rs
3+
4+
#[macro_use] // this imports the `RustEmbed` macro with `pub(crate)` visibility
5+
extern crate same_res_ambigious_extern_macro;
6+
// this imports the same `RustEmbed` macro with `pub` visibility
7+
pub use same_res_ambigious_extern_macro::*;
8+
9+
pub trait RustEmbed {}
10+
11+
pub use RustEmbed as Embed;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0603]: derive macro `Embed` is private
2+
--> $DIR/same-res-ambigious.rs:8:28
3+
|
4+
LL | #[derive(ambigious_extern::Embed)]
5+
| ^^^^^ private derive macro
6+
|
7+
note: the derive macro `Embed` is defined here
8+
--> $DIR/auxiliary/same-res-ambigious-extern-fail.rs:16:9
9+
|
10+
LL | pub use RustEmbed as Embed;
11+
| ^^^^^^^^^
12+
help: import `Embed` directly
13+
|
14+
LL - #[derive(ambigious_extern::Embed)]
15+
LL + #[derive(same_res_ambigious_extern_macro::RustEmbed)]
16+
|
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0603`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0603]: derive macro `Embed` is private
2+
--> $DIR/same-res-ambigious.rs:8:28
3+
|
4+
LL | #[derive(ambigious_extern::Embed)]
5+
| ^^^^^ private derive macro
6+
|
7+
note: the derive macro `Embed` is defined here
8+
--> $DIR/auxiliary/same-res-ambigious-extern-fail.rs:16:9
9+
|
10+
LL | pub use RustEmbed as Embed;
11+
| ^^^^^^^^^
12+
help: import `Embed` directly
13+
|
14+
LL - #[derive(ambigious_extern::Embed)]
15+
LL + #[derive(same_res_ambigious_extern_macro::RustEmbed)]
16+
|
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0603`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ edition: 2018
2+
//@ revisions: fail pass
3+
//@[pass] check-pass
4+
//@[pass] aux-crate: ambigious_extern=same-res-ambigious-extern.rs
5+
//@[fail] aux-crate: ambigious_extern=same-res-ambigious-extern-fail.rs
6+
// see https://github.com/rust-lang/rust/pull/147196
7+
8+
#[derive(ambigious_extern::Embed)] //[fail]~ ERROR: derive macro `Embed` is private
9+
struct Foo{}
10+
11+
fn main(){}

0 commit comments

Comments
 (0)