mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Document missname_getters
This commit is contained in:
parent
81d4590834
commit
5fa0e07cdf
@ -177,6 +177,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
|
|||||||
crate::from_raw_with_void_ptr::FROM_RAW_WITH_VOID_PTR_INFO,
|
crate::from_raw_with_void_ptr::FROM_RAW_WITH_VOID_PTR_INFO,
|
||||||
crate::from_str_radix_10::FROM_STR_RADIX_10_INFO,
|
crate::from_str_radix_10::FROM_STR_RADIX_10_INFO,
|
||||||
crate::functions::DOUBLE_MUST_USE_INFO,
|
crate::functions::DOUBLE_MUST_USE_INFO,
|
||||||
|
crate::functions::MISSNAMED_GETTERS_INFO,
|
||||||
crate::functions::MUST_USE_CANDIDATE_INFO,
|
crate::functions::MUST_USE_CANDIDATE_INFO,
|
||||||
crate::functions::MUST_USE_UNIT_INFO,
|
crate::functions::MUST_USE_UNIT_INFO,
|
||||||
crate::functions::NOT_UNSAFE_PTR_ARG_DEREF_INFO,
|
crate::functions::NOT_UNSAFE_PTR_ARG_DEREF_INFO,
|
||||||
@ -184,7 +185,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
|
|||||||
crate::functions::RESULT_UNIT_ERR_INFO,
|
crate::functions::RESULT_UNIT_ERR_INFO,
|
||||||
crate::functions::TOO_MANY_ARGUMENTS_INFO,
|
crate::functions::TOO_MANY_ARGUMENTS_INFO,
|
||||||
crate::functions::TOO_MANY_LINES_INFO,
|
crate::functions::TOO_MANY_LINES_INFO,
|
||||||
crate::functions::MISSNAMED_GETTERS_INFO,
|
|
||||||
crate::future_not_send::FUTURE_NOT_SEND_INFO,
|
crate::future_not_send::FUTURE_NOT_SEND_INFO,
|
||||||
crate::if_let_mutex::IF_LET_MUTEX_INFO,
|
crate::if_let_mutex::IF_LET_MUTEX_INFO,
|
||||||
crate::if_not_else::IF_NOT_ELSE_INFO,
|
crate::if_not_else::IF_NOT_ELSE_INFO,
|
||||||
|
@ -263,21 +263,38 @@ declare_clippy_lint! {
|
|||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
/// Checks for getter methods that return a field that doesn't correspond
|
||||||
|
/// to the name of the method, when there is a field's whose name matches that of the method.
|
||||||
///
|
///
|
||||||
/// ### Why is this bad?
|
/// ### Why is this bad?
|
||||||
|
/// It is most likely that such a method is a bug caused by a typo or by copy-pasting.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// struct A {
|
||||||
|
/// a: String,
|
||||||
|
/// b: String,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl A {
|
||||||
|
/// fn a(&self) -> &str{
|
||||||
|
/// self.b
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// // example code where clippy issues a warning
|
/// // example code where clippy issues a warning
|
||||||
/// ```
|
/// ```
|
||||||
/// Use instead:
|
/// Use instead:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// // example code which does not raise clippy warning
|
/// impl A {
|
||||||
|
/// fn a(&self) -> &str{
|
||||||
|
/// self.a
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[clippy::version = "1.66.0"]
|
#[clippy::version = "1.66.0"]
|
||||||
pub MISSNAMED_GETTERS,
|
pub MISSNAMED_GETTERS,
|
||||||
suspicious,
|
suspicious,
|
||||||
"default lint description"
|
"getter method returning the wrong field"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
Loading…
Reference in New Issue
Block a user