Skip to content

Commit

Permalink
restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
lengyijun committed Sep 11, 2021
1 parent c81cd9a commit adceb5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
14 changes: 7 additions & 7 deletions clippy_lints/src/same_name_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SymbolStr, Span>,
trait_methods: BTreeMap<SymbolStr, Vec<Span>>,
}

impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, krate: &'tcx Crate<'tcx>) {
let mut mp = FxHashMap::<Res, S>::default();
let mut map = FxHashMap::<Res, ExistingName>::default();

for item in krate.items() {
if let ItemKind::Impl(Impl {
Expand All @@ -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) => {
Expand Down

0 comments on commit adceb5f

Please sign in to comment.