mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
Fix leaking trait imports across modules
Turns out the pass in resolve was a little too eager to travel back up the hierarchy chain when looking for trait candidates. Closes #10465
This commit is contained in:
@@ -5498,11 +5498,10 @@ fn search_for_traits_containing_method(&mut self, name: Ident)
|
||||
|
||||
// Move to the next parent.
|
||||
match search_module.parent_link {
|
||||
NoParentLink => {
|
||||
NoParentLink | ModuleParentLink(..) => {
|
||||
// Done.
|
||||
break;
|
||||
}
|
||||
ModuleParentLink(parent_module, _) |
|
||||
BlockParentLink(parent_module, _) => {
|
||||
search_module = parent_module;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
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(); //~ ERROR: does not implement any method in scope named
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user