rustc: Parameterize ty::Visibility over used ID
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
This commit is contained in:
@@ -648,7 +648,7 @@ pub struct NameBinding<'a> {
|
||||
ambiguity: Option<(&'a NameBinding<'a>, AmbiguityKind)>,
|
||||
expansion: LocalExpnId,
|
||||
span: Span,
|
||||
vis: ty::Visibility,
|
||||
vis: ty::Visibility<DefId>,
|
||||
}
|
||||
|
||||
pub trait ToNameBinding<'a> {
|
||||
@@ -1012,7 +1012,7 @@ pub struct Resolver<'a> {
|
||||
/// Table for mapping struct IDs into struct constructor IDs,
|
||||
/// it's not used during normal resolution, only for better error reporting.
|
||||
/// Also includes of list of each fields visibility
|
||||
struct_constructors: DefIdMap<(Res, ty::Visibility, Vec<ty::Visibility>)>,
|
||||
struct_constructors: DefIdMap<(Res, ty::Visibility<DefId>, Vec<ty::Visibility<DefId>>)>,
|
||||
|
||||
/// Features enabled for this crate.
|
||||
active_features: FxHashSet<Symbol>,
|
||||
@@ -1808,7 +1808,11 @@ impl<'a> Resolver<'a> {
|
||||
self.pat_span_map.insert(node, span);
|
||||
}
|
||||
|
||||
fn is_accessible_from(&self, vis: ty::Visibility, module: Module<'a>) -> bool {
|
||||
fn is_accessible_from(
|
||||
&self,
|
||||
vis: ty::Visibility<impl Into<DefId>>,
|
||||
module: Module<'a>,
|
||||
) -> bool {
|
||||
vis.is_accessible_from(module.nearest_parent_mod(), self)
|
||||
}
|
||||
|
||||
@@ -1862,10 +1866,8 @@ impl<'a> Resolver<'a> {
|
||||
self.crate_loader.maybe_process_path_extern(ident.name)?
|
||||
};
|
||||
let crate_root = self.expect_module(crate_id.as_def_id());
|
||||
Some(
|
||||
(crate_root, ty::Visibility::Public, DUMMY_SP, LocalExpnId::ROOT)
|
||||
.to_name_binding(self.arenas),
|
||||
)
|
||||
let vis = ty::Visibility::<LocalDefId>::Public;
|
||||
Some((crate_root, vis, DUMMY_SP, LocalExpnId::ROOT).to_name_binding(self.arenas))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user