diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-09 21:15:45 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-17 09:50:52 +1000 |
| commit | 400e8e5dc819b1fa7f994fb60dbe8b5112ec3fd2 (patch) | |
| tree | de93c7a1439a8869c653ed6df06c41e3025092c1 /compiler | |
| parent | 4be670f89b94aaeab04b0e52d0efd9c61f1bef9d (diff) | |
| download | rust-400e8e5dc819b1fa7f994fb60dbe8b5112ec3fd2.tar.gz rust-400e8e5dc819b1fa7f994fb60dbe8b5112ec3fd2.zip | |
Fix attribute printing in an error.
The current code assumes that the attribute is just an identifier, and so misprints paths.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 42279258e87..dcfecdc26ea 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -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(' ', "_"), }, ); diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 85eddafefcd..075927a54f8 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -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, } |
