Skip to content

Commit 6897619

Browse files
committed
Remove unused code from rustc_hir
1 parent feaac59 commit 6897619

File tree

4 files changed

+0
-86
lines changed

4 files changed

+0
-86
lines changed

compiler/rustc_hir/src/definitions.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ pub struct DefPath {
188188
}
189189

190190
impl DefPath {
191-
pub fn is_local(&self) -> bool {
192-
self.krate == LOCAL_CRATE
193-
}
194-
195191
pub fn make<FN>(krate: CrateNum, start_index: DefIndex, mut get_key: FN) -> DefPath
196192
where
197193
FN: FnMut(DefIndex) -> DefKey,

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::def_id::DefId;
33
crate use crate::hir_id::HirId;
44
use crate::{itemlikevisit, LangItem};
55

6-
use rustc_ast::node_id::NodeMap;
76
use rustc_ast::util::parser::ExprPrecedence;
87
use rustc_ast::{self as ast, CrateSugar, LlvmAsmDialect};
98
use rustc_ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy};
@@ -306,10 +305,6 @@ impl GenericArgs<'_> {
306305
Self { args: &[], bindings: &[], parenthesized: false }
307306
}
308307

309-
pub fn is_empty(&self) -> bool {
310-
self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
311-
}
312-
313308
pub fn inputs(&self) -> &[Ty<'_>] {
314309
if self.parenthesized {
315310
for arg in self.args {
@@ -467,23 +462,6 @@ impl Generics<'hir> {
467462
}
468463
}
469464

470-
pub fn own_counts(&self) -> GenericParamCount {
471-
// We could cache this as a property of `GenericParamCount`, but
472-
// the aim is to refactor this away entirely eventually and the
473-
// presence of this method will be a constant reminder.
474-
let mut own_counts: GenericParamCount = Default::default();
475-
476-
for param in self.params {
477-
match param.kind {
478-
GenericParamKind::Lifetime { .. } => own_counts.lifetimes += 1,
479-
GenericParamKind::Type { .. } => own_counts.types += 1,
480-
GenericParamKind::Const { .. } => own_counts.consts += 1,
481-
};
482-
}
483-
484-
own_counts
485-
}
486-
487465
pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'_>> {
488466
for param in self.params {
489467
if name == param.name.ident().name {
@@ -2679,8 +2657,6 @@ pub struct Upvar {
26792657
pub span: Span,
26802658
}
26812659

2682-
pub type CaptureModeMap = NodeMap<CaptureBy>;
2683-
26842660
// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
26852661
// has length > 0 if the trait is found through an chain of imports, starting with the
26862662
// import/use statement in the scope where the trait is used.
@@ -2766,32 +2742,4 @@ impl<'hir> Node<'hir> {
27662742
_ => None,
27672743
}
27682744
}
2769-
2770-
pub fn hir_id(&self) -> Option<HirId> {
2771-
match self {
2772-
Node::Item(Item { hir_id, .. })
2773-
| Node::ForeignItem(ForeignItem { hir_id, .. })
2774-
| Node::TraitItem(TraitItem { hir_id, .. })
2775-
| Node::ImplItem(ImplItem { hir_id, .. })
2776-
| Node::Field(StructField { hir_id, .. })
2777-
| Node::AnonConst(AnonConst { hir_id, .. })
2778-
| Node::Expr(Expr { hir_id, .. })
2779-
| Node::Stmt(Stmt { hir_id, .. })
2780-
| Node::Ty(Ty { hir_id, .. })
2781-
| Node::Binding(Pat { hir_id, .. })
2782-
| Node::Pat(Pat { hir_id, .. })
2783-
| Node::Arm(Arm { hir_id, .. })
2784-
| Node::Block(Block { hir_id, .. })
2785-
| Node::Local(Local { hir_id, .. })
2786-
| Node::MacroDef(MacroDef { hir_id, .. })
2787-
| Node::Lifetime(Lifetime { hir_id, .. })
2788-
| Node::Param(Param { hir_id, .. })
2789-
| Node::GenericParam(GenericParam { hir_id, .. }) => Some(*hir_id),
2790-
Node::TraitRef(TraitRef { hir_ref_id, .. }) => Some(*hir_ref_id),
2791-
Node::PathSegment(PathSegment { hir_id, .. }) => *hir_id,
2792-
Node::Variant(Variant { id, .. }) => Some(*id),
2793-
Node::Ctor(variant) => variant.ctor_hir_id(),
2794-
Node::Crate(_) | Node::Visibility(_) => None,
2795-
}
2796-
}
27972745
}

compiler/rustc_hir/src/hir_id.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,3 @@ pub const CRATE_HIR_ID: HirId = HirId {
4545
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
4646
local_id: ItemLocalId::from_u32(0),
4747
};
48-
49-
pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;

compiler/rustc_hir/src/pat_util.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,6 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
5858
}
5959

6060
impl hir::Pat<'_> {
61-
pub fn is_refutable(&self) -> bool {
62-
match self.kind {
63-
PatKind::Lit(_)
64-
| PatKind::Range(..)
65-
| PatKind::Path(hir::QPath::Resolved(Some(..), _) | hir::QPath::TypeRelative(..)) => {
66-
true
67-
}
68-
69-
PatKind::Path(hir::QPath::Resolved(_, ref path))
70-
| PatKind::TupleStruct(hir::QPath::Resolved(_, ref path), ..)
71-
| PatKind::Struct(hir::QPath::Resolved(_, ref path), ..) => match path.res {
72-
Res::Def(DefKind::Variant, _) => true,
73-
_ => false,
74-
},
75-
PatKind::Slice(..) => true,
76-
_ => false,
77-
}
78-
}
79-
8061
/// Call `f` on every "binding" in a pattern, e.g., on `a` in
8162
/// `match foo() { Some(a) => (), None => () }`
8263
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) {
@@ -117,15 +98,6 @@ impl hir::Pat<'_> {
11798
})
11899
}
119100

120-
/// Checks if the pattern contains any patterns that bind something to
121-
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
122-
pub fn contains_bindings_or_wild(&self) -> bool {
123-
self.satisfies(|p| match p.kind {
124-
PatKind::Binding(..) | PatKind::Wild => true,
125-
_ => false,
126-
})
127-
}
128-
129101
/// Checks if the pattern satisfies the given predicate on some sub-pattern.
130102
fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
131103
let mut satisfies = false;

0 commit comments

Comments
 (0)