rust-lang / rust-lang/rust

Conflicts in `#[macro_use] extern crate` imports are treated in ad hoc way

Open
#148,025 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-lang-radar needs-triage T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Currently, if the some name is imported by macro_use for the second time it overwrites the previous import with the same name, so the last name "wins".
(At least when the second macro_use comes from a macro such overwriting is reported as an error.)

Also there's no distinction between explicit macro_use(name) with arguments and "glob" macro_use without arguments, and a "glob" can overwrite an explicit import.

Typically, name resolution in rust doesn't behave this way.
Typically it is order-independent, explicit names shadow glob names, and glob ambiguities are reported as errors on use.

In practice, we should be able to adjust the rules for #[macro_use] extern crates to follow the usual name resolution practices without much breakage.

This is an issue to link from https://github.com/rust-lang/reference/pull/2057.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by investigating Rust name resolution for #[macro_use] extern crate imports, including explicit macro_use(name) and glob macro_use forms. Define the desired order-independent behavior, explicit-over-glob precedence, and treatment of glob ambiguities; done means the rules are specified and validated without the current ad hoc overwriting.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.