From 31e863233872eb3f4239a25f42030c369c22d72b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 27 Sep 2024 11:21:48 -0700 Subject: [PATCH] Fix construction of UseGroup containing crate roots --- src/item.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/item.rs b/src/item.rs index aaee5ede1..819f0fbda 100644 --- a/src/item.rs +++ b/src/item.rs @@ -1411,14 +1411,16 @@ pub(crate) mod parsing { &content, allow_crate_root_in_path && !this_tree_starts_with_crate_root, )? { - Some(tree) => items.push_value(tree), - None => has_any_crate_root_in_path = true, + Some(tree) if !has_any_crate_root_in_path => items.push_value(tree), + _ => has_any_crate_root_in_path = true, } if content.is_empty() { break; } let comma: Token![,] = content.parse()?; - items.push_punct(comma); + if !has_any_crate_root_in_path { + items.push_punct(comma); + } } if has_any_crate_root_in_path { Ok(None)