Skip to content

Commit e97e75a

Browse files
committed
Handler tweaks.
- Avoid unnecessary `inner` local variables. - Use `borrow_mut` everywhere (instead of the synonym `lock`).
1 parent 13c260b commit e97e75a

File tree

1 file changed

+6
-8
lines changed
  • compiler/rustc_errors/src

1 file changed

+6
-8
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ impl Handler {
648648
// This is here to not allow mutation of flags;
649649
// as of this writing it's only used in tests in librustc_middle.
650650
pub fn can_emit_warnings(&self) -> bool {
651-
self.inner.lock().flags.can_emit_warnings
651+
self.inner.borrow_mut().flags.can_emit_warnings
652652
}
653653

654654
/// Resets the diagnostic error count as well as the cached emitted diagnostics.
@@ -675,14 +675,13 @@ impl Handler {
675675
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
676676
/// Retrieve a stashed diagnostic with `steal_diagnostic`.
677677
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
678-
let mut inner = self.inner.borrow_mut();
679-
inner.stash((span.with_parent(None), key), diag);
678+
self.inner.borrow_mut().stash((span.with_parent(None), key), diag);
680679
}
681680

682681
/// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key.
683682
pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
684-
let mut inner = self.inner.borrow_mut();
685-
inner
683+
self.inner
684+
.borrow_mut()
686685
.steal((span.with_parent(None), key))
687686
.map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))
688687
}
@@ -1197,8 +1196,7 @@ impl Handler {
11971196
mut diag: Diagnostic,
11981197
sp: impl Into<MultiSpan>,
11991198
) -> Option<ErrorGuaranteed> {
1200-
let mut inner = self.inner.borrow_mut();
1201-
inner.emit_diagnostic(diag.set_span(sp))
1199+
self.inner.borrow_mut().emit_diagnostic(diag.set_span(sp))
12021200
}
12031201

12041202
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
@@ -1266,7 +1264,7 @@ impl Handler {
12661264
}
12671265

12681266
pub fn flush_delayed(&self) {
1269-
let mut inner = self.inner.lock();
1267+
let mut inner = self.inner.borrow_mut();
12701268
let bugs = std::mem::replace(&mut inner.span_delayed_bugs, Vec::new());
12711269
inner.flush_delayed(bugs, "no errors encountered even though `span_delayed_bug` issued");
12721270
}

0 commit comments

Comments
 (0)