Skip to content

Commit d107d22

Browse files
committed
Refactor module.add_import_directive() -> resolver.add_import_directive().
1 parent aef6971 commit d107d22

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'b> Resolver<'b> {
130130

131131
let subclass = ImportDirectiveSubclass::single(binding.name, source_name);
132132
let span = view_path.span;
133-
parent.add_import_directive(module_path, subclass, span, item.id, vis);
133+
self.add_import_directive(module_path, subclass, span, item.id, vis);
134134
self.unresolved_imports += 1;
135135
}
136136
ViewPathList(_, ref source_items) => {
@@ -176,14 +176,14 @@ impl<'b> Resolver<'b> {
176176
};
177177
let subclass = ImportDirectiveSubclass::single(rename, name);
178178
let (span, id) = (source_item.span, source_item.node.id());
179-
parent.add_import_directive(module_path, subclass, span, id, vis);
179+
self.add_import_directive(module_path, subclass, span, id, vis);
180180
self.unresolved_imports += 1;
181181
}
182182
}
183183
ViewPathGlob(_) => {
184184
let subclass = GlobImport { is_prelude: is_prelude };
185185
let span = view_path.span;
186-
parent.add_import_directive(module_path, subclass, span, item.id, vis);
186+
self.add_import_directive(module_path, subclass, span, item.id, vis);
187187
self.unresolved_imports += 1;
188188
}
189189
}

src/librustc_resolve/resolve_imports.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,11 @@ impl<'a> ::ModuleS<'a> {
212212

213213
Failed(None)
214214
}
215+
}
215216

216-
pub fn add_import_directive(&self,
217+
impl<'a> Resolver<'a> {
218+
// Add an import directive to the current module.
219+
pub fn add_import_directive(&mut self,
217220
module_path: Vec<Name>,
218221
subclass: ImportDirectiveSubclass,
219222
span: Span,
@@ -228,23 +231,21 @@ impl<'a> ::ModuleS<'a> {
228231
vis: vis,
229232
});
230233

231-
self.unresolved_imports.borrow_mut().push(directive);
234+
self.current_module.unresolved_imports.borrow_mut().push(directive);
232235
match directive.subclass {
233236
SingleImport { target, .. } => {
234237
for &ns in &[ValueNS, TypeNS] {
235-
self.resolution(target, ns).borrow_mut().single_imports
236-
.add_directive(directive);
238+
let mut resolution = self.current_module.resolution(target, ns).borrow_mut();
239+
resolution.single_imports.add_directive(directive);
237240
}
238241
}
239242
// We don't add prelude imports to the globs since they only affect lexical scopes,
240243
// which are not relevant to import resolution.
241244
GlobImport { is_prelude: true } => {}
242-
GlobImport { .. } => self.globs.borrow_mut().push(directive),
245+
GlobImport { .. } => self.current_module.globs.borrow_mut().push(directive),
243246
}
244247
}
245-
}
246248

247-
impl<'a> Resolver<'a> {
248249
// Given a binding and an import directive that resolves to it,
249250
// return the corresponding binding defined by the import directive.
250251
fn import(&mut self, binding: &'a NameBinding<'a>, directive: &'a ImportDirective<'a>)

0 commit comments

Comments
 (0)