File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -922,6 +922,10 @@ impl<'a> ModuleData<'a> {
922922 fn is_local ( & self ) -> bool {
923923 self . normal_ancestor_id . is_local ( )
924924 }
925+
926+ fn nearest_item_scope ( & ' a self ) -> Module < ' a > {
927+ if self . is_trait ( ) { self . parent . unwrap ( ) } else { self }
928+ }
925929}
926930
927931impl < ' a > fmt:: Debug for ModuleData < ' a > {
Original file line number Diff line number Diff line change @@ -172,7 +172,6 @@ impl<'a> base::Resolver for Resolver<'a> {
172172 expansion : mark,
173173 } ;
174174 expansion. visit_with ( & mut visitor) ;
175- self . current_module . unresolved_invocations . borrow_mut ( ) . remove ( & mark) ;
176175 invocation. expansion . set ( visitor. legacy_scope ) ;
177176 }
178177
@@ -390,7 +389,7 @@ impl<'a> Resolver<'a> {
390389 Err ( Determinacy :: Determined )
391390 } ,
392391 } ;
393- self . current_module . macro_resolutions . borrow_mut ( )
392+ self . current_module . nearest_item_scope ( ) . macro_resolutions . borrow_mut ( )
394393 . push ( ( path. into_boxed_slice ( ) , span) ) ;
395394 return def;
396395 }
@@ -410,7 +409,7 @@ impl<'a> Resolver<'a> {
410409 }
411410 } ;
412411
413- self . current_module . legacy_macro_resolutions . borrow_mut ( )
412+ self . current_module . nearest_item_scope ( ) . legacy_macro_resolutions . borrow_mut ( )
414413 . push ( ( scope, path[ 0 ] , span, kind) ) ;
415414
416415 result
Original file line number Diff line number Diff line change 1+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ trait T { m ! ( ) ; } //~ ERROR cannot find macro `m!` in this scope
12+
13+ struct S ;
14+ impl S { m ! ( ) ; } //~ ERROR cannot find macro `m!` in this scope
15+
16+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments