Skip to content

Commit 1d96462

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36662 - jseyfried:parse_macro_invoc_paths, r=nrc
parser: support paths in bang macro invocations (e.g. `path::to::macro!()`) r? @nrc
2 parents 3775be8 + 34f4ad1 commit 1d96462

File tree

7 files changed

+265
-260
lines changed

7 files changed

+265
-260
lines changed

src/libsyntax/parse/parser.rs

+222-252
Large diffs are not rendered by default.

src/test/compile-fail/issue-21146.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: expected item, found `parse_error`
11+
// error-pattern: expected one of `!` or `::`, found `<eof>`
1212
include!("auxiliary/issue-21146-inc.rs");
1313
fn main() {}

src/test/compile-fail/macro-context.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ macro_rules! m {
1414
//~| ERROR macro expansion ignores token `typeof`
1515
//~| ERROR macro expansion ignores token `;`
1616
//~| ERROR macro expansion ignores token `;`
17-
//~| ERROR macro expansion ignores token `i`
1817
}
1918

20-
m!(); //~ NOTE the usage of `m!` is likely invalid in item context
21-
2219
fn main() {
2320
let a: m!(); //~ NOTE the usage of `m!` is likely invalid in type context
2421
let i = m!(); //~ NOTE the usage of `m!` is likely invalid in expression context
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
::foo::bar!(); //~ ERROR expected macro name without module separators
12+
foo::bar!(); //~ ERROR expected macro name without module separators
13+
14+
trait T {
15+
foo::bar!(); //~ ERROR expected macro name without module separators
16+
::foo::bar!(); //~ ERROR expected macro name without module separators
17+
}
18+
19+
struct S {
20+
x: foo::bar!(), //~ ERROR expected macro name without module separators
21+
y: ::foo::bar!(), //~ ERROR expected macro name without module separators
22+
}
23+
24+
impl S {
25+
foo::bar!(); //~ ERROR expected macro name without module separators
26+
::foo::bar!(); //~ ERROR expected macro name without module separators
27+
}
28+
29+
fn main() {
30+
foo::bar!(); //~ ERROR expected macro name without module separators
31+
::foo::bar!(); //~ ERROR expected macro name without module separators
32+
33+
let _ = foo::bar!(); //~ ERROR expected macro name without module separators
34+
let _ = ::foo::bar!(); //~ ERROR expected macro name without module separators
35+
36+
let foo::bar!() = 0; //~ ERROR expected macro name without module separators
37+
let ::foo::bar!() = 0; //~ ERROR expected macro name without module separators
38+
}

src/test/compile-fail/self_type_keyword.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ pub fn main() {
3030
ref mut Self => (),
3131
//~^ ERROR expected identifier, found keyword `Self`
3232
Self!() => (),
33-
//~^ ERROR expected identifier, found keyword `Self`
34-
//~^^ ERROR macro undefined: 'Self!'
33+
//~^ ERROR macro undefined: 'Self!'
3534
Foo { x: Self } => (),
3635
//~^ ERROR expected identifier, found keyword `Self`
3736
Foo { Self } => (),

src/test/parse-fail/extern-no-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// compile-flags: -Z parse-only
1212

1313
extern {
14-
f(); //~ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `f`
14+
f(); //~ ERROR expected one of `!` or `::`, found `(`
1515
}
1616

1717
fn main() {

src/test/parse-fail/issue-21153.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
// compile-flags: -Z parse-only
1212

1313
trait MyTrait<T>: Iterator {
14-
Item = T; //~ ERROR expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `Item`
14+
Item = T; //~ ERROR expected one of `!` or `::`, found `=`
15+
//~| ERROR expected item, found `=`
1516
}

0 commit comments

Comments
 (0)