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