]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/map_unwrap_or.stderr
New upstream version 1.63.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / map_unwrap_or.stderr
1 error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
2 --> $DIR/map_unwrap_or.rs:16:13
3 |
4 LL | let _ = opt.map(|x| x + 1)
5 | _____________^
6 LL | | // Should lint even though this call is on a separate line.
7 LL | | .unwrap_or(0);
8 | |_____________________^
9 |
10 = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
11 help: use `map_or(<a>, <f>)` instead
12 |
13 LL - let _ = opt.map(|x| x + 1)
14 LL + let _ = opt.map_or(0, |x| x + 1);
15 |
16
17 error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
18 --> $DIR/map_unwrap_or.rs:20:13
19 |
20 LL | let _ = opt.map(|x| {
21 | _____________^
22 LL | | x + 1
23 LL | | }
24 LL | | ).unwrap_or(0);
25 | |__________________^
26 |
27 help: use `map_or(<a>, <f>)` instead
28 |
29 LL ~ let _ = opt.map_or(0, |x| {
30 LL | x + 1
31 LL | }
32 LL ~ );
33 |
34
35 error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
36 --> $DIR/map_unwrap_or.rs:24:13
37 |
38 LL | let _ = opt.map(|x| x + 1)
39 | _____________^
40 LL | | .unwrap_or({
41 LL | | 0
42 LL | | });
43 | |__________^
44 |
45 help: use `map_or(<a>, <f>)` instead
46 |
47 LL ~ let _ = opt.map_or({
48 LL + 0
49 LL ~ }, |x| x + 1);
50 |
51
52 error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
53 --> $DIR/map_unwrap_or.rs:29:13
54 |
55 LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
56 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57 |
58 help: use `and_then(<f>)` instead
59 |
60 LL - let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
61 LL + let _ = opt.and_then(|x| Some(x + 1));
62 |
63
64 error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
65 --> $DIR/map_unwrap_or.rs:31:13
66 |
67 LL | let _ = opt.map(|x| {
68 | _____________^
69 LL | | Some(x + 1)
70 LL | | }
71 LL | | ).unwrap_or(None);
72 | |_____________________^
73 |
74 help: use `and_then(<f>)` instead
75 |
76 LL ~ let _ = opt.and_then(|x| {
77 LL | Some(x + 1)
78 LL | }
79 LL ~ );
80 |
81
82 error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
83 --> $DIR/map_unwrap_or.rs:35:13
84 |
85 LL | let _ = opt
86 | _____________^
87 LL | | .map(|x| Some(x + 1))
88 LL | | .unwrap_or(None);
89 | |________________________^
90 |
91 help: use `and_then(<f>)` instead
92 |
93 LL - .map(|x| Some(x + 1))
94 LL + .and_then(|x| Some(x + 1));
95 |
96
97 error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
98 --> $DIR/map_unwrap_or.rs:46:13
99 |
100 LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
101 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102 |
103 help: use `map_or(<a>, <f>)` instead
104 |
105 LL - let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
106 LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
107 |
108
109 error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
110 --> $DIR/map_unwrap_or.rs:50:13
111 |
112 LL | let _ = opt.map(|x| {
113 | _____________^
114 LL | | x + 1
115 LL | | }
116 LL | | ).unwrap_or_else(|| 0);
117 | |__________________________^
118
119 error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
120 --> $DIR/map_unwrap_or.rs:54:13
121 |
122 LL | let _ = opt.map(|x| x + 1)
123 | _____________^
124 LL | | .unwrap_or_else(||
125 LL | | 0
126 LL | | );
127 | |_________^
128
129 error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
130 --> $DIR/map_unwrap_or.rs:66:13
131 |
132 LL | let _ = res.map(|x| {
133 | _____________^
134 LL | | x + 1
135 LL | | }
136 LL | | ).unwrap_or_else(|_e| 0);
137 | |____________________________^
138
139 error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
140 --> $DIR/map_unwrap_or.rs:70:13
141 |
142 LL | let _ = res.map(|x| x + 1)
143 | _____________^
144 LL | | .unwrap_or_else(|_e| {
145 LL | | 0
146 LL | | });
147 | |__________^
148
149 error: aborting due to 11 previous errors
150