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.
10 #![deny(clippy::identity_conversion)]
12 fn test_generic<T: Copy>(val: T) -> T {
17 fn test_generic2<T: Copy + Into<i32> + Into<U>, U: From<T>>(val: T) {
19 let _: i32 = val.into();
20 let _: U = val.into();
24 fn test_questionmark() -> Result<(), ()> {
26 let _: i32 = 0i32.into();
34 test_generic2::<i32, i32>(10i32);
35 test_questionmark().unwrap();
37 let _: String = "foo".into();
38 let _: String = From::from("foo");
39 let _ = String::from("foo");
40 #[allow(clippy::identity_conversion)]
42 let _: String = "foo".into();
43 let _ = String::from("foo");
44 let _ = "".lines().into_iter();
47 let _: String = "foo".to_string().into();
48 let _: String = From::from("foo".to_string());
49 let _ = String::from("foo".to_string());
50 let _ = String::from(format!("A: {:04}", 123));
51 let _ = "".lines().into_iter();
52 let _ = vec![1, 2, 3].into_iter().into_iter();
53 let _: String = format!("Hello {}", "world").into();