mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Add tests
This commit is contained in:
parent
76049a7cd0
commit
6482840bc5
1 changed files with 22 additions and 0 deletions
22
tests/compile-fail/used_underscore_binding.rs
Normal file
22
tests/compile-fail/used_underscore_binding.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#[deny(used_underscore_binding)]
|
||||
|
||||
fn main() {
|
||||
let foo = 0u32;
|
||||
prefix_underscore(foo); //should fail
|
||||
non_prefix_underscore(foo); //should pass
|
||||
unused_underscore(foo); //should pass
|
||||
}
|
||||
|
||||
fn prefix_underscore(_x: u32){
|
||||
println!("{}", _x + 1); //~Error: Used binding which is prefixed with an underscore
|
||||
}
|
||||
|
||||
fn non_prefix_underscore(some_foo: u32) {
|
||||
println!("{}", some_foo + 1);
|
||||
}
|
||||
|
||||
fn unused_underscore(_foo: u32) {
|
||||
println!("{}", 1);
|
||||
}
|
Loading…
Reference in a new issue