diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 6e022e9804b4..5da94bebf165 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -153,7 +153,15 @@ impl Ctx { for a in decl.inputs.iter() { self.map.insert(a.id, node_arg); } + match *fk { + visit::fk_method(name, _, _) => { self.path.push(path_name(name)) } + _ => {} + } visit::walk_fn(self, fk, decl, body, sp, id, ()); + match *fk { + visit::fk_method(*) => { self.path.pop(); } + _ => {} + } } fn map_stmt(&mut self, stmt: @stmt) { diff --git a/src/test/auxiliary/inner_static.rs b/src/test/auxiliary/inner_static.rs new file mode 100644 index 000000000000..706586684ec0 --- /dev/null +++ b/src/test/auxiliary/inner_static.rs @@ -0,0 +1,28 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct A; + +impl A { + pub fn foo(&self) -> int { + static a: int = 5; + return a + } + + pub fn bar(&self) -> int { + static a: int = 3; + return a; + } +} + +pub fn foo() -> int { + let a = A::<()>; + return a.foo() + a.bar(); +} diff --git a/src/test/run-pass/inner-static.rs b/src/test/run-pass/inner-static.rs new file mode 100644 index 000000000000..969dc607b801 --- /dev/null +++ b/src/test/run-pass/inner-static.rs @@ -0,0 +1,19 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:inner_static.rs +// xfail-fast + +extern mod inner_static; + +pub fn main() { + let a = inner_static::A::<()>; + assert_eq!(a.bar(), 3); +}