1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
11 #![feature(tool_lints)]
13 #![allow(unused, clippy::many_single_char_names)]
14 #![warn(clippy::ptr_arg)]
18 fn do_vec(x: &Vec<i64>) {
22 fn do_vec_mut(x: &mut Vec<i64>) { // no error here
26 fn do_str(x: &String) {
30 fn do_str_mut(x: &mut String) { // no error here
39 fn do_vec(x: &Vec<i64>);
40 fn do_item(x: &Self::Item);
45 // no error, in trait impl (#425)
48 fn do_vec(x: &Vec<i64>) {}
49 fn do_item(x: &Vec<u8>) {}
52 fn cloned(x: &Vec<u8>) -> Vec<u8> {
54 let f = e.clone(); // OK
56 let h = g.clone(); // Alas, we cannot reliably detect this without following data.
61 fn str_cloned(x: &String) -> String {
71 fn false_positive_capacity(x: &Vec<u8>, y: &String) {
77 fn false_positive_capacity_too(x: &String) -> String {
78 if x.capacity() > 1024 { panic!("Too large!"); }
83 fn test_cow_with_ref(c: &Cow<[i32]>) {
87 fn test_cow(c: Cow<[i32]>) {
95 // no error for &self references where self is of type String (#2293)
96 impl Foo2 for String { fn do_string(&self) {} }