diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-07-07 03:26:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-07 03:26:09 +0200 |
| commit | 7eea141b8755528ecc8cb004deeadd652104d43d (patch) | |
| tree | 4379b4fc10147a4e317290e4cab9c75b5f29dec1 /compiler/rustc_hir | |
| parent | 3e76cd796f297f66c36ade5c6d39ab61464bc677 (diff) | |
| parent | 3c9b98699dae7d99048c07265735b81353cbd8d7 (diff) | |
| download | rust-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_hir')
| -rw-r--r-- | compiler/rustc_hir/src/def.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/intravisit.rs | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 459fe5935e0..df010f87098 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -831,7 +831,7 @@ pub enum LifetimeRes { /// Id of the introducing place. That can be: /// - an item's id, for the item's generic parameters; /// - a TraitRef's ref_id, identifying the `for<...>` binder; - /// - a BareFn type's id. + /// - a FnPtr type's id. /// /// This information is used for impl-trait lifetime captures, to know when to or not to /// capture any given lifetime. diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 559a771931e..0f6f81d7964 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3526,7 +3526,7 @@ impl PrimTy { } #[derive(Debug, Clone, Copy, HashStable_Generic)] -pub struct BareFnTy<'hir> { +pub struct FnPtrTy<'hir> { pub safety: Safety, pub abi: ExternAbi, pub generic_params: &'hir [GenericParam<'hir>], @@ -3645,8 +3645,8 @@ pub enum TyKind<'hir, Unambig = ()> { Ptr(MutTy<'hir>), /// A reference (i.e., `&'a T` or `&'a mut T`). Ref(&'hir Lifetime, MutTy<'hir>), - /// A bare function (e.g., `fn(usize) -> bool`). - BareFn(&'hir BareFnTy<'hir>), + /// A function pointer (e.g., `fn(usize) -> bool`). + FnPtr(&'hir FnPtrTy<'hir>), /// An unsafe binder type (e.g. `unsafe<'a> Foo<'a>`). UnsafeBinder(&'hir UnsafeBinderTy<'hir>), /// The never type (`!`). @@ -4498,7 +4498,7 @@ pub enum ForeignItemKind<'hir> { /// /// All argument idents are actually always present (i.e. `Some`), but /// `&[Option<Ident>]` is used because of code paths shared with `TraitFn` - /// and `BareFnTy`. The sharing is due to all of these cases not allowing + /// and `FnPtrTy`. The sharing is due to all of these cases not allowing /// arbitrary patterns for parameters. Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>), /// A foreign static item (`static ext: u8`). diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index a0bc318e2ca..1bb8f7ad894 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -1001,7 +1001,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) - TyKind::Tup(tuple_element_types) => { walk_list!(visitor, visit_ty_unambig, tuple_element_types); } - TyKind::BareFn(ref function_declaration) => { + TyKind::FnPtr(ref function_declaration) => { walk_list!(visitor, visit_generic_param, function_declaration.generic_params); try_visit!(visitor.visit_fn_decl(function_declaration.decl)); } |
