Skip to content

Commit fc06ea5

Browse files
committed
Add a type parameter to ImportDirective
1 parent d5a91e6 commit fc06ea5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/librustc_resolve/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ pub struct ModuleS<'a> {
828828
extern_crate_id: Option<NodeId>,
829829

830830
resolutions: RefCell<HashMap<(Name, Namespace), NameResolution<'a>>>,
831-
unresolved_imports: RefCell<Vec<&'a ImportDirective>>,
831+
unresolved_imports: RefCell<Vec<&'a ImportDirective<'a>>>,
832832

833833
// The module children of this node, including normal modules and anonymous modules.
834834
// Anonymous children are pseudo-modules that are implicitly created around items
@@ -848,7 +848,7 @@ pub struct ModuleS<'a> {
848848

849849
prelude: RefCell<Option<Module<'a>>>,
850850

851-
glob_importers: RefCell<Vec<(Module<'a>, &'a ImportDirective)>>,
851+
glob_importers: RefCell<Vec<(Module<'a>, &'a ImportDirective<'a>)>>,
852852
resolved_globs: RefCell<(Vec<Module<'a>> /* public */, Vec<Module<'a>> /* private */)>,
853853

854854
// The number of public glob imports in this module.
@@ -891,7 +891,7 @@ impl<'a> ModuleS<'a> {
891891
}
892892
}
893893

894-
fn add_import_directive(&self, import_directive: ImportDirective) {
894+
fn add_import_directive(&self, import_directive: ImportDirective<'a>) {
895895
let import_directive = self.arenas.alloc_import_directive(import_directive);
896896
self.unresolved_imports.borrow_mut().push(import_directive);
897897
}
@@ -1134,7 +1134,7 @@ pub struct Resolver<'a, 'tcx: 'a> {
11341134
struct ResolverArenas<'a> {
11351135
modules: arena::TypedArena<ModuleS<'a>>,
11361136
name_bindings: arena::TypedArena<NameBinding<'a>>,
1137-
import_directives: arena::TypedArena<ImportDirective>,
1137+
import_directives: arena::TypedArena<ImportDirective<'a>>,
11381138
}
11391139

11401140
impl<'a> ResolverArenas<'a> {
@@ -1144,7 +1144,8 @@ impl<'a> ResolverArenas<'a> {
11441144
fn alloc_name_binding(&'a self, name_binding: NameBinding<'a>) -> &'a NameBinding<'a> {
11451145
self.name_bindings.alloc(name_binding)
11461146
}
1147-
fn alloc_import_directive(&'a self, import_directive: ImportDirective) -> &'a ImportDirective {
1147+
fn alloc_import_directive(&'a self, import_directive: ImportDirective<'a>)
1148+
-> &'a ImportDirective {
11481149
self.import_directives.alloc(import_directive)
11491150
}
11501151
}

src/librustc_resolve/resolve_imports.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl ImportDirectiveSubclass {
5757

5858
/// One import directive.
5959
#[derive(Debug,Clone)]
60-
pub struct ImportDirective {
60+
pub struct ImportDirective<'a> {
6161
module_path: Vec<Name>,
6262
subclass: ImportDirectiveSubclass,
6363
span: Span,
@@ -66,14 +66,14 @@ pub struct ImportDirective {
6666
is_prelude: bool,
6767
}
6868

69-
impl ImportDirective {
69+
impl<'a> ImportDirective<'a> {
7070
pub fn new(module_path: Vec<Name>,
7171
subclass: ImportDirectiveSubclass,
7272
span: Span,
7373
id: NodeId,
7474
is_public: bool,
7575
is_prelude: bool)
76-
-> ImportDirective {
76+
-> Self {
7777
ImportDirective {
7878
module_path: module_path,
7979
subclass: subclass,
@@ -86,9 +86,8 @@ impl ImportDirective {
8686

8787
// Given the binding to which this directive resolves in a particular namespace,
8888
// this returns the binding for the name this directive defines in that namespace.
89-
fn import<'a>(&self,
90-
binding: &'a NameBinding<'a>,
91-
privacy_error: Option<Box<PrivacyError<'a>>>) -> NameBinding<'a> {
89+
fn import(&self, binding: &'a NameBinding<'a>, privacy_error: Option<Box<PrivacyError<'a>>>)
90+
-> NameBinding<'a> {
9291
let mut modifiers = match self.is_public {
9392
true => DefModifiers::PUBLIC | DefModifiers::IMPORTABLE,
9493
false => DefModifiers::empty(),
@@ -292,7 +291,7 @@ impl<'a> ::ModuleS<'a> {
292291
struct ImportResolvingError<'a> {
293292
/// Module where the error happened
294293
source_module: Module<'a>,
295-
import_directive: &'a ImportDirective,
294+
import_directive: &'a ImportDirective<'a>,
296295
span: Span,
297296
help: String,
298297
}
@@ -424,7 +423,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
424423
/// don't know whether the name exists at the moment due to other
425424
/// currently-unresolved imports, or success if we know the name exists.
426425
/// If successful, the resolved bindings are written into the module.
427-
fn resolve_import(&mut self, directive: &'b ImportDirective) -> ResolveResult<()> {
426+
fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> ResolveResult<()> {
428427
debug!("(resolving import for module) resolving import `{}::...` in `{}`",
429428
names_to_string(&directive.module_path),
430429
module_to_string(self.resolver.current_module));
@@ -579,7 +578,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
579578
// succeeds or bails out (as importing * from an empty module or a module
580579
// that exports nothing is valid). target_module is the module we are
581580
// actually importing, i.e., `foo` in `use foo::*`.
582-
fn resolve_glob_import(&mut self, target_module: Module<'b>, directive: &'b ImportDirective)
581+
fn resolve_glob_import(&mut self, target_module: Module<'b>, directive: &'b ImportDirective<'b>)
583582
-> ResolveResult<()> {
584583
if let Some(Def::Trait(_)) = target_module.def {
585584
self.resolver.session.span_err(directive.span, "items in traits are not importable.");

0 commit comments

Comments
 (0)