Merge pull request #26 from Twisol/lint-toplevel-ref-arg-example
Add an example of the toplevel_ref_arg lint.
This commit is contained in:
commit
84f39f08f8
@ -10,6 +10,7 @@ Lints included in this crate:
|
||||
- `clippy_box_vec`: Warns on usage of `Box<Vec<T>>`
|
||||
- `clippy_dlist`: Warns on usage of `DList`
|
||||
- `clippy_str_to_string`: Warns on usage of `str::to_string()`
|
||||
- `clippy_toplevel_ref_arg`: Warns when a function argument is declared `ref` (i.e. `fn foo(ref x: u8)`, but not `fn foo((ref x, ref y): (u8, u8))`).
|
||||
|
||||
More to come, please [file an issue](https://github.com/Manishearth/rust-clippy/issues) if you have ideas!
|
||||
|
||||
|
14
examples/toplevel_ref_arg.rs
Normal file
14
examples/toplevel_ref_arg.rs
Normal file
@ -0,0 +1,14 @@
|
||||
#![feature(phase)]
|
||||
|
||||
#[phase(plugin)]
|
||||
extern crate rust_clippy;
|
||||
|
||||
fn the_answer(ref mut x: u8) {
|
||||
*x = 42;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = 0;
|
||||
the_answer(x);
|
||||
println!("The answer is {}.", x);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user