Skip to content

Commit 880c1c5

Browse files
committed
Rename DiagCtxt::with_emitter as DiagCtxt::new.
Because it's now the only constructor.
1 parent f9eef38 commit 880c1c5

File tree

12 files changed

+20
-20
lines changed

12 files changed

+20
-20
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
373373

374374
impl<B: WriteBackendMethods> CodegenContext<B> {
375375
pub fn create_dcx(&self) -> DiagCtxt {
376-
DiagCtxt::with_emitter(Box::new(self.diag_emitter.clone()))
376+
DiagCtxt::new(Box::new(self.diag_emitter.clone()))
377377
}
378378

379379
pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ fn report_ice(
13881388
rustc_errors::ColorConfig::Auto,
13891389
fallback_bundle,
13901390
));
1391-
let dcx = rustc_errors::DiagCtxt::with_emitter(emitter);
1391+
let dcx = rustc_errors::DiagCtxt::new(emitter);
13921392

13931393
// a .span_bug or .bug call has already printed what
13941394
// it wants to print.

compiler/rustc_errors/src/json/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
6161
);
6262

6363
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
64-
let dcx = DiagCtxt::with_emitter(Box::new(je));
64+
let dcx = DiagCtxt::new(Box::new(je));
6565
dcx.span_err(span, "foo");
6666

6767
let bytes = output.lock().unwrap();

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ impl DiagCtxt {
601601
self
602602
}
603603

604-
pub fn with_emitter(emitter: Box<DynEmitter>) -> Self {
604+
pub fn new(emitter: Box<DynEmitter>) -> Self {
605605
Self {
606606
inner: Lock::new(DiagCtxtInner {
607607
flags: DiagCtxtFlags { can_emit_warnings: true, ..Default::default() },

compiler/rustc_expand/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn create_test_handler() -> (DiagCtxt, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
3333
let emitter = HumanEmitter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
3434
.sm(Some(source_map.clone()))
3535
.diagnostic_width(Some(140));
36-
let dcx = DiagCtxt::with_emitter(Box::new(emitter));
36+
let dcx = DiagCtxt::new(Box::new(emitter));
3737
(dcx, source_map, output)
3838
}
3939

compiler/rustc_session/src/parse.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl ParseSess {
239239
let sm = Lrc::new(SourceMap::new(file_path_mapping));
240240
let emitter =
241241
Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle).sm(Some(sm.clone())));
242-
let dcx = DiagCtxt::with_emitter(emitter);
242+
let dcx = DiagCtxt::new(emitter);
243243
ParseSess::with_dcx(dcx, sm)
244244
}
245245

@@ -269,9 +269,9 @@ impl ParseSess {
269269
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
270270
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
271271
let emitter = Box::new(HumanEmitter::stderr(ColorConfig::Auto, fallback_bundle));
272-
let fatal_dcx = DiagCtxt::with_emitter(emitter);
273-
let dcx = DiagCtxt::with_emitter(Box::new(SilentEmitter { fatal_dcx, fatal_note }))
274-
.disable_warnings();
272+
let fatal_dcx = DiagCtxt::new(emitter);
273+
let dcx =
274+
DiagCtxt::new(Box::new(SilentEmitter { fatal_dcx, fatal_note })).disable_warnings();
275275
ParseSess::with_dcx(dcx, sm)
276276
}
277277

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ pub fn build_session(
10801080
);
10811081
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
10821082

1083-
let mut dcx = DiagCtxt::with_emitter(emitter)
1084-
.with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings));
1083+
let mut dcx =
1084+
DiagCtxt::new(emitter).with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings));
10851085
if let Some(ice_file) = ice_file {
10861086
dcx = dcx.with_ice_file(ice_file);
10871087
}
@@ -1402,7 +1402,7 @@ pub struct EarlyDiagCtxt {
14021402
impl EarlyDiagCtxt {
14031403
pub fn new(output: ErrorOutputType) -> Self {
14041404
let emitter = mk_emitter(output);
1405-
Self { dcx: DiagCtxt::with_emitter(emitter) }
1405+
Self { dcx: DiagCtxt::new(emitter) }
14061406
}
14071407

14081408
/// Swap out the underlying dcx once we acquire the user's preference on error emission
@@ -1412,7 +1412,7 @@ impl EarlyDiagCtxt {
14121412
self.dcx.abort_if_errors();
14131413

14141414
let emitter = mk_emitter(output);
1415-
self.dcx = DiagCtxt::with_emitter(emitter);
1415+
self.dcx = DiagCtxt::new(emitter);
14161416
}
14171417

14181418
#[allow(rustc::untranslatable_diagnostic)]

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub(crate) fn new_dcx(
172172
}
173173
};
174174

175-
rustc_errors::DiagCtxt::with_emitter(emitter).with_flags(unstable_opts.dcx_flags(true))
175+
rustc_errors::DiagCtxt::new(emitter).with_flags(unstable_opts.dcx_flags(true))
176176
}
177177

178178
/// Parse, resolve, and typecheck the given crate.

src/librustdoc/doctest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ pub(crate) fn make_test(
582582
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
583583

584584
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
585-
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
585+
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
586586
let sess = ParseSess::with_dcx(dcx, sm);
587587

588588
let mut found_main = false;
@@ -767,7 +767,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
767767

768768
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
769769

770-
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
770+
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
771771
let sess = ParseSess::with_dcx(dcx, sm);
772772
let mut parser =
773773
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {

src/librustdoc/passes/lint/check_code_block_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn check_rust_syntax(
4242
let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
4343

4444
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
45-
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
45+
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
4646
let source = dox[code_block.code].to_owned();
4747
let sess = ParseSess::with_dcx(dcx, sm);
4848

src/tools/clippy/clippy_lints/src/doc/needless_doctest_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn check(
4545
let fallback_bundle =
4646
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
4747
let emitter = HumanEmitter::new(Box::new(io::sink()), fallback_bundle);
48-
let dcx = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
48+
let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings();
4949
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_dcx
5050
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
5151
let sess = ParseSess::with_dcx(dcx, sm);

src/tools/rustfmt/src/parse/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn default_dcx(
154154
);
155155
Box::new(HumanEmitter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
156156
};
157-
DiagCtxt::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
157+
DiagCtxt::new(Box::new(SilentOnIgnoredFilesEmitter {
158158
has_non_ignorable_parser_errors: false,
159159
source_map,
160160
emitter,
@@ -235,7 +235,7 @@ impl ParseSess {
235235
}
236236

237237
pub(crate) fn set_silent_emitter(&mut self) {
238-
self.parse_sess.dcx = DiagCtxt::with_emitter(silent_emitter());
238+
self.parse_sess.dcx = DiagCtxt::new(silent_emitter());
239239
}
240240

241241
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {

0 commit comments

Comments
 (0)