Skip to content

Commit 9714f60

Browse files
committed
Inline and remove FnParam::name.
It has a single call site.
1 parent e885122 commit 9714f60

File tree

1 file changed

+9
-12
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+9
-12
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::visit::TypeVisitableExt;
1919
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
2020
use rustc_middle::{bug, span_bug};
2121
use rustc_session::Session;
22-
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
22+
use rustc_span::{DUMMY_SP, Ident, Span, kw, sym};
2323
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
2424
use rustc_trait_selection::infer::InferCtxtExt;
2525
use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt, SelectionContext};
@@ -2720,21 +2720,18 @@ impl FnParam<'_> {
27202720
}
27212721
}
27222722

2723-
fn name(&self) -> Option<Symbol> {
2724-
match self {
2725-
Self::Param(x) if let hir::PatKind::Binding(_, _, ident, _) = x.pat.kind => {
2726-
Some(ident.name)
2727-
}
2728-
Self::Name(x) if x.name != kw::Empty => Some(x.name),
2729-
_ => None,
2730-
}
2731-
}
2732-
27332723
fn display(&self, idx: usize) -> impl '_ + fmt::Display {
27342724
struct D<'a>(FnParam<'a>, usize);
27352725
impl fmt::Display for D<'_> {
27362726
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2737-
if let Some(name) = self.0.name() {
2727+
let name = match self.0 {
2728+
FnParam::Param(x) if let hir::PatKind::Binding(_, _, ident, _) = x.pat.kind => {
2729+
Some(ident.name)
2730+
}
2731+
FnParam::Name(x) if x.name != kw::Empty => Some(x.name),
2732+
_ => None,
2733+
};
2734+
if let Some(name) = name {
27382735
write!(f, "`{name}`")
27392736
} else {
27402737
write!(f, "parameter #{}", self.1 + 1)

0 commit comments

Comments
 (0)