Skip to content

Commit 2249168

Browse files
committed
Refactor HIR item-like traversal (part 1)
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel Signed-off-by: Miguel Guarniz <[email protected]>
1 parent bb5b250 commit 2249168

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

clippy_lints/src/same_name_method.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
5050
fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
5151
let mut map = FxHashMap::<Res, ExistingName>::default();
5252

53-
for item in cx.tcx.hir().items() {
53+
for id in cx.tcx.hir().items() {
54+
let item = cx.tcx.hir().item(id);
5455
if let ItemKind::Impl(Impl {
5556
items,
5657
of_trait,

tests/ui/same_name_method.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ note: existing `foo` defined here
1111
LL | fn foo() {}
1212
| ^^^^^^^^^^^
1313

14+
error: method's name is the same as an existing method in a trait
15+
--> $DIR/same_name_method.rs:34:13
16+
|
17+
LL | fn clone() {}
18+
| ^^^^^^^^^^^^^
19+
|
20+
note: existing `clone` defined here
21+
--> $DIR/same_name_method.rs:30:18
22+
|
23+
LL | #[derive(Clone)]
24+
| ^^^^^
25+
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
26+
1427
error: method's name is the same as an existing method in a trait
1528
--> $DIR/same_name_method.rs:44:13
1629
|
@@ -47,18 +60,5 @@ note: existing `foo` defined here
4760
LL | impl T1 for S {}
4861
| ^^^^^^^^^^^^^^^^
4962

50-
error: method's name is the same as an existing method in a trait
51-
--> $DIR/same_name_method.rs:34:13
52-
|
53-
LL | fn clone() {}
54-
| ^^^^^^^^^^^^^
55-
|
56-
note: existing `clone` defined here
57-
--> $DIR/same_name_method.rs:30:18
58-
|
59-
LL | #[derive(Clone)]
60-
| ^^^^^
61-
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
62-
6363
error: aborting due to 5 previous errors
6464

0 commit comments

Comments
 (0)