Skip to content

Commit 3c4f1d8

Browse files
committed
Rename {create,emit}_warning as {create,emit}_warn.
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`, all of which use an abbreviated form.
1 parent ff40ad4 commit 3c4f1d8

File tree

23 files changed

+55
-56
lines changed

23 files changed

+55
-56
lines changed

compiler/rustc_ast_passes/src/show_span.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ struct ShowSpanVisitor<'a> {
3838
impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
3939
fn visit_expr(&mut self, e: &'a ast::Expr) {
4040
if let Mode::Expression = self.mode {
41-
self.dcx.emit_warning(errors::ShowSpan { span: e.span, msg: "expression" });
41+
self.dcx.emit_warn(errors::ShowSpan { span: e.span, msg: "expression" });
4242
}
4343
visit::walk_expr(self, e);
4444
}
4545

4646
fn visit_pat(&mut self, p: &'a ast::Pat) {
4747
if let Mode::Pattern = self.mode {
48-
self.dcx.emit_warning(errors::ShowSpan { span: p.span, msg: "pattern" });
48+
self.dcx.emit_warn(errors::ShowSpan { span: p.span, msg: "pattern" });
4949
}
5050
visit::walk_pat(self, p);
5151
}
5252

5353
fn visit_ty(&mut self, t: &'a ast::Ty) {
5454
if let Mode::Type = self.mode {
55-
self.dcx.emit_warning(errors::ShowSpan { span: t.span, msg: "type" });
55+
self.dcx.emit_warn(errors::ShowSpan { span: t.span, msg: "type" });
5656
}
5757
visit::walk_ty(self, t);
5858
}

compiler/rustc_attr/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ pub fn eval_condition(
621621
}
622622
};
623623
let Some(min_version) = parse_version(*min_version) else {
624-
dcx.emit_warning(session_diagnostics::UnknownVersionLiteral { span: *span });
624+
dcx.emit_warn(session_diagnostics::UnknownVersionLiteral { span: *span });
625625
return false;
626626
};
627627

compiler/rustc_codegen_gcc/src/gcc_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
5252
Some(c @ ('+' | '-')) => c,
5353
Some(_) => {
5454
if diagnostics {
55-
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
55+
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
5656
}
5757
return None;
5858
}
@@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
7979
else {
8080
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
8181
};
82-
sess.dcx().emit_warning(unknown_feature);
82+
sess.dcx().emit_warn(unknown_feature);
8383
}
8484

8585
if diagnostics {

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl CodegenBackend for GccCodegenBackend {
191191
#[cfg(feature="master")]
192192
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
193193
if sess.lto() == Lto::Thin {
194-
sess.dcx().emit_warning(LTONotSupported {});
194+
sess.dcx().emit_warn(LTONotSupported {});
195195
}
196196

197197
#[cfg(not(feature="master"))]

compiler/rustc_codegen_llvm/src/back/write.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,12 @@ pub fn target_machine_factory(
245245
match sess.opts.debuginfo_compression {
246246
rustc_session::config::DebugInfoCompression::Zlib => {
247247
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
248-
sess.dcx().emit_warning(UnknownCompression { algorithm: "zlib" });
248+
sess.dcx().emit_warn(UnknownCompression { algorithm: "zlib" });
249249
}
250250
}
251251
rustc_session::config::DebugInfoCompression::Zstd => {
252252
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
253-
sess.dcx().emit_warning(UnknownCompression { algorithm: "zstd" });
253+
sess.dcx().emit_warn(UnknownCompression { algorithm: "zstd" });
254254
}
255255
}
256256
rustc_session::config::DebugInfoCompression::None => {}
@@ -457,7 +457,7 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
457457
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
458458
})
459459
.expect("non-UTF8 diagnostic");
460-
dcx.emit_warning(FromLlvmDiag { message });
460+
dcx.emit_warn(FromLlvmDiag { message });
461461
}
462462
llvm::diagnostic::Unsupported(diagnostic_ref) => {
463463
let message = llvm::build_string(|s| {

compiler/rustc_codegen_llvm/src/llvm_util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
529529
Some(c @ ('+' | '-')) => c,
530530
Some(_) => {
531531
if diagnostics {
532-
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
532+
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
533533
}
534534
return None;
535535
}
@@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
557557
} else {
558558
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
559559
};
560-
sess.dcx().emit_warning(unknown_feature);
560+
sess.dcx().emit_warn(unknown_feature);
561561
} else if feature_state
562562
.is_some_and(|(_name, feature_gate)| !feature_gate.is_stable())
563563
{
564564
// An unstable feature. Warn about using it.
565-
sess.dcx().emit_warning(UnstableCTargetFeature { feature });
565+
sess.dcx().emit_warn(UnstableCTargetFeature { feature });
566566
}
567567
}
568568

compiler/rustc_codegen_ssa/src/back/link.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ fn link_natively<'a>(
10161016
if !prog.status.success() {
10171017
let mut output = prog.stderr.clone();
10181018
output.extend_from_slice(&prog.stdout);
1019-
sess.dcx().emit_warning(errors::ProcessingDymutilFailed {
1019+
sess.dcx().emit_warn(errors::ProcessingDymutilFailed {
10201020
status: prog.status,
10211021
output: escape_string(&output),
10221022
});
@@ -1091,7 +1091,7 @@ fn strip_symbols_with_external_utility<'a>(
10911091
if !prog.status.success() {
10921092
let mut output = prog.stderr.clone();
10931093
output.extend_from_slice(&prog.stdout);
1094-
sess.dcx().emit_warning(errors::StrippingDebugInfoFailed {
1094+
sess.dcx().emit_warn(errors::StrippingDebugInfoFailed {
10951095
util,
10961096
status: prog.status,
10971097
output: escape_string(&output),
@@ -2406,7 +2406,7 @@ fn collect_natvis_visualizers(
24062406
visualizer_paths.push(visualizer_out_file);
24072407
}
24082408
Err(error) => {
2409-
sess.dcx().emit_warning(errors::UnableToWriteDebuggerVisualizer {
2409+
sess.dcx().emit_warn(errors::UnableToWriteDebuggerVisualizer {
24102410
path: visualizer_out_file,
24112411
error,
24122412
});

compiler/rustc_codegen_ssa/src/back/linker.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ impl<'a> Linker for GccLinker<'a> {
446446
// FIXME(81490): ld64 doesn't support these flags but macOS 11
447447
// has -needed-l{} / -needed_library {}
448448
// but we have no way to detect that here.
449-
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
449+
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
450450
} else if self.is_gnu && !self.sess.target.is_like_windows {
451451
self.linker_arg("--no-as-needed");
452452
} else {
453-
self.sess.dcx().emit_warning(errors::LinkerUnsupportedModifier);
453+
self.sess.dcx().emit_warn(errors::LinkerUnsupportedModifier);
454454
}
455455
}
456456
self.hint_dynamic();
@@ -504,7 +504,7 @@ impl<'a> Linker for GccLinker<'a> {
504504
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
505505
// flag but we have no way to detect that here.
506506
// self.cmd.arg("-needed_framework").arg(framework);
507-
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
507+
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
508508
}
509509
self.cmd.arg("-framework").arg(framework);
510510
}
@@ -950,7 +950,7 @@ impl<'a> Linker for MsvcLinker<'a> {
950950
}
951951
}
952952
Err(error) => {
953-
self.sess.dcx().emit_warning(errors::NoNatvisDirectory { error });
953+
self.sess.dcx().emit_warn(errors::NoNatvisDirectory { error });
954954
}
955955
}
956956
}
@@ -1501,7 +1501,7 @@ impl<'a> Linker for L4Bender<'a> {
15011501

15021502
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
15031503
// ToDo, not implemented, copy from GCC
1504-
self.sess.dcx().emit_warning(errors::L4BenderExportingSymbolsUnimplemented);
1504+
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
15051505
return;
15061506
}
15071507

compiler/rustc_codegen_ssa/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,11 @@ fn produce_final_output_artifacts(
573573
if crate_output.outputs.contains_key(&output_type) {
574574
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
575575
// no good solution for this case, so warn the user.
576-
sess.dcx().emit_warning(errors::IgnoringEmitPath { extension });
576+
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
577577
} else if crate_output.single_output_file.is_some() {
578578
// 3) Multiple codegen units, with `-o some_name`. We have
579579
// no good solution for this case, so warn the user.
580-
sess.dcx().emit_warning(errors::IgnoringOutput { extension });
580+
sess.dcx().emit_warn(errors::IgnoringOutput { extension });
581581
} else {
582582
// 4) Multiple codegen units, but no explicit name. We
583583
// just leave the `foo.0.x` files in place.

compiler/rustc_const_eval/src/const_eval/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
630630
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
631631
// way to implement exponential backoff.
632632
let span = ecx.cur_span();
633-
ecx.tcx.dcx().emit_warning(LongRunningWarn { span, item_span: ecx.tcx.span });
633+
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
634634
}
635635
}
636636

compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ fn report_ice(
14291429
}
14301430
Err(err) => {
14311431
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
1432-
dcx.emit_warning(session_diagnostics::IcePathError {
1432+
dcx.emit_warn(session_diagnostics::IcePathError {
14331433
path: path.clone(),
14341434
error: err.to_string(),
14351435
env_var: std::env::var_os("RUSTC_ICE")

compiler/rustc_errors/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1086,16 +1086,16 @@ impl DiagCtxt {
10861086
}
10871087

10881088
#[track_caller]
1089-
pub fn create_warning<'a>(
1089+
pub fn create_warn<'a>(
10901090
&'a self,
10911091
warning: impl IntoDiagnostic<'a, ()>,
10921092
) -> DiagnosticBuilder<'a, ()> {
10931093
warning.into_diagnostic(self, Warning(None))
10941094
}
10951095

10961096
#[track_caller]
1097-
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
1098-
self.create_warning(warning).emit()
1097+
pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
1098+
self.create_warn(warning).emit()
10991099
}
11001100

11011101
#[track_caller]

compiler/rustc_incremental/src/persist/fs.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub(crate) fn prepare_session_directory(
273273
debug!("successfully copied data from: {}", source_directory.display());
274274

275275
if !allows_links {
276-
sess.dcx().emit_warning(errors::HardLinkFailed { path: &session_dir });
276+
sess.dcx().emit_warn(errors::HardLinkFailed { path: &session_dir });
277277
}
278278

279279
sess.init_incr_comp_session(session_dir, directory_lock);
@@ -288,7 +288,7 @@ pub(crate) fn prepare_session_directory(
288288
// Try to remove the session directory we just allocated. We don't
289289
// know if there's any garbage in it from the failed copy action.
290290
if let Err(err) = safe_remove_dir_all(&session_dir) {
291-
sess.dcx().emit_warning(errors::DeletePartial { path: &session_dir, err });
291+
sess.dcx().emit_warn(errors::DeletePartial { path: &session_dir, err });
292292
}
293293

294294
delete_session_dir_lock_file(sess, &lock_file_path);
@@ -322,7 +322,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
322322
);
323323

324324
if let Err(err) = safe_remove_dir_all(&*incr_comp_session_dir) {
325-
sess.dcx().emit_warning(errors::DeleteFull { path: &incr_comp_session_dir, err });
325+
sess.dcx().emit_warn(errors::DeleteFull { path: &incr_comp_session_dir, err });
326326
}
327327

328328
let lock_file_path = lock_file_path(&*incr_comp_session_dir);
@@ -365,7 +365,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
365365
}
366366
Err(e) => {
367367
// Warn about the error. However, no need to abort compilation now.
368-
sess.dcx().emit_warning(errors::Finalize { path: &incr_comp_session_dir, err: e });
368+
sess.dcx().emit_warn(errors::Finalize { path: &incr_comp_session_dir, err: e });
369369

370370
debug!("finalize_session_directory() - error, marking as invalid");
371371
// Drop the file lock, so we can garage collect
@@ -500,7 +500,7 @@ fn lock_directory(
500500

501501
fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
502502
if let Err(err) = safe_remove_file(lock_file_path) {
503-
sess.dcx().emit_warning(errors::DeleteLock { path: lock_file_path, err });
503+
sess.dcx().emit_warn(errors::DeleteLock { path: lock_file_path, err });
504504
}
505505
}
506506

@@ -724,7 +724,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
724724
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
725725
let path = crate_directory.join(directory_name);
726726
if let Err(err) = safe_remove_dir_all(&path) {
727-
sess.dcx().emit_warning(errors::InvalidGcFailed { path: &path, err });
727+
sess.dcx().emit_warn(errors::InvalidGcFailed { path: &path, err });
728728
}
729729
}
730730
}
@@ -830,7 +830,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
830830
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
831831

832832
if let Err(err) = safe_remove_dir_all(&path) {
833-
sess.dcx().emit_warning(errors::FinalizedGcFailed { path: &path, err });
833+
sess.dcx().emit_warn(errors::FinalizedGcFailed { path: &path, err });
834834
} else {
835835
delete_session_dir_lock_file(sess, &lock_file_path(&path));
836836
}
@@ -848,7 +848,7 @@ fn delete_old(sess: &Session, path: &Path) {
848848
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
849849

850850
if let Err(err) = safe_remove_dir_all(path) {
851-
sess.dcx().emit_warning(errors::SessionGcFailed { path: path, err });
851+
sess.dcx().emit_warn(errors::SessionGcFailed { path: path, err });
852852
} else {
853853
delete_session_dir_lock_file(sess, &lock_file_path(path));
854854
}

compiler/rustc_incremental/src/persist/load.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<T: Default> LoadResult<T> {
5151

5252
match self {
5353
LoadResult::LoadDepGraph(path, err) => {
54-
sess.dcx().emit_warning(errors::LoadDepGraph { path, err });
54+
sess.dcx().emit_warn(errors::LoadDepGraph { path, err });
5555
Default::default()
5656
}
5757
LoadResult::DataOutOfDate => {

compiler/rustc_incremental/src/persist/work_product.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
3030
let _ = saved_files.insert(ext.to_string(), file_name);
3131
}
3232
Err(err) => {
33-
sess.dcx().emit_warning(errors::CopyWorkProductToCache {
33+
sess.dcx().emit_warn(errors::CopyWorkProductToCache {
3434
from: path,
3535
to: &path_in_incr_dir,
3636
err,
@@ -50,7 +50,7 @@ pub(crate) fn delete_workproduct_files(sess: &Session, work_product: &WorkProduc
5050
for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() {
5151
let path = in_incr_comp_dir_sess(sess, path);
5252
if let Err(err) = std_fs::remove_file(&path) {
53-
sess.dcx().emit_warning(errors::DeleteWorkProduct { path: &path, err });
53+
sess.dcx().emit_warn(errors::DeleteWorkProduct { path: &path, err });
5454
}
5555
}
5656
}

compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn configure_and_expand(
254254
}
255255

256256
if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
257-
sess.dcx().emit_warning(errors::ProcMacroCratePanicAbort);
257+
sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort);
258258
}
259259

260260
sess.time("maybe_create_a_macro_crate", || {

compiler/rustc_interface/src/queries.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ impl<'tcx> Queries<'tcx> {
213213

214214
// Some other attribute.
215215
Some(_) => {
216-
tcx.dcx().emit_warning(RustcErrorUnexpectedAnnotation {
217-
span: tcx.def_span(def_id),
218-
});
216+
tcx.dcx()
217+
.emit_warn(RustcErrorUnexpectedAnnotation { span: tcx.def_span(def_id) });
219218
}
220219
}
221220
}

compiler/rustc_interface/src/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C
431431

432432
base.retain(|crate_type| {
433433
if output::invalid_output_for_target(session, *crate_type) {
434-
session.dcx().emit_warning(errors::UnsupportedCrateTypeForTarget {
434+
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
435435
crate_type: *crate_type,
436436
target_triple: &session.opts.target_triple,
437437
});
@@ -507,16 +507,16 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
507507
let unnamed_output_types =
508508
sess.opts.output_types.values().filter(|a| a.is_none()).count();
509509
let ofile = if unnamed_output_types > 1 {
510-
sess.dcx().emit_warning(errors::MultipleOutputTypesAdaption);
510+
sess.dcx().emit_warn(errors::MultipleOutputTypesAdaption);
511511
None
512512
} else {
513513
if !sess.opts.cg.extra_filename.is_empty() {
514-
sess.dcx().emit_warning(errors::IgnoringExtraFilename);
514+
sess.dcx().emit_warn(errors::IgnoringExtraFilename);
515515
}
516516
Some(out_file.clone())
517517
};
518518
if sess.io.output_dir != None {
519-
sess.dcx().emit_warning(errors::IgnoringOutDir);
519+
sess.dcx().emit_warn(errors::IgnoringOutDir);
520520
}
521521

522522
let out_filestem =

compiler/rustc_monomorphize/src/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
10931093
MonoItemCollectionMode::Eager
10941094
} else {
10951095
if mode != "lazy" {
1096-
tcx.dcx().emit_warning(UnknownCguCollectionMode { mode });
1096+
tcx.dcx().emit_warn(UnknownCguCollectionMode { mode });
10971097
}
10981098

10991099
MonoItemCollectionMode::Lazy

0 commit comments

Comments
 (0)