]> git.lizzy.rs Git - rust.git/blob - tests/ui/option_if_let_else.stderr
Merge remote-tracking branch 'upstream/beta' into backport_remerge
[rust.git] / tests / ui / option_if_let_else.stderr
1 error: use Option::map_or instead of an if let/else
2   --> $DIR/option_if_let_else.rs:7:5
3    |
4 LL | /     if let Some(x) = string {
5 LL | |         (true, x)
6 LL | |     } else {
7 LL | |         (false, "hello")
8 LL | |     }
9    | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))`
10    |
11    = note: `-D clippy::option-if-let-else` implied by `-D warnings`
12
13 error: use Option::map_or instead of an if let/else
14   --> $DIR/option_if_let_else.rs:25:13
15    |
16 LL |     let _ = if let Some(s) = *string { s.len() } else { 0 };
17    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
18
19 error: use Option::map_or instead of an if let/else
20   --> $DIR/option_if_let_else.rs:26:13
21    |
22 LL |     let _ = if let Some(s) = &num { s } else { &0 };
23    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
24
25 error: use Option::map_or instead of an if let/else
26   --> $DIR/option_if_let_else.rs:27:13
27    |
28 LL |       let _ = if let Some(s) = &mut num {
29    |  _____________^
30 LL | |         *s += 1;
31 LL | |         s
32 LL | |     } else {
33 LL | |         &mut 0
34 LL | |     };
35    | |_____^
36    |
37 help: try
38    |
39 LL |     let _ = num.as_mut().map_or(&mut 0, |s| {
40 LL |         *s += 1;
41 LL |         s
42 LL |     });
43    |
44
45 error: use Option::map_or instead of an if let/else
46   --> $DIR/option_if_let_else.rs:33:13
47    |
48 LL |     let _ = if let Some(ref s) = num { s } else { &0 };
49    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
50
51 error: use Option::map_or instead of an if let/else
52   --> $DIR/option_if_let_else.rs:34:13
53    |
54 LL |       let _ = if let Some(mut s) = num {
55    |  _____________^
56 LL | |         s += 1;
57 LL | |         s
58 LL | |     } else {
59 LL | |         0
60 LL | |     };
61    | |_____^
62    |
63 help: try
64    |
65 LL |     let _ = num.map_or(0, |mut s| {
66 LL |         s += 1;
67 LL |         s
68 LL |     });
69    |
70
71 error: use Option::map_or instead of an if let/else
72   --> $DIR/option_if_let_else.rs:40:13
73    |
74 LL |       let _ = if let Some(ref mut s) = num {
75    |  _____________^
76 LL | |         *s += 1;
77 LL | |         s
78 LL | |     } else {
79 LL | |         &mut 0
80 LL | |     };
81    | |_____^
82    |
83 help: try
84    |
85 LL |     let _ = num.as_mut().map_or(&mut 0, |s| {
86 LL |         *s += 1;
87 LL |         s
88 LL |     });
89    |
90
91 error: use Option::map_or instead of an if let/else
92   --> $DIR/option_if_let_else.rs:49:5
93    |
94 LL | /     if let Some(x) = arg {
95 LL | |         let y = x * x;
96 LL | |         y * y
97 LL | |     } else {
98 LL | |         13
99 LL | |     }
100    | |_____^
101    |
102 help: try
103    |
104 LL |     arg.map_or(13, |x| {
105 LL |         let y = x * x;
106 LL |         y * y
107 LL |     })
108    |
109
110 error: use Option::map_or_else instead of an if let/else
111   --> $DIR/option_if_let_else.rs:62:13
112    |
113 LL |       let _ = if let Some(x) = arg {
114    |  _____________^
115 LL | |         x
116 LL | |     } else {
117 LL | |         // map_or_else must be suggested
118 LL | |         side_effect()
119 LL | |     };
120    | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)`
121
122 error: use Option::map_or_else instead of an if let/else
123   --> $DIR/option_if_let_else.rs:71:13
124    |
125 LL |       let _ = if let Some(x) = arg {
126    |  _____________^
127 LL | |         x * x * x * x
128 LL | |     } else {
129 LL | |         let mut y = 1;
130 ...  |
131 LL | |         y
132 LL | |     };
133    | |_____^
134    |
135 help: try
136    |
137 LL |     let _ = arg.map_or_else(|| {
138 LL |         let mut y = 1;
139 LL |         y = (y + 2 / y) / 2;
140 LL |         y = (y + 2 / y) / 2;
141 LL |         y
142 LL |     }, |x| x * x * x * x);
143    |
144
145 error: use Option::map_or instead of an if let/else
146   --> $DIR/option_if_let_else.rs:100:13
147    |
148 LL |     let _ = if let Some(x) = optional { x + 2 } else { 5 };
149    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
150
151 error: aborting due to 11 previous errors
152