From 829338a64016cd50fc766649d53cf5ea0b27284f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 1 Apr 2024 23:38:18 +0200 Subject: [PATCH] add enum variant field names to make the code clearer --- compiler/rustc_resolve/src/check_unused.rs | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index f6004fed828..fdec48fe26a 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -268,9 +268,9 @@ fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: ast::NodeId, nested enum UnusedSpanResult { Used, - FlatUnused(Span, Span), - NestedFullUnused(Vec, Span), - NestedPartialUnused(Vec, Vec), + FlatUnused { span: Span, remove: Span }, + NestedFullUnused { spans: Vec, remove: Span }, + NestedPartialUnused { spans: Vec, remove: Vec }, } fn calc_unused_spans( @@ -288,14 +288,14 @@ fn calc_unused_spans( match use_tree.kind { ast::UseTreeKind::Simple(..) | ast::UseTreeKind::Glob => { if unused_import.unused.contains(&use_tree_id) { - UnusedSpanResult::FlatUnused(use_tree.span, full_span) + UnusedSpanResult::FlatUnused { span: use_tree.span, remove: full_span } } else { UnusedSpanResult::Used } } ast::UseTreeKind::Nested(ref nested) => { if nested.is_empty() { - return UnusedSpanResult::FlatUnused(use_tree.span, full_span); + return UnusedSpanResult::FlatUnused { span: use_tree.span, remove: full_span }; } let mut unused_spans = Vec::new(); @@ -308,15 +308,15 @@ fn calc_unused_spans( all_nested_unused = false; None } - UnusedSpanResult::FlatUnused(span, remove) => { + UnusedSpanResult::FlatUnused { span, remove } => { unused_spans.push(span); Some(remove) } - UnusedSpanResult::NestedFullUnused(mut spans, remove) => { + UnusedSpanResult::NestedFullUnused { mut spans, remove } => { unused_spans.append(&mut spans); Some(remove) } - UnusedSpanResult::NestedPartialUnused(mut spans, mut to_remove_extra) => { + UnusedSpanResult::NestedPartialUnused { mut spans, remove: mut to_remove_extra } => { all_nested_unused = false; unused_spans.append(&mut spans); to_remove.append(&mut to_remove_extra); @@ -349,9 +349,9 @@ fn calc_unused_spans( if unused_spans.is_empty() { UnusedSpanResult::Used } else if all_nested_unused { - UnusedSpanResult::NestedFullUnused(unused_spans, full_span) + UnusedSpanResult::NestedFullUnused { spans: unused_spans, remove: full_span } } else { - UnusedSpanResult::NestedPartialUnused(unused_spans, to_remove) + UnusedSpanResult::NestedPartialUnused { spans: unused_spans, remove: to_remove } } } } @@ -417,15 +417,15 @@ pub(crate) fn check_unused(&mut self, krate: &ast::Crate) { let mut fixes = Vec::new(); let spans = match calc_unused_spans(unused, &unused.use_tree, unused.use_tree_id) { UnusedSpanResult::Used => continue, - UnusedSpanResult::FlatUnused(span, remove) => { + UnusedSpanResult::FlatUnused { span, remove } => { fixes.push((remove, String::new())); vec![span] } - UnusedSpanResult::NestedFullUnused(spans, remove) => { + UnusedSpanResult::NestedFullUnused { spans, remove } => { fixes.push((remove, String::new())); spans } - UnusedSpanResult::NestedPartialUnused(spans, remove) => { + UnusedSpanResult::NestedPartialUnused { spans, remove } => { for fix in &remove { fixes.push((*fix, String::new())); }