From 8f7b8524d3a0491f668cbe92e19e101fef6bd2d0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 5 Feb 2016 16:04:59 +0530 Subject: [PATCH] Test for double-ref lint --- tests/compile-fail/methods.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index 464a7c26e44..4e515c2aa12 100644 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -1,8 +1,8 @@ #![feature(plugin)] #![plugin(clippy)] -#![allow(unused)] #![deny(clippy, clippy_pedantic)] +#![allow(unused, print_stdout)] use std::collections::BTreeMap; use std::collections::HashMap; @@ -334,3 +334,13 @@ fn clone_on_copy_generic(t: T) { t.clone(); //~ERROR using `clone` on a `Copy` type Some(t).clone(); //~ERROR using `clone` on a `Copy` type } + +fn clone_on_double_ref() { + let x = vec![1]; + let y = &&x; + let z: &Vec<_> = y.clone(); //~ERROR using `clone` on a double + //~| HELP try dereferencing it + //~| SUGGESTION let z: &Vec<_> = (*y).clone(); + //~^^^ERROR using `clone` on a `Copy` type + println!("{:p} {:p}",*y, z); +}