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_parse/src/parser/ty.rs | |
| 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_parse/src/parser/ty.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 0c57a8cc5e1..a997be3405d 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -2,7 +2,7 @@ use rustc_ast::ptr::P; use rustc_ast::token::{self, IdentIsRaw, MetaVarKind, Token, TokenKind}; use rustc_ast::util::case::Case; use rustc_ast::{ - self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnRetTy, + self as ast, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnPtrTy, FnRetTy, GenericBound, GenericBounds, GenericParam, Generics, Lifetime, MacCall, MutTy, Mutability, Pinnedness, PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, TyKind, UnsafeBinderTy, @@ -283,14 +283,14 @@ impl<'a> Parser<'a> { TyKind::Infer } else if self.check_fn_front_matter(false, Case::Sensitive) { // Function pointer type - self.parse_ty_bare_fn(lo, ThinVec::new(), None, recover_return_sign)? + self.parse_ty_fn_ptr(lo, ThinVec::new(), None, recover_return_sign)? } else if self.check_keyword(exp!(For)) { // Function pointer type or bound list (trait object type) starting with a poly-trait. // `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T` // `for<'lt> Trait1<'lt> + Trait2 + 'a` let (lifetime_defs, _) = self.parse_late_bound_lifetime_defs()?; if self.check_fn_front_matter(false, Case::Sensitive) { - self.parse_ty_bare_fn( + self.parse_ty_fn_ptr( lo, lifetime_defs, Some(self.prev_token.span.shrink_to_lo()), @@ -665,7 +665,7 @@ impl<'a> Parser<'a> { Ok(TyKind::Typeof(expr)) } - /// Parses a function pointer type (`TyKind::BareFn`). + /// Parses a function pointer type (`TyKind::FnPtr`). /// ```ignore (illustrative) /// [unsafe] [extern "ABI"] fn (S) -> T /// // ^~~~~^ ^~~~^ ^~^ ^ @@ -674,7 +674,7 @@ impl<'a> Parser<'a> { /// // Function Style ABI Parameter types /// ``` /// We actually parse `FnHeader FnDecl`, but we error on `const` and `async` qualifiers. - fn parse_ty_bare_fn( + fn parse_ty_fn_ptr( &mut self, lo: Span, mut params: ThinVec<GenericParam>, @@ -698,7 +698,7 @@ impl<'a> Parser<'a> { let decl = self.parse_fn_decl(|_| false, AllowPlus::No, recover_return_sign)?; let decl_span = span_start.to(self.prev_token.span); - Ok(TyKind::BareFn(P(BareFnTy { ext, safety, generic_params: params, decl, decl_span }))) + Ok(TyKind::FnPtr(P(FnPtrTy { ext, safety, generic_params: params, decl, decl_span }))) } /// Recover from function pointer types with a generic parameter list (e.g. `fn<'a>(&'a str)`). |
