Skip to content

Commit 5723946

Browse files
committed
rustc_errors: take self by value in DiagnosticBuilder::cancel.
1 parent 7592663 commit 5723946

File tree

6 files changed

+5
-16
lines changed

6 files changed

+5
-16
lines changed

src/modules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
439439
}
440440
}
441441
Err(mod_err) if !mods_outside_ast.is_empty() => {
442-
if let ModError::ParserError(mut e) = mod_err {
442+
if let ModError::ParserError(e) = mod_err {
443443
e.cancel();
444444
}
445445
Ok(Some(SubModKind::MultiExternal(mods_outside_ast)))

src/parse/macros/cfg_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn parse_cfg_if_inner<'a>(
5757
let item = match parser.parse_item(ForceCollect::No) {
5858
Ok(Some(item_ptr)) => item_ptr.into_inner(),
5959
Ok(None) => continue,
60-
Err(mut err) => {
60+
Err(err) => {
6161
err.cancel();
6262
parser.sess.span_diagnostic.reset_err_count();
6363
return Err(

src/parse/macros/lazy_static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) fn parse_lazy_static(
2323
val
2424
}
2525
}
26-
Err(mut err) => {
26+
Err(err) => {
2727
err.cancel();
2828
parser.sess.span_diagnostic.reset_err_count();
2929
return None;

src/parse/macros/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
3636
return Some(MacroArg::$macro_arg($f(x)?));
3737
}
3838
}
39-
Err(mut e) => {
39+
Err(e) => {
4040
e.cancel();
4141
parser.sess.span_diagnostic.reset_err_count();
4242
}

src/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a> Parser<'a> {
115115
match parser.parse_mod(&TokenKind::Eof) {
116116
Ok(result) => Some(result),
117117
Err(mut e) => {
118-
sess.emit_or_cancel_diagnostic(&mut e);
118+
e.emit();
119119
if sess.can_reset_errors() {
120120
sess.reset_errors();
121121
}

src/parse/session.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,6 @@ impl ParseSess {
230230
}
231231
}
232232

233-
pub(crate) fn emit_or_cancel_diagnostic(&self, diagnostic: &mut Diagnostic) {
234-
self.parse_sess.span_diagnostic.emit_diagnostic(diagnostic);
235-
// The Handler will check whether the diagnostic should be emitted
236-
// based on the user's rustfmt configuration and the originating file
237-
// that caused the parser error. If the Handler determined it should skip
238-
// emission then we need to ensure the diagnostic is cancelled.
239-
if !diagnostic.cancelled() {
240-
diagnostic.cancel();
241-
}
242-
}
243-
244233
pub(super) fn can_reset_errors(&self) -> bool {
245234
self.can_reset_errors.load(Ordering::Acquire)
246235
}

0 commit comments

Comments
 (0)