diff options
Diffstat (limited to 'compiler/rustc_hir_analysis')
6 files changed, 27 insertions, 29 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 25064c327d0..a185291887d 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -198,7 +198,7 @@ fn placeholder_type_error_diag<'cx, 'tcx>( let mut is_const_or_static = false; if let Some(hir_ty) = hir_ty - && let hir::TyKind::BareFn(_) = hir_ty.kind + && let hir::TyKind::FnPtr(_) = hir_ty.kind { is_fn = true; diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 573af01a62d..31e9c3b80fb 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -454,7 +454,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S type Result = ControlFlow<Span>; fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx, AmbigArg>) -> ControlFlow<Span> { match ty.kind { - hir::TyKind::BareFn(..) => { + hir::TyKind::FnPtr(..) => { self.outer_index.shift_in(1); let res = intravisit::walk_ty(self, ty); self.outer_index.shift_out(1); diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index a0d1273eb85..8d7ac7db67b 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -704,7 +704,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { #[instrument(level = "debug", skip(self))] fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx, AmbigArg>) { match ty.kind { - hir::TyKind::BareFn(c) => { + hir::TyKind::FnPtr(c) => { let (mut bound_vars, binders): (FxIndexMap<LocalDefId, ResolvedArg>, Vec<_>) = c .generic_params .iter() @@ -728,8 +728,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { where_bound_origin: None, }; self.with(scope, |this| { - // a bare fn has no bounds, so everything - // contained within is scoped within its binder. + // a FnPtr has no bounds, so everything within is scoped within its binder intravisit::walk_ty(this, ty); }); } @@ -758,8 +757,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { where_bound_origin: None, }; self.with(scope, |this| { - // a bare fn has no bounds, so everything - // contained within is scoped within its binder. + // everything within is scoped within its binder intravisit::walk_ty(this, ty); }); } @@ -1419,7 +1417,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { hir::Node::OpaqueTy(_) => "higher-ranked lifetime from outer `impl Trait`", // Other items are fine. hir::Node::Item(_) | hir::Node::TraitItem(_) | hir::Node::ImplItem(_) => return Ok(()), - hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(_), .. }) => { + hir::Node::Ty(hir::Ty { kind: hir::TyKind::FnPtr(_), .. }) => { "higher-ranked lifetime from function pointer" } hir::Node::Ty(hir::Ty { kind: hir::TyKind::TraitObject(..), .. }) => { diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs index ef789743e06..3f928fd056e 100644 --- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs @@ -393,9 +393,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let params = if let Some(generics) = node.generics() { generics.params } else if let hir::Node::Ty(ty) = node - && let hir::TyKind::BareFn(bare_fn) = ty.kind + && let hir::TyKind::FnPtr(fn_ptr) = ty.kind { - bare_fn.generic_params + fn_ptr.generic_params } else { &[] }; diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs index 82e5f65476f..5088c63702e 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs @@ -21,8 +21,8 @@ pub(crate) fn validate_cmse_abi<'tcx>( ExternAbi::CmseNonSecureCall => { let hir_node = tcx.hir_node(hir_id); let hir::Node::Ty(hir::Ty { - span: bare_fn_span, - kind: hir::TyKind::BareFn(bare_fn_ty), + span: fn_ptr_span, + kind: hir::TyKind::FnPtr(fn_ptr_ty), .. }) = hir_node else { @@ -49,18 +49,18 @@ pub(crate) fn validate_cmse_abi<'tcx>( Ok(Err(index)) => { // fn(x: u32, u32, u32, u16, y: u16) -> u32, // ^^^^^^ - let span = if let Some(ident) = bare_fn_ty.param_idents[index] { - ident.span.to(bare_fn_ty.decl.inputs[index].span) + let span = if let Some(ident) = fn_ptr_ty.param_idents[index] { + ident.span.to(fn_ptr_ty.decl.inputs[index].span) } else { - bare_fn_ty.decl.inputs[index].span + fn_ptr_ty.decl.inputs[index].span } - .to(bare_fn_ty.decl.inputs.last().unwrap().span); - let plural = bare_fn_ty.param_idents.len() - index != 1; + .to(fn_ptr_ty.decl.inputs.last().unwrap().span); + let plural = fn_ptr_ty.param_idents.len() - index != 1; dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi }); } Err(layout_err) => { if should_emit_generic_error(abi, layout_err) { - dcx.emit_err(errors::CmseCallGeneric { span: *bare_fn_span }); + dcx.emit_err(errors::CmseCallGeneric { span: *fn_ptr_span }); } } } @@ -68,12 +68,12 @@ pub(crate) fn validate_cmse_abi<'tcx>( match is_valid_cmse_output(tcx, fn_sig) { Ok(true) => {} Ok(false) => { - let span = bare_fn_ty.decl.output.span(); + let span = fn_ptr_ty.decl.output.span(); dcx.emit_err(errors::CmseOutputStackSpill { span, abi }); } Err(layout_err) => { if should_emit_generic_error(abi, layout_err) { - dcx.emit_err(errors::CmseCallGeneric { span: *bare_fn_span }); + dcx.emit_err(errors::CmseCallGeneric { span: *fn_ptr_span }); } } }; diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 434375060df..20d165897e2 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2402,7 +2402,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { hir::TyKind::Tup(fields) => { Ty::new_tup_from_iter(tcx, fields.iter().map(|t| self.lower_ty(t))) } - hir::TyKind::BareFn(bf) => { + hir::TyKind::FnPtr(bf) => { require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, hir_ty.span); Ty::new_fn_ptr( @@ -2660,28 +2660,28 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { debug!(?output_ty); let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, safety, abi); - let bare_fn_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars); + let fn_ptr_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars); - if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(bare_fn_ty), span, .. }) = + if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::FnPtr(fn_ptr_ty), span, .. }) = tcx.hir_node(hir_id) { - check_abi(tcx, hir_id, *span, bare_fn_ty.abi); + check_abi(tcx, hir_id, *span, fn_ptr_ty.abi); } // reject function types that violate cmse ABI requirements - cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, bare_fn_ty); + cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, fn_ptr_ty); - if !bare_fn_ty.references_error() { + if !fn_ptr_ty.references_error() { // Find any late-bound regions declared in return type that do // not appear in the arguments. These are not well-formed. // // Example: // for<'a> fn() -> &'a str <-- 'a is bad // for<'a> fn(&'a String) -> &'a str <-- 'a is ok - let inputs = bare_fn_ty.inputs(); + let inputs = fn_ptr_ty.inputs(); let late_bound_in_args = tcx.collect_constrained_late_bound_regions(inputs.map_bound(|i| i.to_owned())); - let output = bare_fn_ty.output(); + let output = fn_ptr_ty.output(); let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(output); self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| { @@ -2695,7 +2695,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { }); } - bare_fn_ty + fn_ptr_ty } /// Given a fn_hir_id for a impl function, suggest the type that is found on the |
