@@ -109,7 +109,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio
109109
110110impl < ' a , ' v > Visitor < ' v > for LifetimeContext < ' a > {
111111 fn visit_item ( & mut self , item : & ast:: Item ) {
112- // Items save/restore the set of labels. This way innner items
112+ // Items save/restore the set of labels. This way inner items
113113 // can freely reuse names, be they loop labels or lifetimes.
114114 let saved = replace ( & mut self . labels_in_fn , vec ! [ ] ) ;
115115
@@ -151,6 +151,29 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
151151 replace ( & mut self . labels_in_fn , saved) ;
152152 }
153153
154+ fn visit_foreign_item ( & mut self , item : & ast:: ForeignItem ) {
155+ // Items save/restore the set of labels. This way inner items
156+ // can freely reuse names, be they loop labels or lifetimes.
157+ let saved = replace ( & mut self . labels_in_fn , vec ! [ ] ) ;
158+
159+ // Items always introduce a new root scope
160+ self . with ( RootScope , |_, this| {
161+ match item. node {
162+ ast:: ForeignItemFn ( _, ref generics) => {
163+ this. visit_early_late ( subst:: FnSpace , generics, |this| {
164+ visit:: walk_foreign_item ( this, item) ;
165+ } )
166+ }
167+ ast:: ForeignItemStatic ( ..) => {
168+ visit:: walk_foreign_item ( this, item) ;
169+ }
170+ }
171+ } ) ;
172+
173+ // Done traversing the item; restore saved set of labels.
174+ replace ( & mut self . labels_in_fn , saved) ;
175+ }
176+
154177 fn visit_fn ( & mut self , fk : visit:: FnKind < ' v > , fd : & ' v ast:: FnDecl ,
155178 b : & ' v ast:: Block , s : Span , _: ast:: NodeId ) {
156179 match fk {
0 commit comments