]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rust-2018/uniform-paths/macro-rules.rs
69f6a8668add39a7231bbc29b79d3eb93f10bdaf
[rust.git] / src / test / ui / rust-2018 / uniform-paths / macro-rules.rs
1 // edition:2018
2
3 // For the time being `macro_rules` items are treated as *very* private...
4
5 #![feature(decl_macro, uniform_paths)]
6 #![allow(non_camel_case_types)]
7
8 mod m1 {
9     macro_rules! legacy_macro { () => () }
10
11     // ... so they can't be imported by themselves, ...
12     use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
13 }
14
15 mod m2 {
16     macro_rules! legacy_macro { () => () }
17
18     type legacy_macro = u8;
19
20     // ... but don't prevent names from other namespaces from being imported, ...
21     use legacy_macro as _; // OK
22 }
23
24 mod m3 {
25     macro legacy_macro() {}
26
27     fn f() {
28         macro_rules! legacy_macro { () => () }
29
30         // ... but still create ambiguities with other names in the same namespace.
31         use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous
32                                //~| ERROR `legacy_macro` is private, and cannot be re-exported
33     }
34 }
35
36 mod exported {
37     // Exported macros are treated as private as well,
38     // some better rules need to be figured out later.
39     #[macro_export]
40     macro_rules! legacy_macro { () => () }
41
42     use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
43 }
44
45 fn main() {}