#17799·rust-clippy

wildcard_imports: infinite loop and unbounded memory growth on macro-generated glob imports

Author: lxl66566Created Sep 27, 2026Updated Sep 29, 2026
LabelsC-bugI-ICEL-pedantic

Summary

Since nightly-2026-09-26, wildcard_imports can loop forever on macro-generated glob imports.

rust-lang/rust@9f9771dc7e introduced this unbounded loop in check_use_tree:

rust
while !snippet(cx, span, "").ends_with('*') {
    span = use_path.span.with_hi(span.hi() + BytePos(1));
}

check_use_tree now extends the use-path span byte-by-byte until its snippet ends with *, but for a macro-generated import the prefix span points at call-site text while the * only exists inside the macro definition, so the walk can never find it; once the span passes EOF, snippet falls back to "" and the loop is infinite. The process spins one core at 100% and on larger crates keeps growing memory.

Reproducer

main.rs:

rust
macro_rules! glob_import {
    ($p:path) => {
        #[allow(unused_imports)]
        use $p::*;
        #[allow(dead_code)]
        fn __glob_used(_e: Error) {}
    };
}

glob_import!(std::io);

then runs clippy-driver main.rs --crate-type lib -W clippy::wildcard-imports.

Current output

clippy-driver never terminates; one CPU core spins at 100%. On a large project memory grows steadily. Adding any * character after the invocation (even in a comment) makes it complete instantly.

This behavior could be found in any tauri 2.x project, where #[tauri::command] + generate_handler! expands a local macro_rules! containing use ::tauri::ipc::private::*;, making cargo clippy hang.

Desired output

warning: usage of wildcard import
...

Version

First bad: nightly-2026-09-26, clippy 0.1.100 (75a75c3e0a 2026-09-26)

Last good: nightly-2026-09-25, clippy 0.1.100 (f7575a9da8 2026-09-24)

Additional Labels

No response