]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/copied-and-cloned.rs
Rollup merge of #106958 - jyn514:labels, r=m-ou-se
[rust.git] / tests / ui / suggestions / copied-and-cloned.rs
1 // run-rustfix
2
3 fn expect<T>(_: T) {}
4
5 fn main() {
6     let x = Some(&());
7     expect::<Option<()>>(x);
8     //~^ ERROR mismatched types
9     //~| HELP use `Option::copied` to copy the value inside the `Option`
10     let x = Ok(&());
11     expect::<Result<(), ()>>(x);
12     //~^ ERROR mismatched types
13     //~| HELP use `Result::copied` to copy the value inside the `Result`
14     let s = String::new();
15     let x = Some(&s);
16     expect::<Option<String>>(x);
17     //~^ ERROR mismatched types
18     //~| HELP use `Option::cloned` to clone the value inside the `Option`
19     let x = Ok(&s);
20     expect::<Result<String, ()>>(x);
21     //~^ ERROR mismatched types
22     //~| HELP use `Result::cloned` to clone the value inside the `Result`
23 }