Skip to content

Commit

Permalink
Rollup merge of rust-lang#36662 - jseyfried:parse_macro_invoc_paths, …
Browse files Browse the repository at this point in the history
…r=nrc

parser: support paths in bang macro invocations (e.g. `path::to::macro!()`)

r? @nrc
  • Loading branch information
Jonathan Turner authored Sep 26, 2016
2 parents 6573053 + 34f4ad1 commit f685380
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 260 deletions.
474 changes: 222 additions & 252 deletions src/libsyntax/parse/parser.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-21146.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: expected item, found `parse_error`
// error-pattern: expected one of `!` or `::`, found `<eof>`
include!("auxiliary/issue-21146-inc.rs");
fn main() {}
3 changes: 0 additions & 3 deletions src/test/compile-fail/macro-context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ macro_rules! m {
//~| ERROR macro expansion ignores token `typeof`
//~| ERROR macro expansion ignores token `;`
//~| ERROR macro expansion ignores token `;`
//~| ERROR macro expansion ignores token `i`
}

m!(); //~ NOTE the usage of `m!` is likely invalid in item context

fn main() {
let a: m!(); //~ NOTE the usage of `m!` is likely invalid in type context
let i = m!(); //~ NOTE the usage of `m!` is likely invalid in expression context
Expand Down
38 changes: 38 additions & 0 deletions src/test/compile-fail/paths-in-macro-invocations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

::foo::bar!(); //~ ERROR expected macro name without module separators
foo::bar!(); //~ ERROR expected macro name without module separators

trait T {
foo::bar!(); //~ ERROR expected macro name without module separators
::foo::bar!(); //~ ERROR expected macro name without module separators
}

struct S {
x: foo::bar!(), //~ ERROR expected macro name without module separators
y: ::foo::bar!(), //~ ERROR expected macro name without module separators
}

impl S {
foo::bar!(); //~ ERROR expected macro name without module separators
::foo::bar!(); //~ ERROR expected macro name without module separators
}

fn main() {
foo::bar!(); //~ ERROR expected macro name without module separators
::foo::bar!(); //~ ERROR expected macro name without module separators

let _ = foo::bar!(); //~ ERROR expected macro name without module separators
let _ = ::foo::bar!(); //~ ERROR expected macro name without module separators

let foo::bar!() = 0; //~ ERROR expected macro name without module separators
let ::foo::bar!() = 0; //~ ERROR expected macro name without module separators
}
3 changes: 1 addition & 2 deletions src/test/compile-fail/self_type_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ pub fn main() {
ref mut Self => (),
//~^ ERROR expected identifier, found keyword `Self`
Self!() => (),
//~^ ERROR expected identifier, found keyword `Self`
//~^^ ERROR macro undefined: 'Self!'
//~^ ERROR macro undefined: 'Self!'
Foo { x: Self } => (),
//~^ ERROR expected identifier, found keyword `Self`
Foo { Self } => (),
Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/extern-no-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// compile-flags: -Z parse-only

extern {
f(); //~ ERROR expected one of `fn`, `pub`, `static`, or `}`, found `f`
f(); //~ ERROR expected one of `!` or `::`, found `(`
}

fn main() {
Expand Down
3 changes: 2 additions & 1 deletion src/test/parse-fail/issue-21153.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
// compile-flags: -Z parse-only

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

0 comments on commit f685380

Please sign in to comment.