2019-09-20 06:53:58 +00:00
|
|
|
// run-rustfix
|
|
|
|
|
2020-05-04 15:09:02 +00:00
|
|
|
#![deny(clippy::useless_conversion)]
|
2017-02-05 04:41:09 +00:00
|
|
|
|
|
|
|
fn test_generic<T: Copy>(val: T) -> T {
|
|
|
|
let _ = T::from(val);
|
|
|
|
val.into()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_generic2<T: Copy + Into<i32> + Into<U>, U: From<T>>(val: T) {
|
|
|
|
// ok
|
|
|
|
let _: i32 = val.into();
|
|
|
|
let _: U = val.into();
|
|
|
|
let _ = U::from(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_questionmark() -> Result<(), ()> {
|
|
|
|
{
|
|
|
|
let _: i32 = 0i32.into();
|
|
|
|
Ok(Ok(()))
|
|
|
|
}??;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-05-12 19:32:29 +00:00
|
|
|
fn test_issue_3913() -> Result<(), std::io::Error> {
|
|
|
|
use std::fs;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
let path = Path::new(".");
|
|
|
|
for _ in fs::read_dir(path)? {}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2017-02-05 04:41:09 +00:00
|
|
|
fn main() {
|
|
|
|
test_generic(10i32);
|
|
|
|
test_generic2::<i32, i32>(10i32);
|
|
|
|
test_questionmark().unwrap();
|
2019-05-12 19:32:29 +00:00
|
|
|
test_issue_3913().unwrap();
|
2017-02-05 04:41:09 +00:00
|
|
|
|
|
|
|
let _: String = "foo".into();
|
|
|
|
let _: String = From::from("foo");
|
|
|
|
let _ = String::from("foo");
|
2020-05-04 15:09:02 +00:00
|
|
|
#[allow(clippy::useless_conversion)]
|
2017-10-04 13:26:41 +00:00
|
|
|
{
|
|
|
|
let _: String = "foo".into();
|
|
|
|
let _ = String::from("foo");
|
2018-07-30 04:02:05 +00:00
|
|
|
let _ = "".lines().into_iter();
|
2017-10-04 13:26:41 +00:00
|
|
|
}
|
2017-02-05 04:41:09 +00:00
|
|
|
|
|
|
|
let _: String = "foo".to_string().into();
|
|
|
|
let _: String = From::from("foo".to_string());
|
|
|
|
let _ = String::from("foo".to_string());
|
2018-08-07 03:37:11 +00:00
|
|
|
let _ = String::from(format!("A: {:04}", 123));
|
2018-07-30 04:02:05 +00:00
|
|
|
let _ = "".lines().into_iter();
|
|
|
|
let _ = vec![1, 2, 3].into_iter().into_iter();
|
2018-10-27 09:01:27 +00:00
|
|
|
let _: String = format!("Hello {}", "world").into();
|
2017-02-05 04:41:09 +00:00
|
|
|
}
|