about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-12-18 21:38:11 -0500
committerGitHub <noreply@github.com>2024-12-18 21:38:11 -0500
commit033fbe0a475b60cd3eef0dbc5dc43d3764b550d1 (patch)
treef06b9fcf247cac1bd5788c277cf21c29eed7cd4f /compiler
parent0391770c0710cd3d5fcc645c160af6c9cab8a99a (diff)
parent19e44f4db48e21832d17378a32739a70db29cf30 (diff)
downloadrust-033fbe0a475b60cd3eef0dbc5dc43d3764b550d1.tar.gz
rust-033fbe0a475b60cd3eef0dbc5dc43d3764b550d1.zip
Rollup merge of #134481 - estebank:unstable-lint-span, r=compiler-errors
Point at lint name instead of whole attr for gated lints

```
warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |          ^^^^^^^^^^^^^^^^^^
   |
   = note: the `test_unstable_lint` lint is unstable
   = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
note: the lint level is defined here
  --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9
   |
LL | #![warn(unknown_lints)]
   |         ^^^^^^^^^^^^^

warning: unknown lint: `test_unstable_lint`
  --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29
   |
LL | #![allow(test_unstable_lint, another_unstable_lint)]
   |                              ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the `another_unstable_lint` lint is unstable
   = help: add `#![feature(another_unstable_lint)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
```

This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/levels.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs
index 0185f46c35a..5a4ed68440a 100644
--- a/compiler/rustc_lint/src/levels.rs
+++ b/compiler/rustc_lint/src/levels.rs
@@ -914,7 +914,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
 
                 let src = LintLevelSource::Node { name, span: sp, reason };
                 for &id in ids {
-                    if self.check_gated_lint(id, attr.span(), false) {
+                    if self.check_gated_lint(id, sp, false) {
                         self.insert_spec(id, (level, src));
                     }
                 }