diff --git a/compiler/rustc_ast_passes/src/show_span.rs b/compiler/rustc_ast_passes/src/show_span.rs index 9882f1d23ce67..1059007428221 100644 --- a/compiler/rustc_ast_passes/src/show_span.rs +++ b/compiler/rustc_ast_passes/src/show_span.rs @@ -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); } diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 77678dcaba9e1..b3f601b75956c 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -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; }; diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs index df917d527ced8..4babe5bfb813f 100644 --- a/compiler/rustc_codegen_gcc/src/gcc_util.rs +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec c, Some(_) => { if diagnostics { - sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s }); + sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s }); } return None; } @@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec { 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 => {} @@ -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| { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 03b79a143cc31..99f4488ac0f97 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec c, Some(_) => { if diagnostics { - sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s }); + sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s }); } return None; } @@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec( 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), }); @@ -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), @@ -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, }); diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 695aeb0b2fb77..90f5027c26494 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -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(); @@ -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); } @@ -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 }); } } } @@ -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; } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index d2c6b6e0c7bf6..6c066e61a583a 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -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. diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 7fb5f10c6ca75..19489f1e7ef5f 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -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 }); } } diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 3047f5d47e4d6..2e4baf26176c3 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -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") diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9a5e73536fe0c..e3aa9477874c9 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1086,7 +1086,7 @@ impl DiagCtxt { } #[track_caller] - pub fn create_warning<'a>( + pub fn create_warn<'a>( &'a self, warning: impl IntoDiagnostic<'a, ()>, ) -> DiagnosticBuilder<'a, ()> { @@ -1094,8 +1094,8 @@ impl DiagCtxt { } #[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] diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 2c6ae91786d10..e18b1365d9c02 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -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); @@ -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); @@ -322,7 +322,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option) { ); 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); @@ -365,7 +365,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option) { } 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 @@ -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 }); } } @@ -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 }); } } } @@ -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)); } @@ -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)); } diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index ce8f5bb69ae3b..96bfe766c20f5 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -51,7 +51,7 @@ impl LoadResult { 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 => { diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index 1450d8a99abbc..906233ef53ec8 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -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, @@ -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 }); } } } diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index ce76c2cba939c..9795640412069 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -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", || { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 9da806e0779a0..e66ea6f2ca961 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -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) }); } } } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 92a6445ed0916..9fd44e46b316e 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -431,7 +431,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec 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 = diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 08e628408394e..2c40cd4d8f26e 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -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 diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index 775082adbe81e..fbc77f2878081 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -264,14 +264,14 @@ pub(crate) fn emit_unescape_error( } EscapeError::UnskippedWhitespaceWarning => { let (c, char_span) = last_char(); - dcx.emit_warning(UnescapeError::UnskippedWhitespace { + dcx.emit_warn(UnescapeError::UnskippedWhitespace { span: err_span, ch: escaped_char(c), char_span, }); } EscapeError::MultipleSkippedLinesWarning => { - dcx.emit_warning(UnescapeError::MultipleSkippedLinesWarning(err_span)); + dcx.emit_warn(UnescapeError::MultipleSkippedLinesWarning(err_span)); } } } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index db777266b59d2..ec91670175e88 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2150,7 +2150,7 @@ impl<'a> Parser<'a> { if [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suffix) { // #59553: warn instead of reject out of hand to allow the fix to percolate // through the ecosystem when people fix their macros - self.dcx().emit_warning(errors::InvalidLiteralSuffixOnTupleIndex { + self.dcx().emit_warn(errors::InvalidLiteralSuffixOnTupleIndex { span, suffix, exception: Some(()), diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 3e5fb1a6b472e..3e3f2771f5fb1 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -122,7 +122,7 @@ impl<'tcx> CheckConstVisitor<'tcx> { // corresponding feature gate. This encourages nightly users to use feature gates when // possible. None if tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you => { - tcx.dcx().emit_warning(SkippingConstChecks { span }); + tcx.dcx().emit_warn(SkippingConstChecks { span }); return; } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index bc6d6f7d56c2c..ee635de6da4ec 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -263,7 +263,7 @@ impl Session { if !unleashed_features.is_empty() { let mut must_err = false; // Create a diagnostic pointing at where things got unleashed. - self.dcx().emit_warning(errors::SkippingConstChecks { + self.dcx().emit_warn(errors::SkippingConstChecks { unleashed_features: unleashed_features .iter() .map(|(span, gate)| { @@ -574,7 +574,7 @@ impl Session { // We only call `msg` in case we can actually emit warnings. // Otherwise, this could cause a `good_path_delayed_bug` to // trigger (issue #79546). - self.dcx().emit_warning(errors::OptimisationFuelExhausted { msg: msg() }); + self.dcx().emit_warn(errors::OptimisationFuelExhausted { msg: msg() }); } fuel.out_of_fuel = true; } else if fuel.remaining > 0 { @@ -1129,7 +1129,7 @@ pub fn build_session( match profiler { Ok(profiler) => Some(Arc::new(profiler)), Err(e) => { - dcx.emit_warning(errors::FailedToCreateProfiler { err: e.to_string() }); + dcx.emit_warn(errors::FailedToCreateProfiler { err: e.to_string() }); None } } @@ -1341,7 +1341,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { if sess.opts.unstable_opts.stack_protector != StackProtector::None { if !sess.target.options.supports_stack_protector { - sess.dcx().emit_warning(errors::StackProtectorNotSupportedForTarget { + sess.dcx().emit_warn(errors::StackProtectorNotSupportedForTarget { stack_protector: sess.opts.unstable_opts.stack_protector, target_triple: &sess.opts.target_triple, });