- let mut resolutions = self.expect_full_res_from_use(id).fuse();
- // We want to return *something* from this function, so hold onto the first item
- // for later.
- let ret_res = self.lower_res(resolutions.next().unwrap_or(Res::Err));
-
- // Here, we are looping over namespaces, if they exist for the definition
- // being imported. We only handle type and value namespaces because we
- // won't be dealing with macros in the rest of the compiler.
- // Essentially a single `use` which imports two names is desugared into
- // two imports.
- for new_node_id in [id1, id2] {
- let new_id = self.local_def_id(new_node_id);
- let Some(res) = resolutions.next() else {
- debug_assert!(self.children.iter().find(|(id, _)| id == &new_id).is_none());
- // Associate an HirId to both ids even if there is no resolution.
- self.children.push((
- new_id,
- hir::MaybeOwner::NonOwner(hir::HirId::make_owner(new_id))),
- );
- continue;
- };
- let ident = *ident;
- let mut path = path.clone();
- for seg in &mut path.segments {
- // Give the cloned segment the same resolution information
- // as the old one (this is needed for stability checking).
- let new_id = self.next_node_id();
- self.resolver.clone_res(seg.id, new_id);
- seg.id = new_id;
- }
- let span = path.span;
-
- self.with_hir_id_owner(new_node_id, |this| {
- let res = this.lower_res(res);
- let path = this.lower_path_extra(res, &path, ParamMode::Explicit);
- let kind = hir::ItemKind::Use(path, hir::UseKind::Single);
- if let Some(attrs) = attrs {
- this.attrs.insert(hir::ItemLocalId::new(0), attrs);
- }
-
- let item = hir::Item {
- owner_id: hir::OwnerId { def_id: new_id },
- ident: this.lower_ident(ident),
- kind,
- vis_span,
- span: this.lower_span(span),
- };
- hir::OwnerNode::Item(this.arena.alloc(item))
- });
- }
-
- let path = self.lower_path_extra(ret_res, &path, ParamMode::Explicit);