3 #![feature(custom_inner_attributes)]
4 #![warn(clippy::manual_str_repeat)]
10 let _: String = "test".repeat(10);
11 let _: String = "x".repeat(10);
12 let _: String = "'".repeat(10);
13 let _: String = "\"".repeat(10);
17 let _ = x.repeat(count + 2);
20 ($e:expr) => {{ $e }};
22 // FIXME: macro args are fine
23 let _: String = repeat(m!("test")).take(m!(count)).collect();
26 let _: String = (*x).repeat(count);
28 macro_rules! repeat_m {
29 ($e:expr) => {{ repeat($e) }};
31 // Don't lint, repeat is from a macro.
32 let _: String = repeat_m!("test").take(count).collect();
34 let x: Box<str> = Box::from("test");
35 let _: String = x.repeat(count);
39 impl FromIterator<Box<S>> for String {
40 fn from_iter<T: IntoIterator<Item = Box<S>>>(_: T) -> Self {
44 // Don't lint, wrong box type
45 let _: String = repeat(Box::new(S)).take(count).collect();
47 let _: String = Cow::Borrowed("test").repeat(count);
49 let x = "x".to_owned();
50 let _: String = x.repeat(count);
53 // Don't lint, not char literal
54 let _: String = repeat(x).take(count).collect();
58 #![clippy::msrv = "1.15"]
59 // `str::repeat` was stabilized in 1.16. Do not lint this
60 let _: String = std::iter::repeat("test").take(10).collect();
64 #![clippy::msrv = "1.16"]
65 let _: String = "test".repeat(10);