From 663688f70db1e1c4df764de1c0d07037f1a96e9c Mon Sep 17 00:00:00 2001 From: scott-linder Date: Sat, 10 Jun 2017 23:50:57 -0400 Subject: [PATCH] Move old-style test to examples --- clippy_tests/examples/borrow_box.rs | 24 +++++++++++++++++++++ clippy_tests/examples/borrow_box.stderr | 28 +++++++++++++++++++++++++ tests/compile-fail/borrow_box.rs | 25 ---------------------- 3 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 clippy_tests/examples/borrow_box.rs create mode 100644 clippy_tests/examples/borrow_box.stderr delete mode 100644 tests/compile-fail/borrow_box.rs diff --git a/clippy_tests/examples/borrow_box.rs b/clippy_tests/examples/borrow_box.rs new file mode 100644 index 00000000000..a72c664376f --- /dev/null +++ b/clippy_tests/examples/borrow_box.rs @@ -0,0 +1,24 @@ +#![feature(plugin)] +#![plugin(clippy)] + +#![deny(borrowed_box)] +#![allow(blacklisted_name)] +#![allow(unused_variables)] +#![allow(dead_code)] + +pub fn test1(foo: &mut Box) { + println!("{:?}", foo) +} + +pub fn test2() { + let foo: &Box; +} + +struct Test3<'a> { + foo: &'a Box +} + +fn main(){ + test1(&mut Box::new(false)); + test2(); +} diff --git a/clippy_tests/examples/borrow_box.stderr b/clippy_tests/examples/borrow_box.stderr new file mode 100644 index 00000000000..1b4b2c1efa6 --- /dev/null +++ b/clippy_tests/examples/borrow_box.stderr @@ -0,0 +1,28 @@ +error: you seem to be trying to use `&Box`. Consider using just `&T` + --> borrow_box.rs:10:19 + | +10 | pub fn test1(foo: &Box) { //~ ERROR you seem to be trying to use `&Box` + | ^^^^^^^^^^ + | + = note: #[deny(borrowed_box)] implied by #[deny(clippy)] +note: lint level defined here + --> borrow_box.rs:4:9 + | +4 | #![deny(clippy)] + | ^^^^^^ + = help: replace `&Box` with simply `&T` + +error: you seem to be trying to use `&Box`. Consider using just `&T` + --> borrow_box.rs:19:10 + | +19 | foo: &'a Box //~ ERROR you seem to be trying to use `&Box` + | ^^^^^^^^^^^^^ + | + = note: #[deny(borrowed_box)] implied by #[deny(clippy)] + = help: replace `&Box` with simply `&T` + +error: aborting due to previous error(s) + +error: Could not compile `clippy_tests`. + +To learn more, run the command again with --verbose. diff --git a/tests/compile-fail/borrow_box.rs b/tests/compile-fail/borrow_box.rs deleted file mode 100644 index 9c1c36e6475..00000000000 --- a/tests/compile-fail/borrow_box.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![feature(plugin)] -#![plugin(clippy)] - -#![deny(clippy)] -#![allow(boxed_local)] -#![allow(blacklisted_name)] -#![allow(unused_variables)] -#![allow(dead_code)] - -pub fn test1(foo: &Box) { //~ ERROR you seem to be trying to use `&Box` - println!("{:?}", foo) -} - -pub fn test2() { - let foo: &Box; //~ ERROR you seem to be trying to use `&Box` -} - -struct Test3<'a> { - foo: &'a Box //~ ERROR you seem to be trying to use `&Box` -} - -fn main(){ - test1(&Box::new(false)); - test2(); -}