@@ -253,8 +253,8 @@ type FluentId = Cow<'static, str>;
253253/// translatable and non-translatable diagnostic messages.
254254///
255255/// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent
256- /// message so messages of this type must be combined with a `DiagnosticMessage ` (using
257- /// `DiagnosticMessage ::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
256+ /// message so messages of this type must be combined with a `DiagMessage ` (using
257+ /// `DiagMessage ::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
258258/// the `Subdiagnostic` derive refer to Fluent identifiers directly.
259259#[ rustc_diagnostic_item = "SubdiagnosticMessage" ]
260260pub enum SubdiagnosticMessage {
@@ -265,7 +265,7 @@ pub enum SubdiagnosticMessage {
265265 /// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
266266 /// be instantiated multiple times with different values. These subdiagnostics' messages
267267 /// are translated when they are added to the parent diagnostic, producing this variant of
268- /// `DiagnosticMessage `.
268+ /// `DiagMessage `.
269269 Translated ( Cow < ' static , str > ) ,
270270 /// Identifier of a Fluent message. Instances of this variant are generated by the
271271 /// `Subdiagnostic` derive.
@@ -299,16 +299,16 @@ impl From<Cow<'static, str>> for SubdiagnosticMessage {
299299///
300300/// Intended to be removed once diagnostics are entirely translatable.
301301#[ derive( Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
302- #[ rustc_diagnostic_item = "DiagnosticMessage " ]
303- pub enum DiagnosticMessage {
302+ #[ rustc_diagnostic_item = "DiagMessage " ]
303+ pub enum DiagMessage {
304304 /// Non-translatable diagnostic message.
305305 Str ( Cow < ' static , str > ) ,
306306 /// Translatable message which has been already translated.
307307 ///
308308 /// Some diagnostics have repeated subdiagnostics where the same interpolated variables would
309309 /// be instantiated multiple times with different values. These subdiagnostics' messages
310310 /// are translated when they are added to the parent diagnostic, producing this variant of
311- /// `DiagnosticMessage `.
311+ /// `DiagMessage `.
312312 Translated ( Cow < ' static , str > ) ,
313313 /// Identifier for a Fluent message (with optional attribute) corresponding to the diagnostic
314314 /// message. Yet to be translated.
@@ -318,85 +318,81 @@ pub enum DiagnosticMessage {
318318 FluentIdentifier ( FluentId , Option < FluentId > ) ,
319319}
320320
321- impl DiagnosticMessage {
321+ impl DiagMessage {
322322 /// Given a `SubdiagnosticMessage` which may contain a Fluent attribute, create a new
323- /// `DiagnosticMessage ` that combines that attribute with the Fluent identifier of `self`.
323+ /// `DiagMessage ` that combines that attribute with the Fluent identifier of `self`.
324324 ///
325325 /// - If the `SubdiagnosticMessage` is non-translatable then return the message as a
326- /// `DiagnosticMessage `.
326+ /// `DiagMessage `.
327327 /// - If `self` is non-translatable then return `self`'s message.
328328 pub fn with_subdiagnostic_message ( & self , sub : SubdiagnosticMessage ) -> Self {
329329 let attr = match sub {
330- SubdiagnosticMessage :: Str ( s) => return DiagnosticMessage :: Str ( s) ,
331- SubdiagnosticMessage :: Translated ( s) => return DiagnosticMessage :: Translated ( s) ,
330+ SubdiagnosticMessage :: Str ( s) => return DiagMessage :: Str ( s) ,
331+ SubdiagnosticMessage :: Translated ( s) => return DiagMessage :: Translated ( s) ,
332332 SubdiagnosticMessage :: FluentIdentifier ( id) => {
333- return DiagnosticMessage :: FluentIdentifier ( id, None ) ;
333+ return DiagMessage :: FluentIdentifier ( id, None ) ;
334334 }
335335 SubdiagnosticMessage :: FluentAttr ( attr) => attr,
336336 } ;
337337
338338 match self {
339- DiagnosticMessage :: Str ( s) => DiagnosticMessage :: Str ( s. clone ( ) ) ,
340- DiagnosticMessage :: Translated ( s) => DiagnosticMessage :: Translated ( s. clone ( ) ) ,
341- DiagnosticMessage :: FluentIdentifier ( id, _) => {
342- DiagnosticMessage :: FluentIdentifier ( id. clone ( ) , Some ( attr) )
339+ DiagMessage :: Str ( s) => DiagMessage :: Str ( s. clone ( ) ) ,
340+ DiagMessage :: Translated ( s) => DiagMessage :: Translated ( s. clone ( ) ) ,
341+ DiagMessage :: FluentIdentifier ( id, _) => {
342+ DiagMessage :: FluentIdentifier ( id. clone ( ) , Some ( attr) )
343343 }
344344 }
345345 }
346346
347347 pub fn as_str ( & self ) -> Option < & str > {
348348 match self {
349- DiagnosticMessage :: Translated ( s) | DiagnosticMessage :: Str ( s) => Some ( s) ,
350- DiagnosticMessage :: FluentIdentifier ( _, _) => None ,
349+ DiagMessage :: Translated ( s) | DiagMessage :: Str ( s) => Some ( s) ,
350+ DiagMessage :: FluentIdentifier ( _, _) => None ,
351351 }
352352 }
353353}
354354
355- impl From < String > for DiagnosticMessage {
355+ impl From < String > for DiagMessage {
356356 fn from ( s : String ) -> Self {
357- DiagnosticMessage :: Str ( Cow :: Owned ( s) )
357+ DiagMessage :: Str ( Cow :: Owned ( s) )
358358 }
359359}
360- impl From < & ' static str > for DiagnosticMessage {
360+ impl From < & ' static str > for DiagMessage {
361361 fn from ( s : & ' static str ) -> Self {
362- DiagnosticMessage :: Str ( Cow :: Borrowed ( s) )
362+ DiagMessage :: Str ( Cow :: Borrowed ( s) )
363363 }
364364}
365- impl From < Cow < ' static , str > > for DiagnosticMessage {
365+ impl From < Cow < ' static , str > > for DiagMessage {
366366 fn from ( s : Cow < ' static , str > ) -> Self {
367- DiagnosticMessage :: Str ( s)
367+ DiagMessage :: Str ( s)
368368 }
369369}
370370
371371/// A workaround for must_produce_diag ICEs when formatting types in disabled lints.
372372///
373- /// Delays formatting until `.into(): DiagnosticMessage ` is used.
373+ /// Delays formatting until `.into(): DiagMessage ` is used.
374374pub struct DelayDm < F > ( pub F ) ;
375375
376- impl < F : FnOnce ( ) -> String > From < DelayDm < F > > for DiagnosticMessage {
376+ impl < F : FnOnce ( ) -> String > From < DelayDm < F > > for DiagMessage {
377377 fn from ( DelayDm ( f) : DelayDm < F > ) -> Self {
378- DiagnosticMessage :: from ( f ( ) )
378+ DiagMessage :: from ( f ( ) )
379379 }
380380}
381381
382382/// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but
383383/// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagnosticMessage` and the
384- /// subdiagnostic derive refers to typed identifiers that are `DiagnosticMessage `s, so need to be
385- /// able to convert between these, as much as they'll be converted back into `DiagnosticMessage `
384+ /// subdiagnostic derive refers to typed identifiers that are `DiagMessage `s, so need to be
385+ /// able to convert between these, as much as they'll be converted back into `DiagMessage `
386386/// using `with_subdiagnostic_message` eventually. Don't use this other than for the derive.
387- impl Into < SubdiagnosticMessage > for DiagnosticMessage {
387+ impl Into < SubdiagnosticMessage > for DiagMessage {
388388 fn into ( self ) -> SubdiagnosticMessage {
389389 match self {
390- DiagnosticMessage :: Str ( s) => SubdiagnosticMessage :: Str ( s) ,
391- DiagnosticMessage :: Translated ( s) => SubdiagnosticMessage :: Translated ( s) ,
392- DiagnosticMessage :: FluentIdentifier ( id, None ) => {
393- SubdiagnosticMessage :: FluentIdentifier ( id)
394- }
390+ DiagMessage :: Str ( s) => SubdiagnosticMessage :: Str ( s) ,
391+ DiagMessage :: Translated ( s) => SubdiagnosticMessage :: Translated ( s) ,
392+ DiagMessage :: FluentIdentifier ( id, None ) => SubdiagnosticMessage :: FluentIdentifier ( id) ,
395393 // There isn't really a sensible behaviour for this because it loses information but
396394 // this is the most sensible of the behaviours.
397- DiagnosticMessage :: FluentIdentifier ( _, Some ( attr) ) => {
398- SubdiagnosticMessage :: FluentAttr ( attr)
399- }
395+ DiagMessage :: FluentIdentifier ( _, Some ( attr) ) => SubdiagnosticMessage :: FluentAttr ( attr) ,
400396 }
401397 }
402398}
@@ -412,7 +408,7 @@ pub struct SpanLabel {
412408 pub is_primary : bool ,
413409
414410 /// What label should we attach to this span (if any)?
415- pub label : Option < DiagnosticMessage > ,
411+ pub label : Option < DiagMessage > ,
416412}
417413
418414/// A collection of `Span`s.
@@ -426,7 +422,7 @@ pub struct SpanLabel {
426422#[ derive( Clone , Debug , Hash , PartialEq , Eq , Encodable , Decodable ) ]
427423pub struct MultiSpan {
428424 primary_spans : Vec < Span > ,
429- span_labels : Vec < ( Span , DiagnosticMessage ) > ,
425+ span_labels : Vec < ( Span , DiagMessage ) > ,
430426}
431427
432428impl MultiSpan {
@@ -444,7 +440,7 @@ impl MultiSpan {
444440 MultiSpan { primary_spans : vec, span_labels : vec ! [ ] }
445441 }
446442
447- pub fn push_span_label ( & mut self , span : Span , label : impl Into < DiagnosticMessage > ) {
443+ pub fn push_span_label ( & mut self , span : Span , label : impl Into < DiagMessage > ) {
448444 self . span_labels . push ( ( span, label. into ( ) ) ) ;
449445 }
450446
@@ -487,7 +483,7 @@ impl MultiSpan {
487483 replacements_occurred
488484 }
489485
490- pub fn pop_span_label ( & mut self ) -> Option < ( Span , DiagnosticMessage ) > {
486+ pub fn pop_span_label ( & mut self ) -> Option < ( Span , DiagMessage ) > {
491487 self . span_labels . pop ( )
492488 }
493489
0 commit comments