summaryrefslogtreecommitdiff
path: root/compiler/rustc_parse/src/parser/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 1c34e491f21..0c265d7af0e 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -148,9 +148,6 @@ pub struct Parser<'a> {
max_angle_bracket_count: u32,
last_unexpected_token_span: Option<Span>,
- /// Span pointing at the `:` for the last type ascription the parser has seen, and whether it
- /// looked like it could have been a mistyped path or literal `Option:Some(42)`).
- pub last_type_ascription: Option<(Span, bool /* likely path typo */)>,
/// If present, this `Parser` is not parsing Rust code but rather a macro call.
subparser_name: Option<&'static str>,
capture_state: CaptureState,
@@ -165,7 +162,7 @@ pub struct Parser<'a> {
// This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure
// it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
-rustc_data_structures::static_assert_size!(Parser<'_>, 288);
+rustc_data_structures::static_assert_size!(Parser<'_>, 272);
/// Stores span information about a closure.
#[derive(Clone)]
@@ -470,7 +467,6 @@ impl<'a> Parser<'a> {
unmatched_angle_bracket_count: 0,
max_angle_bracket_count: 0,
last_unexpected_token_span: None,
- last_type_ascription: None,
subparser_name,
capture_state: CaptureState {
capturing: Capturing::No,
@@ -909,7 +905,7 @@ impl<'a> Parser<'a> {
expect_err
.span_suggestion_verbose(
self.prev_token.span.shrink_to_hi().until(self.token.span),
- &msg,
+ msg,
" @ ",
Applicability::MaybeIncorrect,
)
@@ -925,7 +921,7 @@ impl<'a> Parser<'a> {
expect_err
.span_suggestion_short(
sp,
- &format!("missing `{}`", token_str),
+ format!("missing `{}`", token_str),
token_str,
Applicability::MaybeIncorrect,
)
@@ -941,10 +937,14 @@ impl<'a> Parser<'a> {
// propagate the help message from sub error 'e' to main error 'expect_err;
expect_err.children.push(xx.clone());
}
- expect_err.emit();
-
e.cancel();
- break;
+ if self.token == token::Colon {
+ // we will try to recover in `maybe_recover_struct_lit_bad_delims`
+ return Err(expect_err);
+ } else {
+ expect_err.emit();
+ break;
+ }
}
}
}