resolve: Assign pub and pub(crate) visibilities to macro_rules items
This commit is contained in:
parent
1190f7cdf7
commit
099b3d86f9
3 changed files with 20 additions and 43 deletions
|
|
@ -1,15 +1,14 @@
|
|||
// edition:2018
|
||||
|
||||
// For the time being `macro_rules` items are treated as *very* private...
|
||||
|
||||
#![feature(decl_macro, uniform_paths)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
mod m1 {
|
||||
// Non-exported legacy macros are treated as `pub(crate)`.
|
||||
macro_rules! legacy_macro { () => () }
|
||||
|
||||
// ... so they can't be imported by themselves, ...
|
||||
use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
use legacy_macro as _; // OK
|
||||
pub(crate) use legacy_macro as _; // OK
|
||||
pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
|
|
@ -17,7 +16,7 @@ mod m2 {
|
|||
|
||||
type legacy_macro = u8;
|
||||
|
||||
// ... but don't prevent names from other namespaces from being imported, ...
|
||||
// Legacy macro imports don't prevent names from other namespaces from being imported.
|
||||
use legacy_macro as _; // OK
|
||||
}
|
||||
|
||||
|
|
@ -27,19 +26,17 @@ mod m3 {
|
|||
fn f() {
|
||||
macro_rules! legacy_macro { () => () }
|
||||
|
||||
// ... but still create ambiguities with other names in the same namespace.
|
||||
// Legacy macro imports create ambiguities with other names in the same namespace.
|
||||
use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous
|
||||
//~| ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
}
|
||||
}
|
||||
|
||||
mod exported {
|
||||
// Exported macros are treated as private as well,
|
||||
// some better rules need to be figured out later.
|
||||
// Exported legacy macros are treated as `pub`.
|
||||
#[macro_export]
|
||||
macro_rules! legacy_macro { () => () }
|
||||
|
||||
use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
pub use legacy_macro as _; // OK
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,15 @@
|
|||
error[E0364]: `legacy_macro` is private, and cannot be re-exported
|
||||
--> $DIR/macro-rules.rs:12:9
|
||||
--> $DIR/macro-rules.rs:11:13
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider marking `legacy_macro` as `pub` in the imported module
|
||||
--> $DIR/macro-rules.rs:12:9
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0364]: `legacy_macro` is private, and cannot be re-exported
|
||||
--> $DIR/macro-rules.rs:31:13
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous
|
||||
LL | pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider marking `legacy_macro` as `pub` in the imported module
|
||||
--> $DIR/macro-rules.rs:31:13
|
||||
--> $DIR/macro-rules.rs:11:13
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous
|
||||
LL | pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0364]: `legacy_macro` is private, and cannot be re-exported
|
||||
--> $DIR/macro-rules.rs:42:9
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider marking `legacy_macro` as `pub` in the imported module
|
||||
--> $DIR/macro-rules.rs:42:9
|
||||
|
|
||||
LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `legacy_macro` is ambiguous (name vs any other name during import resolution)
|
||||
--> $DIR/macro-rules.rs:31:13
|
||||
|
|
||||
|
|
@ -52,7 +28,7 @@ LL | macro legacy_macro() {}
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: use `self::legacy_macro` to refer to this macro unambiguously
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0364, E0659.
|
||||
For more information about an error, try `rustc --explain E0364`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue