Skip to content

Commit 4d3c16a

Browse files
committed
Hard code DEFAULT_LOCALE_RESOURCES in rustc_interface
locale_resources will no longer be used at all soon, so no need for custom drivers to have the ability to define their own locale_resources. Also hard code report_ice to not use any locale resources. It only emits diagnostics that have already been ported to inline fluent messages.
1 parent 66daca1 commit 4d3c16a

12 files changed

Lines changed: 27 additions & 41 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,7 +3771,6 @@ dependencies = [
37713771
"rustc_abi",
37723772
"rustc_ast",
37733773
"rustc_ast_pretty",
3774-
"rustc_borrowck",
37753774
"rustc_codegen_ssa",
37763775
"rustc_const_eval",
37773776
"rustc_data_structures",
@@ -3791,13 +3790,11 @@ dependencies = [
37913790
"rustc_mir_build",
37923791
"rustc_mir_transform",
37933792
"rustc_parse",
3794-
"rustc_passes",
37953793
"rustc_public",
37963794
"rustc_resolve",
37973795
"rustc_session",
37983796
"rustc_span",
37993797
"rustc_target",
3800-
"rustc_trait_selection",
38013798
"serde_json",
38023799
"shlex",
38033800
"tracing",

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jiff = { version = "0.2.5", default-features = false, features = ["std"] }
1010
rustc_abi = { path = "../rustc_abi" }
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
13-
rustc_borrowck = { path = "../rustc_borrowck" }
1413
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
1514
rustc_const_eval = { path = "../rustc_const_eval" }
1615
rustc_data_structures = { path = "../rustc_data_structures" }
@@ -30,13 +29,11 @@ rustc_middle = { path = "../rustc_middle" }
3029
rustc_mir_build = { path = "../rustc_mir_build" }
3130
rustc_mir_transform = { path = "../rustc_mir_transform" }
3231
rustc_parse = { path = "../rustc_parse" }
33-
rustc_passes = { path = "../rustc_passes" }
3432
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
3533
rustc_resolve = { path = "../rustc_resolve" }
3634
rustc_session = { path = "../rustc_session" }
3735
rustc_span = { path = "../rustc_span" }
3836
rustc_target = { path = "../rustc_target" }
39-
rustc_trait_selection = { path = "../rustc_trait_selection" }
4037
serde_json = "1.0.59"
4138
shlex = "1.0"
4239
tracing = { version = "0.1.35" }

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,6 @@ use crate::session_diagnostics::{
108108
RLinkWrongFileType, RlinkCorruptFile, RlinkNotAFile, RlinkUnableToRead, UnstableFeatureUsage,
109109
};
110110

111-
pub fn default_translator() -> Translator {
112-
Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false)
113-
}
114-
115-
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
116-
// tidy-alphabetical-start
117-
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
118-
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
119-
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
120-
rustc_lint::DEFAULT_LOCALE_RESOURCE,
121-
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
122-
rustc_parse::DEFAULT_LOCALE_RESOURCE,
123-
rustc_passes::DEFAULT_LOCALE_RESOURCE,
124-
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
125-
// tidy-alphabetical-end
126-
];
127-
128111
/// Exit status code used for successful compilation and help output.
129112
pub const EXIT_SUCCESS: i32 = 0;
130113

@@ -235,7 +218,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
235218
output_dir: odir,
236219
ice_file,
237220
file_loader: None,
238-
locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(),
239221
lint_caps: Default::default(),
240222
psess_created: None,
241223
hash_untracked_state: None,
@@ -1545,7 +1527,7 @@ fn report_ice(
15451527
extra_info: fn(&DiagCtxt),
15461528
using_internal_features: &AtomicBool,
15471529
) {
1548-
let translator = default_translator();
1530+
let translator = Translator::with_fallback_bundle(vec![], false);
15491531
let emitter =
15501532
Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new(
15511533
stderr_destination(rustc_errors::ColorConfig::Auto),

compiler/rustc_interface/src/interface.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
88
use rustc_data_structures::jobserver::{self, Proxy};
99
use rustc_data_structures::stable_hasher::StableHasher;
1010
use rustc_errors::registry::Registry;
11+
use rustc_errors::translation::Translator;
1112
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
1213
use rustc_lint::LintStore;
1314
use rustc_middle::ty;
@@ -316,6 +317,23 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
316317
check_cfg
317318
}
318319

320+
pub fn default_translator() -> Translator {
321+
Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false)
322+
}
323+
324+
static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
325+
// tidy-alphabetical-start
326+
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
327+
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
328+
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
329+
rustc_lint::DEFAULT_LOCALE_RESOURCE,
330+
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
331+
rustc_parse::DEFAULT_LOCALE_RESOURCE,
332+
rustc_passes::DEFAULT_LOCALE_RESOURCE,
333+
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
334+
// tidy-alphabetical-end
335+
];
336+
319337
/// The compiler configuration
320338
pub struct Config {
321339
/// Command line options
@@ -335,9 +353,6 @@ pub struct Config {
335353
/// bjorn3 for "hooking rust-analyzer's VFS into rustc at some point for
336354
/// running rustc without having to save". (See #102759.)
337355
pub file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
338-
/// The list of fluent resources, used for lints declared with
339-
/// [`Diagnostic`](rustc_errors::Diagnostic) and [`LintDiagnostic`](rustc_errors::LintDiagnostic).
340-
pub locale_resources: Vec<&'static str>,
341356

342357
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
343358

@@ -465,7 +480,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
465480
},
466481
bundle,
467482
config.registry,
468-
config.locale_resources,
483+
DEFAULT_LOCALE_RESOURCES.to_owned(),
469484
config.lint_caps,
470485
target,
471486
util::rustc_version_str().unwrap_or("unknown"),

src/doc/rustc-dev-guide/examples/rustc-interface-example.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ fn main() {
3232
"#
3333
.into(),
3434
},
35-
output_dir: None, // Option<PathBuf>
36-
output_file: None, // Option<PathBuf>
37-
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
38-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(),
35+
output_dir: None, // Option<PathBuf>
36+
output_file: None, // Option<PathBuf>
37+
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
3938
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
4039
// This is a callback from the driver that is called when [`ParseSess`] is created.
4140
psess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>

src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ fn main() {
6666
output_dir: None,
6767
output_file: None,
6868
file_loader: None,
69-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(),
7069
lint_caps: rustc_hash::FxHashMap::default(),
7170
psess_created: Some(Box::new(|parse_sess| {
7271
parse_sess.dcx().set_emitter(Box::new(DebugEmitter {

src/librustdoc/clean/render_macro_matchers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String
6363
let snippet = source_map.span_to_snippet(span).ok()?;
6464

6565
// Create a Parser.
66-
let psess = ParseSess::new(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec());
66+
let psess = ParseSess::new(vec![]);
6767
let file_name = FileName::macro_expansion_source_code(&snippet);
6868
let mut parser = match rustc_parse::new_parser_from_source_str(
6969
&psess,

src/librustdoc/core.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(crate) fn new_dcx(
157157
diagnostic_width: Option<usize>,
158158
unstable_opts: &UnstableOptions,
159159
) -> rustc_errors::DiagCtxt {
160-
let translator = rustc_driver::default_translator();
160+
let translator = rustc_interface::interface::default_translator();
161161
let emitter: Box<DynEmitter> = match error_format {
162162
ErrorOutputType::HumanReadable { kind, color_config } => match kind {
163163
HumanReadableErrorType { short, unicode } => Box::new(
@@ -289,7 +289,6 @@ pub(crate) fn create_config(
289289
output_file: None,
290290
output_dir: None,
291291
file_loader: None,
292-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
293292
lint_caps,
294293
psess_created: None,
295294
hash_untracked_state: None,

src/librustdoc/doctest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
188188
output_file: None,
189189
output_dir: None,
190190
file_loader: None,
191-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
192191
lint_caps,
193192
psess_created: None,
194193
hash_untracked_state: None,

src/librustdoc/doctest/make.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn parse_source(
467467
let filename = FileName::anon_source_code(&wrapped_source);
468468

469469
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
470-
let translator = rustc_driver::default_translator();
470+
let translator = rustc_interface::interface::default_translator();
471471
let supports_color = match get_stderr_color_choice(ColorConfig::Auto, &std::io::stderr()) {
472472
ColorChoice::Auto => unreachable!(),
473473
ColorChoice::AlwaysAnsi | ColorChoice::Always => true,

0 commit comments

Comments
 (0)