Skip to content

Commit edca562

Browse files
committed
Make parser recognize macro invocations in types
Reapplied the changes from https://github.com/freebroccolo/rust/commit/8b07abaa6e8ab42d37656dfad89de0eb5810c3b3 to a clean branch of master
1 parent ad59278 commit edca562

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
5151
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
5252
use ast::{TtDelimited, TtSequence, TtToken};
5353
use ast::{TupleVariantKind, Ty, Ty_, TypeBinding};
54+
use ast::{TyMac};
5455
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
5556
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr};
5657
use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq};
@@ -1369,8 +1370,20 @@ impl<'a> Parser<'a> {
13691370
} else if self.check(&token::ModSep) ||
13701371
self.token.is_ident() ||
13711372
self.token.is_path() {
1372-
// NAMED TYPE
1373-
try!(self.parse_ty_path())
1373+
let path = try!(self.parse_path(LifetimeAndTypesWithoutColons));
1374+
if self.check(&token::Not) {
1375+
// MACRO INVOCATION
1376+
try!(self.bump());
1377+
let delim = try!(self.expect_open_delim());
1378+
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
1379+
seq_sep_none(),
1380+
|p| p.parse_token_tree()));
1381+
let hi = self.span.hi;
1382+
TyMac(spanned(lo, hi, MacInvocTT(path, tts, EMPTY_CTXT)))
1383+
} else {
1384+
// NAMED TYPE
1385+
TyPath(None, path)
1386+
}
13741387
} else if try!(self.eat(&token::Underscore) ){
13751388
// TYPE TO BE INFERRED
13761389
TyInfer

0 commit comments

Comments
 (0)