Test for double-ref lint

This commit is contained in:
Manish Goregaokar 2016-02-05 16:04:59 +05:30
parent 4eb9a921d4
commit 8f7b8524d3

View File

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