@@ -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 UNREACHABLE_CODE ,
@@ -4330,31 +4333,105 @@ declare_lint! {
43304333}
43314334
43324335declare_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.
43354337 ///
43364338 /// ### Example
43374339 ///
43384340 /// ```rust
4339- /// #![feature(diagnostic_namespace)]
4340- /// #[diagnostic::does_not_exist]
4341- /// struct Foo;
4341+ /// #[diagnostic::do_not_recommend(message = "message")]
4342+ /// trait Trait {}
43424343 /// ```
43434344 ///
43444345 /// {{produces}}
43454346 ///
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}}
43464372 ///
43474373 /// ### Explanation
43484374 ///
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 ,
43544382 Warn ,
4355- "unrecognized or malformed diagnostic attribute " ,
4383+ "detects diagnostic attributes that are placed on the wrong item " ,
43564384}
43574385
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+ }
43584435declare_lint ! {
43594436 /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
43604437 /// errors, but previously didn't do that due to rustc bugs.
0 commit comments