Skip to content

Commit f0addd0

Browse files
Make tool-only suggestion to remove attributes on invalid targets
1 parent b96868f commit f0addd0

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ attr_parsing_empty_attribute =
1212
1313
attr_parsing_invalid_target = `#[{$name}]` attribute cannot be used on {$target}
1414
.help = `#[{$name}]` can {$only}be applied to {$applied}
15+
.suggestion = remove the attribute
1516
attr_parsing_invalid_target_lint = `#[{$name}]` attribute cannot be used on {$target}
1617
.warn = {-attr_parsing_previously_accepted}
1718
.help = `#[{$name}]` can {$only}be applied to {$applied}
19+
.suggestion = remove the attribute
1820
1921
attr_parsing_empty_confusables =
2022
expected at least one confusable name

compiler/rustc_attr_parsing/src/lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub fn emit_attribute_lint<L: LintEmitter>(lint: &AttributeLint<HirId>, lint_emi
5353
target: target.plural_name(),
5454
applied: applied.clone(),
5555
only,
56+
attr_span: *span,
5657
},
5758
),
5859
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,16 @@ pub(crate) struct InvalidTargetLint {
489489
pub target: &'static str,
490490
pub applied: String,
491491
pub only: &'static str,
492+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
493+
pub attr_span: Span,
492494
}
493495

494496
#[derive(Diagnostic)]
495497
#[help]
496498
#[diag(attr_parsing_invalid_target)]
497499
pub(crate) struct InvalidTarget {
498500
#[primary_span]
501+
#[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
499502
pub span: Span,
500503
pub name: Symbol,
501504
pub target: &'static str,

0 commit comments

Comments
 (0)