]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
Auto merge of #4164 - mikerite:fix-4144, r=mikerite
[rust.git] / tests / ui / methods.stderr
1 error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name
2   --> $DIR/methods.rs:35:5
3    |
4 LL | /     pub fn add(self, other: T) -> T {
5 LL | |         self
6 LL | |     }
7    | |_____^
8    |
9    = note: `-D clippy::should-implement-trait` implied by `-D warnings`
10
11 error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
12   --> $DIR/methods.rs:70:17
13    |
14 LL |     fn into_u16(&self) -> u16 {
15    |                 ^^^^^
16    |
17    = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
18
19 error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
20   --> $DIR/methods.rs:74:21
21    |
22 LL |     fn to_something(self) -> u32 {
23    |                     ^^^^
24
25 error: methods called `new` usually take no self; consider choosing a less ambiguous name
26   --> $DIR/methods.rs:78:12
27    |
28 LL |     fn new(self) -> Self {
29    |            ^^^^
30
31 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
32   --> $DIR/methods.rs:157:13
33    |
34 LL |       let _ = opt.map(|x| x + 1)
35    |  _____________^
36 LL | |                 // Should lint even though this call is on a separate line.
37 LL | |                .unwrap_or(0);
38    | |____________________________^
39    |
40    = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
41    = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
42
43 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
44   --> $DIR/methods.rs:161:13
45    |
46 LL |       let _ = opt.map(|x| {
47    |  _____________^
48 LL | |                         x + 1
49 LL | |                     }
50 LL | |               ).unwrap_or(0);
51    | |____________________________^
52
53 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
54   --> $DIR/methods.rs:165:13
55    |
56 LL |       let _ = opt.map(|x| x + 1)
57    |  _____________^
58 LL | |                .unwrap_or({
59 LL | |                     0
60 LL | |                 });
61    | |__________________^
62
63 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
64   --> $DIR/methods.rs:170:13
65    |
66 LL |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
67    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68    |
69    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
70
71 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
72   --> $DIR/methods.rs:172:13
73    |
74 LL |       let _ = opt.map(|x| {
75    |  _____________^
76 LL | |         Some(x + 1)
77 LL | |     }
78 LL | |     ).unwrap_or(None);
79    | |_____________________^
80
81 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
82   --> $DIR/methods.rs:176:13
83    |
84 LL |       let _ = opt
85    |  _____________^
86 LL | |         .map(|x| Some(x + 1))
87 LL | |         .unwrap_or(None);
88    | |________________________^
89    |
90    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
91
92 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
93   --> $DIR/methods.rs:187:13
94    |
95 LL |     let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
96    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97    |
98    = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
99
100 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
101   --> $DIR/methods.rs:191:13
102    |
103 LL |       let _ = opt.map(|x| x + 1)
104    |  _____________^
105 LL | |                 // Should lint even though this call is on a separate line.
106 LL | |                .unwrap_or_else(|| 0);
107    | |____________________________________^
108    |
109    = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
110    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
111
112 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
113   --> $DIR/methods.rs:195:13
114    |
115 LL |       let _ = opt.map(|x| {
116    |  _____________^
117 LL | |                         x + 1
118 LL | |                     }
119 LL | |               ).unwrap_or_else(|| 0);
120    | |____________________________________^
121
122 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
123   --> $DIR/methods.rs:199:13
124    |
125 LL |       let _ = opt.map(|x| x + 1)
126    |  _____________^
127 LL | |                .unwrap_or_else(||
128 LL | |                     0
129 LL | |                 );
130    | |_________________^
131
132 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
133   --> $DIR/methods.rs:229:13
134    |
135 LL |     let _ = v.iter().filter(|&x| *x < 0).next();
136    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137    |
138    = note: `-D clippy::filter-next` implied by `-D warnings`
139    = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
140
141 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
142   --> $DIR/methods.rs:232:13
143    |
144 LL |       let _ = v.iter().filter(|&x| {
145    |  _____________^
146 LL | |                                 *x < 0
147 LL | |                             }
148 LL | |                    ).next();
149    | |___________________________^
150
151 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
152   --> $DIR/methods.rs:248:13
153    |
154 LL |     let _ = v.iter().find(|&x| *x < 0).is_some();
155    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156    |
157    = note: `-D clippy::search-is-some` implied by `-D warnings`
158    = note: replace `find(|&x| *x < 0).is_some()` with `any(|x| *x < 0)`
159
160 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
161   --> $DIR/methods.rs:251:13
162    |
163 LL |       let _ = v.iter().find(|&x| {
164    |  _____________^
165 LL | |                               *x < 0
166 LL | |                           }
167 LL | |                    ).is_some();
168    | |______________________________^
169
170 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
171   --> $DIR/methods.rs:257:13
172    |
173 LL |     let _ = v.iter().position(|&x| x < 0).is_some();
174    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175    |
176    = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
177
178 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
179   --> $DIR/methods.rs:260:13
180    |
181 LL |       let _ = v.iter().position(|&x| {
182    |  _____________^
183 LL | |                                   x < 0
184 LL | |                               }
185 LL | |                    ).is_some();
186    | |______________________________^
187
188 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
189   --> $DIR/methods.rs:266:13
190    |
191 LL |     let _ = v.iter().rposition(|&x| x < 0).is_some();
192    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
193    |
194    = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)`
195
196 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
197   --> $DIR/methods.rs:269:13
198    |
199 LL |       let _ = v.iter().rposition(|&x| {
200    |  _____________^
201 LL | |                                    x < 0
202 LL | |                                }
203 LL | |                    ).is_some();
204    | |______________________________^
205
206 error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message
207   --> $DIR/methods.rs:284:13
208    |
209 LL |     let _ = opt.unwrap();
210    |             ^^^^^^^^^^^^
211    |
212    = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
213
214 error: aborting due to 23 previous errors
215