diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 478f5d30a255c..491463865b5db 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -14,7 +14,7 @@ use cranelift_codegen::isa::CallConv; use cranelift_module::ModuleError; use rustc_abi::{CanonAbi, ExternAbi, X86Call}; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; -use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall; +use rustc_codegen_ssa::diagnostics::CompilerBuiltinsCannotCall; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::print::with_no_trimmed_paths; diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index 0e3fa72fbcfb3..184db4cb25778 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use gccjit::{Block, CType, Context, Function, FunctionType, LValue, Location, RValue, Type}; use rustc_abi::{Align, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx}; use rustc_codegen_ssa::base::wants_msvc_seh; -use rustc_codegen_ssa::errors as ssa_errors; +use rustc_codegen_ssa::diagnostics as ssa_errors; use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, MiscCodegenMethods}; use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, ToBaseN}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 06fbd287435d6..09ad3254e5714 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -8,7 +8,7 @@ use gccjit::{ComparisonOp, Function, FunctionType, RValue, ToRValue, Type, Unary use rustc_abi::{Align, BackendRepr, HasDataLayout, WrappingRange}; use rustc_codegen_ssa::base::wants_msvc_seh; use rustc_codegen_ssa::common::IntPredicate; -use rustc_codegen_ssa::errors::InvalidMonomorphization; +use rustc_codegen_ssa::diagnostics::InvalidMonomorphization; use rustc_codegen_ssa::mir::IntrinsicResult; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs index 82ef99703b253..1416f4eec9c4a 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/simd.rs @@ -7,8 +7,8 @@ use rustc_abi::{Align, Size}; use rustc_codegen_ssa::base::compare_simd_types; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; #[cfg(feature = "master")] -use rustc_codegen_ssa::errors::ExpectedPointerMutability; -use rustc_codegen_ssa::errors::InvalidMonomorphization; +use rustc_codegen_ssa::diagnostics::ExpectedPointerMutability; +use rustc_codegen_ssa::diagnostics::InvalidMonomorphization; use rustc_codegen_ssa::mir::operand::OperandRef; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, BuilderMethods}; diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 7ea30a5b4db6d..c018ab23c849a 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -8,7 +8,7 @@ use std::str; use rustc_abi::{HasDataLayout, Size, TargetDataLayout, VariantIdx}; use rustc_codegen_ssa::back::versioned_llvm_target; use rustc_codegen_ssa::base::{wants_msvc_seh, wants_wasm_eh}; -use rustc_codegen_ssa::errors as ssa_errors; +use rustc_codegen_ssa::diagnostics as ssa_errors; use rustc_codegen_ssa::traits::*; use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, ToBaseN}; use rustc_data_structures::fx::FxHashMap; diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 0d11f1e4fb69b..edf943c81a755 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -9,7 +9,7 @@ use rustc_abi::{ use rustc_codegen_ssa::RetagInfo; use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; -use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization}; +use rustc_codegen_ssa::diagnostics::{ExpectedPointerMutability, InvalidMonomorphization}; use rustc_codegen_ssa::mir::IntrinsicResult; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; diff --git a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs index f34a7b956e040..a25131c5ff9b4 100644 --- a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs +++ b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs @@ -37,7 +37,7 @@ use rustc_session::Session; use rustc_span::{Span, Symbol}; use tracing::debug; -use crate::errors; +use crate::diagnostics; #[allow(missing_docs)] pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTracker)) { @@ -107,7 +107,7 @@ impl<'tcx> AssertModuleSource<'tcx> { | CguFields::PartitionReused { cfg, module }) = cgu_fields; if !self.tcx.sess.opts.unstable_opts.query_dep_graph { - self.tcx.dcx().emit_fatal(errors::MissingQueryDepGraph { span }); + self.tcx.dcx().emit_fatal(diagnostics::MissingQueryDepGraph { span }); } if !self.check_config(cfg) { @@ -120,7 +120,11 @@ impl<'tcx> AssertModuleSource<'tcx> { let crate_name = crate_name.as_str(); if !user_path.starts_with(&crate_name) { - self.tcx.dcx().emit_fatal(errors::MalformedCguName { span, user_path, crate_name }); + self.tcx.dcx().emit_fatal(diagnostics::MalformedCguName { + span, + user_path, + crate_name, + }); } // Split of the "special suffix" if there is one. @@ -149,7 +153,7 @@ impl<'tcx> AssertModuleSource<'tcx> { if !self.available_cgus.contains(&cgu_name) { let cgu_names: Vec<&str> = self.available_cgus.items().map(|cgu| cgu.as_str()).into_sorted_stable_ord(); - self.tcx.dcx().emit_err(errors::NoModuleNamed { + self.tcx.dcx().emit_err(diagnostics::NoModuleNamed { span, user_path, cgu_name, @@ -273,7 +277,7 @@ impl CguReuseTracker { if error { let at_least = if at_least { 1 } else { 0 }; - sess.dcx().emit_err(errors::IncorrectCguReuseType { + sess.dcx().emit_err(diagnostics::IncorrectCguReuseType { span: *error_span, cgu_user_name, actual_reuse, @@ -282,7 +286,7 @@ impl CguReuseTracker { }); } } else { - sess.dcx().emit_fatal(errors::CguNotRecorded { cgu_user_name, cgu_name }); + sess.dcx().emit_fatal(diagnostics::CguNotRecorded { cgu_user_name, cgu_name }); } } } diff --git a/compiler/rustc_codegen_ssa/src/back/apple.rs b/compiler/rustc_codegen_ssa/src/back/apple.rs index 1b707a24066e1..104a3de012615 100644 --- a/compiler/rustc_codegen_ssa/src/back/apple.rs +++ b/compiler/rustc_codegen_ssa/src/back/apple.rs @@ -10,7 +10,7 @@ pub(super) use rustc_target::spec::apple::OSVersion; use rustc_target::spec::{Arch, Env, Os, Target}; use tracing::debug; -use crate::errors::{XcrunError, XcrunSdkPathWarning}; +use crate::diagnostics::{XcrunError, XcrunSdkPathWarning}; #[cfg(test)] mod tests; diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 4fc516b244857..c4107b4a60f27 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -26,8 +26,8 @@ use super::rmeta_link::{self, RmetaLinkCache}; use super::symbol_edit::{apply_edits, collect_internal_names}; use crate::common; // Public for ArchiveBuilderBuilder::extract_bundled_libs -pub use crate::errors::ExtractBundledLibsError; -use crate::errors::{ +pub use crate::diagnostics::ExtractBundledLibsError; +use crate::diagnostics::{ ArchiveBuildFailure, DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile, UnknownArchiveKind, }; @@ -502,7 +502,7 @@ impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> { { let actual_kind = archive.kind(); if !archive_kinds_compatible(actual_kind, expected_kind) { - self.sess.dcx().emit_warn(crate::errors::IncompatibleArchiveFormat { + self.sess.dcx().emit_warn(crate::diagnostics::IncompatibleArchiveFormat { path: archive_path.clone(), actual: archive_kind_display_name(actual_kind), expected: archive_kind_display_name(expected_kind), diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 45c9495570ed2..539b228e2b4b2 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -66,7 +66,7 @@ use super::{apple, rmeta_link, versioned_llvm_target}; use crate::base::needs_allocator_shim_for_linking; use crate::{ CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport, - errors, + diagnostics, }; pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) { @@ -187,7 +187,9 @@ pub fn link_binary( let tmpdir = TempDirBuilder::new() .prefix("rustc") .tempdir_in(output.parent().unwrap_or_else(|| Path::new("."))) - .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); + .unwrap_or_else(|error| { + sess.dcx().emit_fatal(diagnostics::CreateTempDir { error }) + }); let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); let crate_name = format!("{}", crate_info.local_crate_name); @@ -259,11 +261,15 @@ pub fn link_binary( if output.is_stdout() { if output.is_tty() { - sess.dcx().emit_err(errors::BinaryOutputToTty { + sess.dcx().emit_err(diagnostics::BinaryOutputToTty { shorthand: OutputType::Exe.shorthand(), }); } else if let Err(e) = copy_to_stdout(&out_filename) { - sess.dcx().emit_err(errors::CopyPath::new(&out_filename, output.as_path(), e)); + sess.dcx().emit_err(diagnostics::CopyPath::new( + &out_filename, + output.as_path(), + e, + )); } tempfiles_for_stdout_output.push(out_filename); } @@ -327,18 +333,18 @@ pub fn each_linked_rlib( info: &CrateInfo, crate_type: Option, f: &mut dyn FnMut(CrateNum, &Path), -) -> Result<(), errors::LinkRlibError> { +) -> Result<(), diagnostics::LinkRlibError> { let fmts = if let Some(crate_type) = crate_type { let Some(fmts) = info.dependency_formats.get(&crate_type) else { - return Err(errors::LinkRlibError::MissingFormat); + return Err(diagnostics::LinkRlibError::MissingFormat); }; fmts } else { let mut dep_formats = info.dependency_formats.iter(); - let (ty1, list1) = dep_formats.next().ok_or(errors::LinkRlibError::MissingFormat)?; + let (ty1, list1) = dep_formats.next().ok_or(diagnostics::LinkRlibError::MissingFormat)?; if let Some((ty2, list2)) = dep_formats.find(|(_, list2)| list1 != *list2) { - return Err(errors::LinkRlibError::IncompatibleDependencyFormats { + return Err(diagnostics::LinkRlibError::IncompatibleDependencyFormats { ty1: format!("{ty1:?}"), ty2: format!("{ty2:?}"), list1: format!("{list1:?}"), @@ -353,16 +359,16 @@ pub fn each_linked_rlib( match fmts.get(cnum) { Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue, Some(_) => {} - None => return Err(errors::LinkRlibError::MissingFormat), + None => return Err(diagnostics::LinkRlibError::MissingFormat), } let crate_name = info.crate_name[&cnum]; let used_crate_source = &info.used_crate_source[&cnum]; if let Some(path) = &used_crate_source.rlib { f(cnum, path); } else if used_crate_source.rmeta.is_some() { - return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name }); + return Err(diagnostics::LinkRlibError::OnlyRmetaFound { crate_name }); } else { - return Err(errors::LinkRlibError::NotFound { crate_name }); + return Err(diagnostics::LinkRlibError::NotFound { crate_name }); } } Ok(()) @@ -505,15 +511,16 @@ fn link_rlib<'a>( && let Some(filename) = native_lib_filenames[i] { let path = find_native_static_library(filename.as_str(), true, sess); - let src = read(path) - .unwrap_or_else(|e| sess.dcx().emit_fatal(errors::ReadFileError { message: e })); + let src = read(path).unwrap_or_else(|e| { + sess.dcx().emit_fatal(diagnostics::ReadFileError { message: e }) + }); let (data, _) = create_wrapper_file(sess, ".bundled_lib".to_string(), &src); let wrapper_file = emit_wrapper_file(sess, &data, tmpdir.as_ref(), filename.as_str()); packed_bundled_libs.push(wrapper_file); } else { let path = find_native_static_library(lib.name.as_str(), lib.verbatim, sess); ab.add_archive(&path, AddArchiveKind::Other).unwrap_or_else(|error| { - sess.dcx().emit_fatal(errors::AddNativeLibrary { library_path: path, error }) + sess.dcx().emit_fatal(diagnostics::AddNativeLibrary { library_path: path, error }) }); } } @@ -531,7 +538,7 @@ fn link_rlib<'a>( ) { ab.add_archive(&output_path, AddArchiveKind::Other).unwrap_or_else(|error| { sess.dcx() - .emit_fatal(errors::AddNativeLibrary { library_path: output_path, error }); + .emit_fatal(diagnostics::AddNativeLibrary { library_path: output_path, error }); }); } } @@ -676,12 +683,12 @@ fn link_staticlib( let exported_symbols = if hide || rename { if !matches!(sess.target.binary_format, BinaryFormat::Elf | BinaryFormat::MachO) { if hide { - sess.dcx().emit_warn(errors::StaticlibHideInternalSymbolsUnsupported { + sess.dcx().emit_warn(diagnostics::StaticlibHideInternalSymbolsUnsupported { binary_format: sess.target.archive_format.to_string(), }); } if rename { - sess.dcx().emit_warn(errors::StaticlibRenameInternalSymbolsUnsupported { + sess.dcx().emit_warn(diagnostics::StaticlibRenameInternalSymbolsUnsupported { binary_format: sess.target.archive_format.to_string(), }); } @@ -721,9 +728,9 @@ fn link_staticlib( if let Some(path) = &used_crate_source.dylib { all_rust_dylibs.push(&**path); } else if used_crate_source.rmeta.is_some() { - sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name }); + sess.dcx().emit_fatal(diagnostics::LinkRlibError::OnlyRmetaFound { crate_name }); } else { - sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name }); + sess.dcx().emit_fatal(diagnostics::LinkRlibError::NotFound { crate_name }); } } @@ -844,7 +851,7 @@ fn link_dwarf_object( Ok(()) }) { Ok(()) => {} - Err(e) => sess.dcx().emit_fatal(errors::ThorinErrorWrapper(e)), + Err(e) => sess.dcx().emit_fatal(diagnostics::ThorinErrorWrapper(e)), } } @@ -1226,7 +1233,7 @@ fn link_natively( let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); let escaped_output = escape_linker_output(&output, flavor); - let err = errors::LinkingFailed { + let err = diagnostics::LinkingFailed { linker_path: &linker_path, exit_status: prog.status, command: cmd, @@ -1247,25 +1254,25 @@ fn link_natively( find_msvc_tools::find_tool(sess.target.arch.desc(), "link.exe") .is_some(); - sess.dcx().emit_note(errors::LinkExeUnexpectedError); + sess.dcx().emit_note(diagnostics::LinkExeUnexpectedError); // STATUS_STACK_BUFFER_OVERRUN is also used for fast abnormal program termination, e.g. abort(). // Emit a special diagnostic to let people know that this most likely doesn't indicate a stack buffer overrun. const STATUS_STACK_BUFFER_OVERRUN: i32 = 0xc0000409u32 as _; if code == STATUS_STACK_BUFFER_OVERRUN { - sess.dcx().emit_note(errors::LinkExeStatusStackBufferOverrun); + sess.dcx().emit_note(diagnostics::LinkExeStatusStackBufferOverrun); } if is_vs_installed && has_linker { // the linker is broken - sess.dcx().emit_note(errors::RepairVSBuildTools); - sess.dcx().emit_note(errors::MissingCppBuildToolComponent); + sess.dcx().emit_note(diagnostics::RepairVSBuildTools); + sess.dcx().emit_note(diagnostics::MissingCppBuildToolComponent); } else if is_vs_installed { // the linker is not installed - sess.dcx().emit_note(errors::SelectCppBuildToolWorkload); + sess.dcx().emit_note(diagnostics::SelectCppBuildToolWorkload); } else { // visual studio is not installed - sess.dcx().emit_note(errors::VisualStudioNotInstalled); + sess.dcx().emit_note(diagnostics::VisualStudioNotInstalled); } } } @@ -1280,9 +1287,9 @@ fn link_natively( let linker_not_found = e.kind() == io::ErrorKind::NotFound; let err = if linker_not_found { - sess.dcx().emit_err(errors::LinkerNotFound { linker_path, error: e }) + sess.dcx().emit_err(diagnostics::LinkerNotFound { linker_path, error: e }) } else { - sess.dcx().emit_err(errors::UnableToExeLinker { + sess.dcx().emit_err(diagnostics::UnableToExeLinker { linker_path, error: e, command_formatted: format!("{cmd:?}"), @@ -1290,9 +1297,9 @@ fn link_natively( }; if sess.target.is_like_msvc && linker_not_found { - sess.dcx().emit_note(errors::MsvcMissingLinker); - sess.dcx().emit_note(errors::CheckInstalledVisualStudio); - sess.dcx().emit_note(errors::InsufficientVSCodeProduct); + sess.dcx().emit_note(diagnostics::MsvcMissingLinker); + sess.dcx().emit_note(diagnostics::CheckInstalledVisualStudio); + sess.dcx().emit_note(diagnostics::InsufficientVSCodeProduct); } err.raise_fatal(); } @@ -1317,13 +1324,13 @@ fn link_natively( if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - sess.dcx().emit_warn(errors::ProcessingDymutilFailed { + sess.dcx().emit_warn(diagnostics::ProcessingDymutilFailed { status: prog.status, output: escape_string(&output), }); } } - Err(error) => sess.dcx().emit_fatal(errors::UnableToRunDsymutil { error }), + Err(error) => sess.dcx().emit_fatal(diagnostics::UnableToRunDsymutil { error }), } } @@ -1382,7 +1389,7 @@ fn link_natively( if sess.target.is_like_aix { // `llvm-strip` doesn't work for AIX - their strip must be used. if !sess.host.is_like_aix { - sess.dcx().emit_warn(errors::AixStripNotUsed); + sess.dcx().emit_warn(diagnostics::AixStripNotUsed); } let stripcmd = "/usr/bin/strip"; match strip { @@ -1421,14 +1428,14 @@ fn strip_with_external_utility(sess: &Session, util: &str, out_filename: &Path, if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - sess.dcx().emit_warn(errors::StrippingDebugInfoFailed { + sess.dcx().emit_warn(diagnostics::StrippingDebugInfoFailed { util, status: prog.status, output: escape_string(&output), }); } } - Err(error) => sess.dcx().emit_fatal(errors::UnableToRun { util, error }), + Err(error) => sess.dcx().emit_fatal(diagnostics::UnableToRun { util, error }), } } @@ -1692,7 +1699,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { )), (Some(linker), None) => { let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { - sess.dcx().emit_fatal(errors::LinkerFileStem); + sess.dcx().emit_fatal(diagnostics::LinkerFileStem); }); let flavor = sess.target.linker_flavor.with_linker_hints(stem); let flavor = adjust_flavor_to_features(flavor, features); @@ -1863,10 +1870,10 @@ fn print_native_static_libs( match out { OutFileName::Real(path) => { out.overwrite(&lib_args.join(" "), sess); - sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path }); + sess.dcx().emit_note(diagnostics::StaticLibraryNativeArtifactsToFile { path }); } OutFileName::Stdout => { - sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts); + sess.dcx().emit_note(diagnostics::StaticLibraryNativeArtifacts); // Prefix for greppability // Note: This must not be translated as tools are allowed to depend on this exact string. sess.dcx().note(format!("native-static-libs: {}", lib_args.join(" "))); @@ -2114,7 +2121,7 @@ fn self_contained_components( // Emit an error if the user requested self-contained mode on the CLI but the target // explicitly refuses it. if sess.target.link_self_contained.is_disabled() { - sess.dcx().emit_err(errors::UnsupportedLinkSelfContained); + sess.dcx().emit_err(diagnostics::UnsupportedLinkSelfContained); } self_contained } else { @@ -2202,14 +2209,14 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty match (crate_type, &sess.target.link_script) { (CrateType::Cdylib | CrateType::Executable, Some(script)) => { if !sess.target.linker_flavor.is_gnu() { - sess.dcx().emit_fatal(errors::LinkScriptUnavailable); + sess.dcx().emit_fatal(diagnostics::LinkScriptUnavailable); } let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-"); let path = tmpdir.join(file_name); if let Err(error) = fs::write(&path, script.as_ref()) { - sess.dcx().emit_fatal(errors::LinkScriptWriteFailure { path, error }); + sess.dcx().emit_fatal(diagnostics::LinkScriptWriteFailure { path, error }); } cmd.link_arg("--script").link_arg(path); @@ -2428,7 +2435,7 @@ fn add_linked_symbol_object( let path = tmpdir.join("symbols.o"); let result = std::fs::write(&path, file.write().unwrap()); if let Err(error) = result { - sess.dcx().emit_fatal(errors::FailedToWrite { path, error }); + sess.dcx().emit_fatal(diagnostics::FailedToWrite { path, error }); } cmd.add_object(&path); } @@ -2868,7 +2875,7 @@ fn linker_with_args( // the directory of the stub to the linker search path. // We make an extra directory for this to avoid polluting the search path. if let Err(error) = fs::create_dir(&raw_dylib_dir) { - sess.dcx().emit_fatal(errors::CreateTempDir { error }) + sess.dcx().emit_fatal(diagnostics::CreateTempDir { error }) } cmd.include_path(&raw_dylib_dir); } @@ -3140,7 +3147,7 @@ fn collect_natvis_visualizers( visualizer_paths.push(visualizer_out_file); } Err(error) => { - sess.dcx().emit_warn(errors::UnableToWriteDebuggerVisualizer { + sess.dcx().emit_warn(diagnostics::UnableToWriteDebuggerVisualizer { path: visualizer_out_file, error, }); @@ -3562,8 +3569,10 @@ fn add_static_crate( false }), ) { - sess.dcx() - .emit_fatal(errors::RlibArchiveBuildFailure { path: cratepath.clone(), error }); + sess.dcx().emit_fatal(diagnostics::RlibArchiveBuildFailure { + path: cratepath.clone(), + error, + }); } if archive.build(&dst, None) { link_upstream(&dst); @@ -3910,7 +3919,7 @@ fn add_lld_args( if !linker_path_exists { // As a sanity check, we emit an error if none of these paths exist: we want // self-contained linking and have no linker. - sess.dcx().emit_fatal(errors::SelfContainedLinkerMissing); + sess.dcx().emit_fatal(diagnostics::SelfContainedLinkerMissing); } } diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index 956373381122d..dbc0abdb50da8 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -15,8 +15,8 @@ use rustc_target::spec::Arch; use crate::back::archive::ImportLibraryItem; use crate::back::link::ArchiveBuilderBuilder; -use crate::errors::ErrorCreatingImportLibrary; -use crate::{NativeLib, common, errors}; +use crate::diagnostics::ErrorCreatingImportLibrary; +use crate::{NativeLib, common, diagnostics}; /// Extract all symbols defined in raw-dylib libraries, collated by library name. /// @@ -41,7 +41,7 @@ fn collate_raw_dylibs_windows<'a>( // FIXME: when we add support for ordinals, figure out if we need to do anything // if we have two DllImport values with the same name but different ordinals. if import.calling_convention != old_import.calling_convention { - sess.dcx().emit_err(errors::MultipleExternalFuncDecl { + sess.dcx().emit_err(diagnostics::MultipleExternalFuncDecl { span: import.span, function: import.name, library_name: &name, diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index e24e7bad2b945..e1b4ce372507c 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -25,7 +25,7 @@ use super::command::Command; use super::symbol_export; use crate::back::symbol_export::allocator_shim_symbols; use crate::base::needs_allocator_shim_for_linking; -use crate::{SymbolExport, errors}; +use crate::{SymbolExport, diagnostics}; #[cfg(test)] mod tests; @@ -484,11 +484,11 @@ impl<'a> 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_warn(errors::Ld64UnimplementedModifier); + self.sess.dcx().emit_warn(diagnostics::Ld64UnimplementedModifier); } else if self.is_gnu && !self.sess.target.is_like_windows { self.link_arg("--no-as-needed"); } else { - self.sess.dcx().emit_warn(errors::LinkerUnsupportedModifier); + self.sess.dcx().emit_warn(diagnostics::LinkerUnsupportedModifier); } } @@ -619,7 +619,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.link_or_cc_arg("-needed_framework").link_or_cc_arg(name); - self.sess.dcx().emit_warn(errors::Ld64UnimplementedModifier); + self.sess.dcx().emit_warn(diagnostics::Ld64UnimplementedModifier); } self.link_or_cc_args(&["-framework", name]); } @@ -822,7 +822,7 @@ impl<'a> Linker for GccLinker<'a> { } }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::LibDefWriteFailure { error }); } self.link_arg("-exported_symbols_list").link_arg(path); } else if self.sess.target.is_like_windows { @@ -842,7 +842,7 @@ impl<'a> Linker for GccLinker<'a> { } }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::LibDefWriteFailure { error }); } self.link_arg(path); } else if self.sess.target.is_like_wasm { @@ -861,7 +861,7 @@ impl<'a> Linker for GccLinker<'a> { writeln!(f, "}};")?; }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::VersionScriptWriteFailure { error }); } self.link_arg("--dynamic-list").link_arg(path); } else { @@ -879,7 +879,7 @@ impl<'a> Linker for GccLinker<'a> { writeln!(f, "\n local:\n *;\n}};")?; }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::VersionScriptWriteFailure { error }); } if self.sess.target.is_like_solaris { self.link_arg("-M").link_arg(path); @@ -1103,7 +1103,7 @@ impl<'a> Linker for MsvcLinker<'a> { } } Err(error) => { - self.sess.dcx().emit_warn(errors::NoNatvisDirectory { error }); + self.sess.dcx().emit_warn(diagnostics::NoNatvisDirectory { error }); } } } @@ -1136,7 +1136,7 @@ impl<'a> Linker for MsvcLinker<'a> { writeln!(f, "EXPORTS")?; }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::LibDefWriteFailure { error }); } let mut arg = OsString::from("/DEF:"); arg.push(path); @@ -1556,7 +1556,7 @@ impl<'a> Linker for L4Bender<'a> { fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[SymbolExport]) { // ToDo, not implemented, copy from GCC - self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented); + self.sess.dcx().emit_warn(diagnostics::L4BenderExportingSymbolsUnimplemented); } fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind) { @@ -2012,7 +2012,7 @@ impl<'a> Linker for BpfLinker<'a> { } fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) { - self.sess.dcx().emit_fatal(errors::BpfStaticlibNotSupported) + self.sess.dcx().emit_fatal(diagnostics::BpfStaticlibNotSupported) } fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) { @@ -2061,7 +2061,7 @@ impl<'a> Linker for BpfLinker<'a> { } }; if let Err(error) = res { - self.sess.dcx().emit_fatal(errors::SymbolFileWriteFailure { error }); + self.sess.dcx().emit_fatal(diagnostics::SymbolFileWriteFailure { error }); } else { self.link_arg("--export-symbols").link_arg(&path); } diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs index ed36fae3cdc4d..0b33c1db8e5dc 100644 --- a/compiler/rustc_codegen_ssa/src/back/lto.rs +++ b/compiler/rustc_codegen_ssa/src/back/lto.rs @@ -14,7 +14,7 @@ use tracing::info; use crate::back::symbol_export::{self, allocator_shim_symbols, symbol_name_for_instance_in_crate}; use crate::back::write::CodegenContext; use crate::base::allocator_kind_for_codegen; -use crate::errors::{DynamicLinkingWithLTO, LtoDisallowed, LtoDylib, LtoProcMacro}; +use crate::diagnostics::{DynamicLinkingWithLTO, LtoDisallowed, LtoDylib, LtoProcMacro}; use crate::traits::*; pub struct ThinModule { diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 6f526879f7766..951a60426b5d5 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -24,7 +24,7 @@ use rustc_target::spec::{CfgAbi, LlvmAbi, Os, RelocModel, Target, ef_avr_arch}; use tracing::debug; use super::apple; -use crate::errors; +use crate::diagnostics; /// The default metadata loader. This is used by cg_llvm and cg_clif. /// @@ -371,7 +371,7 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 { if let Some(ref cpu) = sess.opts.cg.target_cpu { ef_avr_arch(cpu) } else { - sess.dcx().emit_fatal(errors::CpuRequired) + sess.dcx().emit_fatal(diagnostics::CpuRequired) } } Architecture::Csky => { diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 1419fcaf733f3..88abbf8efe905 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -33,11 +33,11 @@ use tracing::debug; use crate::back::link::ensure_removed; use crate::back::lto::{self, SerializedModule, check_lto_allowed}; -use crate::errors::ErrorCreatingRemarkDir; +use crate::diagnostics::ErrorCreatingRemarkDir; use crate::traits::*; use crate::{ CachedModuleCodegen, CompiledModule, CompiledModules, CrateInfo, ModuleCodegen, ModuleKind, - errors, + diagnostics, }; const PRE_LTO_BC_EXT: &str = "pre-lto.bc"; @@ -515,10 +515,10 @@ pub fn produce_final_output_artifacts( // Produce final compile outputs. let copy_gracefully = |from: &Path, to: &OutFileName| match to { OutFileName::Stdout if let Err(e) = copy_to_stdout(from) => { - sess.dcx().emit_err(errors::CopyPath::new(from, to.as_path(), e)); + sess.dcx().emit_err(diagnostics::CopyPath::new(from, to.as_path(), e)); } OutFileName::Real(path) if let Err(e) = fs::copy(from, path) => { - sess.dcx().emit_err(errors::CopyPath::new(from, path, e)); + sess.dcx().emit_err(diagnostics::CopyPath::new(from, path, e)); } _ => {} }; @@ -530,8 +530,9 @@ pub fn produce_final_output_artifacts( let path = crate_output.temp_path_for_cgu(output_type, &module.name); let output = crate_output.path(output_type); if !output_type.is_text_output() && output.is_tty() { - sess.dcx() - .emit_err(errors::BinaryOutputToTty { shorthand: output_type.shorthand() }); + sess.dcx().emit_err(diagnostics::BinaryOutputToTty { + shorthand: output_type.shorthand(), + }); } else { copy_gracefully(&path, &output); } @@ -543,12 +544,14 @@ pub fn produce_final_output_artifacts( if crate_output.outputs.contains_explicit_name(&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_warn(errors::IgnoringEmitPath { extension: output_type.extension() }); + sess.dcx().emit_warn(diagnostics::IgnoringEmitPath { + extension: output_type.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_warn(errors::IgnoringOutput { extension: output_type.extension() }); + sess.dcx() + .emit_warn(diagnostics::IgnoringOutput { extension: output_type.extension() }); } else { // 4) Multiple codegen units, but no explicit name. We // just leave the `foo.0.x` files in place. @@ -900,7 +903,7 @@ fn execute_copy_from_cache_work_item( Some(output_path) } Err(error) => { - dcx.emit_err(errors::CopyPathBuf { + dcx.emit_err(diagnostics::CopyPathBuf { source_file: source_file_in_incr_comp_dir, output_path, error, @@ -945,7 +948,7 @@ fn execute_copy_from_cache_work_item( None }; if should_emit_obj && object.is_none() { - dcx.emit_fatal(errors::NoSavedObjectFile { cgu_name: &module.name }) + dcx.emit_fatal(diagnostics::NoSavedObjectFile { cgu_name: &module.name }) } CompiledModule { diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 43d5e312c6b40..ae049cfc37f95 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -51,7 +51,7 @@ use crate::mir::place::PlaceRef; use crate::traits::*; use crate::{ CachedModuleCodegen, CodegenLintLevelSpecs, CrateInfo, EiiLinkageImplInfo, EiiLinkageInfo, - ModuleCodegen, errors, meth, mir, + ModuleCodegen, diagnostics, meth, mir, }; pub(crate) fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate { @@ -529,7 +529,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let Some(llfn) = cx.declare_c_main(llfty) else { // FIXME: We should be smart and show a better diagnostic here. let span = cx.tcx().def_span(rust_main_def_id); - cx.tcx().dcx().emit_fatal(errors::MultipleMainFunctions { span }); + cx.tcx().dcx().emit_fatal(diagnostics::MultipleMainFunctions { span }); }; // `main` should respect same config for frame pointer elimination as rest of code @@ -698,14 +698,14 @@ pub fn codegen_crate< ) -> OngoingCodegen { if tcx.sess.target.need_explicit_cpu && tcx.sess.opts.cg.target_cpu.is_none() { // The target has no default cpu, but none is set explicitly - tcx.dcx().emit_fatal(errors::CpuRequired); + tcx.dcx().emit_fatal(diagnostics::CpuRequired); } if let Some(target_cpu) = &tcx.sess.opts.cg.target_cpu && tcx.sess.target.unsupported_cpus.contains(&target_cpu.into()) { // The target cpu is explicitly listed as an unsupported cpu - tcx.dcx().emit_fatal(errors::CpuUnsupported { target_cpu: target_cpu.clone() }); + tcx.dcx().emit_fatal(diagnostics::CpuUnsupported { target_cpu: target_cpu.clone() }); } let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index fb21f9ddbf2fa..691b13f03e965 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -19,7 +19,7 @@ use rustc_session::lint; use rustc_span::{Span, sym}; use rustc_target::spec::Os; -use crate::errors; +use crate::diagnostics; use crate::target_features::{ check_target_feature_trait_unsafe, check_tied_features, from_target_feature_attr, }; @@ -517,10 +517,10 @@ fn check_result( .unwrap_or_else(|| tcx.def_span(did)); tcx.dcx() - .create_err(errors::TargetFeatureDisableOrEnable { + .create_err(diagnostics::TargetFeatureDisableOrEnable { features, span: Some(span), - missing_features: Some(errors::MissingFeatures), + missing_features: Some(diagnostics::MissingFeatures), }) .emit(); } diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/diagnostics.rs similarity index 100% rename from compiler/rustc_codegen_ssa/src/errors.rs rename to compiler/rustc_codegen_ssa/src/diagnostics.rs diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 3608f18345ed0..9a42debe1dd97 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -48,7 +48,7 @@ pub mod base; pub mod codegen_attrs; pub mod common; pub mod debuginfo; -pub mod errors; +pub mod diagnostics; pub mod meth; pub mod mir; pub mod mono_item; diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index fba0cff0e6e14..99075536d04a8 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -26,7 +26,7 @@ use super::place::{PlaceRef, PlaceValue}; use super::{CachedLlbb, FunctionCx, LocalRef}; use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization}; use crate::common::{self, IntPredicate}; -use crate::errors::CompilerBuiltinsCannotCall; +use crate::diagnostics::CompilerBuiltinsCannotCall; use crate::mir::IntrinsicResult; use crate::traits::*; use crate::{MemFlags, meth}; diff --git a/compiler/rustc_codegen_ssa/src/mir/constant.rs b/compiler/rustc_codegen_ssa/src/mir/constant.rs index d4747c1cbafc9..7d35d4b72bd1e 100644 --- a/compiler/rustc_codegen_ssa/src/mir/constant.rs +++ b/compiler/rustc_codegen_ssa/src/mir/constant.rs @@ -5,7 +5,7 @@ use rustc_middle::ty::{self, Ty}; use rustc_middle::{bug, mir, span_bug}; use super::FunctionCx; -use crate::errors; +use crate::diagnostics; use crate::mir::operand::OperandRef; use crate::traits::*; @@ -98,7 +98,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.const_vector(&values) }) .unwrap_or_else(|| { - bx.tcx().dcx().emit_err(errors::ShuffleIndicesEvaluation { span: constant.span }); + bx.tcx() + .dcx() + .emit_err(diagnostics::ShuffleIndicesEvaluation { span: constant.span }); // We've errored, so we don't have to produce working code. let llty = bx.backend_type(bx.layout_of(ty)); bx.const_undef(llty) diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index 6116c0fa9eb98..284b7d3f14fed 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -10,7 +10,7 @@ use super::operand::{OperandRef, OperandValue}; use super::place::PlaceValue; use super::{FunctionCx, IntrinsicResult}; use crate::common::{AtomicRmwBinOp, SynchronizationScope}; -use crate::errors::InvalidMonomorphization; +use crate::diagnostics::InvalidMonomorphization; use crate::mir::operand::OperandRefBuilder; use crate::traits::*; use crate::{MemFlags, meth, size_of_val}; diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index b23472c794b88..8f459e5a218d2 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -14,8 +14,8 @@ use rustc_target::spec::{Arch, SanitizerSet}; use rustc_target::target_features::{RUSTC_SPECIFIC_FEATURES, Stability}; use smallvec::SmallVec; -use crate::errors::{CrossArchFeatureNote, FeatureNotValid, FeatureNotValidHint}; -use crate::{errors, target_features}; +use crate::diagnostics::{CrossArchFeatureNote, FeatureNotValid, FeatureNotValidHint}; +use crate::{diagnostics, target_features}; /// Compute the enabled target features from the `#[target_feature]` function attribute. /// Enabled target features are added to `target_features`. @@ -72,7 +72,7 @@ pub(crate) fn from_target_feature_attr( // Only allow target features whose feature gates have been enabled // and which are permitted to be toggled. if let Err(reason) = stability.toggle_allowed() { - tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr { + tcx.dcx().emit_err(diagnostics::ForbiddenTargetFeatureAttr { span: feature_span, feature: feature_str, reason, @@ -104,10 +104,10 @@ pub(crate) fn from_target_feature_attr( AARCH64_SOFTFLOAT_NEON, tcx.local_def_id_to_hir_id(did), feature_span, - errors::Aarch64SoftfloatNeon, + diagnostics::Aarch64SoftfloatNeon, ); } else { - tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr { + tcx.dcx().emit_err(diagnostics::ForbiddenTargetFeatureAttr { span: feature_span, feature: name.as_str(), reason: "this feature is incompatible with the target ABI", @@ -156,7 +156,7 @@ pub(crate) fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, if let DefKind::AssocFn = tcx.def_kind(id) { let parent_id = tcx.local_parent(id); if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) { - tcx.dcx().emit_err(errors::TargetFeatureSafeTrait { + tcx.dcx().emit_err(diagnostics::TargetFeatureSafeTrait { span: attr_span, def: tcx.def_span(id), }); @@ -275,7 +275,7 @@ pub fn cfg_target_feature<'a, const N: usize>( &sess.opts.cg.target_feature, /* err_callback */ |feature| { - sess.dcx().emit_warn(errors::UnknownCTargetFeaturePrefix { feature }); + sess.dcx().emit_warn(diagnostics::UnknownCTargetFeaturePrefix { feature }); }, |base_feature, new_features, enable| { // Iteration order is irrelevant since this only influences an `FxHashMap`. @@ -310,21 +310,21 @@ pub fn cfg_target_feature<'a, const N: usize>( } }); let unknown_feature = if let Some(rust_feature) = rust_feature { - errors::UnknownCTargetFeature { + diagnostics::UnknownCTargetFeature { feature: base_feature, - rust_feature: errors::PossibleFeature::Some { rust_feature }, + rust_feature: diagnostics::PossibleFeature::Some { rust_feature }, } } else { - errors::UnknownCTargetFeature { + diagnostics::UnknownCTargetFeature { feature: base_feature, - rust_feature: errors::PossibleFeature::None, + rust_feature: diagnostics::PossibleFeature::None, } }; sess.dcx().emit_warn(unknown_feature); } Some((_, stability, _)) => { if let Stability::Forbidden { reason, hard_error } = stability { - let diag = errors::ForbiddenCTargetFeature { + let diag = diagnostics::ForbiddenCTargetFeature { feature: base_feature, enabled: if enable { "enabled" } else { "disabled" }, reason, @@ -345,7 +345,7 @@ pub fn cfg_target_feature<'a, const N: usize>( } else { "this feature is not stably supported" }; - sess.dcx().emit_warn(errors::UnstableCTargetFeature { + sess.dcx().emit_warn(diagnostics::UnstableCTargetFeature { feature: base_feature, note, }); @@ -356,7 +356,7 @@ pub fn cfg_target_feature<'a, const N: usize>( ); if let Some(f) = check_tied_features(sess, &enabled_disabled_features) { - sess.dcx().emit_err(errors::TargetFeatureDisableOrEnable { + sess.dcx().emit_err(diagnostics::TargetFeatureDisableOrEnable { features: f, span: None, missing_features: None,