summaryrefslogtreecommitdiffstats
path: root/tests/ui/macros/ambiguity-legacy-vs-modern.rs
blob: 216b9dd0526d2768d961f17bf9b669eb7ed5070a (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
45
46
// Some non-controversial subset of ambiguities "modern macro name" vs "macro_rules"
// is disambiguated to mitigate regressions from macro modularization.
// Scoping for `macro_rules` behaves like scoping for `let` at module level, in general.

#![feature(decl_macro)]

fn same_unnamed_mod() {
    macro m() { 0 }

    macro_rules! m { () => (()) }

    m!() // OK
}

fn nested_unnamed_mod() {
    macro m() { 0 }

    {
        macro_rules! m { () => (()) }

        m!() // OK
    }
}

fn nested_unnamed_mod_fail() {
    macro_rules! m { () => (()) }

    {
        macro m() { 0 }

        m!() //~ ERROR `m` is ambiguous
    }
}

fn nexted_named_mod_fail() {
    macro m() { 0 }

    #[macro_use]
    mod inner {
        macro_rules! m { () => (()) }
    }

    m!() //~ ERROR `m` is ambiguous
}

fn main() {}