Skip to content

In-scope traits are leaking beyond imports #10465

Closed
@alexcrichton

Description

@alexcrichton
pub mod a {
    pub trait A {
        fn foo(&self);
    }

}
pub mod b {
    use a::A;

    pub struct B;
    impl A for B { fn foo(&self) {} }

    pub mod c {
        use b::B;

        fn foo(b: &B) {
            b.foo(); // trait A is not in scope at this location
        }
    }

}

fn main() {}

That code compiles successfully, but I don't believe that it should. A the commented line, the trait A is not in scope for the module c, so I should get an error that b doesn't have any method named foo in scope.

Nominating, this is a backwards-compatibility issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions