about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-03 20:45:54 +0000
committerbors <bors@rust-lang.org>2018-05-03 20:45:54 +0000
commite82261dfbb5feaa2d28d2b138f4aabb2aa52c94b (patch)
tree3bade0f4dfbda64eac4eed19227ac3f46acdf373 /src/libsyntax
parentd68b0eceaaf719a4702ab13a7ca62dea5d966082 (diff)
parent03a0402dbf3143ab6a8b7166f4d1f74aa68f71df (diff)
downloadrust-e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b.tar.gz
rust-e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b.zip
Auto merge of #50413 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests

Successful merges:

 - #50302 (Add query search order check)
 - #50320 (Fix invalid path generation in rustdoc search)
 - #50349 (Rename "show type declaration" to "show declaration")
 - #50360 (Clarify wordings of the `unstable_name_collision` lint.)
 - #50365 (Use two vectors in nearest_common_ancestor.)
 - #50393 (Allow unaligned reads in constants)
 - #50401 (Revert "Implement FromStr for PathBuf")
 - #50406 (Forbid constructing empty identifiers from concat_idents)
 - #50407 (Always inline simple BytePos and CharPos methods.)
 - #50416 (check if the token is a lifetime before parsing)
 - #50417 (Update Cargo)
 - #50421 (Fix ICE when using a..=b in a closure.)

Failed merges:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs8
-rw-r--r--src/libsyntax/parse/parser.rs2
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index d9c3deb30da..71634ada894 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -835,7 +835,13 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
         "path" => token::NtPath(panictry!(p.parse_path_common(PathStyle::Type, false))),
         "meta" => token::NtMeta(panictry!(p.parse_meta_item())),
         "vis" => token::NtVis(panictry!(p.parse_visibility(true))),
-        "lifetime" => token::NtLifetime(p.expect_lifetime().ident),
+        "lifetime" => if p.check_lifetime() {
+            token::NtLifetime(p.expect_lifetime().ident)
+        } else {
+            let token_str = pprust::token_to_string(&p.token);
+            p.fatal(&format!("expected a lifetime, found `{}`", &token_str)).emit();
+            FatalError.raise();
+        }
         // this is not supposed to happen, since it has been checked
         // when compiling the macro.
         _ => p.span_bug(sp, "invalid fragment specifier"),
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 0e3bced3222..bf4a68679df 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2042,7 +2042,7 @@ impl<'a> Parser<'a> {
         })
     }
 
-    fn check_lifetime(&mut self) -> bool {
+    pub fn check_lifetime(&mut self) -> bool {
         self.expected_tokens.push(TokenType::Lifetime);
         self.token.is_lifetime()
     }