Skip to content

Commit 5a64ba6

Browse files
committed
parser: span_fatal -> struct_span_err
1 parent b6fc87c commit 5a64ba6

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

src/librustc_parse/parser/diagnostics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@ crate enum ConsumeClosingDelim {
158158

159159
impl<'a> Parser<'a> {
160160
pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> {
161-
self.span_fatal(self.token.span, m)
162-
}
163-
164-
crate fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> {
165-
self.sess.span_diagnostic.struct_span_fatal(sp, m)
161+
self.sess.span_diagnostic.struct_span_fatal(self.token.span, m)
166162
}
167163

168164
pub(super) fn span_fatal_err<S: Into<MultiSpan>>(

src/librustc_parse/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ impl<'a> Parser<'a> {
11371137
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
11381138
self.parse_opt_lit().ok_or_else(|| {
11391139
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
1140-
self.span_fatal(self.token.span, &msg)
1140+
self.struct_span_err(self.token.span, &msg)
11411141
})
11421142
}
11431143

src/librustc_parse/parser/item.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,7 @@ impl<'a> Parser<'a> {
445445
// FAILURE TO PARSE ITEM
446446
match visibility.node {
447447
VisibilityKind::Inherited => {}
448-
_ => {
449-
return Err(self.span_fatal(self.prev_span, "unmatched visibility `pub`"));
450-
}
448+
_ => return Err(self.struct_span_err(self.prev_span, "unmatched visibility `pub`")),
451449
}
452450

453451
if !attributes_allowed && !attrs.is_empty() {

src/librustc_parse/parser/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'a> Parser<'a> {
262262
err.push_str(" -> ");
263263
}
264264
err.push_str(&path.to_string_lossy());
265-
return Err(self.span_fatal(id_sp, &err[..]));
265+
return Err(self.struct_span_err(id_sp, &err[..]));
266266
}
267267
included_mod_stack.push(path.clone());
268268
drop(included_mod_stack);

src/librustc_parse/parser/pat.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,9 @@ impl<'a> Parser<'a> {
796796
// binding mode then we do not end up here, because the lookahead
797797
// will direct us over to `parse_enum_variant()`.
798798
if self.token == token::OpenDelim(token::Paren) {
799-
return Err(self.span_fatal(self.prev_span, "expected identifier, found enum pattern"));
799+
return Err(
800+
self.struct_span_err(self.prev_span, "expected identifier, found enum pattern")
801+
);
800802
}
801803

802804
Ok(PatKind::Ident(binding_mode, ident, sub))

src/librustc_parse/parser/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'a> Parser<'a> {
325325
fn error_block_no_opening_brace<T>(&mut self) -> PResult<'a, T> {
326326
let sp = self.token.span;
327327
let tok = super::token_descr(&self.token);
328-
let mut e = self.span_fatal(sp, &format!("expected `{{`, found {}", tok));
328+
let mut e = self.struct_span_err(sp, &format!("expected `{{`, found {}", tok));
329329
let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon;
330330

331331
// Check to see if the user has written something like

0 commit comments

Comments
 (0)