@@ -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,105 @@ 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 {}
4284
4285
/// ```
4285
4286
///
4286
4287
/// {{produces}}
4287
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 consider if
4293
+ /// you are using an old version of the compiler; perhaps the option or syntax is only available
4294
+ /// in a newer version. See the [reference] for a list of diagnostic attributes and their
4295
+ /// 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;
4311
+ /// ```
4312
+ ///
4313
+ /// {{produces}}
4288
4314
///
4289
4315
/// ### Explanation
4290
4316
///
4291
- /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
4292
- /// the spelling, and check the diagnostic attribute listing for the correct name. Also
4293
- /// 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 ,
4317
+ /// It is usually a mistake to specify a diagnostic attribute on an item it is not meant for.
4318
+ /// For example, `#[diagnostic::do_not_recommend]` can only be placed on trait implementations,
4319
+ /// and does nothing if placed elsewhere. See the [reference] for a list of diagnostic
4320
+ /// attributes and their correct positions.
4321
+ ///
4322
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4323
+ pub MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
4324
+ Warn ,
4325
+ "detects diagnostic attributes that are placed on the wrong item" ,
4326
+ }
4327
+
4328
+ declare_lint ! {
4329
+ /// The `unknown_diagnostic_attributes` lint detects unknown diagnostic attributes.
4330
+ ///
4331
+ /// ### Example
4332
+ ///
4333
+ /// ```rust
4334
+ /// #[diagnostic::does_not_exist]
4335
+ /// struct Thing;
4336
+ /// ```
4337
+ ///
4338
+ /// {{produces}}
4339
+ ///
4340
+ /// ### Explanation
4341
+ ///
4342
+ /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check the
4343
+ /// spelling, and check the diagnostic attribute listing for the correct name. Also consider if
4344
+ /// you are using an old version of the compiler, and the attribute is only available in a newer
4345
+ /// version. See the [reference] for the list of diagnostic attributes.
4346
+ ///
4347
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4348
+ pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
4296
4349
Warn ,
4297
- "unrecognized or malformed diagnostic attribute " ,
4350
+ "detects unknown diagnostic attributes " ,
4298
4351
}
4299
4352
4353
+ declare_lint ! {
4354
+ /// The `malformed_diagnostic_format_literals` lint detects malformed diagnostic format
4355
+ /// literals.
4356
+ ///
4357
+ /// ### Example
4358
+ ///
4359
+ /// ```rust
4360
+ /// #[diagnostic::on_unimplemented(message = "{Self}} does not implement `Trait`")]
4361
+ /// trait Trait {}
4362
+ /// ```
4363
+ ///
4364
+ /// {{produces}}
4365
+ ///
4366
+ /// ### Explanation
4367
+ ///
4368
+ /// The `#[diagnostic::on_unimplemented]` attribute accepts string literal values that are
4369
+ /// similar to `format!`'s string literal. See the [reference] for details on what is permitted
4370
+ /// in this string literal.
4371
+ ///
4372
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4373
+ pub MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
4374
+ Warn ,
4375
+ "detects diagnostic attribute with malformed diagnostic format literals" ,
4376
+ }
4300
4377
declare_lint ! {
4301
4378
/// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
4302
4379
/// errors, but previously didn't do that due to rustc bugs.
0 commit comments