about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-07-07 03:26:09 +0200
committerGitHub <noreply@github.com>2025-07-07 03:26:09 +0200
commit7eea141b8755528ecc8cb004deeadd652104d43d (patch)
tree4379b4fc10147a4e317290e4cab9c75b5f29dec1 /compiler/rustc_ast/src
parent3e76cd796f297f66c36ade5c6d39ab61464bc677 (diff)
parent3c9b98699dae7d99048c07265735b81353cbd8d7 (diff)
downloadrust-7eea141b8755528ecc8cb004deeadd652104d43d.tar.gz
rust-7eea141b8755528ecc8cb004deeadd652104d43d.zip
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.
Diffstat (limited to 'compiler/rustc_ast/src')
-rw-r--r--compiler/rustc_ast/src/ast.rs6
-rw-r--r--compiler/rustc_ast/src/util/classify.rs2
-rw-r--r--compiler/rustc_ast/src/visit.rs4
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index 491a9bbda79..3c576316f62 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -2422,7 +2422,7 @@ impl Ty {
 }
 
 #[derive(Clone, Encodable, Decodable, Debug)]
-pub struct BareFnTy {
+pub struct FnPtrTy {
     pub safety: Safety,
     pub ext: Extern,
     pub generic_params: ThinVec<GenericParam>,
@@ -2455,8 +2455,8 @@ pub enum TyKind {
     ///
     /// Desugars into `Pin<&'a T>` or `Pin<&'a mut T>`.
     PinnedRef(Option<Lifetime>, MutTy),
-    /// A bare function (e.g., `fn(usize) -> bool`).
-    BareFn(P<BareFnTy>),
+    /// A function pointer type (e.g., `fn(usize) -> bool`).
+    FnPtr(P<FnPtrTy>),
     /// An unsafe existential lifetime binder (e.g., `unsafe<'a> &'a ()`).
     UnsafeBinder(P<UnsafeBinderTy>),
     /// The never type (`!`).
diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs
index 989ebe14bf8..f7daec4b064 100644
--- a/compiler/rustc_ast/src/util/classify.rs
+++ b/compiler/rustc_ast/src/util/classify.rs
@@ -265,7 +265,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
                 ty = &binder.inner_ty;
             }
 
-            ast::TyKind::BareFn(fn_ty) => match &fn_ty.decl.output {
+            ast::TyKind::FnPtr(fn_ty) => match &fn_ty.decl.output {
                 ast::FnRetTy::Default(_) => break None,
                 ast::FnRetTy::Ty(ret) => ty = ret,
             },
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index f8ecff69a76..37fcc0d2167 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -1059,8 +1059,8 @@ macro_rules! common_visitor_and_walkers {
                 TyKind::Tup(tuple_element_types) => {
                     walk_list!(vis, visit_ty, tuple_element_types);
                 }
-                TyKind::BareFn(function_declaration) => {
-                    let BareFnTy { safety, ext: _, generic_params, decl, decl_span } =
+                TyKind::FnPtr(function_declaration) => {
+                    let FnPtrTy { safety, ext: _, generic_params, decl, decl_span } =
                         &$($mut)? **function_declaration;
                     try_visit!(visit_safety(vis, safety));
                     try_visit!(visit_generic_params(vis, generic_params));