Skip to content

Commit

Permalink
Rename HandlerInner as DiagCtxtInner.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Dec 18, 2023
1 parent cde19c0 commit 45f3476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ use std::backtrace::{Backtrace, BacktraceStatus};
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
/// others log errors for later reporting.
pub struct DiagCtxt {
inner: Lock<HandlerInner>,
inner: Lock<DiagCtxtInner>,
}

/// This inner struct exists to keep it all behind a single lock;
/// this is done to prevent possible deadlocks in a multi-threaded compiler,
/// as well as inconsistent state observation.
struct HandlerInner {
struct DiagCtxtInner {
flags: HandlerFlags,
/// The number of lint errors that have been emitted.
lint_err_count: usize,
Expand Down Expand Up @@ -540,7 +540,7 @@ pub struct HandlerFlags {
pub track_diagnostics: bool,
}

impl Drop for HandlerInner {
impl Drop for DiagCtxtInner {
fn drop(&mut self) {
self.emit_stashed_diagnostics();

Expand Down Expand Up @@ -597,7 +597,7 @@ impl DiagCtxt {

pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
Self {
inner: Lock::new(HandlerInner {
inner: Lock::new(DiagCtxtInner {
flags: HandlerFlags { can_emit_warnings: true, ..Default::default() },
lint_err_count: 0,
err_count: 0,
Expand Down Expand Up @@ -1057,7 +1057,7 @@ impl DiagCtxt {
inner.emit_diagnostic(diagnostic).unwrap()
}

// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
// where the explanation of what "good path" is (also, it should be renamed).
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>) {
let mut inner = self.inner.borrow_mut();
Expand Down Expand Up @@ -1396,12 +1396,12 @@ impl DiagCtxt {
}

/// This methods steals all [`LintExpectationId`]s that are stored inside
/// [`HandlerInner`] and indicate that the linked expectation has been fulfilled.
/// [`DiagCtxtInner`] and indicate that the linked expectation has been fulfilled.
#[must_use]
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> {
assert!(
self.inner.borrow().unstable_expect_diagnostics.is_empty(),
"`HandlerInner::unstable_expect_diagnostics` should be empty at this point",
"`DiagCtxtInner::unstable_expect_diagnostics` should be empty at this point",
);
std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
}
Expand All @@ -1414,10 +1414,10 @@ impl DiagCtxt {
}

// Note: we prefer implementing operations on `DiagCtxt`, rather than
// `HandlerInner`, whenever possible. This minimizes functions where
// `DiagCtxtInner`, whenever possible. This minimizes functions where
// `DiagCtxt::foo()` just borrows `inner` and forwards a call to
// `HanderInner::foo`.
impl HandlerInner {
impl DiagCtxtInner {
/// Emit all stashed diagnostics.
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
let has_errors = self.has_errors();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub fn struct_lint_level(
(Level::Expect(expect_id), _) => {
// This case is special as we actually allow the lint itself in this context, but
// we can't return early like in the case for `Level::Allow` because we still
// need the lint diagnostic to be emitted to `rustc_error::HandlerInner`.
// need the lint diagnostic to be emitted to `rustc_error::DiagCtxtInner`.
//
// We can also not mark the lint expectation as fulfilled here right away, as it
// can still be cancelled in the decorate function. All of this means that we simply
Expand Down

0 comments on commit 45f3476

Please sign in to comment.