Add field dummy_binding to Resolver.

This commit is contained in:
Jeffrey Seyfried 2016-08-22 04:05:49 +00:00
parent 95528d1a98
commit 513e955a18
2 changed files with 9 additions and 8 deletions
src/librustc_resolve

View File

@ -65,7 +65,7 @@ use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
use syntax::ast::{Local, Mutability, Pat, PatKind, Path};
use syntax::ast::{PathSegment, PathParameters, QSelf, TraitItemKind, TraitRef, Ty, TyKind};
use syntax_pos::Span;
use syntax_pos::{Span, DUMMY_SP};
use errors::DiagnosticBuilder;
use std::cell::{Cell, RefCell};
@ -1052,6 +1052,7 @@ pub struct Resolver<'a> {
privacy_errors: Vec<PrivacyError<'a>>,
arenas: &'a ResolverArenas<'a>,
dummy_binding: &'a NameBinding<'a>,
}
pub struct ResolverArenas<'a> {
@ -1203,6 +1204,11 @@ impl<'a> Resolver<'a> {
privacy_errors: Vec::new(),
arenas: arenas,
dummy_binding: arenas.alloc_name_binding(NameBinding {
kind: NameBindingKind::Def(Def::Err),
span: DUMMY_SP,
vis: ty::Visibility::Public,
}),
}
}

View File

@ -27,7 +27,7 @@ use rustc::hir::def::*;
use syntax::ast::{NodeId, Name};
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::{Span, DUMMY_SP};
use syntax_pos::Span;
use std::cell::{Cell, RefCell};
@ -442,13 +442,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
// failed resolution
fn import_dummy_binding(&mut self, directive: &'b ImportDirective<'b>) {
if let SingleImport { target, .. } = directive.subclass {
let dummy_binding = self.arenas.alloc_name_binding(NameBinding {
kind: NameBindingKind::Def(Def::Err),
span: DUMMY_SP,
vis: ty::Visibility::Public,
});
let dummy_binding = self.dummy_binding;
let dummy_binding = self.import(dummy_binding, directive);
let _ = self.try_define(directive.parent, target, ValueNS, dummy_binding.clone());
let _ = self.try_define(directive.parent, target, TypeNS, dummy_binding);
}