@@ -64,7 +64,10 @@ declare_lint_pass! {
64
64
LOSSY_PROVENANCE_CASTS ,
65
65
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS ,
66
66
MACRO_USE_EXTERN_CRATE ,
67
+ MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
68
+ MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
67
69
META_VARIABLE_MISUSE ,
70
+ MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
68
71
MISSING_ABI ,
69
72
MISSING_FRAGMENT_SPECIFIER ,
70
73
MISSING_UNSAFE_ON_EXTERN ,
@@ -114,8 +117,8 @@ declare_lint_pass! {
114
117
UNFULFILLED_LINT_EXPECTATIONS ,
115
118
UNINHABITED_STATIC ,
116
119
UNKNOWN_CRATE_TYPES ,
120
+ UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
117
121
UNKNOWN_LINTS ,
118
- UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
119
122
UNNAMEABLE_TEST_ITEMS ,
120
123
UNNAMEABLE_TYPES ,
121
124
UNNECESSARY_TRANSMUTES ,
@@ -4272,31 +4275,104 @@ declare_lint! {
4272
4275
}
4273
4276
4274
4277
declare_lint ! {
4275
- /// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
4276
- /// diagnostic attributes.
4278
+ /// The `malformed_diagnostic_attributes` lint detects malformed diagnostic attributes.
4277
4279
///
4278
4280
/// ### Example
4279
4281
///
4280
4282
/// ```rust
4281
- /// #![feature(diagnostic_namespace)]
4282
- /// #[diagnostic::does_not_exist]
4283
- /// struct Foo;
4283
+ /// #[diagnostic::do_not_recommend(message = "message")]
4284
+ /// trait Trait {}
4285
+ /// ```
4286
+ ///
4287
+ /// {{produces}}
4288
+ ///
4289
+ /// ### Explanation
4290
+ ///
4291
+ /// It is usually a mistake to use options or syntax that is not supported. Check the spelling,
4292
+ /// and check the diagnostic attribute listing for the correct name and syntax. Also
4293
+ /// consider if you are using an old version of the compiler; perhaps the option or syntax
4294
+ /// is only available in a newer version. See the [reference] for a list of diagnostic attributes
4295
+ /// and their syntax.
4296
+ ///
4297
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4298
+ pub MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
4299
+ Warn ,
4300
+ "detects malformed diagnostic attributes" ,
4301
+ }
4302
+
4303
+ declare_lint ! {
4304
+ /// The `misplaced_diagnostic_attributes` lint detects wrongly placed diagnostic attributes.
4305
+ ///
4306
+ /// ### Example
4307
+ ///
4308
+ /// ```rust
4309
+ /// #[diagnostic::do_not_recommend]
4310
+ /// struct NotUserFacing;
4284
4311
/// ```
4285
4312
///
4286
4313
/// {{produces}}
4287
4314
///
4315
+ /// ### Explanation
4316
+ ///
4317
+ /// It is usually a mistake to specify a diagnostic attribute on an item it is not meant for. For example,
4318
+ /// `#[diagnostic::do_not_recommend]` can only be placed on trait implementations, and does nothing if placed
4319
+ /// elsewhere. See the [reference] for a list of diagnostic attributes and their correct positions.
4320
+ ///
4321
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4322
+ pub MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
4323
+ Warn ,
4324
+ "detects diagnostic attributes that are placed on the wrong item" ,
4325
+ }
4326
+
4327
+ declare_lint ! {
4328
+ /// The `unknown_diagnostic_attributes` lint detects unknown diagnostic attributes.
4329
+ ///
4330
+ /// ### Example
4331
+ ///
4332
+ /// ```rust
4333
+ /// #[diagnostic::does_not_exist]
4334
+ /// struct Thing;
4335
+ /// ```
4336
+ ///
4337
+ /// {{produces}}
4288
4338
///
4289
4339
/// ### Explanation
4290
4340
///
4291
4341
/// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
4292
4342
/// the spelling, and check the diagnostic attribute listing for the correct name. Also
4293
4343
/// consider if you are using an old version of the compiler, and the attribute
4294
- /// is only available in a newer version.
4295
- pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
4344
+ /// is only available in a newer version. See the [reference] for the list of diagnostic attributes.
4345
+ ///
4346
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4347
+ pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
4296
4348
Warn ,
4297
- "unrecognized or malformed diagnostic attribute " ,
4349
+ "detects unknown diagnostic attributes " ,
4298
4350
}
4299
4351
4352
+ declare_lint ! {
4353
+ /// The `malformed_diagnostic_format_literals` lint detects malformed
4354
+ /// diagnostic format literals.
4355
+ ///
4356
+ /// ### Example
4357
+ ///
4358
+ /// ```rust
4359
+ /// #[diagnostic::on_unimplemented(message = "{Self}} does not implement `Trait`")]
4360
+ /// trait Trait {}
4361
+ /// ```
4362
+ ///
4363
+ /// {{produces}}
4364
+ ///
4365
+ /// ### Explanation
4366
+ ///
4367
+ /// The `#[diagnostic::on_unimplemented]` attribute accepts string literal values that
4368
+ /// are similar to `format!`'s string literal. See the [reference] for details on
4369
+ /// what is permitted in this string literal.
4370
+ ///
4371
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4372
+ pub MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
4373
+ Warn ,
4374
+ "detects diagnostic attribute with malformed diagnostic format literals" ,
4375
+ }
4300
4376
declare_lint ! {
4301
4377
/// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
4302
4378
/// errors, but previously didn't do that due to rustc bugs.
0 commit comments