]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods.stderr
c35a74463ec88bf62718815acdea4469d63f5b2d
[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:37: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 `new` usually return `Self`
12   --> $DIR/methods.rs:153:5
13    |
14 LL | /     fn new() -> i32 {
15 LL | |         0
16 LL | |     }
17    | |_____^
18    |
19    = note: `-D clippy::new-ret-no-self` implied by `-D warnings`
20
21 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
22   --> $DIR/methods.rs:175:13
23    |
24 LL |       let _ = opt.map(|x| x + 1)
25    |  _____________^
26 LL | |                 // Should lint even though this call is on a separate line.
27 LL | |                .unwrap_or(0);
28    | |____________________________^
29    |
30    = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings`
31    = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)`
32
33 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
34   --> $DIR/methods.rs:179:13
35    |
36 LL |       let _ = opt.map(|x| {
37    |  _____________^
38 LL | |                         x + 1
39 LL | |                     }
40 LL | |               ).unwrap_or(0);
41    | |____________________________^
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:183:13
45    |
46 LL |       let _ = opt.map(|x| x + 1)
47    |  _____________^
48 LL | |                .unwrap_or({
49 LL | |                     0
50 LL | |                 });
51    | |__________________^
52
53 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
54   --> $DIR/methods.rs:188:13
55    |
56 LL |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
57    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58    |
59    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
60
61 error: called `map(f).unwrap_or(None)` on an Option value. This can be done more directly by calling `and_then(f)` instead
62   --> $DIR/methods.rs:190:13
63    |
64 LL |       let _ = opt.map(|x| {
65    |  _____________^
66 LL | |         Some(x + 1)
67 LL | |     }
68 LL | |     ).unwrap_or(None);
69    | |_____________________^
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:194:13
73    |
74 LL |       let _ = opt
75    |  _____________^
76 LL | |         .map(|x| Some(x + 1))
77 LL | |         .unwrap_or(None);
78    | |________________________^
79    |
80    = note: replace `map(|x| Some(x + 1)).unwrap_or(None)` with `and_then(|x| Some(x + 1))`
81
82 error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead
83   --> $DIR/methods.rs:205:13
84    |
85 LL |     let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
86    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87    |
88    = note: replace `map(|p| format!("{}.", p)).unwrap_or(id)` with `map_or(id, |p| format!("{}.", p))`
89
90 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
91   --> $DIR/methods.rs:209:13
92    |
93 LL |       let _ = opt.map(|x| x + 1)
94    |  _____________^
95 LL | |                 // Should lint even though this call is on a separate line.
96 LL | |                .unwrap_or_else(|| 0);
97    | |____________________________________^
98    |
99    = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings`
100    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
101
102 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
103   --> $DIR/methods.rs:213:13
104    |
105 LL |       let _ = opt.map(|x| {
106    |  _____________^
107 LL | |                         x + 1
108 LL | |                     }
109 LL | |               ).unwrap_or_else(|| 0);
110    | |____________________________________^
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:217:13
114    |
115 LL |       let _ = opt.map(|x| x + 1)
116    |  _____________^
117 LL | |                .unwrap_or_else(||
118 LL | |                     0
119 LL | |                 );
120    | |_________________^
121
122 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
123   --> $DIR/methods.rs:247:13
124    |
125 LL |     let _ = v.iter().filter(|&x| *x < 0).next();
126    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127    |
128    = note: `-D clippy::filter-next` implied by `-D warnings`
129    = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)`
130
131 error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead.
132   --> $DIR/methods.rs:250:13
133    |
134 LL |       let _ = v.iter().filter(|&x| {
135    |  _____________^
136 LL | |                                 *x < 0
137 LL | |                             }
138 LL | |                    ).next();
139    | |___________________________^
140
141 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
142   --> $DIR/methods.rs:267:13
143    |
144 LL |     let _ = v.iter().find(|&x| *x < 0).is_some();
145    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| *x < 0)`
146    |
147    = note: `-D clippy::search-is-some` implied by `-D warnings`
148
149 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
150   --> $DIR/methods.rs:268:13
151    |
152 LL |     let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less
153    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| **y == x)`
154
155 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
156   --> $DIR/methods.rs:269:13
157    |
158 LL |     let _ = (0..1).find(|x| *x == 0).is_some();
159    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|x| x == 0)`
160
161 error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`.
162   --> $DIR/methods.rs:272:13
163    |
164 LL |       let _ = v.iter().find(|&x| {
165    |  _____________^
166 LL | |                               *x < 0
167 LL | |                           }
168 LL | |                    ).is_some();
169    | |______________________________^
170
171 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
172   --> $DIR/methods.rs:278:13
173    |
174 LL |     let _ = v.iter().position(|&x| x < 0).is_some();
175    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
176
177 error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`.
178   --> $DIR/methods.rs:281:13
179    |
180 LL |       let _ = v.iter().position(|&x| {
181    |  _____________^
182 LL | |                                   x < 0
183 LL | |                               }
184 LL | |                    ).is_some();
185    | |______________________________^
186
187 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
188   --> $DIR/methods.rs:287:13
189    |
190 LL |     let _ = v.iter().rposition(|&x| x < 0).is_some();
191    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `any(|&x| x < 0)`
192
193 error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`.
194   --> $DIR/methods.rs:290:13
195    |
196 LL |       let _ = v.iter().rposition(|&x| {
197    |  _____________^
198 LL | |                                    x < 0
199 LL | |                                }
200 LL | |                    ).is_some();
201    | |______________________________^
202
203 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
204   --> $DIR/methods.rs:305:13
205    |
206 LL |     let _ = opt.unwrap();
207    |             ^^^^^^^^^^^^
208    |
209    = note: `-D clippy::option-unwrap-used` implied by `-D warnings`
210
211 error: aborting due to 23 previous errors
212