Skip to content

Commit 0fc75d2

Browse files
authored
Unrolled build for #152250
Rollup merge of #152250 - JonathanBrouwer:convert_finish, r=jdonszelmann Remove support for slugs in diagnostic messages This PR contains 5 commits, and is best reviewed commit-by-commit: - ea87331 Removes support from slugs from `rustc_errors` - 62dd371 Removes support from slugs from `rustc_macros` (which declares `derive(Diagnostic)`) - 2289e6c Adjuist the `ui-fulldeps` testsuite to match the changes in `rustc_macros` - 0db0acd Removes support for the fallback bundle (which previously contained all messages, but is now empty) from `rustc_driver_impl` and `rustc_session` - 81d4214 Removes an integration test that tested the translation system using fluent
2 parents 286fbe5 + 81d4214 commit 0fc75d2

File tree

27 files changed

+213
-656
lines changed

27 files changed

+213
-656
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ use crate::session_diagnostics::{
108108
};
109109

110110
pub fn default_translator() -> Translator {
111-
Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false)
111+
Translator::new()
112112
}
113113

114-
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[];
115-
116114
/// Exit status code used for successful compilation and help output.
117115
pub const EXIT_SUCCESS: i32 = 0;
118116

@@ -219,7 +217,6 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
219217
output_dir: odir,
220218
ice_file,
221219
file_loader: None,
222-
locale_resources: DEFAULT_LOCALE_RESOURCES.to_vec(),
223220
lint_caps: Default::default(),
224221
psess_created: None,
225222
hash_untracked_state: None,
@@ -1528,7 +1525,7 @@ fn report_ice(
15281525
extra_info: fn(&DiagCtxt),
15291526
using_internal_features: &AtomicBool,
15301527
) {
1531-
let translator = default_translator();
1528+
let translator = Translator::new();
15321529
let emitter =
15331530
Box::new(rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter::new(
15341531
stderr_destination(rustc_errors::ColorConfig::Auto),

compiler/rustc_error_messages/src/lib.rs

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ pub fn fallback_fluent_bundle(
230230
})))
231231
}
232232

233-
/// Identifier for the Fluent message/attribute corresponding to a diagnostic message.
234-
type FluentId = Cow<'static, str>;
235-
236233
/// Abstraction over a message in a subdiagnostic (i.e. label, note, help, etc) to support both
237234
/// translatable and non-translatable diagnostic messages.
238235
///
@@ -244,18 +241,9 @@ type FluentId = Cow<'static, str>;
244241
pub enum SubdiagMessage {
245242
/// Non-translatable diagnostic message.
246243
Str(Cow<'static, str>),
247-
/// Identifier of a Fluent message. Instances of this variant are generated by the
248-
/// `Subdiagnostic` derive.
249-
FluentIdentifier(FluentId),
250244
/// An inline Fluent message. Instances of this variant are generated by the
251245
/// `Subdiagnostic` derive.
252246
Inline(Cow<'static, str>),
253-
/// Attribute of a Fluent message. Needs to be combined with a Fluent identifier to produce an
254-
/// actual translated message. Instances of this variant are generated by the `fluent_messages`
255-
/// macro.
256-
///
257-
/// <https://projectfluent.org/fluent/guide/attributes.html>
258-
FluentAttr(FluentId),
259247
}
260248

261249
impl From<String> for SubdiagMessage {
@@ -288,12 +276,6 @@ pub enum DiagMessage {
288276
/// are translated when they are added to the parent diagnostic. This is one of the ways
289277
/// this variant of `DiagMessage` is produced.
290278
Str(Cow<'static, str>),
291-
/// Identifier for a Fluent message (with optional attribute) corresponding to the diagnostic
292-
/// message. Yet to be translated.
293-
///
294-
/// <https://projectfluent.org/fluent/guide/hello.html>
295-
/// <https://projectfluent.org/fluent/guide/attributes.html>
296-
FluentIdentifier(FluentId, Option<FluentId>),
297279
/// An inline Fluent message, containing the to be translated diagnostic message.
298280
Inline(Cow<'static, str>),
299281
}
@@ -305,27 +287,16 @@ impl DiagMessage {
305287
/// - If the `SubdiagMessage` is non-translatable then return the message as a `DiagMessage`.
306288
/// - If `self` is non-translatable then return `self`'s message.
307289
pub fn with_subdiagnostic_message(&self, sub: SubdiagMessage) -> Self {
308-
let attr = match sub {
309-
SubdiagMessage::Str(s) => return DiagMessage::Str(s),
310-
SubdiagMessage::FluentIdentifier(id) => {
311-
return DiagMessage::FluentIdentifier(id, None);
312-
}
313-
SubdiagMessage::Inline(s) => return DiagMessage::Inline(s),
314-
SubdiagMessage::FluentAttr(attr) => attr,
315-
};
316-
317-
match self {
318-
DiagMessage::FluentIdentifier(id, _) => {
319-
DiagMessage::FluentIdentifier(id.clone(), Some(attr))
320-
}
321-
_ => panic!("Tried to add a subdiagnostic to a message without a fluent identifier"),
290+
match sub {
291+
SubdiagMessage::Str(s) => DiagMessage::Str(s),
292+
SubdiagMessage::Inline(s) => DiagMessage::Inline(s),
322293
}
323294
}
324295

325296
pub fn as_str(&self) -> Option<&str> {
326297
match self {
327298
DiagMessage::Str(s) => Some(s),
328-
DiagMessage::FluentIdentifier(_, _) | DiagMessage::Inline(_) => None,
299+
DiagMessage::Inline(_) => None,
329300
}
330301
}
331302
}
@@ -355,10 +326,6 @@ impl From<DiagMessage> for SubdiagMessage {
355326
fn from(val: DiagMessage) -> Self {
356327
match val {
357328
DiagMessage::Str(s) => SubdiagMessage::Str(s),
358-
DiagMessage::FluentIdentifier(id, None) => SubdiagMessage::FluentIdentifier(id),
359-
// There isn't really a sensible behaviour for this because it loses information but
360-
// this is the most sensible of the behaviours.
361-
DiagMessage::FluentIdentifier(_, Some(attr)) => SubdiagMessage::FluentAttr(attr),
362329
DiagMessage::Inline(s) => SubdiagMessage::Inline(s),
363330
}
364331
}

compiler/rustc_errors/src/json/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
4545
rustc_span::create_default_session_globals_then(|| {
4646
let sm = Arc::new(SourceMap::new(FilePathMapping::empty()));
4747
sm.new_source_file(filename(&sm, "test.rs"), code.to_owned());
48-
let translator = Translator::with_fallback_bundle(vec![], false);
48+
let translator = Translator::new();
4949

5050
let output = Arc::new(Mutex::new(Vec::new()));
5151
let je = JsonEmitter::new(

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ pub mod error;
8383
pub mod json;
8484
mod lock;
8585
pub mod markdown;
86-
#[cfg(test)]
87-
mod tests;
8886
pub mod timings;
8987
pub mod translation;
9088

compiler/rustc_errors/src/tests.rs

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)