@@ -63,7 +63,10 @@ declare_lint_pass! {
6363 LOSSY_PROVENANCE_CASTS ,
6464 MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS ,
6565 MACRO_USE_EXTERN_CRATE ,
66+ MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
67+ MALFORMED_DIAGNOSTIC_FORMAT_LITERALS ,
6668 META_VARIABLE_MISUSE ,
69+ MISPLACED_DIAGNOSTIC_ATTRIBUTES ,
6770 MISSING_ABI ,
6871 MISSING_FRAGMENT_SPECIFIER ,
6972 MISSING_UNSAFE_ON_EXTERN ,
@@ -113,8 +116,8 @@ declare_lint_pass! {
113116 UNFULFILLED_LINT_EXPECTATIONS ,
114117 UNINHABITED_STATIC ,
115118 UNKNOWN_CRATE_TYPES ,
119+ UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
116120 UNKNOWN_LINTS ,
117- UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ,
118121 UNNAMEABLE_TEST_ITEMS ,
119122 UNNAMEABLE_TYPES ,
120123 UNNECESSARY_TRANSMUTES ,
@@ -4297,31 +4300,104 @@ declare_lint! {
42974300}
42984301
42994302declare_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.
43024304 ///
43034305 /// ### Example
43044306 ///
43054307 /// ```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;
43094336 /// ```
43104337 ///
43114338 /// {{produces}}
43124339 ///
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}}
43134363 ///
43144364 /// ### Explanation
43154365 ///
43164366 /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
43174367 /// the spelling, and check the diagnostic attribute listing for the correct name. Also
43184368 /// 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 ,
43214373 Warn ,
4322- "unrecognized or malformed diagnostic attribute " ,
4374+ "detects unknown diagnostic attributes " ,
43234375}
43244376
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+ }
43254401declare_lint ! {
43264402 /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
43274403 /// errors, but previously didn't do that due to rustc bugs.
0 commit comments