Skip to content

Commit b65fcda

Browse files
Rollup merge of rust-lang#125270 - pietroalbini:pa-no-sad-contributors, r=Nilstrieb
Followup fixes from rust-lang#123344 ``@Nilstrieb`` doesn't deserve [to be sad](rust-lang#123344 (comment)), so this PR addresses the two pieces of feedback from that PR. r? ``@Nilstrieb``
2 parents 0fd615f + 5d03c3d commit b65fcda

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_ast/src/ast.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,13 @@ pub enum UseTreeKind {
27332733
/// `use prefix` or `use prefix as rename`
27342734
Simple(Option<Ident>),
27352735
/// `use prefix::{...}`
2736+
///
2737+
/// The span represents the braces of the nested group and all elements within:
2738+
///
2739+
/// ```text
2740+
/// use foo::{bar, baz};
2741+
/// ^^^^^^^^^^
2742+
/// ```
27362743
Nested { items: ThinVec<(UseTree, NodeId)>, span: Span },
27372744
/// `use prefix::*`
27382745
Glob,

compiler/rustc_resolve/src/check_unused.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,21 @@ fn calc_unused_spans(
299299

300300
let mut unused_spans = Vec::new();
301301
let mut to_remove = Vec::new();
302-
let mut used_childs = 0;
302+
let mut used_children = 0;
303303
let mut contains_self = false;
304304
let mut previous_unused = false;
305305
for (pos, (use_tree, use_tree_id)) in nested.iter().enumerate() {
306306
let remove = match calc_unused_spans(unused_import, use_tree, *use_tree_id) {
307307
UnusedSpanResult::Used => {
308-
used_childs += 1;
308+
used_children += 1;
309309
None
310310
}
311311
UnusedSpanResult::Unused { mut spans, remove } => {
312312
unused_spans.append(&mut spans);
313313
Some(remove)
314314
}
315315
UnusedSpanResult::PartialUnused { mut spans, remove: mut to_remove_extra } => {
316-
used_childs += 1;
316+
used_children += 1;
317317
unused_spans.append(&mut spans);
318318
to_remove.append(&mut to_remove_extra);
319319
None
@@ -322,7 +322,7 @@ fn calc_unused_spans(
322322
if let Some(remove) = remove {
323323
let remove_span = if nested.len() == 1 {
324324
remove
325-
} else if pos == nested.len() - 1 || used_childs > 0 {
325+
} else if pos == nested.len() - 1 || used_children > 0 {
326326
// Delete everything from the end of the last import, to delete the
327327
// previous comma
328328
nested[pos - 1].0.span.shrink_to_hi().to(use_tree.span)
@@ -346,7 +346,7 @@ fn calc_unused_spans(
346346
}
347347
if unused_spans.is_empty() {
348348
UnusedSpanResult::Used
349-
} else if used_childs == 0 {
349+
} else if used_children == 0 {
350350
UnusedSpanResult::Unused { spans: unused_spans, remove: full_span }
351351
} else {
352352
// If there is only one remaining child that is used, the braces around the use
@@ -360,7 +360,7 @@ fn calc_unused_spans(
360360
// `self`: `use foo::{self};` is valid Rust syntax, while `use foo::self;` errors
361361
// out. We also cannot turn `use foo::{self}` into `use foo`, as the former doesn't
362362
// import types with the same name as the module.
363-
if used_childs == 1 && !contains_self {
363+
if used_children == 1 && !contains_self {
364364
// Left brace, from the start of the nested group to the first item.
365365
to_remove.push(
366366
tree_span.shrink_to_lo().to(nested.first().unwrap().0.span.shrink_to_lo()),

0 commit comments

Comments
 (0)