Skip to content

Commit c1d2d88

Browse files
committed
Rename to ambiguous_method_names
1 parent b66bb7f commit c1d2d88

File tree

7 files changed

+64
-90
lines changed

7 files changed

+64
-90
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4776,7 +4776,7 @@ Released 2018-09-13
47764776
[`almost_complete_letter_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_letter_range
47774777
[`almost_complete_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range
47784778
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
4779-
[`ambiguous_method_calls`]: https://rust-lang.github.io/rust-clippy/master/index.html#ambiguous_method_calls
4779+
[`ambiguous_method_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#ambiguous_method_names
47804780
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
47814781
[`arc_with_non_send_sync`]: https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
47824782
[`arithmetic_side_effects`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects

clippy_lints/src/ambiguous_method_calls.rs renamed to clippy_lints/src/ambiguous_method_names.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ declare_clippy_lint! {
6767
/// Base.ambiguous(); // prints "trait impl"
6868
/// ```
6969
#[clippy::version = "1.74.0"]
70-
pub AMBIGUOUS_METHOD_CALLS,
70+
pub AMBIGUOUS_METHOD_NAMES,
7171
pedantic,
7272
"declarations and calls for same-named methods in struct impls and trait impls"
7373
}
7474

7575
#[derive(Clone)]
76-
pub struct AmbiguousMethodCalls<'tcx> {
76+
pub struct AmbiguousMethodNames<'tcx> {
7777
trait_methods: FxHashMap<(Ty<'tcx>, Symbol), Span>,
7878
inherent_methods: Vec<(Ty<'tcx>, Symbol, Span)>,
7979
}
8080

81-
impl<'tcx> AmbiguousMethodCalls<'tcx> {
81+
impl<'tcx> AmbiguousMethodNames<'tcx> {
8282
pub fn new() -> Self {
8383
Self {
8484
trait_methods: FxHashMap::default(),
@@ -95,9 +95,9 @@ impl<'tcx> AmbiguousMethodCalls<'tcx> {
9595
}
9696
}
9797

98-
impl_lint_pass!(AmbiguousMethodCalls<'_> => [AMBIGUOUS_METHOD_CALLS]);
98+
impl_lint_pass!(AmbiguousMethodNames<'_> => [AMBIGUOUS_METHOD_NAMES]);
9999

100-
impl<'tcx> LateLintPass<'tcx> for AmbiguousMethodCalls<'tcx> {
100+
impl<'tcx> LateLintPass<'tcx> for AmbiguousMethodNames<'tcx> {
101101
fn check_fn(
102102
&mut self,
103103
cx: &LateContext<'tcx>,
@@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for AmbiguousMethodCalls<'tcx> {
130130
if let Some(tm_span) = self.trait_methods.get(k) {
131131
span_lint_and_note(
132132
cx,
133-
AMBIGUOUS_METHOD_CALLS,
133+
AMBIGUOUS_METHOD_NAMES,
134134
*span,
135135
"ambiguous inherent method name",
136136
Some(*tm_span),

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
4040
crate::absolute_paths::ABSOLUTE_PATHS_INFO,
4141
crate::allow_attributes::ALLOW_ATTRIBUTES_INFO,
4242
crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO,
43-
crate::ambiguous_method_calls::AMBIGUOUS_METHOD_CALLS_INFO,
43+
crate::ambiguous_method_names::AMBIGUOUS_METHOD_NAMES_INFO,
4444
crate::approx_const::APPROX_CONSTANT_INFO,
4545
crate::arc_with_non_send_sync::ARC_WITH_NON_SEND_SYNC_INFO,
4646
crate::as_conversions::AS_CONVERSIONS_INFO,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mod renamed_lints;
6868
mod absolute_paths;
6969
mod allow_attributes;
7070
mod almost_complete_range;
71-
mod ambiguous_method_calls;
71+
mod ambiguous_method_names;
7272
mod approx_const;
7373
mod arc_with_non_send_sync;
7474
mod as_conversions;
@@ -1118,7 +1118,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11181118
msrv(),
11191119
))
11201120
});
1121-
store.register_late_pass(|_| Box::new(ambiguous_method_calls::AmbiguousMethodCalls::new()));
1121+
store.register_late_pass(|_| Box::new(ambiguous_method_names::AmbiguousMethodNames::new()));
11221122
// add lints here, do not remove this comment, it's used in `new_lint`
11231123
}
11241124

tests/ui/ambiguous_method_calls.stderr

Lines changed: 0 additions & 79 deletions
This file was deleted.

tests/ui/ambiguous_method_calls.rs renamed to tests/ui/ambiguous_method_names.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(dead_code)]
2-
#![warn(clippy::ambiguous_method_calls)]
2+
#![warn(clippy::ambiguous_method_names)]
33

44
fn main() {
55
Base.ambiguous();
@@ -14,6 +14,9 @@ fn main() {
1414
Base.another();
1515

1616
ambiguous();
17+
18+
S::<u64>(42).f();
19+
S::<i32>(-42).f();
1720
}
1821

1922
fn ambiguous() {}
@@ -66,3 +69,13 @@ impl MyTrait for Other {
6669
println!("not actually ambiguous either")
6770
}
6871
}
72+
73+
struct S<T>(T);
74+
75+
impl S<i32> {
76+
fn f(&self) {}
77+
}
78+
79+
impl S<u64> {
80+
fn f(&self) {}
81+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error: ambiguous inherent method name
2+
--> $DIR/ambiguous_method_names.rs:36:8
3+
|
4+
LL | fn ambiguous(&self) {
5+
| ^^^^^^^^^
6+
|
7+
note: trait method defined here
8+
--> $DIR/ambiguous_method_names.rs:50:8
9+
|
10+
LL | fn ambiguous(&self) {
11+
| ^^^^^^^^^
12+
= note: `-D clippy::ambiguous-method-names` implied by `-D warnings`
13+
= help: to override `-D warnings` add `#[allow(clippy::ambiguous_method_names)]`
14+
15+
error: ambiguous inherent method name
16+
--> $DIR/ambiguous_method_names.rs:40:8
17+
|
18+
LL | fn also_ambiguous(&self) {}
19+
| ^^^^^^^^^^^^^^
20+
|
21+
note: trait method defined here
22+
--> $DIR/ambiguous_method_names.rs:54:8
23+
|
24+
LL | fn also_ambiguous(&self) {}
25+
| ^^^^^^^^^^^^^^
26+
27+
error: ambiguous inherent method name
28+
--> $DIR/ambiguous_method_names.rs:46:8
29+
|
30+
LL | fn another(&self) {}
31+
| ^^^^^^^
32+
|
33+
note: trait method defined here
34+
--> $DIR/ambiguous_method_names.rs:58:8
35+
|
36+
LL | fn another(&self) {}
37+
| ^^^^^^^
38+
39+
error: aborting due to 3 previous errors
40+

0 commit comments

Comments
 (0)