Auto merge of #147196 - LorrensP-2158466:same-res-ambiguity-test, r=p… · rust-lang/rust@5c7ae0c (original) (raw)
6 files changed
lines changed
| Original file line number | Diff line number | Diff 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; |
| Original file line number | Diff line number | Diff 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 | +} |
| Original file line number | Diff line number | Diff 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; |
| Original file line number | Diff line number | Diff 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`. |
| Original file line number | Diff line number | Diff 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`. |
| Original file line number | Diff line number | Diff 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(){} |