From 8770f794674dd2af61159b4fef889e6257bfdd8b Mon Sep 17 00:00:00 2001 From: Jonathan Castello Date: Wed, 24 Dec 2014 17:48:03 -0800 Subject: [PATCH 1/2] Add an example of the toplevel_ref_arg lint. --- examples/toplevel_ref_arg.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/toplevel_ref_arg.rs diff --git a/examples/toplevel_ref_arg.rs b/examples/toplevel_ref_arg.rs new file mode 100644 index 000000000000..0be737f90288 --- /dev/null +++ b/examples/toplevel_ref_arg.rs @@ -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); +} From a7d5048d48d54f691a10552a49e4b9bef89e89b0 Mon Sep 17 00:00:00 2001 From: Jonathan Castello Date: Wed, 24 Dec 2014 18:37:50 -0800 Subject: [PATCH 2/2] Update README.md for `clippy_toplevel_ref_arg`. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 91caaeba41a9..3d5e366f56db 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Lints included in this crate: - `clippy_box_vec`: Warns on usage of `Box>` - `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!