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 <mi9uel9@gmail.com>
This commit is contained in:
parent
bb5b250fa1
commit
224916823a
@ -50,7 +50,8 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
|
||||
fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
|
||||
let mut map = FxHashMap::<Res, ExistingName>::default();
|
||||
|
||||
for item in cx.tcx.hir().items() {
|
||||
for id in cx.tcx.hir().items() {
|
||||
let item = cx.tcx.hir().item(id);
|
||||
if let ItemKind::Impl(Impl {
|
||||
items,
|
||||
of_trait,
|
||||
|
@ -11,6 +11,19 @@ note: existing `foo` defined here
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:34:13
|
||||
|
|
||||
LL | fn clone() {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: existing `clone` defined here
|
||||
--> $DIR/same_name_method.rs:30:18
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^
|
||||
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:44:13
|
||||
|
|
||||
@ -47,18 +60,5 @@ note: existing `foo` defined here
|
||||
LL | impl T1 for S {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:34:13
|
||||
|
|
||||
LL | fn clone() {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: existing `clone` defined here
|
||||
--> $DIR/same_name_method.rs:30:18
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^
|
||||
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user