Rename DiagCtxt::with_emitter
as DiagCtxt::new
.
Because it's now the only constructor.
This commit is contained in:
parent
f9eef38e32
commit
880c1c585f
12 changed files with 20 additions and 20 deletions
|
@ -373,7 +373,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
||||||
|
|
||||||
impl<B: WriteBackendMethods> CodegenContext<B> {
|
impl<B: WriteBackendMethods> CodegenContext<B> {
|
||||||
pub fn create_dcx(&self) -> DiagCtxt {
|
pub fn create_dcx(&self) -> DiagCtxt {
|
||||||
DiagCtxt::with_emitter(Box::new(self.diag_emitter.clone()))
|
DiagCtxt::new(Box::new(self.diag_emitter.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
|
pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
|
||||||
|
|
|
@ -1388,7 +1388,7 @@ fn report_ice(
|
||||||
rustc_errors::ColorConfig::Auto,
|
rustc_errors::ColorConfig::Auto,
|
||||||
fallback_bundle,
|
fallback_bundle,
|
||||||
));
|
));
|
||||||
let dcx = rustc_errors::DiagCtxt::with_emitter(emitter);
|
let dcx = rustc_errors::DiagCtxt::new(emitter);
|
||||||
|
|
||||||
// a .span_bug or .bug call has already printed what
|
// a .span_bug or .bug call has already printed what
|
||||||
// it wants to print.
|
// it wants to print.
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
|
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(je));
|
let dcx = DiagCtxt::new(Box::new(je));
|
||||||
dcx.span_err(span, "foo");
|
dcx.span_err(span, "foo");
|
||||||
|
|
||||||
let bytes = output.lock().unwrap();
|
let bytes = output.lock().unwrap();
|
||||||
|
|
|
@ -601,7 +601,7 @@ impl DiagCtxt {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
|
pub fn new(emitter: Box<DynEmitter>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: Lock::new(DiagCtxtInner {
|
inner: Lock::new(DiagCtxtInner {
|
||||||
flags: DiagCtxtFlags { can_emit_warnings: true, ..Default::default() },
|
flags: DiagCtxtFlags { can_emit_warnings: true, ..Default::default() },
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn create_test_handler() -> (DiagCtxt, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
||||||
let emitter = HumanEmitter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
let emitter = HumanEmitter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
||||||
.sm(Some(source_map.clone()))
|
.sm(Some(source_map.clone()))
|
||||||
.diagnostic_width(Some(140));
|
.diagnostic_width(Some(140));
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter));
|
let dcx = DiagCtxt::new(Box::new(emitter));
|
||||||
(dcx, source_map, output)
|
(dcx, source_map, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl ParseSess {
|
||||||
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
||||||
let emitter =
|
let emitter =
|
||||||
Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle).sm(Some(sm.clone())));
|
Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle).sm(Some(sm.clone())));
|
||||||
let dcx = DiagCtxt::with_emitter(emitter);
|
let dcx = DiagCtxt::new(emitter);
|
||||||
ParseSess::with_dcx(dcx, sm)
|
ParseSess::with_dcx(dcx, sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,9 +269,9 @@ impl ParseSess {
|
||||||
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
|
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let emitter = Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle));
|
let emitter = Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle));
|
||||||
let fatal_dcx = DiagCtxt::with_emitter(emitter);
|
let fatal_dcx = DiagCtxt::new(emitter);
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(SilentEmitter { fatal_dcx, fatal_note }))
|
let dcx =
|
||||||
.disable_warnings();
|
DiagCtxt::new(Box::new(SilentEmitter { fatal_dcx, fatal_note })).disable_warnings();
|
||||||
ParseSess::with_dcx(dcx, sm)
|
ParseSess::with_dcx(dcx, sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1080,8 +1080,8 @@ pub fn build_session(
|
||||||
);
|
);
|
||||||
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
|
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
|
||||||
|
|
||||||
let mut dcx = DiagCtxt::with_emitter(emitter)
|
let mut dcx =
|
||||||
.with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings));
|
DiagCtxt::new(emitter).with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings));
|
||||||
if let Some(ice_file) = ice_file {
|
if let Some(ice_file) = ice_file {
|
||||||
dcx = dcx.with_ice_file(ice_file);
|
dcx = dcx.with_ice_file(ice_file);
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ pub struct EarlyDiagCtxt {
|
||||||
impl EarlyDiagCtxt {
|
impl EarlyDiagCtxt {
|
||||||
pub fn new(output: ErrorOutputType) -> Self {
|
pub fn new(output: ErrorOutputType) -> Self {
|
||||||
let emitter = mk_emitter(output);
|
let emitter = mk_emitter(output);
|
||||||
Self { dcx: DiagCtxt::with_emitter(emitter) }
|
Self { dcx: DiagCtxt::new(emitter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Swap out the underlying dcx once we acquire the user's preference on error emission
|
/// Swap out the underlying dcx once we acquire the user's preference on error emission
|
||||||
|
@ -1412,7 +1412,7 @@ impl EarlyDiagCtxt {
|
||||||
self.dcx.abort_if_errors();
|
self.dcx.abort_if_errors();
|
||||||
|
|
||||||
let emitter = mk_emitter(output);
|
let emitter = mk_emitter(output);
|
||||||
self.dcx = DiagCtxt::with_emitter(emitter);
|
self.dcx = DiagCtxt::new(emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
|
|
|
@ -172,7 +172,7 @@ pub(crate) fn new_dcx(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rustc_errors::DiagCtxt::with_emitter(emitter).with_flags(unstable_opts.dcx_flags(true))
|
rustc_errors::DiagCtxt::new(emitter).with_flags(unstable_opts.dcx_flags(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse, resolve, and typecheck the given crate.
|
/// Parse, resolve, and typecheck the given crate.
|
||||||
|
|
|
@ -582,7 +582,7 @@ pub(crate) fn make_test(
|
||||||
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let sess = ParseSess::with_dcx(dcx, sm);
|
||||||
|
|
||||||
let mut found_main = false;
|
let mut found_main = false;
|
||||||
|
@ -767,7 +767,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
|
||||||
|
|
||||||
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let sess = ParseSess::with_dcx(dcx, sm);
|
||||||
let mut parser =
|
let mut parser =
|
||||||
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
|
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn check_rust_syntax(
|
||||||
let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
|
let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
|
||||||
|
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
||||||
let source = dox[code_block.code].to_owned();
|
let source = dox[code_block.code].to_owned();
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let sess = ParseSess::with_dcx(dcx, sm);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub fn check(
|
||||||
let fallback_bundle =
|
let fallback_bundle =
|
||||||
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
||||||
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
|
||||||
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let sess = ParseSess::with_dcx(dcx, sm);
|
let sess = ParseSess::with_dcx(dcx, sm);
|
||||||
|
|
|
@ -154,7 +154,7 @@ fn default_dcx(
|
||||||
);
|
);
|
||||||
Box::new(HumanEmitter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
Box::new(HumanEmitter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
||||||
};
|
};
|
||||||
DiagCtxt::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
|
DiagCtxt::new(Box::new(SilentOnIgnoredFilesEmitter {
|
||||||
has_non_ignorable_parser_errors: false,
|
has_non_ignorable_parser_errors: false,
|
||||||
source_map,
|
source_map,
|
||||||
emitter,
|
emitter,
|
||||||
|
@ -235,7 +235,7 @@ impl ParseSess {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_silent_emitter(&mut self) {
|
pub(crate) fn set_silent_emitter(&mut self) {
|
||||||
self.parse_sess.dcx = DiagCtxt::with_emitter(silent_emitter());
|
self.parse_sess.dcx = DiagCtxt::new(silent_emitter());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
|
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue