about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-05-19 11:04:09 -0400
committerGitHub <noreply@github.com>2024-05-19 11:04:09 -0400
commitb65fcda4d5dfa90f920170ab99e658b7cbc4a26f (patch)
tree538f7d609bfefcac0c1826ba9c22294c72fd9a57
parent0fd615f70e9482dbec68cc19f1126c4660e4f22a (diff)
parent5d03c3d3a5a16526fe9db57f7f022d3266e31ed1 (diff)
downloadrust-b65fcda4d5dfa90f920170ab99e658b7cbc4a26f.tar.gz
rust-b65fcda4d5dfa90f920170ab99e658b7cbc4a26f.zip
Rollup merge of #125270 - pietroalbini:pa-no-sad-contributors, r=Nilstrieb
Followup fixes from #123344

``@Nilstrieb`` doesn't deserve [to be sad](https://github.com/rust-lang/rust/pull/123344#issuecomment-2100978863), so this PR addresses the two pieces of feedback from that PR.

r? ``@Nilstrieb``
-rw-r--r--compiler/rustc_ast/src/ast.rs7
-rw-r--r--compiler/rustc_resolve/src/check_unused.rs12
2 files changed, 13 insertions, 6 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index 5d37bbd689f..1a166956075 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -2733,6 +2733,13 @@ pub enum UseTreeKind {
     /// `use prefix` or `use prefix as rename`
     Simple(Option<Ident>),
     /// `use prefix::{...}`
+    ///
+    /// The span represents the braces of the nested group and all elements within:
+    ///
+    /// ```text
+    /// use foo::{bar, baz};
+    ///          ^^^^^^^^^^
+    /// ```
     Nested { items: ThinVec<(UseTree, NodeId)>, span: Span },
     /// `use prefix::*`
     Glob,
diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs
index 5fe68085d65..180e7f6def3 100644
--- a/compiler/rustc_resolve/src/check_unused.rs
+++ b/compiler/rustc_resolve/src/check_unused.rs
@@ -299,13 +299,13 @@ fn calc_unused_spans(
 
             let mut unused_spans = Vec::new();
             let mut to_remove = Vec::new();
-            let mut used_childs = 0;
+            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) {
                     UnusedSpanResult::Used => {
-                        used_childs += 1;
+                        used_children += 1;
                         None
                     }
                     UnusedSpanResult::Unused { mut spans, remove } => {
@@ -313,7 +313,7 @@ fn calc_unused_spans(
                         Some(remove)
                     }
                     UnusedSpanResult::PartialUnused { mut spans, remove: mut to_remove_extra } => {
-                        used_childs += 1;
+                        used_children += 1;
                         unused_spans.append(&mut spans);
                         to_remove.append(&mut to_remove_extra);
                         None
@@ -322,7 +322,7 @@ fn calc_unused_spans(
                 if let Some(remove) = remove {
                     let remove_span = if nested.len() == 1 {
                         remove
-                    } else if pos == nested.len() - 1 || used_childs > 0 {
+                    } 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.span.shrink_to_hi().to(use_tree.span)
@@ -346,7 +346,7 @@ fn calc_unused_spans(
             }
             if unused_spans.is_empty() {
                 UnusedSpanResult::Used
-            } else if used_childs == 0 {
+            } else if used_children == 0 {
                 UnusedSpanResult::Unused { spans: unused_spans, remove: full_span }
             } else {
                 // If there is only one remaining child that is used, the braces around the use
@@ -360,7 +360,7 @@ fn calc_unused_spans(
                 // `self`: `use foo::{self};` is valid Rust syntax, while `use foo::self;` errors
                 // out. We also cannot turn `use foo::{self}` into `use foo`, as the former doesn't
                 // import types with the same name as the module.
-                if used_childs == 1 && !contains_self {
+                if used_children == 1 && !contains_self {
                     // Left brace, from the start of the nested group to the first item.
                     to_remove.push(
                         tree_span.shrink_to_lo().to(nested.first().unwrap().0.span.shrink_to_lo()),