Skip to content

Glob import causes ambiguity on nightly #145575

@Dasaav-dsv

Description

@Dasaav-dsv

On nightly, using std is now rejected due to ambiguity when there is a glob import from a module that exports std

This affects the following crates:
CasualX/pelite#287

May be related to #145524

Code

I tried this code:

extern crate no_std_compat as std;

mod inner {
    use crate::*;
    use std::str;
}

fn main() {
    println!("Hello, world!");
}

I expected to see this happen: Code is accepted on stable and nightly.

Instead, this happened: Code was accepted on stable, but rejected on nightly (starting from nightly-2025-08-15).

error[E0659]: `std` is ambiguous
 --> src\main.rs:5:9
  |
5 |     use std::str;
  |         ^^^ ambiguous name
  |
  = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
  = note: `std` could refer to a built-in crate
  = help: use `::std` to refer to this crate unambiguously
note: `std` could also refer to the crate imported here
 --> src\main.rs:4:9
  |
4 |     use crate::*;
  |         ^^^^^^^^
  = help: consider adding an explicit import of `std` to disambiguate
  = help: or use `self::std` to refer to this crate unambiguously

Version it worked on

It most recently worked on: nightly-2025-08-14

Version with regression

rustc --version --verbose:

$ rustc +nightly-2025-08-15 -vV    
rustc 1.91.0-nightly (898aff704 2025-08-14)
binary: rustc
commit-hash: 898aff704d6f0d00343f21d31b8b9bfac8e43007
commit-date: 2025-08-14
host: x86_64-pc-windows-msvc
release: 1.91.0-nightly
LLVM version: 21.1.0

@rustbot modify labels: +regression-from-stable-to-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions