@@ -3,8 +3,8 @@ use std::ops::Range;
33use rustc_errors:: E0232 ;
44use rustc_hir:: AttrPath ;
55use rustc_hir:: attrs:: diagnostic:: {
6- AppendConstMessage , Directive , FilterFormatString , Flag , FormatArg , FormatString , LitOrArg ,
7- Name , NameValue , OnUnimplementedCondition , Piece , Predicate ,
6+ Directive , FilterFormatString , Flag , FormatArg , FormatString , LitOrArg , Name , NameValue ,
7+ OnUnimplementedCondition , Piece , Predicate ,
88} ;
99use rustc_hir:: lints:: { AttributeLintKind , FormatWarning } ;
1010use rustc_macros:: Diagnostic ;
@@ -92,7 +92,6 @@ fn parse_directive_items<'p, S: Stage>(
9292 let mut notes = ThinVec :: new ( ) ;
9393 let mut parent_label = None ;
9494 let mut subcommands = ThinVec :: new ( ) ;
95- let mut append_const_msg = None ;
9695
9796 for item in items {
9897 let span = item. span ( ) ;
@@ -131,7 +130,6 @@ fn parse_directive_items<'p, S: Stage>(
131130 let Some ( ret) = ( ||{
132131 Some ( $( $code) * )
133132 } ) ( ) else {
134-
135133 malformed ! ( )
136134 } ;
137135 ret
@@ -159,8 +157,13 @@ fn parse_directive_items<'p, S: Stage>(
159157 let item: & MetaItemParser = or_malformed ! ( item. meta_item( ) ?) ;
160158 let name = or_malformed ! ( item. ident( ) ?) . name ;
161159
162- // Some things like `message = "message"` must have a value.
163- // But with things like `append_const_msg` that is optional.
160+ // Currently, as of April 2026, all arguments of all diagnostic attrs
161+ // must have a value, like `message = "message"`. Thus in a well-formed
162+ // diagnostic attribute this is never `None`.
163+ //
164+ // But we don't assert its presence yet because we don't want to mention it
165+ // if someone does something like `#[diagnostic::on_unimplemented(doesnt_exist)]`.
166+ // That happens in the big `match` below.
164167 let value: Option < Ident > = match item. args ( ) . name_value ( ) {
165168 Some ( nv) => Some ( or_malformed ! ( nv. value_as_ident( ) ?) ) ,
166169 None => None ,
@@ -223,14 +226,6 @@ fn parse_directive_items<'p, S: Stage>(
223226 let value = or_malformed ! ( value?) ;
224227 notes. push ( parse_format ( value) )
225228 }
226-
227- ( Mode :: RustcOnUnimplemented , sym:: append_const_msg) => {
228- append_const_msg = if let Some ( msg) = value {
229- Some ( AppendConstMessage :: Custom ( msg. name , item. span ( ) ) )
230- } else {
231- Some ( AppendConstMessage :: Default )
232- }
233- }
234229 ( Mode :: RustcOnUnimplemented , sym:: parent_label) => {
235230 let value = or_malformed ! ( value?) ;
236231 if parent_label. is_none ( ) {
@@ -290,7 +285,6 @@ fn parse_directive_items<'p, S: Stage>(
290285 label,
291286 notes,
292287 parent_label,
293- append_const_msg,
294288 } )
295289}
296290
0 commit comments