Rollup merge of #121783 - nnethercote:emitter-cleanups, r=oli-obk
Emitter cleanups Some cleanups I made when reading emitter code. In particular, `HumanEmitter` and `JsonEmitter` have gone from three constructors to one. r? `@oli-obk`
This commit is contained in:
commit
0e9f02d6fa
15 changed files with 138 additions and 219 deletions
|
@ -59,11 +59,11 @@ pub use snippet::Style;
|
|||
// See https://github.com/rust-lang/rust/pull/115393.
|
||||
pub use termcolor::{Color, ColorSpec, WriteColor};
|
||||
|
||||
use emitter::{is_case_difference, DynEmitter, Emitter, HumanEmitter};
|
||||
use emitter::{is_case_difference, DynEmitter, Emitter};
|
||||
use registry::Registry;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
|
||||
use rustc_data_structures::sync::{Lock, Lrc};
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_data_structures::AtomicRef;
|
||||
use rustc_lint_defs::LintExpectationId;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
|
@ -217,10 +217,10 @@ impl CodeSuggestion {
|
|||
|
||||
use rustc_span::{CharPos, Pos};
|
||||
|
||||
/// Extracts a substring from the provided `line_opt` based on the specified low and high indices,
|
||||
/// appends it to the given buffer `buf`, and returns the count of newline characters in the substring
|
||||
/// for accurate highlighting.
|
||||
/// If `line_opt` is `None`, a newline character is appended to the buffer, and 0 is returned.
|
||||
/// Extracts a substring from the provided `line_opt` based on the specified low and high
|
||||
/// indices, appends it to the given buffer `buf`, and returns the count of newline
|
||||
/// characters in the substring for accurate highlighting. If `line_opt` is `None`, a
|
||||
/// newline character is appended to the buffer, and 0 is returned.
|
||||
///
|
||||
/// ## Returns
|
||||
///
|
||||
|
@ -482,8 +482,8 @@ struct DiagCtxtInner {
|
|||
/// have been converted.
|
||||
check_unstable_expect_diagnostics: bool,
|
||||
|
||||
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of
|
||||
/// the lint level. [`LintExpectationId`]s created early during the compilation
|
||||
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part
|
||||
/// of the lint level. [`LintExpectationId`]s created early during the compilation
|
||||
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
||||
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
||||
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s
|
||||
|
@ -590,13 +590,6 @@ impl Drop for DiagCtxtInner {
|
|||
}
|
||||
|
||||
impl DiagCtxt {
|
||||
pub fn with_tty_emitter(
|
||||
sm: Option<Lrc<SourceMap>>,
|
||||
fallback_bundle: LazyFallbackBundle,
|
||||
) -> Self {
|
||||
let emitter = Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle).sm(sm));
|
||||
Self::with_emitter(emitter)
|
||||
}
|
||||
pub fn disable_warnings(mut self) -> Self {
|
||||
self.inner.get_mut().flags.can_emit_warnings = false;
|
||||
self
|
||||
|
@ -612,7 +605,7 @@ impl DiagCtxt {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
|
||||
pub fn new(emitter: Box<DynEmitter>) -> Self {
|
||||
Self {
|
||||
inner: Lock::new(DiagCtxtInner {
|
||||
flags: DiagCtxtFlags { can_emit_warnings: true, ..Default::default() },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue