diff --git a/Cargo.lock b/Cargo.lock index 23abc6626aaba..1b969121b71da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3771,7 +3771,6 @@ dependencies = [ "rustc_abi", "rustc_ast", "rustc_ast_pretty", - "rustc_borrowck", "rustc_codegen_ssa", "rustc_const_eval", "rustc_data_structures", @@ -3791,13 +3790,11 @@ dependencies = [ "rustc_mir_build", "rustc_mir_transform", "rustc_parse", - "rustc_passes", "rustc_public", "rustc_resolve", "rustc_session", "rustc_span", "rustc_target", - "rustc_trait_selection", "serde_json", "shlex", "tracing", diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 39e512be6820f..10e1b1987194a 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -10,7 +10,6 @@ jiff = { version = "0.2.5", default-features = false, features = ["std"] } rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } -rustc_borrowck = { path = "../rustc_borrowck" } rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } rustc_const_eval = { path = "../rustc_const_eval" } rustc_data_structures = { path = "../rustc_data_structures" } @@ -30,13 +29,11 @@ rustc_middle = { path = "../rustc_middle" } rustc_mir_build = { path = "../rustc_mir_build" } rustc_mir_transform = { path = "../rustc_mir_transform" } rustc_parse = { path = "../rustc_parse" } -rustc_passes = { path = "../rustc_passes" } rustc_public = { path = "../rustc_public", features = ["rustc_internal"] } rustc_resolve = { path = "../rustc_resolve" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } -rustc_trait_selection = { path = "../rustc_trait_selection" } serde_json = "1.0.59" shlex = "1.0" tracing = { version = "0.1.35" } diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 2e97b4fed245d..2c0269a582855 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -108,23 +108,6 @@ use crate::session_diagnostics::{ RLinkWrongFileType, RlinkCorruptFile, RlinkNotAFile, RlinkUnableToRead, UnstableFeatureUsage, }; -pub fn default_translator() -> Translator { - Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false) -} - -pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[ - // tidy-alphabetical-start - rustc_borrowck::DEFAULT_LOCALE_RESOURCE, - rustc_const_eval::DEFAULT_LOCALE_RESOURCE, - rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE, - rustc_lint::DEFAULT_LOCALE_RESOURCE, - rustc_mir_build::DEFAULT_LOCALE_RESOURCE, - rustc_parse::DEFAULT_LOCALE_RESOURCE, - rustc_passes::DEFAULT_LOCALE_RESOURCE, - rustc_trait_selection::DEFAULT_LOCALE_RESOURCE, - // tidy-alphabetical-end -]; - /// Exit status code used for successful compilation and help output. pub const EXIT_SUCCESS: i32 = 0; @@ -235,7 +218,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send)) output_dir: odir, ice_file, file_loader: None, - locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(), lint_caps: Default::default(), psess_created: None, hash_untracked_state: None, @@ -1545,7 +1527,7 @@ fn report_ice( extra_info: fn(&DiagCtxt), using_internal_features: &AtomicBool, ) { - let translator = default_translator(); + let translator = Translator::with_fallback_bundle(vec![], false); let emitter = Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new( stderr_destination(rustc_errors::ColorConfig::Auto), diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 9fcc5908952d4..d7ddebe796bf2 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -8,6 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::jobserver::{self, Proxy}; use rustc_data_structures::stable_hasher::StableHasher; use rustc_errors::registry::Registry; +use rustc_errors::translation::Translator; use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed}; use rustc_lint::LintStore; use rustc_middle::ty; @@ -316,6 +317,23 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch check_cfg } +pub fn default_translator() -> Translator { + Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false) +} + +static DEFAULT_LOCALE_RESOURCES: &[&str] = &[ + // tidy-alphabetical-start + rustc_borrowck::DEFAULT_LOCALE_RESOURCE, + rustc_const_eval::DEFAULT_LOCALE_RESOURCE, + rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE, + rustc_lint::DEFAULT_LOCALE_RESOURCE, + rustc_mir_build::DEFAULT_LOCALE_RESOURCE, + rustc_parse::DEFAULT_LOCALE_RESOURCE, + rustc_passes::DEFAULT_LOCALE_RESOURCE, + rustc_trait_selection::DEFAULT_LOCALE_RESOURCE, + // tidy-alphabetical-end +]; + /// The compiler configuration pub struct Config { /// Command line options @@ -335,9 +353,6 @@ pub struct Config { /// bjorn3 for "hooking rust-analyzer's VFS into rustc at some point for /// running rustc without having to save". (See #102759.) pub file_loader: Option>, - /// The list of fluent resources, used for lints declared with - /// [`Diagnostic`](rustc_errors::Diagnostic) and [`LintDiagnostic`](rustc_errors::LintDiagnostic). - pub locale_resources: Vec<&'static str>, pub lint_caps: FxHashMap, @@ -465,7 +480,7 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se }, bundle, config.registry, - config.locale_resources, + DEFAULT_LOCALE_RESOURCES.to_owned(), config.lint_caps, target, util::rustc_version_str().unwrap_or("unknown"), diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs index 360f70c8e865a..e845ea534b407 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-example.rs @@ -32,10 +32,9 @@ fn main() { "# .into(), }, - output_dir: None, // Option - output_file: None, // Option - file_loader: None, // Option> - locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(), + output_dir: None, // Option + output_file: None, // Option + file_loader: None, // Option> lint_caps: FxHashMap::default(), // FxHashMap // This is a callback from the driver that is called when [`ParseSess`] is created. psess_created: None, //Option> diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs index 2512ba3c3f924..06374268e1ba4 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs @@ -66,7 +66,6 @@ fn main() { output_dir: None, output_file: None, file_loader: None, - locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(), lint_caps: rustc_hash::FxHashMap::default(), psess_created: Some(Box::new(|parse_sess| { parse_sess.dcx().set_emitter(Box::new(DebugEmitter { diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index b5a8d64ff4f56..4e7349943767c 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -63,7 +63,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option, unstable_opts: &UnstableOptions, ) -> rustc_errors::DiagCtxt { - let translator = rustc_driver::default_translator(); + let translator = rustc_interface::interface::default_translator(); let emitter: Box = match error_format { ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { short, unicode } => Box::new( @@ -289,7 +289,6 @@ pub(crate) fn create_config( output_file: None, output_dir: None, file_loader: None, - locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), lint_caps, psess_created: None, hash_untracked_state: None, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 6cd7d2c628d58..bdf4ac9fd49ee 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -188,7 +188,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions output_file: None, output_dir: None, file_loader: None, - locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), lint_caps, psess_created: None, hash_untracked_state: None, diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index d30d869cd4c19..21e12e844d080 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -467,7 +467,7 @@ fn parse_source( let filename = FileName::anon_source_code(&wrapped_source); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); - let translator = rustc_driver::default_translator(); + let translator = rustc_interface::interface::default_translator(); let supports_color = match get_stderr_color_choice(ColorConfig::Auto, &std::io::stderr()) { ColorChoice::Auto => unreachable!(), ColorChoice::AlwaysAnsi | ColorChoice::Always => true, diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index b08533317abeb..30d07901ba40c 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -36,7 +36,7 @@ fn check_rust_syntax( code_block: RustCodeBlock, ) { let buffer = Arc::new(Lock::new(Buffer::default())); - let translator = rustc_driver::default_translator(); + let translator = rustc_interface::interface::default_translator(); let emitter = BufferEmitter { buffer: Arc::clone(&buffer), translator }; let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); diff --git a/tests/ui-fulldeps/run-compiler-twice.rs b/tests/ui-fulldeps/run-compiler-twice.rs index 241d9e7efbd72..53b139e788884 100644 --- a/tests/ui-fulldeps/run-compiler-twice.rs +++ b/tests/ui-fulldeps/run-compiler-twice.rs @@ -64,7 +64,6 @@ fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path output_dir: None, ice_file: None, file_loader: None, - locale_resources: Vec::new(), lint_caps: Default::default(), psess_created: None, hash_untracked_state: None,