Merge pull request from Twisol/lint-toplevel-ref-arg-example

Add an example of the toplevel_ref_arg lint.
This commit is contained in:
Manish Goregaokar 2014-12-25 20:53:33 +05:30
commit 84f39f08f8
2 changed files with 15 additions and 0 deletions

@ -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!

@ -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);
}