@@ -109,7 +109,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio
109
109
110
110
impl < ' a , ' v > Visitor < ' v > for LifetimeContext < ' a > {
111
111
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
113
113
// can freely reuse names, be they loop labels or lifetimes.
114
114
let saved = replace ( & mut self . labels_in_fn , vec ! [ ] ) ;
115
115
@@ -151,6 +151,29 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
151
151
replace ( & mut self . labels_in_fn , saved) ;
152
152
}
153
153
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
+
154
177
fn visit_fn ( & mut self , fk : visit:: FnKind < ' v > , fd : & ' v ast:: FnDecl ,
155
178
b : & ' v ast:: Block , s : Span , _: ast:: NodeId ) {
156
179
match fk {
0 commit comments