diff options
| author | bors <bors@rust-lang.org> | 2019-08-04 16:19:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-04 16:19:04 +0000 |
| commit | f01b9f803b59f170f5dabaaa8aedc96abe45bfea (patch) | |
| tree | e7388497c7f95770a07c90e2a67edbc0aa9851f4 /src/libsyntax/parse | |
| parent | 460072ebeed5a2463109894592ac172b47cdfb74 (diff) | |
| parent | c82e1f2d0e0b7fec9265eac851b2ac8b500ec4cc (diff) | |
| download | rust-f01b9f803b59f170f5dabaaa8aedc96abe45bfea.tar.gz rust-f01b9f803b59f170f5dabaaa8aedc96abe45bfea.zip | |
Auto merge of #62816 - estebank:type-ascription-macros, r=petrochenkov
Point at type ascription before macro invocation on expansion parse error Fix https://github.com/rust-lang/rust/issues/47666. Follow up to https://github.com/rust-lang/rust/pull/62791. r? @petrochenkov
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 880dd6e1649..b14000aeaf3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1415,7 +1415,12 @@ impl<'a> Parser<'a> { if self.eat(&token::Not) { // Macro invocation in type position let (delim, tts) = self.expect_delimited_token_tree()?; - let node = Mac_ { path, tts, delim }; + let node = Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + }; TyKind::Mac(respan(lo.to(self.prev_span), node)) } else { // Just a type path or bound list (trait object type) starting with a trait. @@ -2246,7 +2251,12 @@ impl<'a> Parser<'a> { // MACRO INVOCATION expression let (delim, tts) = self.expect_delimited_token_tree()?; hi = self.prev_span; - ex = ExprKind::Mac(respan(lo.to(hi), Mac_ { path, tts, delim })); + ex = ExprKind::Mac(respan(lo.to(hi), Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + })); } else if self.check(&token::OpenDelim(token::Brace)) { if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) { return expr; @@ -3963,7 +3973,12 @@ impl<'a> Parser<'a> { // Parse macro invocation self.bump(); let (delim, tts) = self.expect_delimited_token_tree()?; - let mac = respan(lo.to(self.prev_span), Mac_ { path, tts, delim }); + let mac = respan(lo.to(self.prev_span), Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + }); pat = PatKind::Mac(mac); } token::DotDotDot | token::DotDotEq | token::DotDot => { @@ -4403,7 +4418,12 @@ impl<'a> Parser<'a> { MacStmtStyle::NoBraces }; - let mac = respan(lo.to(hi), Mac_ { path, tts, delim }); + let mac = respan(lo.to(hi), Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + }); let node = if delim == MacDelimiter::Brace || self.token == token::Semi || self.token == token::Eof { StmtKind::Mac(P((mac, style, attrs.into()))) @@ -7518,7 +7538,12 @@ impl<'a> Parser<'a> { } let hi = self.prev_span; - let mac = respan(mac_lo.to(hi), Mac_ { path, tts, delim }); + let mac = respan(mac_lo.to(hi), Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + }); let item = self.mk_item(lo.to(hi), Ident::invalid(), ItemKind::Mac(mac), visibility, attrs); return Ok(Some(item)); @@ -7568,7 +7593,12 @@ impl<'a> Parser<'a> { self.expect(&token::Semi)?; } - Ok(Some(respan(lo.to(self.prev_span), Mac_ { path, tts, delim }))) + Ok(Some(respan(lo.to(self.prev_span), Mac_ { + path, + tts, + delim, + prior_type_ascription: self.last_type_ascription, + }))) } else { Ok(None) } |
