From 5a64ba63862906588b0dcd8ea2ed9884ec44f4a8 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 31 Dec 2019 00:20:41 +0100 Subject: [PATCH] parser: span_fatal -> struct_span_err --- src/librustc_parse/parser/diagnostics.rs | 6 +----- src/librustc_parse/parser/expr.rs | 2 +- src/librustc_parse/parser/item.rs | 4 +--- src/librustc_parse/parser/module.rs | 2 +- src/librustc_parse/parser/pat.rs | 4 +++- src/librustc_parse/parser/stmt.rs | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index 2e58b702d925..630087fb7e80 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -158,11 +158,7 @@ crate enum ConsumeClosingDelim { impl<'a> Parser<'a> { pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> { - self.span_fatal(self.token.span, m) - } - - crate fn span_fatal>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> { - self.sess.span_diagnostic.struct_span_fatal(sp, m) + self.sess.span_diagnostic.struct_span_fatal(self.token.span, m) } pub(super) fn span_fatal_err>( diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index f5cefeca3391..49ca5abe97f6 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1137,7 +1137,7 @@ impl<'a> Parser<'a> { pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> { self.parse_opt_lit().ok_or_else(|| { let msg = format!("unexpected token: {}", super::token_descr(&self.token)); - self.span_fatal(self.token.span, &msg) + self.struct_span_err(self.token.span, &msg) }) } diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 64482f09edec..d7b242f61012 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -445,9 +445,7 @@ impl<'a> Parser<'a> { // FAILURE TO PARSE ITEM match visibility.node { VisibilityKind::Inherited => {} - _ => { - return Err(self.span_fatal(self.prev_span, "unmatched visibility `pub`")); - } + _ => return Err(self.struct_span_err(self.prev_span, "unmatched visibility `pub`")), } if !attributes_allowed && !attrs.is_empty() { diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs index 7f5104d260d6..1b7d54a1c1e0 100644 --- a/src/librustc_parse/parser/module.rs +++ b/src/librustc_parse/parser/module.rs @@ -262,7 +262,7 @@ impl<'a> Parser<'a> { err.push_str(" -> "); } err.push_str(&path.to_string_lossy()); - return Err(self.span_fatal(id_sp, &err[..])); + return Err(self.struct_span_err(id_sp, &err[..])); } included_mod_stack.push(path.clone()); drop(included_mod_stack); diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 6a98d29675e7..4895d5428df3 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -796,7 +796,9 @@ impl<'a> Parser<'a> { // binding mode then we do not end up here, because the lookahead // will direct us over to `parse_enum_variant()`. if self.token == token::OpenDelim(token::Paren) { - return Err(self.span_fatal(self.prev_span, "expected identifier, found enum pattern")); + return Err( + self.struct_span_err(self.prev_span, "expected identifier, found enum pattern") + ); } Ok(PatKind::Ident(binding_mode, ident, sub)) diff --git a/src/librustc_parse/parser/stmt.rs b/src/librustc_parse/parser/stmt.rs index 1d0897a3cf3f..1f72c66ea03d 100644 --- a/src/librustc_parse/parser/stmt.rs +++ b/src/librustc_parse/parser/stmt.rs @@ -325,7 +325,7 @@ impl<'a> Parser<'a> { fn error_block_no_opening_brace(&mut self) -> PResult<'a, T> { let sp = self.token.span; let tok = super::token_descr(&self.token); - let mut e = self.span_fatal(sp, &format!("expected `{{`, found {}", tok)); + let mut e = self.struct_span_err(sp, &format!("expected `{{`, found {}", tok)); let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon; // Check to see if the user has written something like