@@ -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 ,
@@ -4282,31 +4285,105 @@ declare_lint! {
42824285}
42834286
42844287declare_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.
42874289 ///
42884290 /// ### Example
42894291 ///
42904292 /// ```rust
4291- /// #![feature(diagnostic_namespace)]
4292- /// #[diagnostic::does_not_exist]
4293- /// struct Foo;
4293+ /// #[diagnostic::do_not_recommend(message = "message")]
4294+ /// trait Trait {}
42944295 /// ```
42954296 ///
42964297 /// {{produces}}
42974298 ///
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}}
42984324 ///
42994325 /// ### Explanation
43004326 ///
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 ,
43064334 Warn ,
4307- "unrecognized or malformed diagnostic attribute " ,
4335+ "detects diagnostic attributes that are placed on the wrong item " ,
43084336}
43094337
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+ }
43104387declare_lint ! {
43114388 /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
43124389 /// errors, but previously didn't do that due to rustc bugs.
0 commit comments