@@ -64,7 +64,10 @@ declare_lint_pass! {
6464 LOSSY_PROVENANCE_CASTS ,
6565 MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS ,
6666 MACRO_USE_EXTERN_CRATE ,
67+ MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
68+ MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
6769 META_VARIABLE_MISUSE ,
70+ MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
6871 MISSING_ABI ,
6972 MISSING_FRAGMENT_SPECIFIER ,
7073 MISSING_UNSAFE_ON_EXTERN ,
@@ -114,8 +117,8 @@ declare_lint_pass! {
114117 UNFULFILLED_LINT_EXPECTATIONS ,
115118 UNINHABITED_STATIC ,
116119 UNKNOWN_CRATE_TYPES ,
120+ UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
117121 UNKNOWN_LINTS ,
118- UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
119122 UNNAMEABLE_TEST_ITEMS ,
120123 UNNAMEABLE_TYPES ,
121124 UNNECESSARY_TRANSMUTES ,
@@ -4272,31 +4275,104 @@ declare_lint! {
42724275}
42734276
42744277declare_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.
42774279 ///
42784280 /// ### Example
42794281 ///
42804282 /// ```rust
4281- /// #![feature(diagnostic_namespace)]
4282- /// #[diagnostic::does_not_exist]
4283- /// struct Foo;
4283+ /// #[diagnostic::do_not_recommend(message = "message")]
4284+ /// trait Trait {}
4285+ /// ```
4286+ ///
4287+ /// {{produces}}
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
4293+ /// consider if you are using an old version of the compiler; perhaps the option or syntax
4294+ /// is only available in a newer version. See the [reference] for a list of diagnostic attributes
4295+ /// and their 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;
42844311 /// ```
42854312 ///
42864313 /// {{produces}}
42874314 ///
4315+ /// ### Explanation
4316+ ///
4317+ /// It is usually a mistake to specify a diagnostic attribute on an item it is not meant for. For example,
4318+ /// `#[diagnostic::do_not_recommend]` can only be placed on trait implementations, and does nothing if placed
4319+ /// elsewhere. See the [reference] for a list of diagnostic attributes and their correct positions.
4320+ ///
4321+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4322+ pub MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
4323+ Warn ,
4324+ "detects diagnostic attributes that are placed on the wrong item" ,
4325+ }
4326+
4327+ declare_lint ! {
4328+ /// The `unknown_diagnostic_attributes` lint detects unknown diagnostic attributes.
4329+ ///
4330+ /// ### Example
4331+ ///
4332+ /// ```rust
4333+ /// #[diagnostic::does_not_exist]
4334+ /// struct Thing;
4335+ /// ```
4336+ ///
4337+ /// {{produces}}
42884338 ///
42894339 /// ### Explanation
42904340 ///
42914341 /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
42924342 /// the spelling, and check the diagnostic attribute listing for the correct name. Also
42934343 /// 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 ,
4344+ /// is only available in a newer version. See the [reference] for the list of diagnostic attributes.
4345+ ///
4346+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4347+ pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
42964348 Warn ,
4297- "unrecognized or malformed diagnostic attribute " ,
4349+ "detects unknown diagnostic attributes " ,
42984350}
42994351
4352+ declare_lint ! {
4353+ /// The `malformed_diagnostic_format_literals` lint detects malformed
4354+ /// diagnostic format literals.
4355+ ///
4356+ /// ### Example
4357+ ///
4358+ /// ```rust
4359+ /// #[diagnostic::on_unimplemented(message = "{Self}} does not implement `Trait`")]
4360+ /// trait Trait {}
4361+ /// ```
4362+ ///
4363+ /// {{produces}}
4364+ ///
4365+ /// ### Explanation
4366+ ///
4367+ /// The `#[diagnostic::on_unimplemented]` attribute accepts string literal values that
4368+ /// are similar to `format!`'s string literal. See the [reference] for details on
4369+ /// what is permitted in this string literal.
4370+ ///
4371+ /// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
4372+ pub MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
4373+ Warn ,
4374+ "detects diagnostic attribute with malformed diagnostic format literals" ,
4375+ }
43004376declare_lint ! {
43014377 /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
43024378 /// errors, but previously didn't do that due to rustc bugs.
0 commit comments