Remove unused code from rustc_hir
This commit is contained in:
parent
feaac592a3
commit
6897619d6d
@ -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,
|
||||
|
@ -3,7 +3,6 @@
|
||||
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};
|
||||
@ -306,10 +305,6 @@ pub const fn none() -> Self {
|
||||
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 {
|
||||
@ -467,23 +462,6 @@ pub const fn empty() -> 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 {
|
||||
@ -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.
|
||||
@ -2766,32 +2742,4 @@ pub fn generics(&self) -> Option<&'hir Generics<'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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,5 +45,3 @@ pub struct ItemLocalId { .. }
|
||||
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
|
||||
local_id: ItemLocalId::from_u32(0),
|
||||
};
|
||||
|
||||
pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
|
||||
|
@ -58,25 +58,6 @@ fn enumerate_and_adjust(
|
||||
}
|
||||
|
||||
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)) {
|
||||
@ -117,15 +98,6 @@ pub fn contains_bindings(&self) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user