]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #40518 - michaelwoerister:hir-id, r=eddyb
authorCorey Farwell <coreyf@rwell.org>
Thu, 23 Mar 2017 03:37:59 +0000 (23:37 -0400)
committerGitHub <noreply@github.com>
Thu, 23 Mar 2017 03:37:59 +0000 (23:37 -0400)
Introduce HirId, a replacement for ast::NodeId after lowering to HIR

This is the first step towards implementing #40303. This PR introduces the `HirId` type and generates a `HirId` for everything that would be assigned one (i.e. stuff in the HIR), but the HIR data types still use `NodeId` for now. Changing that is a big refactoring that I want to do in a separate PR.

A `HirId` uniquely identifies a node in the HIR of the current crate. It is composed of the `owner`, which is the `DefIndex` of the directly enclosing `hir::Item`, `hir::TraitItem`, or `hir::ImplItem` (i.e. the closest "item-like"), and the `local_id` which is unique within the given owner.

This PR is also running a number of consistency checks for the generated `HirId`s:
- Does `NodeId` in the HIR have a corresponding `HirId`?
- Is the `owner` part of each `HirId` consistent with its position in the HIR?
- Do the numerical values of the `local_id` part all lie within a dense range of integers?

cc @rust-lang/compiler

r? @eddyb or @nikomatsakis


Trivial merge