Skip to content

Commit

Permalink
Remove unused code from rustc_hir
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Oct 14, 2020
1 parent feaac59 commit 6897619
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 86 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_hir/src/definitions.rs
Expand Up @@ -188,10 +188,6 @@ pub struct DefPath {
}

impl DefPath {
pub fn is_local(&self) -> bool {
self.krate == LOCAL_CRATE
}

pub fn make<FN>(krate: CrateNum, start_index: DefIndex, mut get_key: FN) -> DefPath
where
FN: FnMut(DefIndex) -> DefKey,
Expand Down
52 changes: 0 additions & 52 deletions compiler/rustc_hir/src/hir.rs
Expand Up @@ -3,7 +3,6 @@ use crate::def_id::DefId;
crate use crate::hir_id::HirId;
use crate::{itemlikevisit, LangItem};

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

pub fn is_empty(&self) -> bool {
self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
}

pub fn inputs(&self) -> &[Ty<'_>] {
if self.parenthesized {
for arg in self.args {
Expand Down Expand Up @@ -467,23 +462,6 @@ impl Generics<'hir> {
}
}

pub fn own_counts(&self) -> GenericParamCount {
// We could cache this as a property of `GenericParamCount`, but
// the aim is to refactor this away entirely eventually and the
// presence of this method will be a constant reminder.
let mut own_counts: GenericParamCount = Default::default();

for param in self.params {
match param.kind {
GenericParamKind::Lifetime { .. } => own_counts.lifetimes += 1,
GenericParamKind::Type { .. } => own_counts.types += 1,
GenericParamKind::Const { .. } => own_counts.consts += 1,
};
}

own_counts
}

pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'_>> {
for param in self.params {
if name == param.name.ident().name {
Expand Down Expand Up @@ -2679,8 +2657,6 @@ pub struct Upvar {
pub span: Span,
}

pub type CaptureModeMap = NodeMap<CaptureBy>;

// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
// has length > 0 if the trait is found through an chain of imports, starting with the
// import/use statement in the scope where the trait is used.
Expand Down Expand Up @@ -2766,32 +2742,4 @@ impl<'hir> Node<'hir> {
_ => None,
}
}

pub fn hir_id(&self) -> Option<HirId> {
match self {
Node::Item(Item { hir_id, .. })
| Node::ForeignItem(ForeignItem { hir_id, .. })
| Node::TraitItem(TraitItem { hir_id, .. })
| Node::ImplItem(ImplItem { hir_id, .. })
| Node::Field(StructField { hir_id, .. })
| Node::AnonConst(AnonConst { hir_id, .. })
| Node::Expr(Expr { hir_id, .. })
| Node::Stmt(Stmt { hir_id, .. })
| Node::Ty(Ty { hir_id, .. })
| Node::Binding(Pat { hir_id, .. })
| Node::Pat(Pat { hir_id, .. })
| Node::Arm(Arm { hir_id, .. })
| Node::Block(Block { hir_id, .. })
| Node::Local(Local { hir_id, .. })
| Node::MacroDef(MacroDef { hir_id, .. })
| Node::Lifetime(Lifetime { hir_id, .. })
| Node::Param(Param { hir_id, .. })
| Node::GenericParam(GenericParam { hir_id, .. }) => Some(*hir_id),
Node::TraitRef(TraitRef { hir_ref_id, .. }) => Some(*hir_ref_id),
Node::PathSegment(PathSegment { hir_id, .. }) => *hir_id,
Node::Variant(Variant { id, .. }) => Some(*id),
Node::Ctor(variant) => variant.ctor_hir_id(),
Node::Crate(_) | Node::Visibility(_) => None,
}
}
}
2 changes: 0 additions & 2 deletions compiler/rustc_hir/src/hir_id.rs
Expand Up @@ -45,5 +45,3 @@ pub const CRATE_HIR_ID: HirId = HirId {
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
local_id: ItemLocalId::from_u32(0),
};

pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
28 changes: 0 additions & 28 deletions compiler/rustc_hir/src/pat_util.rs
Expand Up @@ -58,25 +58,6 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
}

impl hir::Pat<'_> {
pub fn is_refutable(&self) -> bool {
match self.kind {
PatKind::Lit(_)
| PatKind::Range(..)
| PatKind::Path(hir::QPath::Resolved(Some(..), _) | hir::QPath::TypeRelative(..)) => {
true
}

PatKind::Path(hir::QPath::Resolved(_, ref path))
| PatKind::TupleStruct(hir::QPath::Resolved(_, ref path), ..)
| PatKind::Struct(hir::QPath::Resolved(_, ref path), ..) => match path.res {
Res::Def(DefKind::Variant, _) => true,
_ => false,
},
PatKind::Slice(..) => true,
_ => false,
}
}

/// Call `f` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) {
Expand Down Expand Up @@ -117,15 +98,6 @@ impl hir::Pat<'_> {
})
}

/// Checks if the pattern contains any patterns that bind something to
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
pub fn contains_bindings_or_wild(&self) -> bool {
self.satisfies(|p| match p.kind {
PatKind::Binding(..) | PatKind::Wild => true,
_ => false,
})
}

/// Checks if the pattern satisfies the given predicate on some sub-pattern.
fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
let mut satisfies = false;
Expand Down

0 comments on commit 6897619

Please sign in to comment.