Skip to content

Commit 1090fa4

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 0a13b43 commit 1090fa4

13 files changed

Lines changed: 34 additions & 52 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,10 +3772,7 @@ dependencies = [
37723772
"libc",
37733773
"rustc_abi",
37743774
"rustc_ast",
3775-
"rustc_ast_passes",
37763775
"rustc_ast_pretty",
3777-
"rustc_borrowck",
3778-
"rustc_builtin_macros",
37793776
"rustc_codegen_ssa",
37803777
"rustc_const_eval",
37813778
"rustc_data_structures",
@@ -3795,14 +3792,11 @@ dependencies = [
37953792
"rustc_mir_build",
37963793
"rustc_mir_transform",
37973794
"rustc_parse",
3798-
"rustc_passes",
3799-
"rustc_pattern_analysis",
38003795
"rustc_public",
38013796
"rustc_resolve",
38023797
"rustc_session",
38033798
"rustc_span",
38043799
"rustc_target",
3805-
"rustc_trait_selection",
38063800
"serde_json",
38073801
"shlex",
38083802
"tracing",
@@ -4116,6 +4110,7 @@ dependencies = [
41164110
"rustc_monomorphize",
41174111
"rustc_parse",
41184112
"rustc_passes",
4113+
"rustc_pattern_analysis",
41194114
"rustc_privacy",
41204115
"rustc_query_impl",
41214116
"rustc_query_system",

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ anstyle = "1.0.13"
99
jiff = { version = "0.2.5", default-features = false, features = ["std"] }
1010
rustc_abi = { path = "../rustc_abi" }
1111
rustc_ast = { path = "../rustc_ast" }
12-
rustc_ast_passes = { path = "../rustc_ast_passes" }
1312
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
14-
rustc_borrowck = { path = "../rustc_borrowck" }
15-
rustc_builtin_macros = { path = "../rustc_builtin_macros" }
1613
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
1714
rustc_const_eval = { path = "../rustc_const_eval" }
1815
rustc_data_structures = { path = "../rustc_data_structures" }
@@ -32,14 +29,11 @@ rustc_middle = { path = "../rustc_middle" }
3229
rustc_mir_build = { path = "../rustc_mir_build" }
3330
rustc_mir_transform = { path = "../rustc_mir_transform" }
3431
rustc_parse = { path = "../rustc_parse" }
35-
rustc_passes = { path = "../rustc_passes" }
36-
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
3732
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
3833
rustc_resolve = { path = "../rustc_resolve" }
3934
rustc_session = { path = "../rustc_session" }
4035
rustc_span = { path = "../rustc_span" }
4136
rustc_target = { path = "../rustc_target" }
42-
rustc_trait_selection = { path = "../rustc_trait_selection" }
4337
serde_json = "1.0.59"
4438
shlex = "1.0"
4539
tracing = { version = "0.1.35" }

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +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_ast_passes::DEFAULT_LOCALE_RESOURCE,
118-
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
119-
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
120-
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
121-
rustc_errors::DEFAULT_LOCALE_RESOURCE,
122-
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
123-
rustc_lint::DEFAULT_LOCALE_RESOURCE,
124-
rustc_middle::DEFAULT_LOCALE_RESOURCE,
125-
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
126-
rustc_parse::DEFAULT_LOCALE_RESOURCE,
127-
rustc_passes::DEFAULT_LOCALE_RESOURCE,
128-
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
129-
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
130-
// tidy-alphabetical-end
131-
];
132-
133111
/// Exit status code used for successful compilation and help output.
134112
pub const EXIT_SUCCESS: i32 = 0;
135113

@@ -240,7 +218,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
240218
output_dir: odir,
241219
ice_file,
242220
file_loader: None,
243-
locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(),
244221
lint_caps: Default::default(),
245222
psess_created: None,
246223
hash_untracked_state: None,
@@ -1550,7 +1527,7 @@ fn report_ice(
15501527
extra_info: fn(&DiagCtxt),
15511528
using_internal_features: &AtomicBool,
15521529
) {
1553-
let translator = default_translator();
1530+
let translator = Translator::with_fallback_bundle(vec![], false);
15541531
let emitter =
15551532
Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new(
15561533
stderr_destination(rustc_errors::ColorConfig::Auto),

compiler/rustc_interface/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ rustc_mir_transform = { path = "../rustc_mir_transform" }
3333
rustc_monomorphize = { path = "../rustc_monomorphize" }
3434
rustc_parse = { path = "../rustc_parse" }
3535
rustc_passes = { path = "../rustc_passes" }
36+
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
3637
rustc_privacy = { path = "../rustc_privacy" }
3738
rustc_query_impl = { path = "../rustc_query_impl" }
3839
rustc_query_system = { path = "../rustc_query_system" }

compiler/rustc_interface/src/interface.rs

Lines changed: 24 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,28 @@ 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_ast_passes::DEFAULT_LOCALE_RESOURCE,
327+
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
328+
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
329+
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
330+
rustc_errors::DEFAULT_LOCALE_RESOURCE,
331+
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
332+
rustc_lint::DEFAULT_LOCALE_RESOURCE,
333+
rustc_middle::DEFAULT_LOCALE_RESOURCE,
334+
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
335+
rustc_parse::DEFAULT_LOCALE_RESOURCE,
336+
rustc_passes::DEFAULT_LOCALE_RESOURCE,
337+
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
338+
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
339+
// tidy-alphabetical-end
340+
];
341+
319342
/// The compiler configuration
320343
pub struct Config {
321344
/// Command line options
@@ -335,9 +358,6 @@ pub struct Config {
335358
/// bjorn3 for "hooking rust-analyzer's VFS into rustc at some point for
336359
/// running rustc without having to save". (See #102759.)
337360
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>,
341361

342362
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
343363

@@ -465,7 +485,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
465485
},
466486
bundle,
467487
config.registry,
468-
config.locale_resources,
488+
DEFAULT_LOCALE_RESOURCES.to_owned(),
469489
config.lint_caps,
470490
target,
471491
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,

0 commit comments

Comments
 (0)