diff options
| author | bors <bors@rust-lang.org> | 2019-05-10 00:51:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-10 00:51:14 +0000 |
| commit | 03bd2f653f0d0adb69d862fbeec64663157e71e1 (patch) | |
| tree | 3067cec05b04e1d4e72aef71a9be0d1a5f83affc /src/libsyntax/parse/parser.rs | |
| parent | adcd4aa8d07945d5ef09129b05e8e1ff1bcce58e (diff) | |
| parent | 45b09453dbf120cc23d889435aac3ed7d2ec8eb7 (diff) | |
| download | rust-03bd2f653f0d0adb69d862fbeec64663157e71e1.tar.gz rust-03bd2f653f0d0adb69d862fbeec64663157e71e1.zip | |
Auto merge of #60683 - Centril:rollup-p05qh5d, r=Centril
Rollup of 8 pull requests Successful merges: - #59348 (Clean up and add tests for slice drop shims) - #60188 (Identify when a stmt could have been parsed as an expr) - #60234 (std: Derive `Default` for `io::Cursor`) - #60618 (Comment ext::tt::transcribe) - #60648 (Skip codegen for one UI test with long file path) - #60671 (remove unneeded `extern crate`s from build tools) - #60675 (Remove the old await! macro) - #60676 (Fix async desugaring providing wrong input to procedural macros.) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 80 |
1 files changed, 66 insertions, 14 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f3eac71ee77..d97d1e2f0f4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -50,7 +50,10 @@ use crate::symbol::{Symbol, keywords}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId, FatalError}; use rustc_target::spec::abi::{self, Abi}; -use syntax_pos::{Span, MultiSpan, BytePos, FileName}; +use syntax_pos::{ + Span, MultiSpan, BytePos, FileName, + hygiene::CompilerDesugaringKind, +}; use log::{debug, trace}; use std::borrow::Cow; @@ -186,6 +189,7 @@ enum PrevTokenKind { Interpolated, Eof, Ident, + BitOr, Other, } @@ -1375,6 +1379,7 @@ impl<'a> Parser<'a> { token::DocComment(..) => PrevTokenKind::DocComment, token::Comma => PrevTokenKind::Comma, token::BinOp(token::Plus) => PrevTokenKind::Plus, + token::BinOp(token::Or) => PrevTokenKind::BitOr, token::Interpolated(..) => PrevTokenKind::Interpolated, token::Eof => PrevTokenKind::Eof, token::Ident(..) => PrevTokenKind::Ident, @@ -2806,6 +2811,12 @@ impl<'a> Parser<'a> { let msg = format!("expected expression, found {}", self.this_token_descr()); let mut err = self.fatal(&msg); + let sp = self.sess.source_map().start_point(self.span); + if let Some(sp) = self.sess.ambiguous_block_expr_parse.borrow() + .get(&sp) + { + self.sess.expr_parentheses_needed(&mut err, *sp, None); + } err.span_label(self.span, "expected expression"); return Err(err); } @@ -2845,7 +2856,7 @@ impl<'a> Parser<'a> { "struct literals are not allowed here", ); err.multipart_suggestion( - "surround the struct literal with parenthesis", + "surround the struct literal with parentheses", vec