Skip to content

Commit

Permalink
Remove some unused functions.
Browse files Browse the repository at this point in the history
And remove `pub` from some local-only ones.
  • Loading branch information
nnethercote committed Nov 21, 2023
1 parent c965a76 commit ec10e37
Showing 1 changed file with 4 additions and 54 deletions.
58 changes: 4 additions & 54 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_error_messages::MultiSpan;
use rustc_index::IndexVec;
use rustc_macros::HashStable_Generic;
use rustc_span::hygiene::MacroKind;
Expand Down Expand Up @@ -76,13 +75,6 @@ impl ParamName {
ParamName::Fresh | ParamName::Error => Ident::with_dummy_span(kw::UnderscoreLifetime),
}
}

pub fn normalize_to_macros_2_0(&self) -> ParamName {
match *self {
ParamName::Plain(ident) => ParamName::Plain(ident.normalize_to_macros_2_0()),
param_name => param_name,
}
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)]
Expand Down Expand Up @@ -116,7 +108,7 @@ pub enum LifetimeName {
}

impl LifetimeName {
pub fn is_elided(&self) -> bool {
fn is_elided(&self) -> bool {
match self {
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,

Expand Down Expand Up @@ -289,10 +281,6 @@ impl GenericArg<'_> {
}
}

pub fn is_synthetic(&self) -> bool {
matches!(self, GenericArg::Lifetime(lifetime) if lifetime.ident == Ident::empty())
}

pub fn descr(&self) -> &'static str {
match self {
GenericArg::Lifetime(_) => "lifetime",
Expand Down Expand Up @@ -368,11 +356,6 @@ impl<'hir> GenericArgs<'hir> {
panic!("GenericArgs::inputs: not a `Fn(T) -> U`");
}

#[inline]
pub fn has_type_params(&self) -> bool {
self.args.iter().any(|arg| matches!(arg, GenericArg::Type(_)))
}

pub fn has_err(&self) -> bool {
self.args.iter().any(|arg| match arg {
GenericArg::Type(ty) => matches!(ty.kind, TyKind::Err(_)),
Expand All @@ -383,11 +366,6 @@ impl<'hir> GenericArgs<'hir> {
})
}

#[inline]
pub fn num_type_params(&self) -> usize {
self.args.iter().filter(|arg| matches!(arg, GenericArg::Type(_))).count()
}

#[inline]
pub fn num_lifetime_params(&self) -> usize {
self.args.iter().filter(|arg| matches!(arg, GenericArg::Lifetime(_))).count()
Expand Down Expand Up @@ -589,14 +567,6 @@ impl<'hir> Generics<'hir> {
self.params.iter().find(|&param| name == param.name.ident().name)
}

pub fn spans(&self) -> MultiSpan {
if self.params.is_empty() {
self.span.into()
} else {
self.params.iter().map(|p| p.span).collect::<Vec<Span>>().into()
}
}

/// If there are generic parameters, return where to introduce a new one.
pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
if let Some(first) = self.params.first()
Expand Down Expand Up @@ -679,7 +649,7 @@ impl<'hir> Generics<'hir> {
)
}

pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
fn span_for_predicate_removal(&self, pos: usize) -> Span {
let predicate = &self.predicates[pos];
let span = predicate.span();

Expand Down Expand Up @@ -812,7 +782,7 @@ pub struct WhereRegionPredicate<'hir> {

impl<'hir> WhereRegionPredicate<'hir> {
/// Returns `true` if `param_def_id` matches the `lifetime` of this predicate.
pub fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
self.lifetime.res == LifetimeName::Param(param_def_id)
}
}
Expand Down Expand Up @@ -869,7 +839,7 @@ pub struct OwnerNodes<'tcx> {
}

impl<'tcx> OwnerNodes<'tcx> {
pub fn node(&self) -> OwnerNode<'tcx> {
fn node(&self) -> OwnerNode<'tcx> {
use rustc_index::Idx;
let node = self.nodes[ItemLocalId::new(0)].as_ref().unwrap().node;
let node = node.as_owner().unwrap(); // Indexing must ensure it is an OwnerNode.
Expand Down Expand Up @@ -1272,10 +1242,6 @@ impl BinOpKind {
matches!(self, BinOpKind::And | BinOpKind::Or)
}

pub fn is_shift(self) -> bool {
matches!(self, BinOpKind::Shl | BinOpKind::Shr)
}

pub fn is_comparison(self) -> bool {
match self {
BinOpKind::Eq
Expand Down Expand Up @@ -2115,16 +2081,6 @@ impl<'hir> QPath<'hir> {
QPath::LangItem(_, span, _) => span,
}
}

/// Returns the span of the last segment of this `QPath`. For example, `method` in
/// `<() as Trait>::method`.
pub fn last_segment_span(&self) -> Span {
match *self {
QPath::Resolved(_, path) => path.segments.last().unwrap().ident.span,
QPath::TypeRelative(_, segment) => segment.ident.span,
QPath::LangItem(_, span, _) => span,
}
}
}

/// Hints at the original code for a let statement.
Expand Down Expand Up @@ -3896,12 +3852,6 @@ impl<'hir> Node<'hir> {
}
}

/// Get the fields for the tuple-constructor,
/// if this node is a tuple constructor, otherwise None
pub fn tuple_fields(&self) -> Option<&'hir [FieldDef<'hir>]> {
if let Node::Ctor(&VariantData::Tuple(fields, _, _)) = self { Some(fields) } else { None }
}

/// Expect a [`Node::Param`] or panic.
#[track_caller]
pub fn expect_param(self) -> &'hir Param<'hir> {
Expand Down

0 comments on commit ec10e37

Please sign in to comment.