diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 809b8b7f6a74d..5b9f3231fc744 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -3336,13 +3336,12 @@ pub enum UseTreeKind { /// use foo::{bar, baz}; /// ^^^^^^^^^^ /// ``` - Nested { items: ThinVec<(UseTree, NodeId)>, span: Span }, + Nested { items: ThinVec, span: Span }, /// `use prefix::*` Glob(Span), } /// A tree of paths sharing common prefixes. -/// Used in `use` items both at top-level and inside of braces in import groups. #[derive(Clone, Encodable, Decodable, Debug, Walkable)] pub struct UseTree { pub prefix: Path, @@ -3384,6 +3383,13 @@ impl UseTree { } } +/// Used in nested `use` trees. +#[derive(Clone, Encodable, Decodable, Debug, Walkable)] +pub struct UseTreeAndId { + pub inner: UseTree, + pub id: NodeId, +} + /// Distinguishes between `Attribute`s that decorate items and Attributes that /// are contained as statements within items. These two cases need to be /// distinguished for pretty-printing. diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index c12f24a7eff87..4270ac0656deb 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -347,7 +347,6 @@ macro_rules! for_each_ast_visit_hook { visit_mac_call(MacCall) => walk_mac; visit_macro_def(MacroDef) => walk_macro_def; visit_mut_restriction(MutRestriction) => walk_mut_restriction; - //visit_nested_use_tree((UseTree, NodeId)) => walk_nested_use_tree; visit_param(Param) => walk_param; visit_param_bound(GenericBound, _ctxt: BoundKind) => walk_param_bound; visit_pat(Pat) => walk_pat; @@ -368,6 +367,7 @@ macro_rules! for_each_ast_visit_hook { visit_ty(Ty) => walk_ty; visit_ty_pat(TyPat) => walk_ty_pat; visit_use_tree(UseTree) => walk_use_tree; + visit_use_tree_and_id(UseTreeAndId) => walk_use_tree_and_id; visit_variant(Variant) => walk_variant; visit_variant_data(VariantData) => walk_variant_data; visit_vis(Visibility) => walk_vis; @@ -477,6 +477,7 @@ macro_rules! common_visitor_and_walkers { ThinVec, ThinVec, ThinVec, + ThinVec, // tidy-alphabetical-end } @@ -681,13 +682,6 @@ macro_rules! common_visitor_and_walkers { fn visit_stmt(&mut self, s: &$lt Stmt) -> Self::Result { walk_stmt(self, s) } - - fn visit_nested_use_tree(&mut self, use_tree: &$lt UseTree, id: NodeId) - -> Self::Result - { - try_visit!(self.visit_id(id)); - self.visit_use_tree(use_tree) - } )? // `MutVisitor`-only methods @@ -812,14 +806,6 @@ macro_rules! common_visitor_and_walkers { ) -> V::Result; } - $(impl_visitable!(|&$lt self: ThinVec<(UseTree, NodeId)>, vis: &mut V| { - for (nested_tree, nested_id) in self { - try_visit!(vis.visit_nested_use_tree(nested_tree, *nested_id)); - } - V::Result::output() - });)? - $(${ignore($mut)} impl_visitable_list!(ThinVec<(UseTree, NodeId)>,);)? - fn walk_item_inner<$($lt,)? K: WalkItemKind, V: $Visitor$(<$lt>)?>( visitor: &mut V, item: &$($lt)? $($mut)? Item, diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index b8baf21898a96..cfb7d66656f82 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -680,7 +680,8 @@ impl<'hir> LoweringContext<'_, 'hir> { let prefix = Path { segments, span }; // Add all the nested `PathListItem`s to the HIR. - for &(ref use_tree, id) in trees { + for use_tree in trees { + let id = use_tree.id; let owner_id = self.owner_id(id); // Each `use` import is an item and thus are owners of the @@ -692,7 +693,8 @@ impl<'hir> LoweringContext<'_, 'hir> { // `prefix` is lowered multiple times, but in different HIR owners. // So each segment gets renewed `HirId` with the same // `ItemLocalId` and the new owner. (See `lower_node_id`) - let kind = this.lower_use_tree(use_tree, &prefix, id, vis_span, attrs); + let kind = + this.lower_use_tree(&use_tree.inner, &prefix, id, vis_span, attrs); if !attrs.is_empty() { this.curr_owner.attrs.insert(hir::ItemLocalId::ZERO, attrs); } @@ -701,7 +703,7 @@ impl<'hir> LoweringContext<'_, 'hir> { owner_id, kind, vis_span, - span: this.lower_span(use_tree.span()), + span: this.lower_span(use_tree.inner.span()), eii: find_attr!(attrs, EiiImpl(..) | EiiDeclaration(..)), }; hir::OwnerNode::Item(this.arena.alloc(item)) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1a351cc1420f3..20027ab68b9ea 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -674,12 +674,13 @@ fn index_ast<'tcx>( match tree.kind { UseTreeKind::Glob(_) | UseTreeKind::Simple(_) => {} UseTreeKind::Nested { items: ref nested_vec, span } => { - for &(ref nested, id) in nested_vec { + for nested in nested_vec { + let id = nested.id; self.insert(id, AstOwner::NestedUseTree(parent)); items.push(self.make_dummy(id, span, ItemKind::MacCall)); let def_id = self.owners[&id].def_id; - self.visit_item_id_use_tree(nested, def_id, items); + self.visit_item_id_use_tree(&nested.inner, def_id, items); } } } diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index ae13f627fcbe5..6ce34cecc7e97 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -911,14 +911,15 @@ impl<'a> State<'a> { } if items.is_empty() { self.word("{}"); - } else if let [(item, _)] = items.as_slice() + } else if let [item] = items.as_slice() && !item + .inner .prefix .segments .first() .is_some_and(|seg| seg.ident.name == rustc_span::symbol::kw::SelfLower) { - self.print_use_tree(item); + self.print_use_tree(&item.inner); } else { let cb = self.cbox(INDENT_UNIT); self.word("{"); @@ -926,10 +927,10 @@ impl<'a> State<'a> { let ib = self.ibox(0); for (idx, use_tree) in items.iter().enumerate() { let is_last = idx == items.len() - 1; - self.print_use_tree(&use_tree.0); + self.print_use_tree(&use_tree.inner); if !is_last { self.word(","); - if let ast::UseTreeKind::Nested { .. } = use_tree.0.kind { + if let ast::UseTreeKind::Nested { .. } = use_tree.inner.kind { self.hardbreak(); } else { self.space(); diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 80ea2e3d877fc..ef39ca049b811 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -2,7 +2,7 @@ use rustc_ast::token::{self, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::{ BinOpKind, BorrowKind, DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, - Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, + Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeAndId, UseTreeKind, }; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; @@ -97,14 +97,12 @@ impl<'cx, 'a> Context<'cx, 'a> { /// /// use ::core::asserting::{ ... }; fn build_initial_imports(&self) -> Stmt { - let nested_tree = |this: &Self, sym| { - ( - UseTree { - prefix: this.cx.path(this.span, vec![Ident::with_dummy_span(sym)]), - kind: UseTreeKind::Simple(None), - }, - DUMMY_NODE_ID, - ) + let nested_tree = |this: &Self, sym| UseTreeAndId { + inner: UseTree { + prefix: this.cx.path(this.span, vec![Ident::with_dummy_span(sym)]), + kind: UseTreeKind::Simple(None), + }, + id: DUMMY_NODE_ID, }; self.cx.stmt_item( self.span, diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index c58629111ac00..fc86bdfcf4f18 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1463,8 +1463,8 @@ impl DeclaredIdents for Box { ast::UseTreeKind::Glob(_) => {} ast::UseTreeKind::Simple(_) => idents.push(ut.ident()), ast::UseTreeKind::Nested { items, .. } => { - for (ut, _) in items { - collect_use_tree_leaves(ut, idents); + for tree in items { + collect_use_tree_leaves(&tree.inner, idents); } } } diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 7452e3e08ade9..17c078615c411 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1318,17 +1318,17 @@ impl UnusedImportBraces { fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) { if let ast::UseTreeKind::Nested { ref items, .. } = use_tree.kind { // Recursively check nested UseTrees - for (tree, _) in items { - self.check_use_tree(cx, tree, item); + for tree in items { + self.check_use_tree(cx, &tree.inner, item); } // Trigger the lint only if there is one nested item - let [(tree, _)] = items.as_slice() else { return }; + let [tree] = items.as_slice() else { return }; // Trigger the lint if the nested item is a non-self single item - let node_name = match tree.kind { + let node_name = match tree.inner.kind { ast::UseTreeKind::Simple(rename) => { - let orig_ident = tree.prefix.segments.last().unwrap().ident; + let orig_ident = tree.inner.prefix.segments.last().unwrap().ident; if orig_ident.name == kw::SelfLower { return; } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index d4717b88bbb14..2ab012e0ecc2f 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1368,7 +1368,7 @@ impl<'a> Parser<'a> { &mut self, use_token_span: Span, prefix: Option<&'b UsePathList<'b>>, - ) -> PResult<'a, ThinVec<(UseTree, ast::NodeId)>> { + ) -> PResult<'a, ThinVec> { self.parse_delim_comma_seq(exp!(OpenBrace), exp!(CloseBrace), |p| { p.recover_vcs_conflict_marker(); @@ -1386,7 +1386,7 @@ impl<'a> Parser<'a> { p.emit_error_attr_in_use_tree(use_token_span, prefix, use_tree.span(), attr_span); } - Ok((use_tree, DUMMY_NODE_ID)) + Ok(UseTreeAndId { inner: use_tree, id: DUMMY_NODE_ID }) }) .map(|(r, _)| r) } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index bf0a6d7ee3b49..33bed2eb46c9f 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -583,16 +583,17 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { } } + /// Note: + /// - `item` is the top-level `use` item. + /// - `use_tree` is the particular use tree within the top-level `use` item. fn build_reduced_graph_for_use_tree( &mut self, - // This particular use tree + item: &Item, use_tree: &ast::UseTree, id: NodeId, parent_prefix: &[Segment], nested: bool, list_stem: bool, - // The whole `use` item - item: &Item, vis: Visibility, root_span: Span, feed: TyCtxtFeed<'tcx, LocalDefId>, @@ -753,12 +754,19 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { } } ast::UseTreeKind::Nested { ref items, .. } => { - for &(ref tree, id) in items { + for tree in items { + let id = tree.id; self.with_owner(id, None, DefKind::Use, use_tree.span(), |this, feed| { this.build_reduced_graph_for_use_tree( - // This particular use tree - tree, id, &prefix, true, false, // The whole `use` item - item, vis, root_span, feed, + item, + &tree.inner, + id, + &prefix, + true, + false, + vis, + root_span, + feed, ) }); } @@ -775,20 +783,11 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { prefix: ast::Path::from_ident(Ident::new(kw::SelfLower, new_span)), kind: ast::UseTreeKind::Simple(Some(Ident::new(kw::Underscore, new_span))), }; + let vis = Visibility::Restricted( + self.parent_scope.module.nearest_parent_mod().expect_local(), + ); self.build_reduced_graph_for_use_tree( - // This particular use tree - &tree, - id, - &prefix, - true, - true, - // The whole `use` item - item, - Visibility::Restricted( - self.parent_scope.module.nearest_parent_mod().expect_local(), - ), - root_span, - feed, + item, &tree, id, &prefix, true, true, vis, root_span, feed, ); } } @@ -835,14 +834,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { match item.kind { ItemKind::Use(ref use_tree) => { self.build_reduced_graph_for_use_tree( - // This particular use tree + item, use_tree, item.id, &[], false, false, - // The whole `use` item - item, vis, use_tree.span(), feed, diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 8337b2848edc3..fdac03a8f7163 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -148,9 +148,9 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> { } } - fn check_imports_as_underscore(&mut self, items: &[(ast::UseTree, ast::NodeId)]) { - for (item, id) in items { - self.check_import_as_underscore(item, *id); + fn check_imports_as_underscore(&mut self, items: &[ast::UseTreeAndId]) { + for use_tree in items { + self.check_import_as_underscore(&use_tree.inner, use_tree.id); } } @@ -247,10 +247,9 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for UnusedImportCheckVisitor<'a, 'ra, 'tcx> { fn visit_item(&mut self, item: &'a ast::Item) { self.item_span = item.span_with_attributes(); match &item.kind { - // Ignore is_public import statements because there's no way to be sure - // whether they're used or not. Also ignore imports with a dummy span - // because this means that they were generated in some fashion by the - // compiler and we don't need to consider them. + // Ignore imports with a dummy span because this means that they + // were generated in some fashion by the compiler and we don't need + // to consider them. ast::ItemKind::Use(..) if item.span.is_dummy() => return, // Use the base UseTree's NodeId as the item id // This allows the grouping of all the lints in the same item @@ -276,9 +275,9 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for UnusedImportCheckVisitor<'a, 'ra, 'tcx> { visit::walk_item(self, item); } - fn visit_nested_use_tree(&mut self, use_tree: &'a ast::UseTree, id: ast::NodeId) { - self.check_use_tree(use_tree, id); - visit::walk_use_tree(self, use_tree); + fn visit_use_tree_and_id(&mut self, tree: &'a ast::UseTreeAndId) { + self.check_use_tree(&tree.inner, tree.id); + visit::walk_use_tree_and_id(self, tree); } } @@ -321,8 +320,8 @@ fn calc_unused_spans( let mut used_children = 0; let mut contains_self = false; let mut previous_unused = false; - for (pos, (use_tree, use_tree_id)) in nested.iter().enumerate() { - let remove = match calc_unused_spans(unused_import, use_tree, *use_tree_id) { + for (pos, use_tree) in nested.iter().enumerate() { + let remove = match calc_unused_spans(unused_import, &use_tree.inner, use_tree.id) { UnusedSpanResult::Used => { used_children += 1; None @@ -344,10 +343,11 @@ fn calc_unused_spans( } else if pos == nested.len() - 1 || used_children > 0 { // Delete everything from the end of the last import, to delete the // previous comma - nested[pos - 1].0.hi_span().shrink_to_hi().to(use_tree.hi_span()) + nested[pos - 1].inner.hi_span().shrink_to_hi().to(use_tree.inner.hi_span()) } else { // Delete everything until the next import, to delete the trailing commas - use_tree.prefix.span.to(nested[pos + 1].0.prefix.span.shrink_to_lo()) + let inner = &nested[pos + 1].inner; + use_tree.inner.prefix.span.to(inner.prefix.span.shrink_to_lo()) }; // Try to collapse adjacent spans into a single one. This prevents all cases of @@ -359,9 +359,9 @@ fn calc_unused_spans( to_remove.push(remove_span); } } - contains_self |= use_tree.prefix == kw::SelfLower - && matches!(use_tree.kind, ast::UseTreeKind::Simple(_)) - && !unused_import.unused.contains(&use_tree_id); + contains_self |= use_tree.inner.prefix == kw::SelfLower + && matches!(use_tree.inner.kind, ast::UseTreeKind::Simple(_)) + && !unused_import.unused.contains(&use_tree.id); previous_unused = remove.is_some(); } if unused_spans.is_empty() { @@ -386,7 +386,7 @@ fn calc_unused_spans( tree_span.shrink_to_lo().to(nested .first() .unwrap() - .0 + .inner .prefix .span .shrink_to_lo()), @@ -396,7 +396,7 @@ fn calc_unused_spans( nested .last() .unwrap() - .0 + .inner .hi_span() .shrink_to_hi() .to(tree_span.shrink_to_hi()), diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 095d5131c0b60..dd1e4c0344418 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2850,8 +2850,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } } else if let UseTreeKind::Nested { items, .. } = &use_tree.kind { - for (use_tree, _) in items { - self.future_proof_import(use_tree); + for use_tree in items { + self.future_proof_import(&use_tree.inner); } } } diff --git a/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs b/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs index 837aefc767c8c..dfcab8c74434a 100644 --- a/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs +++ b/src/tools/clippy/clippy_lints/src/single_component_path_imports.rs @@ -209,15 +209,15 @@ impl SingleComponentPathImports { // keep track of `use {some_module, some_other_module};` usages if let UseTreeKind::Nested { items, .. } = &use_tree.kind { for tree in items { - let segments = &tree.0.prefix.segments; + let segments = &tree.inner.prefix.segments; if segments.len() == 1 - && let UseTreeKind::Simple(None) = tree.0.kind + && let UseTreeKind::Simple(None) = tree.inner.kind { let name = segments[0].ident.name; if !macros.contains(&name) { single_use_usages.push(SingleUse { name, - span: tree.0.span(), + span: tree.inner.span(), item_id: item.id, can_suggest: false, }); @@ -237,7 +237,7 @@ impl SingleComponentPathImports { // nested case such as `use self::{module1::Struct1, module2::Struct2}` if let UseTreeKind::Nested { items, .. } = &use_tree.kind { for tree in items { - let segments = &tree.0.prefix.segments; + let segments = &tree.inner.prefix.segments; if !segments.is_empty() { imports_reused_with_self.push(segments[0].ident.name); } diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_self_imports.rs b/src/tools/clippy/clippy_lints/src/unnecessary_self_imports.rs index 677a459a03c7b..cd31d728ead14 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_self_imports.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_self_imports.rs @@ -104,18 +104,18 @@ struct SelfImport<'a> { fn for_each_self_import<'a>(tree: &'a UseTree, emit_lint: impl Fn(SelfImport<'a>) + Copy) { fn inner<'a>(tree: &'a UseTree, emit_lint: impl Fn(SelfImport<'a>) + Copy, is_toplevel: bool) { if let UseTreeKind::Nested { items, .. } = &tree.kind { - if let [(self_tree, _)] = &**items - && let [self_seg] = &*self_tree.prefix.segments + if let [self_tree] = &**items + && let [self_seg] = &*self_tree.inner.prefix.segments && self_seg.ident.name == kw::SelfLower { emit_lint(SelfImport { tree, - self_tree, + self_tree: &self_tree.inner, is_toplevel, }); } else { - for (subtree, _) in &**items { - inner(subtree, emit_lint, false); + for subtree in &**items { + inner(&subtree.inner, emit_lint, false); } } } diff --git a/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs b/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs index 8756a09d56b47..20b5d36b8d5f3 100644 --- a/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs +++ b/src/tools/clippy/clippy_lints/src/unsafe_removed_from_name.rs @@ -52,8 +52,8 @@ fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext<'_>, span: Span) { }, UseTreeKind::Simple(None) | UseTreeKind::Glob(_) => {}, UseTreeKind::Nested { ref items, .. } => { - for (use_tree, _) in items { - check_use_tree(use_tree, cx, span); + for use_tree in items { + check_use_tree(&use_tree.inner, cx, span); } }, } diff --git a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs index c340c56781082..74be29dbb38c0 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs @@ -778,7 +778,9 @@ fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool { match (l, r) { (Glob(_), Glob(_)) => true, (Simple(l), Simple(r)) => both(l.as_ref(), r.as_ref(), |l, r| eq_id(*l, *r)), - (Nested { items: l, .. }, Nested { items: r, .. }) => over(l, r, |(l, _), (r, _)| eq_use_tree(l, r)), + (Nested { items: l, .. }, Nested { items: r, .. }) => { + over(l, r, |l, r| eq_use_tree(&l.inner, &r.inner)) + } _ => false, } } diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs index c5a2a5de2f175..f062eaa332d92 100644 --- a/src/tools/rustfmt/src/imports.rs +++ b/src/tools/rustfmt/src/imports.rs @@ -477,7 +477,7 @@ impl UseTree { // This needs to be done before sorting use items. let items = itemize_list( context.snippet_provider, - list.iter().map(|(tree, _)| tree), + list.iter().map(|tree| &tree.inner), "}", ",", |tree| tree.prefix.span.lo(), @@ -501,7 +501,7 @@ impl UseTree { list.iter() .zip(items) .map(|(t, list_item)| { - Self::from_ast(context, &t.0, Some(list_item), None, None, None) + Self::from_ast(context, &t.inner, Some(list_item), None, None, None) }) .collect(), );