Description
Right now, our lowering code uses string-paths to call e.g. Iterator::next
when lowering for
loops:
rust/src/librustc/hir/lowering.rs
Lines 4653 to 4655 in c6ac575
This triggers a name resolution call
rust/src/librustc/hir/lowering.rs
Lines 5263 to 5273 in c6ac575
which will then give us a resolved path, but that's
- potentially expensive, since it happens every time a specific path is generated (which happens a lot for
?
andfor
expansions/lowerings) - seems uncool since it's stringly typed
I think it would be neat if we could instead create the lang_items
table early in the process and just grab the appropriate item out of that table.
cc @Centril @eddyb @petrochenkov
As a first experiment to check out the impact we could create a cache for path resolutions so we only run the path resolution code once and just overwrite all HirId
s in the generated path with new HirId
s whenever we fetch a cached resolution.