]> git.lizzy.rs Git - rust.git/blob - tests/ui/did_you_mean/issue-42764.rs
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / did_you_mean / issue-42764.rs
1 enum DoubleOption<T> {
2     FirstSome(T),
3     AlternativeSome(T),
4     Nothing,
5 }
6
7 fn this_function_expects_a_double_option<T>(d: DoubleOption<T>) {}
8
9 fn main() {
10     let n: usize = 42;
11     this_function_expects_a_double_option(n);
12     //~^ ERROR mismatched types
13     //~| HELP try wrapping the expression in a variant of `DoubleOption`
14 }
15
16
17 // But don't issue the "try using a variant" help if the one-"variant" ADT is
18 // actually a one-field struct.
19
20 struct Payload;
21
22 struct Wrapper { payload: Payload }
23
24 struct Context { wrapper: Wrapper }
25
26 fn overton() {
27     let _c = Context { wrapper: Payload{} };
28     //~^ ERROR mismatched types
29     //~| try wrapping the expression in `Wrapper`
30 }