Skip to content

Commit

Permalink
Rename {create,emit}_warning as {create,emit}_warn.
Browse files Browse the repository at this point in the history
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`,
all of which use an abbreviated form.
  • Loading branch information
nnethercote committed Jan 9, 2024
1 parent ff40ad4 commit 3c4f1d8
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 56 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast_passes/src/show_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ struct ShowSpanVisitor<'a> {
impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
fn visit_expr(&mut self, e: &'a ast::Expr) {
if let Mode::Expression = self.mode {
self.dcx.emit_warning(errors::ShowSpan { span: e.span, msg: "expression" });
self.dcx.emit_warn(errors::ShowSpan { span: e.span, msg: "expression" });
}
visit::walk_expr(self, e);
}

fn visit_pat(&mut self, p: &'a ast::Pat) {
if let Mode::Pattern = self.mode {
self.dcx.emit_warning(errors::ShowSpan { span: p.span, msg: "pattern" });
self.dcx.emit_warn(errors::ShowSpan { span: p.span, msg: "pattern" });
}
visit::walk_pat(self, p);
}

fn visit_ty(&mut self, t: &'a ast::Ty) {
if let Mode::Type = self.mode {
self.dcx.emit_warning(errors::ShowSpan { span: t.span, msg: "type" });
self.dcx.emit_warn(errors::ShowSpan { span: t.span, msg: "type" });
}
visit::walk_ty(self, t);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ pub fn eval_condition(
}
};
let Some(min_version) = parse_version(*min_version) else {
dcx.emit_warning(session_diagnostics::UnknownVersionLiteral { span: *span });
dcx.emit_warn(session_diagnostics::UnknownVersionLiteral { span: *span });
return false;
};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
Some(c @ ('+' | '-')) => c,
Some(_) => {
if diagnostics {
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
}
return None;
}
Expand All @@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
else {
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
};
sess.dcx().emit_warning(unknown_feature);
sess.dcx().emit_warn(unknown_feature);
}

if diagnostics {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl CodegenBackend for GccCodegenBackend {
#[cfg(feature="master")]
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
if sess.lto() == Lto::Thin {
sess.dcx().emit_warning(LTONotSupported {});
sess.dcx().emit_warn(LTONotSupported {});
}

#[cfg(not(feature="master"))]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ pub fn target_machine_factory(
match sess.opts.debuginfo_compression {
rustc_session::config::DebugInfoCompression::Zlib => {
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
sess.dcx().emit_warning(UnknownCompression { algorithm: "zlib" });
sess.dcx().emit_warn(UnknownCompression { algorithm: "zlib" });
}
}
rustc_session::config::DebugInfoCompression::Zstd => {
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
sess.dcx().emit_warning(UnknownCompression { algorithm: "zstd" });
sess.dcx().emit_warn(UnknownCompression { algorithm: "zstd" });
}
}
rustc_session::config::DebugInfoCompression::None => {}
Expand Down Expand Up @@ -457,7 +457,7 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
})
.expect("non-UTF8 diagnostic");
dcx.emit_warning(FromLlvmDiag { message });
dcx.emit_warn(FromLlvmDiag { message });
}
llvm::diagnostic::Unsupported(diagnostic_ref) => {
let message = llvm::build_string(|s| {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
Some(c @ ('+' | '-')) => c,
Some(_) => {
if diagnostics {
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
}
return None;
}
Expand Down Expand Up @@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
} else {
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
};
sess.dcx().emit_warning(unknown_feature);
sess.dcx().emit_warn(unknown_feature);
} else if feature_state
.is_some_and(|(_name, feature_gate)| !feature_gate.is_stable())
{
// An unstable feature. Warn about using it.
sess.dcx().emit_warning(UnstableCTargetFeature { feature });
sess.dcx().emit_warn(UnstableCTargetFeature { feature });
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ fn link_natively<'a>(
if !prog.status.success() {
let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout);
sess.dcx().emit_warning(errors::ProcessingDymutilFailed {
sess.dcx().emit_warn(errors::ProcessingDymutilFailed {
status: prog.status,
output: escape_string(&output),
});
Expand Down Expand Up @@ -1091,7 +1091,7 @@ fn strip_symbols_with_external_utility<'a>(
if !prog.status.success() {
let mut output = prog.stderr.clone();
output.extend_from_slice(&prog.stdout);
sess.dcx().emit_warning(errors::StrippingDebugInfoFailed {
sess.dcx().emit_warn(errors::StrippingDebugInfoFailed {
util,
status: prog.status,
output: escape_string(&output),
Expand Down Expand Up @@ -2406,7 +2406,7 @@ fn collect_natvis_visualizers(
visualizer_paths.push(visualizer_out_file);
}
Err(error) => {
sess.dcx().emit_warning(errors::UnableToWriteDebuggerVisualizer {
sess.dcx().emit_warn(errors::UnableToWriteDebuggerVisualizer {
path: visualizer_out_file,
error,
});
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ impl<'a> Linker for GccLinker<'a> {
// FIXME(81490): ld64 doesn't support these flags but macOS 11
// has -needed-l{} / -needed_library {}
// but we have no way to detect that here.
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
} else if self.is_gnu && !self.sess.target.is_like_windows {
self.linker_arg("--no-as-needed");
} else {
self.sess.dcx().emit_warning(errors::LinkerUnsupportedModifier);
self.sess.dcx().emit_warn(errors::LinkerUnsupportedModifier);
}
}
self.hint_dynamic();
Expand Down Expand Up @@ -504,7 +504,7 @@ impl<'a> Linker for GccLinker<'a> {
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
// flag but we have no way to detect that here.
// self.cmd.arg("-needed_framework").arg(framework);
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier);
}
self.cmd.arg("-framework").arg(framework);
}
Expand Down Expand Up @@ -950,7 +950,7 @@ impl<'a> Linker for MsvcLinker<'a> {
}
}
Err(error) => {
self.sess.dcx().emit_warning(errors::NoNatvisDirectory { error });
self.sess.dcx().emit_warn(errors::NoNatvisDirectory { error });
}
}
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ impl<'a> Linker for L4Bender<'a> {

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

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,11 @@ fn produce_final_output_artifacts(
if crate_output.outputs.contains_key(&output_type) {
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
// no good solution for this case, so warn the user.
sess.dcx().emit_warning(errors::IgnoringEmitPath { extension });
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
} else if crate_output.single_output_file.is_some() {
// 3) Multiple codegen units, with `-o some_name`. We have
// no good solution for this case, so warn the user.
sess.dcx().emit_warning(errors::IgnoringOutput { extension });
sess.dcx().emit_warn(errors::IgnoringOutput { extension });
} else {
// 4) Multiple codegen units, but no explicit name. We
// just leave the `foo.0.x` files in place.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
// way to implement exponential backoff.
let span = ecx.cur_span();
ecx.tcx.dcx().emit_warning(LongRunningWarn { span, item_span: ecx.tcx.span });
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ fn report_ice(
}
Err(err) => {
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
dcx.emit_warning(session_diagnostics::IcePathError {
dcx.emit_warn(session_diagnostics::IcePathError {
path: path.clone(),
error: err.to_string(),
env_var: std::env::var_os("RUSTC_ICE")
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,16 +1086,16 @@ impl DiagCtxt {
}

#[track_caller]
pub fn create_warning<'a>(
pub fn create_warn<'a>(
&'a self,
warning: impl IntoDiagnostic<'a, ()>,
) -> DiagnosticBuilder<'a, ()> {
warning.into_diagnostic(self, Warning(None))
}

#[track_caller]
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
self.create_warning(warning).emit()
pub fn emit_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
self.create_warn(warning).emit()
}

#[track_caller]
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_incremental/src/persist/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub(crate) fn prepare_session_directory(
debug!("successfully copied data from: {}", source_directory.display());

if !allows_links {
sess.dcx().emit_warning(errors::HardLinkFailed { path: &session_dir });
sess.dcx().emit_warn(errors::HardLinkFailed { path: &session_dir });
}

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

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

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

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

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

fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
if let Err(err) = safe_remove_file(lock_file_path) {
sess.dcx().emit_warning(errors::DeleteLock { path: lock_file_path, err });
sess.dcx().emit_warn(errors::DeleteLock { path: lock_file_path, err });
}
}

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

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

if let Err(err) = safe_remove_dir_all(path) {
sess.dcx().emit_warning(errors::SessionGcFailed { path: path, err });
sess.dcx().emit_warn(errors::SessionGcFailed { path: path, err });
} else {
delete_session_dir_lock_file(sess, &lock_file_path(path));
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/src/persist/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<T: Default> LoadResult<T> {

match self {
LoadResult::LoadDepGraph(path, err) => {
sess.dcx().emit_warning(errors::LoadDepGraph { path, err });
sess.dcx().emit_warn(errors::LoadDepGraph { path, err });
Default::default()
}
LoadResult::DataOutOfDate => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_incremental/src/persist/work_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
let _ = saved_files.insert(ext.to_string(), file_name);
}
Err(err) => {
sess.dcx().emit_warning(errors::CopyWorkProductToCache {
sess.dcx().emit_warn(errors::CopyWorkProductToCache {
from: path,
to: &path_in_incr_dir,
err,
Expand All @@ -50,7 +50,7 @@ pub(crate) fn delete_workproduct_files(sess: &Session, work_product: &WorkProduc
for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() {
let path = in_incr_comp_dir_sess(sess, path);
if let Err(err) = std_fs::remove_file(&path) {
sess.dcx().emit_warning(errors::DeleteWorkProduct { path: &path, err });
sess.dcx().emit_warn(errors::DeleteWorkProduct { path: &path, err });
}
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn configure_and_expand(
}

if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
sess.dcx().emit_warning(errors::ProcMacroCratePanicAbort);
sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort);
}

sess.time("maybe_create_a_macro_crate", || {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ impl<'tcx> Queries<'tcx> {

// Some other attribute.
Some(_) => {
tcx.dcx().emit_warning(RustcErrorUnexpectedAnnotation {
span: tcx.def_span(def_id),
});
tcx.dcx()
.emit_warn(RustcErrorUnexpectedAnnotation { span: tcx.def_span(def_id) });
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C

base.retain(|crate_type| {
if output::invalid_output_for_target(session, *crate_type) {
session.dcx().emit_warning(errors::UnsupportedCrateTypeForTarget {
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
crate_type: *crate_type,
target_triple: &session.opts.target_triple,
});
Expand Down Expand Up @@ -507,16 +507,16 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
let unnamed_output_types =
sess.opts.output_types.values().filter(|a| a.is_none()).count();
let ofile = if unnamed_output_types > 1 {
sess.dcx().emit_warning(errors::MultipleOutputTypesAdaption);
sess.dcx().emit_warn(errors::MultipleOutputTypesAdaption);
None
} else {
if !sess.opts.cg.extra_filename.is_empty() {
sess.dcx().emit_warning(errors::IgnoringExtraFilename);
sess.dcx().emit_warn(errors::IgnoringExtraFilename);
}
Some(out_file.clone())
};
if sess.io.output_dir != None {
sess.dcx().emit_warning(errors::IgnoringOutDir);
sess.dcx().emit_warn(errors::IgnoringOutDir);
}

let out_filestem =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_monomorphize/src/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
MonoItemCollectionMode::Eager
} else {
if mode != "lazy" {
tcx.dcx().emit_warning(UnknownCguCollectionMode { mode });
tcx.dcx().emit_warn(UnknownCguCollectionMode { mode });
}

MonoItemCollectionMode::Lazy
Expand Down
Loading

0 comments on commit 3c4f1d8

Please sign in to comment.