Fix attribute printing in an error.
The current code assumes that the attribute is just an identifier, and so misprints paths.
This commit is contained in:
parent
4be670f89b
commit
400e8e5dc8
4 changed files with 9 additions and 6 deletions
|
@ -561,12 +561,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
allowed_target: Target,
|
||||
) {
|
||||
if target != allowed_target {
|
||||
let path = attr.path();
|
||||
let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
|
||||
let attr_name = path.join("::");
|
||||
self.tcx.emit_node_span_lint(
|
||||
UNUSED_ATTRIBUTES,
|
||||
hir_id,
|
||||
attr.span(),
|
||||
errors::OnlyHasEffectOn {
|
||||
attr_name: attr.name_or_empty(),
|
||||
attr_name,
|
||||
target_name: allowed_target.name().replace(' ', "_"),
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1433,7 +1433,7 @@ pub(crate) struct UselessAssignment<'a> {
|
|||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_only_has_effect_on)]
|
||||
pub(crate) struct OnlyHasEffectOn {
|
||||
pub attr_name: Symbol,
|
||||
pub attr_name: String,
|
||||
pub target_name: String,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue