Skip to content

Commit ec10e37

Browse files
committed
Remove some unused functions.
And remove `pub` from some local-only ones.
1 parent c965a76 commit ec10e37

File tree

1 file changed

+4
-54
lines changed

1 file changed

+4
-54
lines changed

compiler/rustc_hir/src/hir.rs

+4-54
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1313
use rustc_data_structures::fingerprint::Fingerprint;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_data_structures::sorted_map::SortedMap;
16-
use rustc_error_messages::MultiSpan;
1716
use rustc_index::IndexVec;
1817
use rustc_macros::HashStable_Generic;
1918
use rustc_span::hygiene::MacroKind;
@@ -76,13 +75,6 @@ impl ParamName {
7675
ParamName::Fresh | ParamName::Error => Ident::with_dummy_span(kw::UnderscoreLifetime),
7776
}
7877
}
79-
80-
pub fn normalize_to_macros_2_0(&self) -> ParamName {
81-
match *self {
82-
ParamName::Plain(ident) => ParamName::Plain(ident.normalize_to_macros_2_0()),
83-
param_name => param_name,
84-
}
85-
}
8678
}
8779

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

118110
impl LifetimeName {
119-
pub fn is_elided(&self) -> bool {
111+
fn is_elided(&self) -> bool {
120112
match self {
121113
LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Infer => true,
122114

@@ -289,10 +281,6 @@ impl GenericArg<'_> {
289281
}
290282
}
291283

292-
pub fn is_synthetic(&self) -> bool {
293-
matches!(self, GenericArg::Lifetime(lifetime) if lifetime.ident == Ident::empty())
294-
}
295-
296284
pub fn descr(&self) -> &'static str {
297285
match self {
298286
GenericArg::Lifetime(_) => "lifetime",
@@ -368,11 +356,6 @@ impl<'hir> GenericArgs<'hir> {
368356
panic!("GenericArgs::inputs: not a `Fn(T) -> U`");
369357
}
370358

371-
#[inline]
372-
pub fn has_type_params(&self) -> bool {
373-
self.args.iter().any(|arg| matches!(arg, GenericArg::Type(_)))
374-
}
375-
376359
pub fn has_err(&self) -> bool {
377360
self.args.iter().any(|arg| match arg {
378361
GenericArg::Type(ty) => matches!(ty.kind, TyKind::Err(_)),
@@ -383,11 +366,6 @@ impl<'hir> GenericArgs<'hir> {
383366
})
384367
}
385368

386-
#[inline]
387-
pub fn num_type_params(&self) -> usize {
388-
self.args.iter().filter(|arg| matches!(arg, GenericArg::Type(_))).count()
389-
}
390-
391369
#[inline]
392370
pub fn num_lifetime_params(&self) -> usize {
393371
self.args.iter().filter(|arg| matches!(arg, GenericArg::Lifetime(_))).count()
@@ -589,14 +567,6 @@ impl<'hir> Generics<'hir> {
589567
self.params.iter().find(|&param| name == param.name.ident().name)
590568
}
591569

592-
pub fn spans(&self) -> MultiSpan {
593-
if self.params.is_empty() {
594-
self.span.into()
595-
} else {
596-
self.params.iter().map(|p| p.span).collect::<Vec<Span>>().into()
597-
}
598-
}
599-
600570
/// If there are generic parameters, return where to introduce a new one.
601571
pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
602572
if let Some(first) = self.params.first()
@@ -679,7 +649,7 @@ impl<'hir> Generics<'hir> {
679649
)
680650
}
681651

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

@@ -812,7 +782,7 @@ pub struct WhereRegionPredicate<'hir> {
812782

813783
impl<'hir> WhereRegionPredicate<'hir> {
814784
/// Returns `true` if `param_def_id` matches the `lifetime` of this predicate.
815-
pub fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
785+
fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
816786
self.lifetime.res == LifetimeName::Param(param_def_id)
817787
}
818788
}
@@ -869,7 +839,7 @@ pub struct OwnerNodes<'tcx> {
869839
}
870840

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

1275-
pub fn is_shift(self) -> bool {
1276-
matches!(self, BinOpKind::Shl | BinOpKind::Shr)
1277-
}
1278-
12791245
pub fn is_comparison(self) -> bool {
12801246
match self {
12811247
BinOpKind::Eq
@@ -2115,16 +2081,6 @@ impl<'hir> QPath<'hir> {
21152081
QPath::LangItem(_, span, _) => span,
21162082
}
21172083
}
2118-
2119-
/// Returns the span of the last segment of this `QPath`. For example, `method` in
2120-
/// `<() as Trait>::method`.
2121-
pub fn last_segment_span(&self) -> Span {
2122-
match *self {
2123-
QPath::Resolved(_, path) => path.segments.last().unwrap().ident.span,
2124-
QPath::TypeRelative(_, segment) => segment.ident.span,
2125-
QPath::LangItem(_, span, _) => span,
2126-
}
2127-
}
21282084
}
21292085

21302086
/// Hints at the original code for a let statement.
@@ -3896,12 +3852,6 @@ impl<'hir> Node<'hir> {
38963852
}
38973853
}
38983854

3899-
/// Get the fields for the tuple-constructor,
3900-
/// if this node is a tuple constructor, otherwise None
3901-
pub fn tuple_fields(&self) -> Option<&'hir [FieldDef<'hir>]> {
3902-
if let Node::Ctor(&VariantData::Tuple(fields, _, _)) = self { Some(fields) } else { None }
3903-
}
3904-
39053855
/// Expect a [`Node::Param`] or panic.
39063856
#[track_caller]
39073857
pub fn expect_param(self) -> &'hir Param<'hir> {

0 commit comments

Comments
 (0)