From 9bed0ddb0e782f7227d4ffcfa5eddeb8b13bf52a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 19 Nov 2012 13:59:59 -0800 Subject: [PATCH] Fix parsing of interpolated paths --- src/libsyntax/parse/parser.rs | 3 ++- src/test/run-pass/macro-path.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/macro-path.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f49447215fe3..3e8f0840883e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -566,7 +566,8 @@ impl Parser { self.parse_borrowed_pointee() } else if self.token_is_fn_keyword(self.token) { self.parse_ty_fn(None, None) - } else if self.token == token::MOD_SEP || is_ident(self.token) { + } else if self.token == token::MOD_SEP + || is_ident_or_path(self.token) { let path = self.parse_path_with_tps(colons_before_params); ty_path(path, self.get_id()) } else { self.fatal(~"expected type"); }; diff --git a/src/test/run-pass/macro-path.rs b/src/test/run-pass/macro-path.rs new file mode 100644 index 000000000000..6c5a944ee291 --- /dev/null +++ b/src/test/run-pass/macro-path.rs @@ -0,0 +1,16 @@ +mod m { + pub type t = int; +} + +fn macros() { + macro_rules! foo { + ($p:path) => { + fn f() -> $p { 10 } + f() + } + } +} + +fn main() { + assert foo!(m::t) == 10; +}