Auto merge of #140717 - mejrs:diagnostic_lints, r=oli-obk
Split up the `unknown_or_malformed_diagnostic_attributes` lint
This splits up the lint into the following lint group:
- `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler
- `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for
- `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid
- `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters
- this pr doesn't create it, but future lints for things like deprecations can also go here.
This PR does not start emitting lints in places that previously did not.
## Motivation
I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does
I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv.
At this time, there are two options to silence these lints:
- `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes.
- write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute:
```rust
#[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]`
struct Foo;
```
or conditionally `allow` the lint:
```rust
// lib.rs
#![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))]
```
I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future:
```rust
#[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")]
#[diagnostic::new_attr_in_rust_99(thing = ..)]`
struct Foo;
This commit is contained in:
@@ -339,6 +339,14 @@ fn register_builtins(store: &mut LintStore) {
|
|||||||
|
|
||||||
add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
|
add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
|
||||||
|
|
||||||
|
add_lint_group!(
|
||||||
|
"unknown_or_malformed_diagnostic_attributes",
|
||||||
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
|
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
|
UNKNOWN_DIAGNOSTIC_ATTRIBUTES
|
||||||
|
);
|
||||||
|
|
||||||
// Register renamed and removed lints.
|
// Register renamed and removed lints.
|
||||||
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
|
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
|
||||||
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
|
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
|
||||||
|
|||||||
@@ -63,7 +63,10 @@ declare_lint_pass! {
|
|||||||
LOSSY_PROVENANCE_CASTS,
|
LOSSY_PROVENANCE_CASTS,
|
||||||
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
||||||
MACRO_USE_EXTERN_CRATE,
|
MACRO_USE_EXTERN_CRATE,
|
||||||
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
META_VARIABLE_MISUSE,
|
META_VARIABLE_MISUSE,
|
||||||
|
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
MISSING_ABI,
|
MISSING_ABI,
|
||||||
MISSING_UNSAFE_ON_EXTERN,
|
MISSING_UNSAFE_ON_EXTERN,
|
||||||
MUST_NOT_SUSPEND,
|
MUST_NOT_SUSPEND,
|
||||||
@@ -112,8 +115,8 @@ declare_lint_pass! {
|
|||||||
UNFULFILLED_LINT_EXPECTATIONS,
|
UNFULFILLED_LINT_EXPECTATIONS,
|
||||||
UNINHABITED_STATIC,
|
UNINHABITED_STATIC,
|
||||||
UNKNOWN_CRATE_TYPES,
|
UNKNOWN_CRATE_TYPES,
|
||||||
|
UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||||
UNKNOWN_LINTS,
|
UNKNOWN_LINTS,
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
|
||||||
UNNAMEABLE_TEST_ITEMS,
|
UNNAMEABLE_TEST_ITEMS,
|
||||||
UNNAMEABLE_TYPES,
|
UNNAMEABLE_TYPES,
|
||||||
UNREACHABLE_CODE,
|
UNREACHABLE_CODE,
|
||||||
@@ -4284,31 +4287,105 @@ declare_lint! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
|
/// The `malformed_diagnostic_attributes` lint detects malformed diagnostic attributes.
|
||||||
/// diagnostic attributes.
|
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(diagnostic_namespace)]
|
/// #[diagnostic::do_not_recommend(message = "message")]
|
||||||
/// #[diagnostic::does_not_exist]
|
/// trait Trait {}
|
||||||
/// struct Foo;
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// {{produces}}
|
/// {{produces}}
|
||||||
///
|
///
|
||||||
|
/// ### Explanation
|
||||||
|
///
|
||||||
|
/// It is usually a mistake to use options or syntax that is not supported. Check the spelling,
|
||||||
|
/// and check the diagnostic attribute listing for the correct name and syntax. Also consider if
|
||||||
|
/// you are using an old version of the compiler; perhaps the option or syntax is only available
|
||||||
|
/// in a newer version. See the [reference] for a list of diagnostic attributes and the syntax
|
||||||
|
/// of each.
|
||||||
|
///
|
||||||
|
/// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
|
||||||
|
pub MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
|
Warn,
|
||||||
|
"detects malformed diagnostic attributes",
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_lint! {
|
||||||
|
/// The `misplaced_diagnostic_attributes` lint detects wrongly placed diagnostic attributes.
|
||||||
|
///
|
||||||
|
/// ### Example
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// #[diagnostic::do_not_recommend]
|
||||||
|
/// struct NotUserFacing;
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// {{produces}}
|
||||||
///
|
///
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
|
/// It is usually a mistake to specify a diagnostic attribute on an item it is not meant for.
|
||||||
/// the spelling, and check the diagnostic attribute listing for the correct name. Also
|
/// For example, `#[diagnostic::do_not_recommend]` can only be placed on trait implementations,
|
||||||
/// consider if you are using an old version of the compiler, and the attribute
|
/// and does nothing if placed elsewhere. See the [reference] for a list of diagnostic
|
||||||
/// is only available in a newer version.
|
/// attributes and their correct positions.
|
||||||
pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
///
|
||||||
|
/// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
|
||||||
|
pub MISPLACED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
Warn,
|
Warn,
|
||||||
"unrecognized or malformed diagnostic attribute",
|
"detects diagnostic attributes that are placed on the wrong item",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_lint! {
|
||||||
|
/// The `unknown_diagnostic_attributes` lint detects unknown diagnostic attributes.
|
||||||
|
///
|
||||||
|
/// ### Example
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// #[diagnostic::does_not_exist]
|
||||||
|
/// struct Thing;
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// {{produces}}
|
||||||
|
///
|
||||||
|
/// ### Explanation
|
||||||
|
///
|
||||||
|
/// It is usually a mistake to specify a diagnostic attribute that does not exist. Check the
|
||||||
|
/// spelling, and check the diagnostic attribute listing for the correct name. Also consider if
|
||||||
|
/// you are using an old version of the compiler and the attribute is only available in a newer
|
||||||
|
/// version. See the [reference] for the list of diagnostic attributes.
|
||||||
|
///
|
||||||
|
/// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
|
||||||
|
pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||||
|
Warn,
|
||||||
|
"detects unknown diagnostic attributes",
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_lint! {
|
||||||
|
/// The `malformed_diagnostic_format_literals` lint detects malformed diagnostic format
|
||||||
|
/// literals.
|
||||||
|
///
|
||||||
|
/// ### Example
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// #[diagnostic::on_unimplemented(message = "{Self}} does not implement `Trait`")]
|
||||||
|
/// trait Trait {}
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// {{produces}}
|
||||||
|
///
|
||||||
|
/// ### Explanation
|
||||||
|
///
|
||||||
|
/// The `#[diagnostic::on_unimplemented]` attribute accepts string literal values that are
|
||||||
|
/// similar to `format!`'s string literal. See the [reference] for details on what is permitted
|
||||||
|
/// in this string literal.
|
||||||
|
///
|
||||||
|
/// [reference]: https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-diagnostic-tool-attribute-namespace
|
||||||
|
pub MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
|
Warn,
|
||||||
|
"detects diagnostic attribute with malformed diagnostic format literals",
|
||||||
|
}
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
|
/// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
|
||||||
/// errors, but previously didn't do that due to rustc bugs.
|
/// errors, but previously didn't do that due to rustc bugs.
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use rustc_session::config::CrateType;
|
|||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_session::lint::builtin::{
|
use rustc_session::lint::builtin::{
|
||||||
CONFLICTING_REPR_HINTS, INVALID_DOC_ATTRIBUTES, INVALID_MACRO_EXPORT_ARGUMENTS,
|
CONFLICTING_REPR_HINTS, INVALID_DOC_ATTRIBUTES, INVALID_MACRO_EXPORT_ARGUMENTS,
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MISPLACED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
|
||||||
};
|
};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
@@ -460,7 +460,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if `#[diagnostic::do_not_recommend]` is applied on a trait impl.
|
/// Checks if `#[diagnostic::do_not_recommend]` is applied on a trait impl and that it has no
|
||||||
|
/// arguments.
|
||||||
fn check_do_not_recommend(
|
fn check_do_not_recommend(
|
||||||
&self,
|
&self,
|
||||||
attr_span: Span,
|
attr_span: Span,
|
||||||
@@ -477,7 +478,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
self.tcx.emit_node_span_lint(
|
self.tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
hir_id,
|
hir_id,
|
||||||
attr_span,
|
attr_span,
|
||||||
errors::IncorrectDoNotRecommendLocation,
|
errors::IncorrectDoNotRecommendLocation,
|
||||||
@@ -485,7 +486,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||||||
}
|
}
|
||||||
if !attr.is_word() {
|
if !attr.is_word() {
|
||||||
self.tcx.emit_node_span_lint(
|
self.tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
hir_id,
|
hir_id,
|
||||||
attr_span,
|
attr_span,
|
||||||
errors::DoNotRecommendDoesNotExpectArgs,
|
errors::DoNotRecommendDoesNotExpectArgs,
|
||||||
@@ -497,7 +498,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||||||
fn check_diagnostic_on_unimplemented(&self, attr_span: Span, hir_id: HirId, target: Target) {
|
fn check_diagnostic_on_unimplemented(&self, attr_span: Span, hir_id: HirId, target: Target) {
|
||||||
if !matches!(target, Target::Trait) {
|
if !matches!(target, Target::Trait) {
|
||||||
self.tcx.emit_node_span_lint(
|
self.tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MISPLACED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
hir_id,
|
hir_id,
|
||||||
attr_span,
|
attr_span,
|
||||||
DiagnosticOnUnimplementedOnlyForTraits,
|
DiagnosticOnUnimplementedOnlyForTraits,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use rustc_middle::middle::stability;
|
|||||||
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
|
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
|
||||||
use rustc_session::lint::BuiltinLintDiag;
|
use rustc_session::lint::BuiltinLintDiag;
|
||||||
use rustc_session::lint::builtin::{
|
use rustc_session::lint::builtin::{
|
||||||
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||||
UNUSED_MACRO_RULES, UNUSED_MACROS,
|
UNUSED_MACRO_RULES, UNUSED_MACROS,
|
||||||
};
|
};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
@@ -689,7 +689,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
self.tcx.sess.psess.buffer_lint(
|
self.tcx.sess.psess.buffer_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||||
attribute.span(),
|
attribute.span(),
|
||||||
node_id,
|
node_id,
|
||||||
BuiltinLintDiag::UnknownDiagnosticAttribute { span: attribute.span(), typo_name },
|
BuiltinLintDiag::UnknownDiagnosticAttribute { span: attribute.span(), typo_name },
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ use rustc_macros::LintDiagnostic;
|
|||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::print::PrintTraitRefExt;
|
use rustc_middle::ty::print::PrintTraitRefExt;
|
||||||
use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKind, TyCtxt};
|
use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKind, TyCtxt};
|
||||||
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
|
use rustc_session::lint::builtin::{
|
||||||
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
|
};
|
||||||
use rustc_span::{Span, Symbol, sym};
|
use rustc_span::{Span, Symbol, sym};
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
@@ -382,7 +384,7 @@ impl IgnoredDiagnosticOption {
|
|||||||
if let (Some(new_item), Some(old_item)) = (new, old) {
|
if let (Some(new_item), Some(old_item)) = (new, old) {
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
new_item,
|
new_item,
|
||||||
IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name },
|
IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name },
|
||||||
@@ -533,7 +535,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||||||
if is_diagnostic_namespace_variant {
|
if is_diagnostic_namespace_variant {
|
||||||
if let Some(def_id) = item_def_id.as_local() {
|
if let Some(def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
tcx.local_def_id_to_hir_id(def_id),
|
tcx.local_def_id_to_hir_id(def_id),
|
||||||
vec![item.span()],
|
vec![item.span()],
|
||||||
MalformedOnUnimplementedAttrLint::new(item.span()),
|
MalformedOnUnimplementedAttrLint::new(item.span()),
|
||||||
@@ -689,7 +691,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||||||
|
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
report_span,
|
report_span,
|
||||||
MalformedOnUnimplementedAttrLint::new(report_span),
|
MalformedOnUnimplementedAttrLint::new(report_span),
|
||||||
@@ -702,7 +704,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||||||
Attribute::Unparsed(p) if !matches!(p.args, AttrArgs::Empty) => {
|
Attribute::Unparsed(p) if !matches!(p.args, AttrArgs::Empty) => {
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
attr.span(),
|
attr.span(),
|
||||||
MalformedOnUnimplementedAttrLint::new(attr.span()),
|
MalformedOnUnimplementedAttrLint::new(attr.span()),
|
||||||
@@ -712,7 +714,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||||||
_ => {
|
_ => {
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
attr.span(),
|
attr.span(),
|
||||||
MissingOptionsForOnUnimplementedAttr,
|
MissingOptionsForOnUnimplementedAttr,
|
||||||
@@ -859,7 +861,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||||||
if self.is_diagnostic_namespace_variant {
|
if self.is_diagnostic_namespace_variant {
|
||||||
if let Some(trait_def_id) = trait_def_id.as_local() {
|
if let Some(trait_def_id) = trait_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
tcx.local_def_id_to_hir_id(trait_def_id),
|
tcx.local_def_id_to_hir_id(trait_def_id),
|
||||||
self.span,
|
self.span,
|
||||||
WrappedParserError { description: e.description, label: e.label },
|
WrappedParserError { description: e.description, label: e.label },
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
|
|||||||
use rustc_parse_format::{
|
use rustc_parse_format::{
|
||||||
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
|
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
|
||||||
};
|
};
|
||||||
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
|
use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_FORMAT_LITERALS;
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_span::{InnerSpan, Span, Symbol, kw, sym};
|
use rustc_span::{InnerSpan, Span, Symbol, kw, sym};
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ impl FormatWarning {
|
|||||||
let this = tcx.item_ident(item_def_id);
|
let this = tcx.item_ident(item_def_id);
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
span,
|
span,
|
||||||
UnknownFormatParameterForOnUnimplementedAttr {
|
UnknownFormatParameterForOnUnimplementedAttr {
|
||||||
@@ -82,7 +82,7 @@ impl FormatWarning {
|
|||||||
FormatWarning::PositionalArgument { span, .. } => {
|
FormatWarning::PositionalArgument { span, .. } => {
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
span,
|
span,
|
||||||
DisallowedPositionalArgument,
|
DisallowedPositionalArgument,
|
||||||
@@ -92,7 +92,7 @@ impl FormatWarning {
|
|||||||
FormatWarning::InvalidSpecifier { span, .. } => {
|
FormatWarning::InvalidSpecifier { span, .. } => {
|
||||||
if let Some(item_def_id) = item_def_id.as_local() {
|
if let Some(item_def_id) = item_def_id.as_local() {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
|
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
|
||||||
tcx.local_def_id_to_hir_id(item_def_id),
|
tcx.local_def_id_to_hir_id(item_def_id),
|
||||||
span,
|
span,
|
||||||
InvalidFormatSpecifier,
|
InvalidFormatSpecifier,
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
|
|||||||
"Lints that detect identifiers which will be come keywords in later editions",
|
"Lints that detect identifiers which will be come keywords in later editions",
|
||||||
),
|
),
|
||||||
("deprecated-safe", "Lints for functions which were erroneously marked as safe in the past"),
|
("deprecated-safe", "Lints for functions which were erroneously marked as safe in the past"),
|
||||||
|
(
|
||||||
|
"unknown-or-malformed-diagnostic-attributes",
|
||||||
|
"detects unknown or malformed diagnostic attributes",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
type LintGroups = BTreeMap<String, BTreeSet<String>>;
|
type LintGroups = BTreeMap<String, BTreeSet<String>>;
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
|||||||
LL | #[diagnostic::do_not_recommend()]
|
LL | #[diagnostic::do_not_recommend()]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: missing options for `on_unimplemented` attribute
|
warning: missing options for `on_unimplemented` attribute
|
||||||
--> $DIR/malformed-attrs.rs:138:1
|
--> $DIR/malformed-attrs.rs:138:1
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ note: the lint level is defined here
|
|||||||
|
|
|
|
||||||
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= note: `#[deny(unknown_diagnostic_attributes)]` implied by `#[deny(unknown_or_malformed_diagnostic_attributes)]`
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
|||||||
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||||
--> $DIR/does_not_acccept_args.rs:15:1
|
--> $DIR/does_not_acccept_args.rs:15:1
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
|||||||
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||||
--> $DIR/does_not_acccept_args.rs:15:1
|
--> $DIR/does_not_acccept_args.rs:15:1
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implement
|
|||||||
LL | #[diagnostic::do_not_recommend]
|
LL | #[diagnostic::do_not_recommend]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(misplaced_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||||
--> $DIR/incorrect-locations.rs:11:1
|
--> $DIR/incorrect-locations.rs:11:1
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implement
|
|||||||
LL | #[diagnostic::do_not_recommend]
|
LL | #[diagnostic::do_not_recommend]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(misplaced_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||||
--> $DIR/incorrect-locations.rs:11:1
|
--> $DIR/incorrect-locations.rs:11:1
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string \
|
multiline string \
|
||||||
{unknown}")]
|
{unknown}")]
|
||||||
//~^ ERROR there is no parameter `unknown` on trait `MultiLine` [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR there is no parameter `unknown` on trait `MultiLine` [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLine {}
|
pub trait MultiLine {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string {unknown}")]
|
multiline string {unknown}")]
|
||||||
//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLine2 {}
|
pub trait MultiLine2 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string {unknown}")]
|
multiline string {unknown}")]
|
||||||
//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLine3 {}
|
pub trait MultiLine3 {}
|
||||||
|
|
||||||
|
|
||||||
@@ -25,23 +25,23 @@ pub trait MultiLine3 {}
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
multiline string {unknown}")]
|
multiline string {unknown}")]
|
||||||
//~^ ERROR there is no parameter `unknown` on trait `MultiLine4` [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR there is no parameter `unknown` on trait `MultiLine4` [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLine4 {}
|
pub trait MultiLine4 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string \
|
multiline string \
|
||||||
{Self:+}")]
|
{Self:+}")]
|
||||||
//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLineFmt {}
|
pub trait MultiLineFmt {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string {Self:X}")]
|
multiline string {Self:X}")]
|
||||||
//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLineFmt2 {}
|
pub trait MultiLineFmt2 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "here is a big \
|
#[diagnostic::on_unimplemented(message = "here is a big \
|
||||||
multiline string {Self:#}")]
|
multiline string {Self:#}")]
|
||||||
//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLineFmt3 {}
|
pub trait MultiLineFmt3 {}
|
||||||
|
|
||||||
|
|
||||||
@@ -51,5 +51,5 @@ pub trait MultiLineFmt3 {}
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
multiline string {Self:?}")]
|
multiline string {Self:?}")]
|
||||||
//~^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^ ERROR invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
pub trait MultiLineFmt4 {}
|
pub trait MultiLineFmt4 {}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ note: the lint level is defined here
|
|||||||
|
|
|
|
||||||
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
= note: `#[deny(malformed_diagnostic_format_literals)]` implied by `#[deny(unknown_or_malformed_diagnostic_attributes)]`
|
||||||
|
|
||||||
error: there is no parameter `unknown` on trait `MultiLine2`
|
error: there is no parameter `unknown` on trait `MultiLine2`
|
||||||
--> $DIR/multiline_spans.rs:12:60
|
--> $DIR/multiline_spans.rs:12:60
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: unknown diagnostic attribute
|
|||||||
LL | #[diagnostic::non_existing_attribute]
|
LL | #[diagnostic::non_existing_attribute]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(unknown_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: unknown diagnostic attribute
|
warning: unknown diagnostic attribute
|
||||||
--> $DIR/non_existing_attributes_accepted.rs:8:15
|
--> $DIR/non_existing_attributes_accepted.rs:8:15
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ trait ImportantTrait2 {}
|
|||||||
#[diagnostic::on_unimplemented(message = "Test {1:}")]
|
#[diagnostic::on_unimplemented(message = "Test {1:}")]
|
||||||
//~^WARN positional format arguments are not allowed here
|
//~^WARN positional format arguments are not allowed here
|
||||||
//~|WARN positional format arguments are not allowed here
|
//~|WARN positional format arguments are not allowed here
|
||||||
//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~|WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~|WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
trait ImportantTrait3 {}
|
trait ImportantTrait3 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "Test {Self:123}")]
|
#[diagnostic::on_unimplemented(message = "Test {Self:123}")]
|
||||||
@@ -22,13 +22,13 @@ trait ImportantTrait3 {}
|
|||||||
trait ImportantTrait4 {}
|
trait ImportantTrait4 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "Test {Self:!}")]
|
#[diagnostic::on_unimplemented(message = "Test {Self:!}")]
|
||||||
//~^WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~|WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
trait ImportantTrait5 {}
|
trait ImportantTrait5 {}
|
||||||
|
|
||||||
#[diagnostic::on_unimplemented(message = "Test {Self:}")]
|
#[diagnostic::on_unimplemented(message = "Test {Self:}")]
|
||||||
//~^WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~^WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
//~|WARN invalid format specifier [unknown_or_malformed_diagnostic_attributes]
|
//~|WARN invalid format specifier [malformed_diagnostic_format_literals]
|
||||||
trait ImportantTrait6 {}
|
trait ImportantTrait6 {}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: unmatched `}` found
|
|||||||
LL | #[diagnostic::on_unimplemented(message = "{{Test } thing")]
|
LL | #[diagnostic::on_unimplemented(message = "{{Test } thing")]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_format_literals)]` on by default
|
||||||
|
|
||||||
warning: positional format arguments are not allowed here
|
warning: positional format arguments are not allowed here
|
||||||
--> $DIR/broken_format.rs:7:49
|
--> $DIR/broken_format.rs:7:49
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti
|
|||||||
LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")]
|
LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(misplaced_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: malformed `on_unimplemented` attribute
|
warning: malformed `on_unimplemented` attribute
|
||||||
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5
|
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5
|
||||||
@@ -13,6 +13,7 @@ LL | on(Self = "&str"),
|
|||||||
| ^^^^^^^^^^^^^^^^^ invalid option found here
|
| ^^^^^^^^^^^^^^^^^ invalid option found here
|
||||||
|
|
|
|
||||||
= help: only `message`, `note` and `label` are allowed as options
|
= help: only `message`, `note` and `label` are allowed as options
|
||||||
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: malformed `on_unimplemented` attribute
|
warning: malformed `on_unimplemented` attribute
|
||||||
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:12:5
|
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:12:5
|
||||||
@@ -45,6 +46,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}",
|
|||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: expect either a generic argument name or `{Self}` as format argument
|
= help: expect either a generic argument name or `{Self}` as format argument
|
||||||
|
= note: `#[warn(malformed_diagnostic_format_literals)]` on by default
|
||||||
|
|
||||||
warning: there is no parameter `direct` on trait `Baz`
|
warning: there is no parameter `direct` on trait `Baz`
|
||||||
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:33:34
|
--> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:33:34
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti
|
|||||||
LL | #[diagnostic::on_unimplemented(message = "Baz")]
|
LL | #[diagnostic::on_unimplemented(message = "Baz")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(misplaced_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: malformed `on_unimplemented` attribute
|
warning: malformed `on_unimplemented` attribute
|
||||||
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
|
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
|
||||||
@@ -13,6 +13,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")]
|
|||||||
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
|
| ^^^^^^^^^^^^^^^^^^^ invalid option found here
|
||||||
|
|
|
|
||||||
= help: only `message`, `note` and `label` are allowed as options
|
= help: only `message`, `note` and `label` are allowed as options
|
||||||
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: malformed `on_unimplemented` attribute
|
warning: malformed `on_unimplemented` attribute
|
||||||
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:12:50
|
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:12:50
|
||||||
@@ -61,6 +62,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")]
|
|||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: expect either a generic argument name or `{Self}` as format argument
|
= help: expect either a generic argument name or `{Self}` as format argument
|
||||||
|
= note: `#[warn(malformed_diagnostic_format_literals)]` on by default
|
||||||
|
|
||||||
warning: malformed `on_unimplemented` attribute
|
warning: malformed `on_unimplemented` attribute
|
||||||
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
|
--> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:3:32
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ LL | if(Self = "()"),
|
|||||||
| ^^^^^^^^^^^^^^^ invalid option found here
|
| ^^^^^^^^^^^^^^^ invalid option found here
|
||||||
|
|
|
|
||||||
= help: only `message`, `note` and `label` are allowed as options
|
= help: only `message`, `note` and `label` are allowed as options
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `message` is ignored due to previous definition of `message`
|
warning: `message` is ignored due to previous definition of `message`
|
||||||
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:10:32
|
--> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:10:32
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definiti
|
|||||||
LL | #[diagnostic::on_unimplemented(message = "blah", label = "blah", note = "blah")]
|
LL | #[diagnostic::on_unimplemented(message = "blah", label = "blah", note = "blah")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(misplaced_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
error[E0277]: the trait bound `{integer}: Alias` is not satisfied
|
error[E0277]: the trait bound `{integer}: Alias` is not satisfied
|
||||||
--> $DIR/on_impl_trait.rs:16:9
|
--> $DIR/on_impl_trait.rs:16:9
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ LL | message = "first message",
|
|||||||
LL | message = "second message",
|
LL | message = "second message",
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `message` is already declared here
|
||||||
|
|
|
|
||||||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
= note: `#[warn(malformed_diagnostic_attributes)]` on by default
|
||||||
|
|
||||||
warning: `label` is ignored due to previous definition of `label`
|
warning: `label` is ignored due to previous definition of `label`
|
||||||
--> $DIR/report_warning_on_duplicated_options.rs:11:5
|
--> $DIR/report_warning_on_duplicated_options.rs:11:5
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//@ reference: attributes.diagnostic.namespace.unknown-invalid-syntax
|
//@ reference: attributes.diagnostic.namespace.unknown-invalid-syntax
|
||||||
#![deny(unknown_or_malformed_diagnostic_attributes)]
|
#![deny(unknown_diagnostic_attributes)]
|
||||||
|
|
||||||
#[diagnostic::onunimplemented]
|
#[diagnostic::onunimplemented]
|
||||||
//~^ERROR unknown diagnostic attribute
|
//~^ERROR unknown diagnostic attribute
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ LL | #[diagnostic::onunimplemented]
|
|||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/suggest_typos.rs:2:9
|
--> $DIR/suggest_typos.rs:2:9
|
||||||
|
|
|
|
||||||
LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
|
LL | #![deny(unknown_diagnostic_attributes)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
help: an attribute with a similar name exists
|
help: an attribute with a similar name exists
|
||||||
|
|
|
|
||||||
LL | #[diagnostic::on_unimplemented]
|
LL | #[diagnostic::on_unimplemented]
|
||||||
|
|||||||
Reference in New Issue
Block a user