Rename HandlerInner
as DiagCtxtInner
.
This commit is contained in:
parent
cde19c016e
commit
45f347681d
2 changed files with 10 additions and 10 deletions
|
@ -413,13 +413,13 @@ use std::backtrace::{Backtrace, BacktraceStatus};
|
||||||
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
|
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
|
||||||
/// others log errors for later reporting.
|
/// others log errors for later reporting.
|
||||||
pub struct DiagCtxt {
|
pub struct DiagCtxt {
|
||||||
inner: Lock<HandlerInner>,
|
inner: Lock<DiagCtxtInner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This inner struct exists to keep it all behind a single lock;
|
/// This inner struct exists to keep it all behind a single lock;
|
||||||
/// this is done to prevent possible deadlocks in a multi-threaded compiler,
|
/// this is done to prevent possible deadlocks in a multi-threaded compiler,
|
||||||
/// as well as inconsistent state observation.
|
/// as well as inconsistent state observation.
|
||||||
struct HandlerInner {
|
struct DiagCtxtInner {
|
||||||
flags: HandlerFlags,
|
flags: HandlerFlags,
|
||||||
/// The number of lint errors that have been emitted.
|
/// The number of lint errors that have been emitted.
|
||||||
lint_err_count: usize,
|
lint_err_count: usize,
|
||||||
|
@ -540,7 +540,7 @@ pub struct HandlerFlags {
|
||||||
pub track_diagnostics: bool,
|
pub track_diagnostics: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for HandlerInner {
|
impl Drop for DiagCtxtInner {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.emit_stashed_diagnostics();
|
self.emit_stashed_diagnostics();
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ impl DiagCtxt {
|
||||||
|
|
||||||
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
|
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: Lock::new(HandlerInner {
|
inner: Lock::new(DiagCtxtInner {
|
||||||
flags: HandlerFlags { can_emit_warnings: true, ..Default::default() },
|
flags: HandlerFlags { can_emit_warnings: true, ..Default::default() },
|
||||||
lint_err_count: 0,
|
lint_err_count: 0,
|
||||||
err_count: 0,
|
err_count: 0,
|
||||||
|
@ -1057,7 +1057,7 @@ impl DiagCtxt {
|
||||||
inner.emit_diagnostic(diagnostic).unwrap()
|
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).
|
// where the explanation of what "good path" is (also, it should be renamed).
|
||||||
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>) {
|
||||||
let mut inner = self.inner.borrow_mut();
|
let mut inner = self.inner.borrow_mut();
|
||||||
|
@ -1396,12 +1396,12 @@ impl DiagCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This methods steals all [`LintExpectationId`]s that are stored inside
|
/// 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]
|
#[must_use]
|
||||||
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> {
|
pub fn steal_fulfilled_expectation_ids(&self) -> FxHashSet<LintExpectationId> {
|
||||||
assert!(
|
assert!(
|
||||||
self.inner.borrow().unstable_expect_diagnostics.is_empty(),
|
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)
|
std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
|
||||||
}
|
}
|
||||||
|
@ -1414,10 +1414,10 @@ impl DiagCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: we prefer implementing operations on `DiagCtxt`, rather than
|
// 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
|
// `DiagCtxt::foo()` just borrows `inner` and forwards a call to
|
||||||
// `HanderInner::foo`.
|
// `HanderInner::foo`.
|
||||||
impl HandlerInner {
|
impl DiagCtxtInner {
|
||||||
/// Emit all stashed diagnostics.
|
/// Emit all stashed diagnostics.
|
||||||
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
|
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
|
||||||
let has_errors = self.has_errors();
|
let has_errors = self.has_errors();
|
||||||
|
|
|
@ -308,7 +308,7 @@ pub fn struct_lint_level(
|
||||||
(Level::Expect(expect_id), _) => {
|
(Level::Expect(expect_id), _) => {
|
||||||
// This case is special as we actually allow the lint itself in this context, but
|
// 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
|
// 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
|
// 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
|
// can still be cancelled in the decorate function. All of this means that we simply
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue