-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blacklisted_name should not be triggered in tests #8986
Comments
Hello. I tried your code, but the following two cases cannot be reproduced. (rust playrground) (If the verification method is incorrect, please let me know.) #![warn(clippy::blacklisted_name)]
fn main() {}
#[cfg(test)]
mod abc {
fn _abc() {
let foo = ();
dbg!(foo);
}
}
#[test]
fn bcd() {
let foo = ();
dbg!(foo);
} last case, I think we should not lint.
|
Playground seems not to pass --tests flag to the compiler so I ran clippy in local enviroment.
Yes. I reconsider this and agree with you. But the lint has been fixed in PR #7379 in order to trigger on |
I can reproduce now, thanks! It doesn't seem urgent, so I hope someone interested will do it. |
@rustbot claim |
I think the lint is working as intended right now. For the following input: #![warn(clippy::blacklisted_name)]
fn main() {}
#[cfg(test)]
mod abc {
fn _abc() {
let foo = ();
dbg!(foo);
}
}
#[test]
fn bcd() {
let foo = ();
dbg!(foo);
}
fn _test() {
let foo = ();
dbg!(foo);
}
mod tests {
fn _mf() {
let foo = ();
dbg!(foo);
}
} I get only 1 warning: warning: use of a blacklisted/placeholder name `foo`
--> src/main.rs:19:9
|
19 | let foo = ();
| ^^^
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![warn(clippy::blacklisted_name)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name
warning: `clippy-example-1` (bin "clippy-example-1") generated 1 warning Which is expected, since the function The rust-clippy/clippy_utils/src/lib.rs Lines 2220 to 2228 in 580f642
Does my reasoning make sense or not? |
Summary
blacklisted_name should toralate use of such name as
foo
.As far as I see the source code, it tries to allow
foo
in tests, but it doesn't.Similar to #8758
Lint Name
blacklisted_name
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
No warning
Version
Additional Labels
@rustbot label +E-easy
The text was updated successfully, but these errors were encountered: