about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/lints.rs
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-30 07:01:27 +0200
committerGitHub <noreply@github.com>2025-05-30 07:01:27 +0200
commit7aba37da44991e9046d1e09044c36da06a82b86c (patch)
tree5572aa8e997a2fbeb4958980251cce641094cb2f /compiler/rustc_lint/src/lints.rs
parent1ac1950c337039add1a83113ed6d1bd64bcb1142 (diff)
parentf80e3ac4ed1e1df2c337cbf7b231cb72ec4e3b7a (diff)
downloadrust-7aba37da44991e9046d1e09044c36da06a82b86c.tar.gz
rust-7aba37da44991e9046d1e09044c36da06a82b86c.zip
Rollup merge of #133823 - estebank:issue-56328, r=petrochenkov
Use `cfg_attr_trace` in AST with a placeholder attribute for accurate suggestion

In rust-lang/rust#138515, we insert a placeholder attribute so that checks for attributes can still know about the placement of `cfg` attributes. When we suggest removing items with `cfg_attr`s (fix rust-lang/rust#56328) and make them verbose. We tweak the wording of the existing "unused `extern crate`" lint.

```
warning: unused `extern crate`
  --> $DIR/removing-extern-crate.rs:9:1
   |
LL | extern crate removing_extern_crate as foo;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused
   |
note: the lint level is defined here
  --> $DIR/removing-extern-crate.rs:6:9
   |
LL | #![warn(rust_2018_idioms)]
   |         ^^^^^^^^^^^^^^^^
   = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]`
help: remove the unused `extern crate`
   |
LL - #[cfg_attr(test, macro_use)]
LL - extern crate removing_extern_crate as foo;
   |
```

r? `@petrochenkov`

try-job: x86_64-gnu-aux
Diffstat (limited to 'compiler/rustc_lint/src/lints.rs')
-rw-r--r--compiler/rustc_lint/src/lints.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs
index caad2694f19..10d0e2c93a8 100644
--- a/compiler/rustc_lint/src/lints.rs
+++ b/compiler/rustc_lint/src/lints.rs
@@ -3077,7 +3077,9 @@ pub(crate) struct ByteSliceInPackedStructWithDerive {
 #[derive(LintDiagnostic)]
 #[diag(lint_unused_extern_crate)]
 pub(crate) struct UnusedExternCrate {
-    #[suggestion(code = "", applicability = "machine-applicable")]
+    #[label]
+    pub span: Span,
+    #[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
     pub removal_span: Span,
 }