mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 21:53:23 +00:00
Merge pull request #1760 from Manishearth/fix1647
Fix span in `blacklisted_name`
This commit is contained in:
commit
fe85cde91c
4 changed files with 78 additions and 23 deletions
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
|
|||
if self.blacklist.iter().any(|s| ident.node == *s) {
|
||||
span_lint(cx,
|
||||
BLACKLISTED_NAME,
|
||||
pat.span,
|
||||
ident.span,
|
||||
&format!("use of a blacklisted/placeholder name `{}`", ident.node));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(single_match)]
|
||||
#![allow(unused_variables, similar_names)]
|
||||
#![allow(dead_code, similar_names, single_match, toplevel_ref_arg, unused_mut, unused_variables)]
|
||||
#![deny(blacklisted_name)]
|
||||
|
||||
fn test(foo: ()) {}
|
||||
|
@ -21,3 +19,18 @@ fn main() {
|
|||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn issue_1647(mut foo: u8) {
|
||||
let mut bar = 0;
|
||||
if let Some(mut baz) = Some(42) {}
|
||||
}
|
||||
|
||||
fn issue_1647_ref() {
|
||||
let ref bar = 0;
|
||||
if let Some(ref baz) = Some(42) {}
|
||||
}
|
||||
|
||||
fn issue_1647_ref_mut() {
|
||||
let ref mut bar = 0;
|
||||
if let Some(ref mut baz) = Some(42) {}
|
||||
}
|
||||
|
|
|
@ -1,50 +1,92 @@
|
|||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:9:9
|
||||
--> $DIR/blacklisted_name.rs:7:9
|
||||
|
|
||||
9 | fn test(foo: ()) {}
|
||||
7 | fn test(foo: ()) {}
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/blacklisted_name.rs:7:9
|
||||
--> $DIR/blacklisted_name.rs:5:9
|
||||
|
|
||||
7 | #![deny(blacklisted_name)]
|
||||
5 | #![deny(blacklisted_name)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:12:9
|
||||
--> $DIR/blacklisted_name.rs:10:9
|
||||
|
|
||||
12 | let foo = 42;
|
||||
10 | let foo = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:13:9
|
||||
--> $DIR/blacklisted_name.rs:11:9
|
||||
|
|
||||
13 | let bar = 42;
|
||||
11 | let bar = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:14:9
|
||||
--> $DIR/blacklisted_name.rs:12:9
|
||||
|
|
||||
14 | let baz = 42;
|
||||
12 | let baz = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:20:10
|
||||
--> $DIR/blacklisted_name.rs:18:10
|
||||
|
|
||||
20 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
18 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:20:20
|
||||
--> $DIR/blacklisted_name.rs:18:20
|
||||
|
|
||||
20 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
18 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:20:26
|
||||
--> $DIR/blacklisted_name.rs:18:26
|
||||
|
|
||||
20 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
| ^^^^^^^^^^^^^
|
||||
18 | (foo, Some(bar), baz @ Some(_)) => (),
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:23:19
|
||||
|
|
||||
23 | fn issue_1647(mut foo: u8) {
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:24:13
|
||||
|
|
||||
24 | let mut bar = 0;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:25:21
|
||||
|
|
||||
25 | if let Some(mut baz) = Some(42) {}
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:29:13
|
||||
|
|
||||
29 | let ref bar = 0;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:30:21
|
||||
|
|
||||
30 | if let Some(ref baz) = Some(42) {}
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:34:17
|
||||
|
|
||||
34 | let ref mut bar = 0;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:35:25
|
||||
|
|
||||
35 | if let Some(ref mut baz) = Some(42) {}
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ error: use of a blacklisted/placeholder name `titi`
|
|||
--> $DIR/conf_french_blacklisted_name.rs:20:28
|
||||
|
|
||||
20 | (toto, Some(tata), titi @ Some(_)) => (),
|
||||
| ^^^^^^^^^^^^^^
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue