3 #![deny(clippy::useless_conversion)]
4 #![allow(clippy::unnecessary_wraps)]
6 fn test_generic<T: Copy>(val: T) -> T {
11 fn test_generic2<T: Copy + Into<i32> + Into<U>, U: From<T>>(val: T) {
13 let _: i32 = val.into();
14 let _: U = val.into();
18 fn test_questionmark() -> Result<(), ()> {
20 let _: i32 = 0i32.into();
26 fn test_issue_3913() -> Result<(), std::io::Error> {
30 let path = Path::new(".");
31 for _ in fs::read_dir(path)? {}
36 fn test_issue_5833() -> Result<(), ()> {
37 let text = "foo\r\nbar\n\nbaz\n";
38 let lines = text.lines();
39 if Some("ok") == lines.into_iter().next() {}
46 test_generic2::<i32, i32>(10i32);
47 test_questionmark().unwrap();
48 test_issue_3913().unwrap();
49 test_issue_5833().unwrap();
51 let _: String = "foo".into();
52 let _: String = From::from("foo");
53 let _ = String::from("foo");
54 #[allow(clippy::useless_conversion)]
56 let _: String = "foo".into();
57 let _ = String::from("foo");
58 let _ = "".lines().into_iter();
61 let _: String = "foo".to_string().into();
62 let _: String = From::from("foo".to_string());
63 let _ = String::from("foo".to_string());
64 let _ = String::from(format!("A: {:04}", 123));
65 let _ = "".lines().into_iter();
66 let _ = vec![1, 2, 3].into_iter().into_iter();
67 let _: String = format!("Hello {}", "world").into();
69 // keep parentheses around `a + b` for suggestion (see #4750)
72 let _ = i32::from(a + b) * 3;
75 let s: Foo<'a'> = Foo;
76 let _: Foo<'b'> = s.into();
77 let s2: Foo<'a'> = Foo;
78 let _: Foo<'a'> = s2.into();
79 let s3: Foo<'a'> = Foo;
80 let _ = Foo::<'a'>::from(s3);
81 let s4: Foo<'a'> = Foo;
82 let _ = vec![s4, s4, s4].into_iter().into_iter();
85 #[derive(Copy, Clone)]
86 struct Foo<const C: char>;
88 impl From<Foo<'a'>> for Foo<'b'> {
89 fn from(_s: Foo<'a'>) -> Self {