Skip to content

Commit

Permalink
Review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Aug 27, 2024
1 parent 9883151 commit db08c17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
22 changes: 9 additions & 13 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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
Expand Down

0 comments on commit db08c17

Please sign in to comment.