Skip to content

Commit 628e898

Browse files
compiler: rename hir::BareFn* to hir::FnPtr*
1 parent da7dd37 commit 628e898

File tree

17 files changed

+41
-41
lines changed

17 files changed

+41
-41
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12691269
let path = self.make_lang_item_qpath(LangItem::Pin, span, Some(args));
12701270
hir::TyKind::Path(path)
12711271
}
1272-
TyKind::BareFn(f) => {
1272+
TyKind::FnPtr(f) => {
12731273
let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1274-
hir::TyKind::BareFn(self.arena.alloc(hir::BareFnTy {
1274+
hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
12751275
generic_params,
12761276
safety: self.lower_safety(f.safety, hir::Safety::Safe),
12771277
abi: self.lower_extern(f.ext),

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ pub enum LifetimeRes {
831831
/// Id of the introducing place. That can be:
832832
/// - an item's id, for the item's generic parameters;
833833
/// - a TraitRef's ref_id, identifying the `for<...>` binder;
834-
/// - a BareFn type's id.
834+
/// - a FnPtr type's id.
835835
///
836836
/// This information is used for impl-trait lifetime captures, to know when to or not to
837837
/// capture any given lifetime.

compiler/rustc_hir/src/hir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ impl PrimTy {
35263526
}
35273527

35283528
#[derive(Debug, Clone, Copy, HashStable_Generic)]
3529-
pub struct BareFnTy<'hir> {
3529+
pub struct FnPtrTy<'hir> {
35303530
pub safety: Safety,
35313531
pub abi: ExternAbi,
35323532
pub generic_params: &'hir [GenericParam<'hir>],
@@ -3646,7 +3646,7 @@ pub enum TyKind<'hir, Unambig = ()> {
36463646
/// A reference (i.e., `&'a T` or `&'a mut T`).
36473647
Ref(&'hir Lifetime, MutTy<'hir>),
36483648
/// A bare function (e.g., `fn(usize) -> bool`).
3649-
BareFn(&'hir BareFnTy<'hir>),
3649+
FnPtr(&'hir FnPtrTy<'hir>),
36503650
/// An unsafe binder type (e.g. `unsafe<'a> Foo<'a>`).
36513651
UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
36523652
/// The never type (`!`).
@@ -4498,7 +4498,7 @@ pub enum ForeignItemKind<'hir> {
44984498
///
44994499
/// All argument idents are actually always present (i.e. `Some`), but
45004500
/// `&[Option<Ident>]` is used because of code paths shared with `TraitFn`
4501-
/// and `BareFnTy`. The sharing is due to all of these cases not allowing
4501+
/// and `FnPtrTy`. The sharing is due to all of these cases not allowing
45024502
/// arbitrary patterns for parameters.
45034503
Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
45044504
/// A foreign static item (`static ext: u8`).

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
10011001
TyKind::Tup(tuple_element_types) => {
10021002
walk_list!(visitor, visit_ty_unambig, tuple_element_types);
10031003
}
1004-
TyKind::BareFn(ref function_declaration) => {
1004+
TyKind::FnPtr(ref function_declaration) => {
10051005
walk_list!(visitor, visit_generic_param, function_declaration.generic_params);
10061006
try_visit!(visitor.visit_fn_decl(function_declaration.decl));
10071007
}

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn placeholder_type_error_diag<'cx, 'tcx>(
198198
let mut is_const_or_static = false;
199199

200200
if let Some(hir_ty) = hir_ty
201-
&& let hir::TyKind::BareFn(_) = hir_ty.kind
201+
&& let hir::TyKind::FnPtr(_) = hir_ty.kind
202202
{
203203
is_fn = true;
204204

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
454454
type Result = ControlFlow<Span>;
455455
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx, AmbigArg>) -> ControlFlow<Span> {
456456
match ty.kind {
457-
hir::TyKind::BareFn(..) => {
457+
hir::TyKind::FnPtr(..) => {
458458
self.outer_index.shift_in(1);
459459
let res = intravisit::walk_ty(self, ty);
460460
self.outer_index.shift_out(1);

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
704704
#[instrument(level = "debug", skip(self))]
705705
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx, AmbigArg>) {
706706
match ty.kind {
707-
hir::TyKind::BareFn(c) => {
707+
hir::TyKind::FnPtr(c) => {
708708
let (mut bound_vars, binders): (FxIndexMap<LocalDefId, ResolvedArg>, Vec<_>) = c
709709
.generic_params
710710
.iter()
@@ -1419,7 +1419,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14191419
hir::Node::OpaqueTy(_) => "higher-ranked lifetime from outer `impl Trait`",
14201420
// Other items are fine.
14211421
hir::Node::Item(_) | hir::Node::TraitItem(_) | hir::Node::ImplItem(_) => return Ok(()),
1422-
hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(_), .. }) => {
1422+
hir::Node::Ty(hir::Ty { kind: hir::TyKind::FnPtr(_), .. }) => {
14231423
"higher-ranked lifetime from function pointer"
14241424
}
14251425
hir::Node::Ty(hir::Ty { kind: hir::TyKind::TraitObject(..), .. }) => {

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
393393
let params = if let Some(generics) = node.generics() {
394394
generics.params
395395
} else if let hir::Node::Ty(ty) = node
396-
&& let hir::TyKind::BareFn(bare_fn) = ty.kind
396+
&& let hir::TyKind::FnPtr(fn_ptr) = ty.kind
397397
{
398-
bare_fn.generic_params
398+
fn_ptr.generic_params
399399
} else {
400400
&[]
401401
};

compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub(crate) fn validate_cmse_abi<'tcx>(
2121
ExternAbi::CmseNonSecureCall => {
2222
let hir_node = tcx.hir_node(hir_id);
2323
let hir::Node::Ty(hir::Ty {
24-
span: bare_fn_span,
25-
kind: hir::TyKind::BareFn(bare_fn_ty),
24+
span: fn_ptr_span,
25+
kind: hir::TyKind::FnPtr(fn_ptr_ty),
2626
..
2727
}) = hir_node
2828
else {
@@ -49,31 +49,31 @@ pub(crate) fn validate_cmse_abi<'tcx>(
4949
Ok(Err(index)) => {
5050
// fn(x: u32, u32, u32, u16, y: u16) -> u32,
5151
// ^^^^^^
52-
let span = if let Some(ident) = bare_fn_ty.param_idents[index] {
53-
ident.span.to(bare_fn_ty.decl.inputs[index].span)
52+
let span = if let Some(ident) = fn_ptr_ty.param_idents[index] {
53+
ident.span.to(fn_ptr_ty.decl.inputs[index].span)
5454
} else {
55-
bare_fn_ty.decl.inputs[index].span
55+
fn_ptr_ty.decl.inputs[index].span
5656
}
57-
.to(bare_fn_ty.decl.inputs.last().unwrap().span);
58-
let plural = bare_fn_ty.param_idents.len() - index != 1;
57+
.to(fn_ptr_ty.decl.inputs.last().unwrap().span);
58+
let plural = fn_ptr_ty.param_idents.len() - index != 1;
5959
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
6060
}
6161
Err(layout_err) => {
6262
if should_emit_generic_error(abi, layout_err) {
63-
dcx.emit_err(errors::CmseCallGeneric { span: *bare_fn_span });
63+
dcx.emit_err(errors::CmseCallGeneric { span: *fn_ptr_span });
6464
}
6565
}
6666
}
6767

6868
match is_valid_cmse_output(tcx, fn_sig) {
6969
Ok(true) => {}
7070
Ok(false) => {
71-
let span = bare_fn_ty.decl.output.span();
71+
let span = fn_ptr_ty.decl.output.span();
7272
dcx.emit_err(errors::CmseOutputStackSpill { span, abi });
7373
}
7474
Err(layout_err) => {
7575
if should_emit_generic_error(abi, layout_err) {
76-
dcx.emit_err(errors::CmseCallGeneric { span: *bare_fn_span });
76+
dcx.emit_err(errors::CmseCallGeneric { span: *fn_ptr_span });
7777
}
7878
}
7979
};

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24022402
hir::TyKind::Tup(fields) => {
24032403
Ty::new_tup_from_iter(tcx, fields.iter().map(|t| self.lower_ty(t)))
24042404
}
2405-
hir::TyKind::BareFn(bf) => {
2405+
hir::TyKind::FnPtr(bf) => {
24062406
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, hir_ty.span);
24072407

24082408
Ty::new_fn_ptr(
@@ -2660,28 +2660,28 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
26602660
debug!(?output_ty);
26612661

26622662
let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, safety, abi);
2663-
let bare_fn_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars);
2663+
let fn_ptr_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars);
26642664

2665-
if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(bare_fn_ty), span, .. }) =
2665+
if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::FnPtr(fn_ptr_ty), span, .. }) =
26662666
tcx.hir_node(hir_id)
26672667
{
2668-
check_abi(tcx, hir_id, *span, bare_fn_ty.abi);
2668+
check_abi(tcx, hir_id, *span, fn_ptr_ty.abi);
26692669
}
26702670

26712671
// reject function types that violate cmse ABI requirements
2672-
cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, bare_fn_ty);
2672+
cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, fn_ptr_ty);
26732673

2674-
if !bare_fn_ty.references_error() {
2674+
if !fn_ptr_ty.references_error() {
26752675
// Find any late-bound regions declared in return type that do
26762676
// not appear in the arguments. These are not well-formed.
26772677
//
26782678
// Example:
26792679
// for<'a> fn() -> &'a str <-- 'a is bad
26802680
// for<'a> fn(&'a String) -> &'a str <-- 'a is ok
2681-
let inputs = bare_fn_ty.inputs();
2681+
let inputs = fn_ptr_ty.inputs();
26822682
let late_bound_in_args =
26832683
tcx.collect_constrained_late_bound_regions(inputs.map_bound(|i| i.to_owned()));
2684-
let output = bare_fn_ty.output();
2684+
let output = fn_ptr_ty.output();
26852685
let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(output);
26862686

26872687
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
@@ -2695,7 +2695,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
26952695
});
26962696
}
26972697

2698-
bare_fn_ty
2698+
fn_ptr_ty
26992699
}
27002700

27012701
/// Given a fn_hir_id for a impl function, suggest the type that is found on the

0 commit comments

Comments
 (0)