diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 40df82ef7b7c..60e48728dc1a 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1055,6 +1055,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(panic_unimplemented::UNIMPLEMENTED), LintId::of(panic_unimplemented::UNREACHABLE), LintId::of(pattern_type_mismatch::PATTERN_TYPE_MISMATCH), + LintId::of(same_name_method::SAME_NAME_METHOD), LintId::of(shadow::SHADOW_REUSE), LintId::of(shadow::SHADOW_SAME), LintId::of(strings::STRING_ADD), @@ -1146,7 +1147,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(ranges::RANGE_PLUS_ONE), LintId::of(redundant_else::REDUNDANT_ELSE), LintId::of(ref_option_ref::REF_OPTION_REF), - LintId::of(same_name_method::SAME_NAME_METHOD), LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED), LintId::of(shadow::SHADOW_UNRELATED), LintId::of(strings::STRING_ADD_ASSIGN), diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 530d4c3afc8e..68e8dfafef04 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -34,20 +34,20 @@ declare_clippy_lint! { /// } /// ``` pub SAME_NAME_METHOD, - pedantic, + restriction, "two method with same name" } declare_lint_pass!(SameNameMethod => [SAME_NAME_METHOD]); -struct S { +struct ExistingName { impl_methods: BTreeMap, trait_methods: BTreeMap>, } impl<'tcx> LateLintPass<'tcx> for SameNameMethod { fn check_crate_post(&mut self, cx: &LateContext<'tcx>, krate: &'tcx Crate<'tcx>) { - let mut mp = FxHashMap::::default(); + let mut map = FxHashMap::::default(); for item in krate.items() { if let ItemKind::Impl(Impl { @@ -58,16 +58,16 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { }) = &item.kind { if let TyKind::Path(QPath::Resolved(_, Path { res, .. })) = self_ty.kind { - if !mp.contains_key(res) { - mp.insert( + if !map.contains_key(res) { + map.insert( *res, - S { + ExistingName { impl_methods: BTreeMap::new(), trait_methods: BTreeMap::new(), }, ); } - let s = mp.get_mut(res).unwrap(); + let s = map.get_mut(res).unwrap(); match of_trait { Some(trait_ref) => {