Skip to content

Commit 7eea141

Browse files
authored
Rollup merge of #143544 - workingjubilee:rename-bare-fn, r=fmease
compiler: rename BareFn to FnPtr At some point "BareFn" was the chosen name for a "bare" function, without the niceties of `~fn`, `&fn`, or a few other ways of writing a function type. However, at some point the syntax for a "bare function" and any other function diverged even more. We started calling them what they are: function pointers, denoted by their own syntax. However, we never changed the *internal* name for these, as this divergence was very gradual. Personally, I have repeatedly searched for "FnPtr" and gotten confused until I find the name is BareFn, only to forget this until the next time, since I don't routinely interact with the higher-level AST and HIR. But even tools that interact with these internal types only touch on them in a few places, making a migration easy enough. Let's use a more intuitive and obvious name, as this 12+ year old name has little to do with current Rust.
2 parents 3e76cd7 + 3c9b986 commit 7eea141

File tree

40 files changed

+114
-120
lines changed

40 files changed

+114
-120
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ impl Ty {
24222422
}
24232423

24242424
#[derive(Clone, Encodable, Decodable, Debug)]
2425-
pub struct BareFnTy {
2425+
pub struct FnPtrTy {
24262426
pub safety: Safety,
24272427
pub ext: Extern,
24282428
pub generic_params: ThinVec<GenericParam>,
@@ -2455,8 +2455,8 @@ pub enum TyKind {
24552455
///
24562456
/// Desugars into `Pin<&'a T>` or `Pin<&'a mut T>`.
24572457
PinnedRef(Option<Lifetime>, MutTy),
2458-
/// A bare function (e.g., `fn(usize) -> bool`).
2459-
BareFn(P<BareFnTy>),
2458+
/// A function pointer type (e.g., `fn(usize) -> bool`).
2459+
FnPtr(P<FnPtrTy>),
24602460
/// An unsafe existential lifetime binder (e.g., `unsafe<'a> &'a ()`).
24612461
UnsafeBinder(P<UnsafeBinderTy>),
24622462
/// The never type (`!`).

compiler/rustc_ast/src/util/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
265265
ty = &binder.inner_ty;
266266
}
267267

268-
ast::TyKind::BareFn(fn_ty) => match &fn_ty.decl.output {
268+
ast::TyKind::FnPtr(fn_ty) => match &fn_ty.decl.output {
269269
ast::FnRetTy::Default(_) => break None,
270270
ast::FnRetTy::Ty(ret) => ty = ret,
271271
},

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ macro_rules! common_visitor_and_walkers {
10591059
TyKind::Tup(tuple_element_types) => {
10601060
walk_list!(vis, visit_ty, tuple_element_types);
10611061
}
1062-
TyKind::BareFn(function_declaration) => {
1063-
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } =
1062+
TyKind::FnPtr(function_declaration) => {
1063+
let FnPtrTy { safety, ext: _, generic_params, decl, decl_span } =
10641064
&$($mut)? **function_declaration;
10651065
try_visit!(visit_safety(vis, safety));
10661066
try_visit!(visit_generic_params(vis, generic_params));

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_ast_passes/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetim
4848
4949
ast_passes_bad_c_variadic = only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
5050
51-
ast_passes_bare_fn_invalid_safety = function pointers cannot be declared with `safe` safety qualifier
52-
.suggestion = remove safe from this item
53-
5451
ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
5552
.cannot_have = cannot have a body
5653
.invalid = the invalid body
@@ -135,6 +132,9 @@ ast_passes_fn_param_forbidden_self =
135132
ast_passes_fn_param_too_many =
136133
function can not have more than {$max_num_args} arguments
137134
135+
ast_passes_fn_ptr_invalid_safety = function pointers cannot be declared with `safe` safety qualifier
136+
.suggestion = remove safe from this item
137+
138138
ast_passes_fn_without_body =
139139
free function without a body
140140
.suggestion = provide a definition for the function

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ impl<'a> AstValidator<'a> {
499499
}
500500
}
501501

502-
fn check_bare_fn_safety(&self, span: Span, safety: Safety) {
502+
fn check_fn_ptr_safety(&self, span: Span, safety: Safety) {
503503
if matches!(safety, Safety::Safe(_)) {
504-
self.dcx().emit_err(errors::InvalidSafetyOnBareFn { span });
504+
self.dcx().emit_err(errors::InvalidSafetyOnFnPtr { span });
505505
}
506506
}
507507

@@ -785,8 +785,8 @@ impl<'a> AstValidator<'a> {
785785

786786
fn visit_ty_common(&mut self, ty: &'a Ty) {
787787
match &ty.kind {
788-
TyKind::BareFn(bfty) => {
789-
self.check_bare_fn_safety(bfty.decl_span, bfty.safety);
788+
TyKind::FnPtr(bfty) => {
789+
self.check_fn_ptr_safety(bfty.decl_span, bfty.safety);
790790
self.check_fn_decl(&bfty.decl, SelfSemantic::No);
791791
Self::check_decl_no_pat(&bfty.decl, |span, _, _| {
792792
self.dcx().emit_err(errors::PatternFnPointer { span });

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ pub(crate) struct InvalidSafetyOnItem {
225225
}
226226

227227
#[derive(Diagnostic)]
228-
#[diag(ast_passes_bare_fn_invalid_safety)]
229-
pub(crate) struct InvalidSafetyOnBareFn {
228+
#[diag(ast_passes_fn_ptr_invalid_safety)]
229+
pub(crate) struct InvalidSafetyOnFnPtr {
230230
#[primary_span]
231231
pub span: Span,
232232
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
286286

287287
fn visit_ty(&mut self, ty: &'a ast::Ty) {
288288
match &ty.kind {
289-
ast::TyKind::BareFn(bare_fn_ty) => {
289+
ast::TyKind::FnPtr(fn_ptr_ty) => {
290290
// Function pointers cannot be `const`
291-
self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params);
291+
self.check_late_bound_lifetime_defs(&fn_ptr_ty.generic_params);
292292
}
293293
ast::TyKind::Never => {
294294
gate!(&self, never_type, ty.span, "the `!` type is experimental");

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ impl<'a> State<'a> {
12851285
self.print_type(typ);
12861286
self.pclose();
12871287
}
1288-
ast::TyKind::BareFn(f) => {
1288+
ast::TyKind::FnPtr(f) => {
12891289
self.print_ty_fn(f.ext, f.safety, &f.decl, None, &f.generic_params);
12901290
}
12911291
ast::TyKind::UnsafeBinder(f) => {

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,12 @@ fn find_type_parameters(
414414
impl<'a, 'b> visit::Visitor<'a> for Visitor<'a, 'b> {
415415
fn visit_ty(&mut self, ty: &'a ast::Ty) {
416416
let stack_len = self.bound_generic_params_stack.len();
417-
if let ast::TyKind::BareFn(bare_fn) = &ty.kind
418-
&& !bare_fn.generic_params.is_empty()
417+
if let ast::TyKind::FnPtr(fn_ptr) = &ty.kind
418+
&& !fn_ptr.generic_params.is_empty()
419419
{
420420
// Given a field `x: for<'a> fn(T::SomeType<'a>)`, we wan't to account for `'a` so
421421
// that we generate `where for<'a> T::SomeType<'a>: ::core::clone::Clone`. #122622
422-
self.bound_generic_params_stack.extend(bare_fn.generic_params.iter().cloned());
422+
self.bound_generic_params_stack.extend(fn_ptr.generic_params.iter().cloned());
423423
}
424424

425425
if let ast::TyKind::Path(_, path) = &ty.kind

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: 4 additions & 4 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>],
@@ -3645,8 +3645,8 @@ pub enum TyKind<'hir, Unambig = ()> {
36453645
Ptr(MutTy<'hir>),
36463646
/// A reference (i.e., `&'a T` or `&'a mut T`).
36473647
Ref(&'hir Lifetime, MutTy<'hir>),
3648-
/// A bare function (e.g., `fn(usize) -> bool`).
3649-
BareFn(&'hir BareFnTy<'hir>),
3648+
/// A function pointer (e.g., `fn(usize) -> bool`).
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: 4 additions & 6 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()
@@ -728,8 +728,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
728728
where_bound_origin: None,
729729
};
730730
self.with(scope, |this| {
731-
// a bare fn has no bounds, so everything
732-
// contained within is scoped within its binder.
731+
// a FnPtr has no bounds, so everything within is scoped within its binder
733732
intravisit::walk_ty(this, ty);
734733
});
735734
}
@@ -758,8 +757,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
758757
where_bound_origin: None,
759758
};
760759
self.with(scope, |this| {
761-
// a bare fn has no bounds, so everything
762-
// contained within is scoped within its binder.
760+
// everything within is scoped within its binder
763761
intravisit::walk_ty(this, ty);
764762
});
765763
}
@@ -1419,7 +1417,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14191417
hir::Node::OpaqueTy(_) => "higher-ranked lifetime from outer `impl Trait`",
14201418
// Other items are fine.
14211419
hir::Node::Item(_) | hir::Node::TraitItem(_) | hir::Node::ImplItem(_) => return Ok(()),
1422-
hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(_), .. }) => {
1420+
hir::Node::Ty(hir::Ty { kind: hir::TyKind::FnPtr(_), .. }) => {
14231421
"higher-ranked lifetime from function pointer"
14241422
}
14251423
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

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a> State<'a> {
405405
}
406406
self.pclose();
407407
}
408-
hir::TyKind::BareFn(f) => {
408+
hir::TyKind::FnPtr(f) => {
409409
self.print_ty_fn(f.abi, f.safety, f.decl, None, f.generic_params, f.param_idents);
410410
}
411411
hir::TyKind::UnsafeBinder(unsafe_binder) => {

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
203203
let adjusted_ty =
204204
self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
205205

206-
// If the callee is a bare function or a closure, then we're all set.
206+
// If the callee is a function pointer or a closure, then we're all set.
207207
match *adjusted_ty.kind() {
208208
ty::FnDef(..) | ty::FnPtr(..) => {
209209
let adjustments = self.adjust_steps(autoderef);

compiler/rustc_lint/src/nonstandard_style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
431431
}
432432

433433
fn check_ty(&mut self, cx: &LateContext<'_>, ty: &hir::Ty<'_, hir::AmbigArg>) {
434-
if let hir::TyKind::BareFn(hir::BareFnTy { param_idents, .. }) = &ty.kind {
434+
if let hir::TyKind::FnPtr(hir::FnPtrTy { param_idents, .. }) = &ty.kind {
435435
for param_ident in *param_idents {
436436
if let Some(param_ident) = param_ident {
437437
self.check_snake_case(cx, "variable", param_ident);

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
15771577
impl<'tcx> hir::intravisit::Visitor<'_> for FnPtrFinder<'tcx> {
15781578
fn visit_ty(&mut self, ty: &'_ hir::Ty<'_, AmbigArg>) {
15791579
debug!(?ty);
1580-
if let hir::TyKind::BareFn(hir::BareFnTy { abi, .. }) = ty.kind
1580+
if let hir::TyKind::FnPtr(hir::FnPtrTy { abi, .. }) = ty.kind
15811581
&& !abi.is_rustic_abi()
15821582
{
15831583
self.spans.push(ty.span);

0 commit comments

Comments
 (0)