Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0d11be5

Browse files
committed
Auto merge of #143556 - jhpratt:rollup-nid39y2, r=jhpratt
Rollup of 9 pull requests Successful merges: - #143206 (Align attr fixes) - #143236 (Stabilize `mixed_integer_ops_unsigned_sub`) - #143344 (Port `#[path]` to the new attribute parsing infrastructure ) - #143359 (Link to 2024 edition page for `!` fallback changes) - #143456 (mbe: Change `unused_macro_rules` to a `DenseBitSet`) - #143529 (Renamed retain_mut to retain on LinkedList as mentioned in the ACP) - #143535 (Remove duplicate word) - #143544 (compiler: rename BareFn to FnPtr) - #143552 (lib: more eagerly return `self.len()` from `ceil_char_boundary`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ca98d4d + 2992997 commit 0d11be5

File tree

71 files changed

+405
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+405
-272
lines changed

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,6 +4474,7 @@ dependencies = [
44744474
"rustc_feature",
44754475
"rustc_fluent_macro",
44764476
"rustc_hir",
4477+
"rustc_index",
44774478
"rustc_macros",
44784479
"rustc_metadata",
44794480
"rustc_middle",

‎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) => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /