summary refs log tree commit diff
path: root/src/test/ui/rust-2018/uniform-paths/macro-rules.rs
blob: e8098a467904e31ccef5d4bb5b9c7f314fc69a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// edition:2018

// For the time being `macro_rules` items are treated as *very* private...

#![feature(underscore_imports, decl_macro, uniform_paths)]

mod m1 {
    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
}

mod m2 {
    macro_rules! legacy_macro { () => () }

    type legacy_macro = u8;

    // ... but don't prevent names from other namespaces from being imported, ...
    use legacy_macro as _; // OK
}

mod m3 {
    macro legacy_macro() {}

    fn f() {
        macro_rules! legacy_macro { () => () }

        // ... but still 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.
    #[macro_export]
    macro_rules! legacy_macro { () => () }

    use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
}

fn main() {}