5 #![deny(clippy, clippy_pedantic)]
12 fn add(self, other: T) -> T { self } //~ERROR defining a method called `add`
13 fn drop(&mut self) { } //~ERROR defining a method called `drop`
15 fn sub(&self, other: T) -> &T { self } // no error, self is a ref
16 fn div(self) -> T { self } // no error, different #arguments
17 fn rem(self, other: T) { } // no error, wrong return type
19 fn into_u32(self) -> u32 { 0 } // fine
20 fn into_u16(&self) -> u16 { 0 } //~ERROR methods called `into_*` usually take self by value
22 fn to_something(self) -> u32 { 0 } //~ERROR methods called `to_*` usually take self by reference
29 fn to_something(self) -> u32 { 0 } // ok because U is Copy
34 fn mul(self, other: T) -> T { self } // no error, obviously
41 let _ = opt.unwrap(); //~ERROR used unwrap() on an Option
43 let res: Result<i32, ()> = Ok(0);
44 let _ = res.unwrap(); //~ERROR used unwrap() on a Result
46 let _ = "str".to_string(); //~ERROR `"str".to_owned()` is faster
49 let string = v.to_string(); //~ERROR `(*v).to_owned()` is faster
50 let _again = string.to_string(); //~ERROR `String.to_string()` is a no-op
52 res.ok().expect("disaster!"); //~ERROR called `ok().expect()`
53 // the following should not warn, since `expect` isn't implemented unless
54 // the error type implements `Debug`
55 let res2: Result<i32, MyError> = Ok(0);
56 res2.ok().expect("oh noes!");
57 // we currently don't warn if the error type has a type parameter
58 // (but it would be nice if we did)
59 let res3: Result<u32, MyErrorWithParam<u8>>= Ok(0);
60 res3.ok().expect("whoof");
61 let res4: Result<u32, io::Error> = Ok(0);
62 res4.ok().expect("argh"); //~ERROR called `ok().expect()`
63 let res5: io::Result<u32> = Ok(0);
64 res5.ok().expect("oops"); //~ERROR called `ok().expect()`
65 let res6: Result<u32, &str> = Ok(0);
66 res6.ok().expect("meh"); //~ERROR called `ok().expect()`
69 struct MyError(()); // doesn't implement Debug
72 struct MyErrorWithParam<T> {