diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
commit | 4547b622d8d29df964fa2914213088b148c498fc (patch) | |
tree | 9fc6b25f3c3add6b745be9a2400a6e96140046e9 /compiler/rustc_resolve/src/def_collector.rs | |
parent | Releasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz rustc-4547b622d8d29df964fa2914213088b148c498fc.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_resolve/src/def_collector.rs')
-rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index d36e0f61d..2764a6c28 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -118,8 +118,8 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { match i.kind { ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => { // If this is a unit or tuple-like struct, register the constructor. - if let Some(ctor_hir_id) = struct_def.ctor_id() { - this.create_def(ctor_hir_id, DefPathData::Ctor, i.span); + if let Some(ctor_node_id) = struct_def.ctor_node_id() { + this.create_def(ctor_node_id, DefPathData::Ctor, i.span); } } _ => {} @@ -131,12 +131,9 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { if let FnKind::Fn(_, _, sig, _, generics, body) = fn_kind { - if let Async::Yes { closure_id, return_impl_trait_id, .. } = sig.header.asyncness { + if let Async::Yes { closure_id, .. } = sig.header.asyncness { self.visit_generics(generics); - let return_impl_trait_id = - self.create_def(return_impl_trait_id, DefPathData::ImplTrait, span); - // 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. @@ -144,9 +141,7 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { for param in &sig.decl.inputs { self.visit_param(param); } - self.with_parent(return_impl_trait_id, |this| { - this.visit_fn_ret_ty(&sig.decl.output) - }); + self.visit_fn_ret_ty(&sig.decl.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 // def-id for it. @@ -163,14 +158,6 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) { self.create_def(id, DefPathData::Use, use_tree.span); - match use_tree.kind { - UseTreeKind::Simple(_, id1, id2) => { - self.create_def(id1, DefPathData::Use, use_tree.prefix.span); - self.create_def(id2, DefPathData::Use, use_tree.prefix.span); - } - UseTreeKind::Glob => (), - UseTreeKind::Nested(..) => {} - } visit::walk_use_tree(self, use_tree, id); } @@ -196,8 +183,8 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { } let def = self.create_def(v.id, DefPathData::TypeNs(v.ident.name), v.span); self.with_parent(def, |this| { - if let Some(ctor_hir_id) = v.data.ctor_id() { - this.create_def(ctor_hir_id, DefPathData::Ctor, v.span); + if let Some(ctor_node_id) = v.data.ctor_node_id() { + this.create_def(ctor_node_id, DefPathData::Ctor, v.span); } visit::walk_variant(this, v) }); @@ -262,11 +249,11 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> { fn visit_expr(&mut self, expr: &'a Expr) { let parent_def = match expr.kind { ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id), - ExprKind::Closure(_, _, asyncness, ..) => { + ExprKind::Closure(ref closure) => { // Async closures desugar to closures inside of closures, so // we must create two defs. let closure_def = self.create_def(expr.id, DefPathData::ClosureExpr, expr.span); - match asyncness { + match closure.asyncness { Async::Yes { closure_id, .. } => { self.create_def(closure_id, DefPathData::ClosureExpr, expr.span) } |