Skip to content

Derive macro glob import flagged as ambiguous with implicit prelude import #150165

@jgeibel-burns

Description

@jgeibel-burns

Code

I tried this code:

use derive_more::From; // version = "2.1.0", features = ["from"]

mod inner {
    use super::*;
    
    #[derive(From)]
    struct Demo {
        one: u8,
        two: u8,
    }
}

I expected to see this happen: compile successfully, matching the behavior on stable and nightly-2025-12-14. I expect that implicit imports from the prelude would be lower priority (and thus not ambiguous) compared to glob imports written by the user.

Instead, this happened:

$ cargo +nightly-2025-12-15 check
error[E0659]: `From` is ambiguous
 --> src/lib.rs:6:14
  |
6 |     #[derive(From)]
  |              ^^^^ 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: `From` could refer to the derive macro imported here
 --> src/lib.rs:4:9
  |
4 |     use super::*;
  |         ^^^^^^^^
  = help: consider adding an explicit import of `From` to disambiguate
  = help: or use `self::From` to refer to this derive macro unambiguously
note: `From` could also refer to a derive macro from prelude
 --> library/std/src/prelude/mod.rs:161:12

For more information about this error, try `rustc --explain E0659`.
error: could not compile `rust-nightly-2025-12-17-breakage-demo` (lib) due to 1 previous error

Version it worked on

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

Version with regression

cargo +nightly-2025-12-15 --version --verbose:

cargo 1.94.0-nightly (e91b2baa6 2025-12-13)
release: 1.94.0-nightly
commit-hash: e91b2baa632c0c7e84216c91ecfe107c37d887c1
commit-date: 2025-12-13
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Ubuntu 26.4.0 (resolute) [64-bit]

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.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