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