@@ -50,6 +50,33 @@ impl Mode {
5050 Self :: DiagnosticOnUnknown => "diagnostic::on_unknown" ,
5151 }
5252 }
53+
54+ fn expected_options ( & self ) -> & ' static str {
55+ const DEFAULT : & str =
56+ "at least one of the `message`, `note` and `label` options are expected" ;
57+ match self {
58+ Self :: RustcOnUnimplemented => {
59+ "see <https://rustc-dev-guide.rust-lang.org/diagnostics.html#rustc_on_unimplemented>"
60+ }
61+ Self :: DiagnosticOnUnimplemented => DEFAULT ,
62+ Self :: DiagnosticOnConst => DEFAULT ,
63+ Self :: DiagnosticOnMove => DEFAULT ,
64+ Self :: DiagnosticOnUnknown => DEFAULT ,
65+ }
66+ }
67+
68+ fn allowed_options ( & self ) -> & ' static str {
69+ const DEFAULT : & str = "only `message`, `note` and `label` are allowed as options" ;
70+ match self {
71+ Self :: RustcOnUnimplemented => {
72+ "see <https://rustc-dev-guide.rust-lang.org/diagnostics.html#rustc_on_unimplemented>"
73+ }
74+ Self :: DiagnosticOnUnimplemented => DEFAULT ,
75+ Self :: DiagnosticOnConst => DEFAULT ,
76+ Self :: DiagnosticOnMove => DEFAULT ,
77+ Self :: DiagnosticOnUnknown => DEFAULT ,
78+ }
79+ }
5380}
5481
5582fn merge_directives < S : Stage > (
@@ -118,14 +145,19 @@ fn parse_list<'p, S: Stage>(
118145 MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
119146 AttributeLintKind :: MissingOptionsForDiagnosticAttribute {
120147 attribute : mode. as_str ( ) ,
148+ options : mode. expected_options ( ) ,
121149 } ,
122150 span,
123151 ) ;
124152 }
125153 ArgParser :: NameValue ( _) => {
126154 cx. emit_lint (
127155 MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
128- AttributeLintKind :: MalFormedDiagnosticAttribute { attribute : mode. as_str ( ) , span } ,
156+ AttributeLintKind :: MalFormedDiagnosticAttribute {
157+ attribute : mode. as_str ( ) ,
158+ options : mode. allowed_options ( ) ,
159+ span,
160+ } ,
129161 span,
130162 ) ;
131163 }
@@ -153,7 +185,8 @@ fn parse_directive_items<'p, S: Stage>(
153185 cx. emit_lint (
154186 MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
155187 AttributeLintKind :: MalFormedDiagnosticAttribute {
156- attribute : mode. as_str ( ) ,
188+ attribute : mode. as_str ( ) ,
189+ options : mode. allowed_options ( ) ,
157190 span,
158191 } ,
159192 span,
0 commit comments