use rustc_data_structures::intern::Interned;
use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
use rustc_hir::def::{self, PartialRes};
-use rustc_hir::def_id::DefId;
use rustc_middle::metadata::ModChild;
use rustc_middle::span_bug;
use rustc_middle::ty;
/// One import.
#[derive(Debug, Clone)]
-crate struct Import<'a> {
+pub(crate) struct Import<'a> {
pub kind: ImportKind<'a>,
/// The ID of the `extern crate`, `UseTree` etc that imported this `Import`.
/// Records information about the resolution of a name in a namespace of a module.
#[derive(Clone, Default, Debug)]
-crate struct NameResolution<'a> {
+pub(crate) struct NameResolution<'a> {
/// Single imports that may define the name in the namespace.
/// Imports are arena-allocated, so it's ok to use pointers as keys.
pub single_imports: FxHashSet<Interned<'a, Import<'a>>>,
})
}
- crate fn add_single_import(&mut self, import: &'a Import<'a>) {
+ pub(crate) fn add_single_import(&mut self, import: &'a Import<'a>) {
self.single_imports.insert(Interned::new_unchecked(import));
}
}
impl<'a> Resolver<'a> {
// Given a binding and an import that resolves to it,
// return the corresponding binding defined by the import.
- crate fn import(
+ pub(crate) fn import(
&self,
binding: &'a NameBinding<'a>,
import: &'a Import<'a>,
}
// Define the name or return the existing binding if there is a collision.
- crate fn try_define(
+ pub(crate) fn try_define(
&mut self,
module: Module<'a>,
key: BindingKey,
pub r: &'a mut Resolver<'b>,
}
-impl<'a, 'b> ty::DefIdTree for &'a ImportResolver<'a, 'b> {
- fn parent(self, id: DefId) -> Option<DefId> {
- self.r.parent(id)
- }
-}
-
impl<'a, 'b> ImportResolver<'a, 'b> {
// Import resolution
//
}
if !is_prelude &&
max_vis.get() != ty::Visibility::Invisible && // Allow empty globs.
- !max_vis.get().is_at_least(import.vis.get(), &*self)
+ !max_vis.get().is_at_least(import.vis.get(), &*self.r)
{
let msg = "glob import doesn't reexport anything because no candidate is public enough";
self.r.lint_buffer.buffer_lint(UNUSED_IMPORTS, import.id, import.span, msg);