From db08c17693478408b6fcc71bf7c95e735c4aac19 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 27 Aug 2024 21:20:41 +0000 Subject: [PATCH] Review comments. --- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_resolve/src/def_collector.rs | 22 +++++++++------------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 480d2f38d5f5a..7b041768983e6 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -76,7 +76,7 @@ impl<'a> FnKind<'a> { pub fn header(&self) -> Option<&'a FnHeader> { match *self { FnKind::Fn(_, _, sig, _, _, _) => Some(&sig.header), - FnKind::Closure(_, _, _, _) => None, + FnKind::Closure(..) => None, } } diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 833ab3812af50..ab38b528e9f36 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1404,7 +1404,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let ident = Ident::new(name, span); let (param, bounds, path) = self.lower_universal_param_and_bounds( *def_node_id, - t.span, + span, ident, bounds, ); diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index bc86259f4e9b3..23d2b477d5434 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -182,18 +182,6 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { } fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { - let walk_fn_decl = |this: &mut Self, - coroutine_kind: CoroutineKind, - FnDecl { inputs, output }: &'a FnDecl| { - for param in inputs { - this.visit_param(param); - } - - let (return_id, return_span) = coroutine_kind.return_id(); - let return_def = this.create_def(return_id, kw::Empty, DefKind::OpaqueTy, return_span); - this.with_parent(return_def, |this| this.visit_fn_ret_ty(output)); - }; - match fn_kind { FnKind::Fn(_ctxt, _ident, FnSig { header, decl, span: _ }, _vis, generics, body) if let Some(coroutine_kind) = header.coroutine_kind => @@ -204,7 +192,15 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { // For async functions, we need to create their inner defs inside of a // closure to match their desugared representation. Besides that, // we must mirror everything that `visit::walk_fn` below does. - walk_fn_decl(self, coroutine_kind, decl); + let FnDecl { inputs, output } = &**decl; + for param in inputs { + self.visit_param(param); + } + + let (return_id, return_span) = coroutine_kind.return_id(); + let return_def = + self.create_def(return_id, kw::Empty, DefKind::OpaqueTy, return_span); + self.with_parent(return_def, |this| this.visit_fn_ret_ty(output)); // If this async fn has no body (i.e. it's an async fn signature in a trait) // then the closure_def will never be used, and we should avoid generating a