Skip to content

Commit ea36128

Browse files
Remove SubdiagMessage in favour of the identical DiagMessage
1 parent 71dc761 commit ea36128

File tree

10 files changed

+56
-162
lines changed

10 files changed

+56
-162
lines changed

compiler/rustc_error_messages/src/lib.rs

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

233-
/// Abstraction over a message in a subdiagnostic (i.e. label, note, help, etc) to support both
234-
/// translatable and non-translatable diagnostic messages.
235-
///
236-
/// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent
237-
/// message so messages of this type must be combined with a `DiagMessage` (using
238-
/// `DiagMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
239-
/// the `Subdiagnostic` derive refer to Fluent identifiers directly.
240-
#[rustc_diagnostic_item = "SubdiagMessage"]
241-
pub enum SubdiagMessage {
242-
/// Non-translatable diagnostic message.
243-
Str(Cow<'static, str>),
244-
/// An inline Fluent message. Instances of this variant are generated by the
245-
/// `Subdiagnostic` derive.
246-
Inline(Cow<'static, str>),
247-
}
248-
249-
impl From<String> for SubdiagMessage {
250-
fn from(s: String) -> Self {
251-
SubdiagMessage::Str(Cow::Owned(s))
252-
}
253-
}
254-
impl From<&'static str> for SubdiagMessage {
255-
fn from(s: &'static str) -> Self {
256-
SubdiagMessage::Str(Cow::Borrowed(s))
257-
}
258-
}
259-
impl From<Cow<'static, str>> for SubdiagMessage {
260-
fn from(s: Cow<'static, str>) -> Self {
261-
SubdiagMessage::Str(s)
262-
}
263-
}
264-
265233
/// Abstraction over a message in a diagnostic to support both translatable and non-translatable
266234
/// diagnostic messages.
267235
///
@@ -281,18 +249,6 @@ pub enum DiagMessage {
281249
}
282250

283251
impl DiagMessage {
284-
/// Given a `SubdiagMessage` which may contain a Fluent attribute, create a new
285-
/// `DiagMessage` that combines that attribute with the Fluent identifier of `self`.
286-
///
287-
/// - If the `SubdiagMessage` is non-translatable then return the message as a `DiagMessage`.
288-
/// - If `self` is non-translatable then return `self`'s message.
289-
pub fn with_subdiagnostic_message(&self, sub: SubdiagMessage) -> Self {
290-
match sub {
291-
SubdiagMessage::Str(s) => DiagMessage::Str(s),
292-
SubdiagMessage::Inline(s) => DiagMessage::Inline(s),
293-
}
294-
}
295-
296252
pub fn as_str(&self) -> Option<&str> {
297253
match self {
298254
DiagMessage::Str(s) => Some(s),
@@ -317,20 +273,6 @@ impl From<Cow<'static, str>> for DiagMessage {
317273
}
318274
}
319275

320-
/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
321-
/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagMessage` and the
322-
/// subdiagnostic derive refers to typed identifiers that are `DiagMessage`s, so need to be
323-
/// able to convert between these, as much as they'll be converted back into `DiagMessage`
324-
/// using `with_subdiagnostic_message` eventually. Don't use this other than for the derive.
325-
impl From<DiagMessage> for SubdiagMessage {
326-
fn from(val: DiagMessage) -> Self {
327-
match val {
328-
DiagMessage::Str(s) => SubdiagMessage::Str(s),
329-
DiagMessage::Inline(s) => SubdiagMessage::Inline(s),
330-
}
331-
}
332-
}
333-
334276
/// A span together with some additional data.
335277
#[derive(Clone, Debug)]
336278
pub struct SpanLabel {

0 commit comments

Comments
 (0)