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 @@ -151,7 +151,6 @@ impl<'a> base::Resolver for Resolver<'a> {
151151 expansion : mark,
152152 } ;
153153 expansion. visit_with ( & mut visitor) ;
154- self . current_module . unresolved_invocations . borrow_mut ( ) . remove ( & mark) ;
155154 invocation. expansion . set ( visitor. legacy_scope ) ;
156155 }
157156
@@ -351,7 +350,7 @@ impl<'a> Resolver<'a> {
351350 Err ( Determinacy :: Determined )
352351 } ,
353352 } ;
354- self . current_module . macro_resolutions . borrow_mut ( )
353+ self . current_module . nearest_item_scope ( ) . macro_resolutions . borrow_mut ( )
355354 . push ( ( path. into_boxed_slice ( ) , span) ) ;
356355 return def;
357356 }
@@ -371,7 +370,7 @@ impl<'a> Resolver<'a> {
371370 } ,
372371 } ;
373372
374- self . current_module . legacy_macro_resolutions . borrow_mut ( )
373+ self . current_module . nearest_item_scope ( ) . legacy_macro_resolutions . borrow_mut ( )
375374 . push ( ( scope, path[ 0 ] , span, kind) ) ;
376375
377376 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