rust-lang / rust-lang/rust

shadowed traits from glob imports in the same scope get ignored

Open
#144,993 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-resolve C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

while glob imports from an outer/or nested scope do not

mod glob {
    pub trait Tr {
        fn method(&self) {}
    }
    impl Tr for () {}
}

// use glob::*; // ok
fn main() {
    // use glob::*; // error
    trait Tr {} // no method
    {
        use glob::*; // ok
        ().method();
    }
}

cc @petrochenkov. I want to make sure it's tracked somewhere outside of #144131. Also just really enjoyed learning about this current behavior and wanted to use my test somehow 😁

Originally posted by @lcnr in https://github.com/rust-lang/rust/pull/144131#discussion_r2256790398

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 with the Rust reproducer in the issue and compare glob-import trait resolution in the outer, nested, and same scopes. Read the discussion linked from PR #144131 to understand the existing behavior and intended resolution. Done means the same-scope case is handled consistently with the other scopes and the reproducer is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.