Address review comments

This commit is contained in:
Vadim Petrochenkov 2018-12-01 22:14:37 +03:00
parent 2d4b633be3
commit eb1d2e637e
2 changed files with 15 additions and 4 deletions

View file

@ -1519,8 +1519,11 @@ pub struct Resolver<'a, 'b: 'a> {
/// The current self item if inside an ADT (used for better errors).
current_self_item: Option<NodeId>,
/// FIXME: Refactor things so that this is passed through arguments and not resolver.
/// FIXME: Refactor things so that these fields are passed through arguments and not resolver.
/// We are resolving a last import segment during import validation.
last_import_segment: bool,
/// This binding should be ignored during in-module resolution, so that we don't get
/// "self-confirming" import resolutions during import validation.
blacklisted_binding: Option<&'a NameBinding<'a>>,
/// The idents for the primitive types.

View file

@ -42,10 +42,15 @@ use std::{mem, ptr};
#[derive(Clone, Debug)]
pub enum ImportDirectiveSubclass<'a> {
SingleImport {
/// `source` in `use prefix::source as target`.
source: Ident,
/// `target` in `use prefix::source as target`.
target: Ident,
/// Bindings to which `source` refers to.
source_bindings: PerNS<Cell<Result<&'a NameBinding<'a>, Determinacy>>>,
/// Bindings introduced by `target`.
target_bindings: PerNS<Cell<Option<&'a NameBinding<'a>>>>,
/// `true` for `...::{self [as target]}` imports, `false` otherwise.
type_ns_only: bool,
},
GlobImport {
@ -946,9 +951,12 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
// Consistency checks, analogous to `finalize_current_module_macro_resolutions`.
let initial_def = source_bindings[ns].get().map(|initial_binding| {
all_ns_err = false;
if target.name == "_" &&
initial_binding.is_extern_crate() && !initial_binding.is_import() {
this.used_imports.insert((directive.id, TypeNS));
if let Some(target_binding) = target_bindings[ns].get() {
if target.name == "_" &&
initial_binding.is_extern_crate() && !initial_binding.is_import() {
this.record_use(ident, ns, target_binding,
directive.module_path.is_empty());
}
}
initial_binding.def_ignoring_ambiguity()
});