File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -177,14 +177,14 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
177
177
crate :: from_raw_with_void_ptr:: FROM_RAW_WITH_VOID_PTR_INFO ,
178
178
crate :: from_str_radix_10:: FROM_STR_RADIX_10_INFO ,
179
179
crate :: functions:: DOUBLE_MUST_USE_INFO ,
180
+ crate :: functions:: MISSNAMED_GETTERS_INFO ,
180
181
crate :: functions:: MUST_USE_CANDIDATE_INFO ,
181
182
crate :: functions:: MUST_USE_UNIT_INFO ,
182
183
crate :: functions:: NOT_UNSAFE_PTR_ARG_DEREF_INFO ,
183
184
crate :: functions:: RESULT_LARGE_ERR_INFO ,
184
185
crate :: functions:: RESULT_UNIT_ERR_INFO ,
185
186
crate :: functions:: TOO_MANY_ARGUMENTS_INFO ,
186
187
crate :: functions:: TOO_MANY_LINES_INFO ,
187
- crate :: functions:: MISSNAMED_GETTERS_INFO ,
188
188
crate :: future_not_send:: FUTURE_NOT_SEND_INFO ,
189
189
crate :: if_let_mutex:: IF_LET_MUTEX_INFO ,
190
190
crate :: if_not_else:: IF_NOT_ELSE_INFO ,
Original file line number Diff line number Diff line change @@ -263,21 +263,38 @@ declare_clippy_lint! {
263
263
264
264
declare_clippy_lint ! {
265
265
/// ### What it does
266
+ /// Checks for getter methods that return a field that doesn't correspond
267
+ /// to the name of the method, when there is a field's whose name matches that of the method.
266
268
///
267
269
/// ### Why is this bad?
270
+ /// It is most likely that such a method is a bug caused by a typo or by copy-pasting.
268
271
///
269
272
/// ### Example
270
273
/// ```rust
274
+ /// struct A {
275
+ /// a: String,
276
+ /// b: String,
277
+ /// }
278
+ ///
279
+ /// impl A {
280
+ /// fn a(&self) -> &str{
281
+ /// self.b
282
+ /// }
283
+ /// }
271
284
/// // example code where clippy issues a warning
272
285
/// ```
273
286
/// Use instead:
274
287
/// ```rust
275
- /// // example code which does not raise clippy warning
288
+ /// impl A {
289
+ /// fn a(&self) -> &str{
290
+ /// self.a
291
+ /// }
292
+ /// }
276
293
/// ```
277
294
#[ clippy:: version = "1.66.0" ]
278
295
pub MISSNAMED_GETTERS ,
279
296
suspicious,
280
- "default lint description "
297
+ "getter method returning the wrong field "
281
298
}
282
299
283
300
#[ derive( Copy , Clone ) ]
You can’t perform that action at this time.
0 commit comments