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