fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2 3fn expect<T>(_: T) {} 4 5struct Issue114925 { 6 x: Option<String>, 7} 8 9fn issue_114925(lol: &mut Issue114925, x: Option<&String>) { 10 lol.x = x.clone().cloned(); 11 //~^ ERROR mismatched types 12 //~| HELP use `Option::cloned` to clone the value inside the `Option` 13} 14 15fn main() { 16 let x = Some(&()); 17 expect::<Option<()>>(x.copied()); 18 //~^ ERROR mismatched types 19 //~| HELP use `Option::copied` to copy the value inside the `Option` 20 let x = Ok(&()); 21 expect::<Result<(), ()>>(x.copied()); 22 //~^ ERROR mismatched types 23 //~| HELP use `Result::copied` to copy the value inside the `Result` 24 let s = String::new(); 25 let x = Some(&s); 26 expect::<Option<String>>(x.cloned()); 27 //~^ ERROR mismatched types 28 //~| HELP use `Option::cloned` to clone the value inside the `Option` 29 let x = Ok(&s); 30 expect::<Result<String, ()>>(x.cloned()); 31 //~^ ERROR mismatched types 32 //~| HELP use `Result::cloned` to clone the value inside the `Result` 33 34 let s = String::new(); 35 let x = Some(s.clone()); 36 let y = Some(&s); 37 println!("{}", x == y.cloned()); 38 //~^ ERROR mismatched types 39 //~| HELP use `Option::cloned` to clone the value inside the `Option` 40 //FIXME(#114050) ~| HELP use `Option::as_ref` to convert `Option<String>` to `Option<&String>` 41 42 let mut s = (); 43 let x = Some(s); 44 let y = Some(&mut s); 45 println!("{}", x == y.copied()); 46 //~^ ERROR mismatched types 47 //~| HELP use `Option::copied` to copy the value inside the `Option` 48 49 let mut s = String::new(); 50 let x = Some(s.clone()); 51 let y = Some(&mut s); 52 println!("{}", x == y.cloned()); 53 //~^ ERROR mismatched types 54 //~| HELP use `Option::cloned` to clone the value inside the `Option` 55 56 issue_114925(&mut Issue114925 { x: None }, None); 57}