Skip to content

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

Open

Description

@lxl66566

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:

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:

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

Activity

  1. added
    C-bugCategory: Clippy is not doing the correct thing
    on Sep 27, 2026
  2. added
    I-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
    L-pedanticLint: Belongs in the pedantic lint group
    on Sep 27, 2026
  3. CommanderStorm commented on Sep 27, 2026

    @CommanderStorm
    Contributor

    (ICE seems most approriate label, is not quite the same.. I am aware)

  4. self-assigned this
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️L-pedanticLint: Belongs in the pedantic lint group

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions