about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser/expr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-05 02:11:06 +0000
committerbors <bors@rust-lang.org>2019-09-05 02:11:06 +0000
commita24f636e60a5da57ab641d800ac5952bbde98b65 (patch)
treedf8c02fb78ed123bf2e2e65501a037753fe6f4fe /src/libsyntax/parse/parser/expr.rs
parentf257c40b199198eacc65bb31f932ee04305e6d41 (diff)
parent51ae5d053b6125027010faff963b333d8e48c77a (diff)
downloadrust-a24f636e60a5da57ab641d800ac5952bbde98b65.tar.gz
rust-a24f636e60a5da57ab641d800ac5952bbde98b65.zip
Auto merge of #64160 - Centril:rollup-vrfj1pt, r=Centril
Rollup of 15 pull requests

Successful merges:

 - #62860 (Stabilize checked_duration_since for 1.38.0)
 - #63549 (Rev::rposition counts from the wrong end)
 - #63985 (Stabilize pin_into_inner in 1.39.0)
 - #64005 (Add a `Place::is_indirect` method to determine whether a `Place` contains a `Deref` projection)
 - #64031 (Harden `param_attrs` test wrt. usage of a proc macro `#[attr]`)
 - #64038 (Check impl trait substs when checking for recursive types)
 - #64043 (Add some more tests for underscore imports)
 - #64092 (Update xLTO compatibility table in rustc book.)
 - #64110 (Refer to "`self` type" instead of "receiver type")
 - #64120 (Move path parsing earlier)
 - #64123 (Added warning around code with reference to uninit bytes)
 - #64128 (unused_parens: account for or-patterns and `&(mut x)`)
 - #64141 (Minimize uses of `LocalInternedString`)
 - #64142 (Fix doc links in `std::cmp` module)
 - #64148 (fix a few typos in comments)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax/parse/parser/expr.rs')
-rw-r--r--src/libsyntax/parse/parser/expr.rs56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs
index 5b9f0f1df67..e502a08f4b2 100644
--- a/src/libsyntax/parse/parser/expr.rs
+++ b/src/libsyntax/parse/parser/expr.rs
@@ -889,6 +889,36 @@ impl<'a> Parser<'a> {
                     hi = path.span;
                     return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs));
                 }
+                if self.token.is_path_start() {
+                    let path = self.parse_path(PathStyle::Expr)?;
+
+                    // `!`, as an operator, is prefix, so we know this isn't that
+                    if self.eat(&token::Not) {
+                        // MACRO INVOCATION expression
+                        let (delim, tts) = self.expect_delimited_token_tree()?;
+                        hi = self.prev_span;
+                        ex = ExprKind::Mac(Mac {
+                            path,
+                            tts,
+                            delim,
+                            span: lo.to(hi),
+                            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;
+                        } else {
+                            hi = path.span;
+                            ex = ExprKind::Path(None, path);
+                        }
+                    } else {
+                        hi = path.span;
+                        ex = ExprKind::Path(None, path);
+                    }
+
+                    let expr = self.mk_expr(lo.to(hi), ex, attrs);
+                    return self.maybe_recover_from_bad_qpath(expr, true);
+                }
                 if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) {
                     return self.parse_lambda_expr(attrs);
                 }
@@ -1007,32 +1037,6 @@ impl<'a> Parser<'a> {
                     let (await_hi, e_kind) = self.parse_incorrect_await_syntax(lo, self.prev_span)?;
                     hi = await_hi;
                     ex = e_kind;
-                } else if self.token.is_path_start() {
-                    let path = self.parse_path(PathStyle::Expr)?;
-
-                    // `!`, as an operator, is prefix, so we know this isn't that
-                    if self.eat(&token::Not) {
-                        // MACRO INVOCATION expression
-                        let (delim, tts) = self.expect_delimited_token_tree()?;
-                        hi = self.prev_span;
-                        ex = ExprKind::Mac(Mac {
-                            path,
-                            tts,
-                            delim,
-                            span: lo.to(hi),
-                            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;
-                        } else {
-                            hi = path.span;
-                            ex = ExprKind::Path(None, path);
-                        }
-                    } else {
-                        hi = path.span;
-                        ex = ExprKind::Path(None, path);
-                    }
                 } else {
                     if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
                         // Don't complain about bare semicolons after unclosed braces