Skip to content

Commit 3d3c966

Browse files
committed
Remove rustc_hir_id crate.
`rustc_hir_id` is a very small crate containing some basic HIR types (e.g. `HirId`) so that other crates can use them without depending on `rustc_hir` (which is a much bigger crate). However, `rustc_span` already has a module called `def_id` which also contains some basic HIR types (e.g. `DefId`). So there's not much point also have `rustc_hir_id`. This commit moves the contents of `rustc_hir_id` into that module.
1 parent 46db830 commit 3d3c966

36 files changed

Lines changed: 214 additions & 269 deletions

Cargo.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,6 @@ dependencies = [
39563956
"rustc_error_messages",
39573957
"rustc_errors",
39583958
"rustc_hashes",
3959-
"rustc_hir_id",
39603959
"rustc_index",
39613960
"rustc_lint_defs",
39623961
"rustc_macros",
@@ -3993,17 +3992,6 @@ dependencies = [
39933992
"tracing",
39943993
]
39953994

3996-
[[package]]
3997-
name = "rustc_hir_id"
3998-
version = "0.0.0"
3999-
dependencies = [
4000-
"rustc_data_structures",
4001-
"rustc_index",
4002-
"rustc_macros",
4003-
"rustc_serialize",
4004-
"rustc_span",
4005-
]
4006-
40073995
[[package]]
40083996
name = "rustc_hir_pretty"
40093997
version = "0.0.0"
@@ -4186,7 +4174,6 @@ version = "0.0.0"
41864174
dependencies = [
41874175
"rustc_data_structures",
41884176
"rustc_error_messages",
4189-
"rustc_hir_id",
41904177
"rustc_macros",
41914178
"rustc_serialize",
41924179
"rustc_span",

compiler/rustc_hir/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
1515
rustc_error_messages = { path = "../rustc_error_messages" }
1616
rustc_errors = { path = "../rustc_errors" }
1717
rustc_hashes = { path = "../rustc_hashes" }
18-
rustc_hir_id = { path = "../rustc_hir_id" }
1918
rustc_index = { path = "../rustc_index" }
2019
rustc_lint_defs = { path = "../rustc_lint_defs" }
2120
rustc_macros = { path = "../rustc_macros" }

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl DefKind {
512512
/// pointing to the definition of `str_to_string` in the current crate.
513513
//
514514
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
515-
pub enum Res<Id = hir::HirId> {
515+
pub enum Res<Id = crate::def_id::HirId> {
516516
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
517517
///
518518
/// **Not bound to a specific namespace.**

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ use tracing::debug;
3333

3434
use crate::attrs::AttributeKind;
3535
use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
36-
use crate::def_id::{DefId, LocalDefIdMap};
37-
pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
36+
use crate::def_id::{DefId, HirId, ItemLocalId, ItemLocalMap, LocalDefIdMap, OwnerId};
3837
use crate::intravisit::{FnKind, VisitorExt};
3938
use crate::lints::DelayedLints;
4039

@@ -4911,7 +4910,7 @@ impl<'hir> OwnerNode<'hir> {
49114910
| OwnerNode::TraitItem(TraitItem { owner_id, .. })
49124911
| OwnerNode::ImplItem(ImplItem { owner_id, .. })
49134912
| OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4914-
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4913+
OwnerNode::Crate(..) => crate::def_id::CRATE_HIR_ID.owner,
49154914
OwnerNode::Synthetic => unreachable!(),
49164915
}
49174916
}

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use rustc_ast::visit::{VisitorResult, try_visit, visit_opt, walk_list};
6969
use rustc_span::def_id::LocalDefId;
7070
use rustc_span::{Ident, Span, Symbol};
7171

72+
use crate::def_id::HirId;
7273
use crate::hir::*;
7374

7475
pub trait IntoVisitor<'hir> {

compiler/rustc_hir/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ pub mod def_path_hash_map;
2323
pub mod definitions;
2424
pub mod diagnostic_items;
2525
pub use rustc_span::def_id;
26+
pub use rustc_span::def_id::{
27+
CRATE_HIR_ID, CRATE_OWNER_ID, HirId, HirIdMap, HirIdMapEntry, HirIdSet, ItemLocalId,
28+
ItemLocalMap, ItemLocalMapEntry, ItemLocalSet, OwnerId,
29+
};
2630
mod hir;
27-
pub use rustc_hir_id::{self as hir_id, *};
2831
pub mod intravisit;
2932
pub mod lang_items;
3033
pub mod limit;

compiler/rustc_hir/src/pat_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::iter::Enumerate;
33
use rustc_span::{Ident, Span};
44

55
use crate::def::{CtorOf, DefKind, Res};
6-
use crate::def_id::{DefId, DefIdSet};
7-
use crate::hir::{self, BindingMode, ByRef, HirId, PatKind};
6+
use crate::def_id::{DefId, DefIdSet, HirId};
7+
use crate::hir::{self, BindingMode, ByRef, PatKind};
88

99
pub struct EnumerateAndAdjust<I> {
1010
enumerate: Enumerate<I>,

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
22
use rustc_span::HashStableContext;
3-
use rustc_span::def_id::DefPathHash;
3+
use rustc_span::def_id::{DefPathHash, ItemLocalId};
44

55
use crate::HashIgnoredAttrId;
66
use crate::hir::{
77
AttributeMap, BodyId, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
88
};
9-
use crate::hir_id::ItemLocalId;
109

1110
impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for BodyId {
1211
type KeyType = (DefPathHash, ItemLocalId);

compiler/rustc_hir_id/Cargo.toml

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

compiler/rustc_hir_id/src/lib.rs

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

0 commit comments

Comments
 (0)