@@ -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_FRAGMENT_SPECIFIER ,
69
72
MISSING_UNSAFE_ON_EXTERN ,
@@ -113,8 +116,8 @@ declare_lint_pass! {
113
116
UNFULFILLED_LINT_EXPECTATIONS ,
114
117
UNINHABITED_STATIC ,
115
118
UNKNOWN_CRATE_TYPES ,
119
+ UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
116
120
UNKNOWN_LINTS ,
117
- UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
118
121
UNNAMEABLE_TEST_ITEMS ,
119
122
UNNAMEABLE_TYPES ,
120
123
UNREACHABLE_CODE ,
@@ -4330,31 +4333,105 @@ declare_lint! {
4330
4333
}
4331
4334
4332
4335
declare_lint ! {
4333
- /// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
4334
- /// diagnostic attributes.
4336
+ /// The `malformed_diagnostic_attributes` lint detects malformed diagnostic attributes.
4335
4337
///
4336
4338
/// ### Example
4337
4339
///
4338
4340
/// ```rust
4339
- /// #![feature(diagnostic_namespace)]
4340
- /// #[diagnostic::does_not_exist]
4341
- /// struct Foo;
4341
+ /// #[diagnostic::do_not_recommend(message = "message")]
4342
+ /// trait Trait {}
4342
4343
/// ```
4343
4344
///
4344
4345
/// {{produces}}
4345
4346
///
4347
+ /// ### Explanation
4348
+ ///
4349
+ /// It is usually a mistake to use options or syntax that is not supported. Check the spelling,
4350
+ /// and check the diagnostic attribute listing for the correct name and syntax. Also consider if
4351
+ /// you are using an old version of the compiler; perhaps the option or syntax is only available
4352
+ /// in a newer version. See the [reference] for a list of diagnostic attributes and the syntax
4353
+ /// of each.
4354
+ ///
4355
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4356
+ pub MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
4357
+ Warn ,
4358
+ "detects malformed diagnostic attributes" ,
4359
+ }
4360
+
4361
+ declare_lint ! {
4362
+ /// The `misplaced_diagnostic_attributes` lint detects wrongly placed diagnostic attributes.
4363
+ ///
4364
+ /// ### Example
4365
+ ///
4366
+ /// ```rust
4367
+ /// #[diagnostic::do_not_recommend]
4368
+ /// struct NotUserFacing;
4369
+ /// ```
4370
+ ///
4371
+ /// {{produces}}
4346
4372
///
4347
4373
/// ### Explanation
4348
4374
///
4349
- /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
4350
- /// the spelling, and check the diagnostic attribute listing for the correct name. Also
4351
- /// consider if you are using an old version of the compiler, and the attribute
4352
- /// is only available in a newer version.
4353
- pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
4375
+ /// It is usually a mistake to specify a diagnostic attribute on an item it is not meant for.
4376
+ /// For example, `#[diagnostic::do_not_recommend]` can only be placed on trait implementations,
4377
+ /// and does nothing if placed elsewhere. See the [reference] for a list of diagnostic
4378
+ /// attributes and their correct positions.
4379
+ ///
4380
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4381
+ pub MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
4354
4382
Warn ,
4355
- "unrecognized or malformed diagnostic attribute " ,
4383
+ "detects diagnostic attributes that are placed on the wrong item " ,
4356
4384
}
4357
4385
4386
+ declare_lint ! {
4387
+ /// The `unknown_diagnostic_attributes` lint detects unknown diagnostic attributes.
4388
+ ///
4389
+ /// ### Example
4390
+ ///
4391
+ /// ```rust
4392
+ /// #[diagnostic::does_not_exist]
4393
+ /// struct Thing;
4394
+ /// ```
4395
+ ///
4396
+ /// {{produces}}
4397
+ ///
4398
+ /// ### Explanation
4399
+ ///
4400
+ /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check the
4401
+ /// spelling, and check the diagnostic attribute listing for the correct name. Also consider if
4402
+ /// you are using an old version of the compiler and the attribute is only available in a newer
4403
+ /// version. See the [reference] for the list of diagnostic attributes.
4404
+ ///
4405
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4406
+ pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
4407
+ Warn ,
4408
+ "detects unknown diagnostic attributes" ,
4409
+ }
4410
+
4411
+ declare_lint ! {
4412
+ /// The `malformed_diagnostic_format_literals` lint detects malformed diagnostic format
4413
+ /// literals.
4414
+ ///
4415
+ /// ### Example
4416
+ ///
4417
+ /// ```rust
4418
+ /// #[diagnostic::on_unimplemented(message = "{Self}} does not implement `Trait`")]
4419
+ /// trait Trait {}
4420
+ /// ```
4421
+ ///
4422
+ /// {{produces}}
4423
+ ///
4424
+ /// ### Explanation
4425
+ ///
4426
+ /// The `#[diagnostic::on_unimplemented]` attribute accepts string literal values that are
4427
+ /// similar to `format!`'s string literal. See the [reference] for details on what is permitted
4428
+ /// in this string literal.
4429
+ ///
4430
+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4431
+ pub MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
4432
+ Warn ,
4433
+ "detects diagnostic attribute with malformed diagnostic format literals" ,
4434
+ }
4358
4435
declare_lint ! {
4359
4436
/// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
4360
4437
/// errors, but previously didn't do that due to rustc bugs.
0 commit comments