Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: da5a69d
Choose a base ref
...
head repository: rust-lang/rust
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a978e7c
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on May 15, 2025

  1. Permit duplicate macro imports

    Consider a crate that depends on both `serde` (without the `derive`
    feature) and `serde_derive`, and imports `serde::Serialize` (a trait)
    and `serde_derive::Serialize` (a macro). Then, imagine some other crate
    in a build graph depends on `serde` *with* the `derive` feature; they
    import both the macro and trait simultaneously with `use
    serde::Serialize`. If duplicate imports of the same item are always
    forbidden, these crates cannot co-exist in the same build-graph; the
    former crate will fail to build, as its first import (which will now
    also import the `Serialize` macro) conflicts with its second import.
    
    This build hazard is confusing — the author of the second crate had no
    idea that their dependence on the `derive` feature might be problematic
    for other crates. The author of the first crate can mitigate the hazard
    by only glob-importing from proc-macro crates, but glob imports run
    against many's personal preference and tooling affordances (e.g.,
    `rust-analyzer`'s auto-import feature).
    
    We mitigate this hazard across the ecosystem by permitting duplicate
    imports of macros. We don't limit this exception to proc macros, as it
    should not be a breaking change to rewrite a proc macro into a
    by-example macro. Although it would be semantically unproblematic to
    permit *all* duplicate imports (not just those of macros), other kinds
    of imports have not, in practice, posed the same hazard, and there might
    be cases we'd like to warn-by-default against. For now, we only permit
    duplicate macro imports.
    
    See https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Allowing.20same-name.20imports.20of.20the.20same.20item/near/516777221
    jswrenn committed May 15, 2025
    Configuration menu
    Copy the full SHA
    a978e7c View commit details
    Browse the repository at this point in the history
Loading