diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index e4d1ee195c4..e105452e1c5 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -155,14 +155,10 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { ) }; - let imports_string = if used_imports.len() == 1 { - used_imports.iter().next().unwrap().to_string() + let mut imports = used_imports.items().map(ToString::to_string).into_sorted_stable_ord(false); + let imports_string = if imports.len() == 1 { + imports.pop().unwrap() } else { - let mut imports = used_imports - .iter() - .map(ToString::to_string) - .collect::>(); - imports.sort(); if braced_glob { imports.join(", ") } else {