Remove some unused functions.

And remove `pub` from some local-only ones.
This commit is contained in:
Nicholas Nethercote 2023-11-21 12:40:34 +11:00
parent c965a7608d
commit ec10e3726c

View File

@ -13,7 +13,6 @@
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;
@ -76,13 +75,6 @@ pub fn ident(&self) -> Ident {
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)]
@ -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,
@ -289,10 +281,6 @@ pub fn hir_id(&self) -> HirId {
}
}
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",
@ -368,11 +356,6 @@ pub fn inputs(&self) -> &[Ty<'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(_)),
@ -383,11 +366,6 @@ pub fn has_err(&self) -> bool {
})
}
#[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()
@ -589,14 +567,6 @@ pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'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()
@ -679,7 +649,7 @@ pub fn bounds_span_for_suggestions(&self, param_def_id: LocalDefId) -> Option<Sp
)
}
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();
@ -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)
}
}
@ -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.
@ -1272,10 +1242,6 @@ pub fn is_lazy(self) -> bool {
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
@ -2115,16 +2081,6 @@ pub fn qself_span(&self) -> Span {
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.
@ -3896,12 +3852,6 @@ pub fn fn_kind(self) -> Option<FnKind<'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> {