Skip to content

Commit ccc9ba5

Browse files
committedJan 29, 2025
Auto merge of #136225 - fmease:rollup-fm7m744, r=fmease
Rollup of 7 pull requests Successful merges: - #135625 ([cfg_match] Document the use of expressions.) - #135902 (Do not consider child bound assumptions for rigid alias) - #135943 (Rename `Piece::String` to `Piece::Lit`) - #136104 (Add mermaid graphs of NLL regions and SCCs to polonius MIR dump) - #136143 (Update books) - #136147 (ABI-required target features: warn when they are missing in base CPU) - #136164 (Refactor FnKind variant to hold &Fn) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 122fb29 + 2839307 commit ccc9ba5

File tree

66 files changed

+563
-395
lines changed

Some content is hidden

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

66 files changed

+563
-395
lines changed
 

‎compiler/rustc_ast/src/mut_visit.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,14 @@ fn walk_coroutine_kind<T: MutVisitor>(vis: &mut T, coroutine_kind: &mut Coroutin
954954

955955
fn walk_fn<T: MutVisitor>(vis: &mut T, kind: FnKind<'_>) {
956956
match kind {
957-
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span }, _visibility, generics, body) => {
957+
FnKind::Fn(
958+
_ctxt,
959+
_ident,
960+
_vis,
961+
Fn { defaultness, generics, body, sig: FnSig { header, decl, span } },
962+
) => {
958963
// Identifier and visibility are visited as a part of the item.
964+
visit_defaultness(vis, defaultness);
959965
vis.visit_fn_header(header);
960966
vis.visit_generics(generics);
961967
vis.visit_fn_decl(decl);
@@ -1205,13 +1211,8 @@ impl WalkItemKind for ItemKind {
12051211
ItemKind::Const(item) => {
12061212
visit_const_item(item, vis);
12071213
}
1208-
ItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
1209-
visit_defaultness(vis, defaultness);
1210-
vis.visit_fn(
1211-
FnKind::Fn(FnCtxt::Free, ident, sig, visibility, generics, body),
1212-
span,
1213-
id,
1214-
);
1214+
ItemKind::Fn(func) => {
1215+
vis.visit_fn(FnKind::Fn(FnCtxt::Free, ident, visibility, &mut *func), span, id);
12151216
}
12161217
ItemKind::Mod(safety, mod_kind) => {
12171218
visit_safety(vis, safety);
@@ -1329,10 +1330,9 @@ impl WalkItemKind for AssocItemKind {
13291330
AssocItemKind::Const(item) => {
13301331
visit_const_item(item, visitor);
13311332
}
1332-
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
1333-
visit_defaultness(visitor, defaultness);
1333+
AssocItemKind::Fn(func) => {
13341334
visitor.visit_fn(
1335-
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, visibility, generics, body),
1335+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, visibility, &mut *func),
13361336
span,
13371337
id,
13381338
);
@@ -1476,10 +1476,9 @@ impl WalkItemKind for ForeignItemKind {
14761476
visitor.visit_ty(ty);
14771477
visit_opt(expr, |expr| visitor.visit_expr(expr));
14781478
}
1479-
ForeignItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
1480-
visit_defaultness(visitor, defaultness);
1479+
ForeignItemKind::Fn(func) => {
14811480
visitor.visit_fn(
1482-
FnKind::Fn(FnCtxt::Foreign, ident, sig, visibility, generics, body),
1481+
FnKind::Fn(FnCtxt::Foreign, ident, visibility, &mut *func),
14831482
span,
14841483
id,
14851484
);
@@ -1965,14 +1964,7 @@ impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNo
19651964
#[derive(Debug)]
19661965
pub enum FnKind<'a> {
19671966
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
1968-
Fn(
1969-
FnCtxt,
1970-
&'a mut Ident,
1971-
&'a mut FnSig,
1972-
&'a mut Visibility,
1973-
&'a mut Generics,
1974-
&'a mut Option<P<Block>>,
1975-
),
1967+
Fn(FnCtxt, &'a mut Ident, &'a mut Visibility, &'a mut Fn),
19761968

19771969
/// E.g., `|x, y| body`.
19781970
Closure(

‎compiler/rustc_ast/src/visit.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl BoundKind {
6565
#[derive(Copy, Clone, Debug)]
6666
pub enum FnKind<'a> {
6767
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
68-
Fn(FnCtxt, &'a Ident, &'a FnSig, &'a Visibility, &'a Generics, &'a Option<P<Block>>),
68+
Fn(FnCtxt, &'a Ident, &'a Visibility, &'a Fn),
6969

7070
/// E.g., `|x, y| body`.
7171
Closure(&'a ClosureBinder, &'a Option<CoroutineKind>, &'a FnDecl, &'a Expr),
@@ -74,7 +74,7 @@ pub enum FnKind<'a> {
7474
impl<'a> FnKind<'a> {
7575
pub fn header(&self) -> Option<&'a FnHeader> {
7676
match *self {
77-
FnKind::Fn(_, _, sig, _, _, _) => Some(&sig.header),
77+
FnKind::Fn(_, _, _, Fn { sig, .. }) => Some(&sig.header),
7878
FnKind::Closure(..) => None,
7979
}
8080
}
@@ -88,7 +88,7 @@ impl<'a> FnKind<'a> {
8888

8989
pub fn decl(&self) -> &'a FnDecl {
9090
match self {
91-
FnKind::Fn(_, _, sig, _, _, _) => &sig.decl,
91+
FnKind::Fn(_, _, _, Fn { sig, .. }) => &sig.decl,
9292
FnKind::Closure(_, _, decl, _) => decl,
9393
}
9494
}
@@ -374,8 +374,8 @@ impl WalkItemKind for ItemKind {
374374
try_visit!(visitor.visit_ty(ty));
375375
visit_opt!(visitor, visit_expr, expr);
376376
}
377-
ItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
378-
let kind = FnKind::Fn(FnCtxt::Free, ident, sig, vis, generics, body);
377+
ItemKind::Fn(func) => {
378+
let kind = FnKind::Fn(FnCtxt::Free, ident, vis, &*func);
379379
try_visit!(visitor.visit_fn(kind, span, id));
380380
}
381381
ItemKind::Mod(_unsafety, mod_kind) => match mod_kind {
@@ -715,8 +715,8 @@ impl WalkItemKind for ForeignItemKind {
715715
try_visit!(visitor.visit_ty(ty));
716716
visit_opt!(visitor, visit_expr, expr);
717717
}
718-
ForeignItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
719-
let kind = FnKind::Fn(FnCtxt::Foreign, ident, sig, vis, generics, body);
718+
ForeignItemKind::Fn(func) => {
719+
let kind = FnKind::Fn(FnCtxt::Foreign, ident, vis, &*func);
720720
try_visit!(visitor.visit_fn(kind, span, id));
721721
}
722722
ForeignItemKind::TyAlias(box TyAlias {
@@ -858,7 +858,12 @@ pub fn walk_fn_decl<'a, V: Visitor<'a>>(
858858

859859
pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Result {
860860
match kind {
861-
FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span: _ }, _vis, generics, body) => {
861+
FnKind::Fn(
862+
_ctxt,
863+
_ident,
864+
_vis,
865+
Fn { defaultness: _, sig: FnSig { header, decl, span: _ }, generics, body },
866+
) => {
862867
// Identifier and visibility are visited as a part of the item.
863868
try_visit!(visitor.visit_fn_header(header));
864869
try_visit!(visitor.visit_generics(generics));
@@ -892,8 +897,8 @@ impl WalkItemKind for AssocItemKind {
892897
try_visit!(visitor.visit_ty(ty));
893898
visit_opt!(visitor, visit_expr, expr);
894899
}
895-
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
896-
let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body);
900+
AssocItemKind::Fn(func) => {
901+
let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, vis, &*func);
897902
try_visit!(visitor.visit_fn(kind, span, id));
898903
}
899904
AssocItemKind::Type(box TyAlias {

0 commit comments

Comments
 (0)
Please sign in to comment.