Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
) {
let binding = self.arenas.alloc_name_binding(NameBindingData {
kind: NameBindingKind::Res(res),
ambiguity,
ambiguity: CmCell::new(ambiguity),
// External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment.
warn_ambiguity: true,
vis,
warn_ambiguity: CmCell::new(true),
vis: CmCell::new(vis),
span,
expansion,
});
Expand Down Expand Up @@ -1159,18 +1159,18 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
self.r.potentially_unused_imports.push(import);
module.for_each_child_mut(self, |this, ident, ns, binding| {
if ns == MacroNS {
let import = if this.r.is_accessible_from(binding.vis, this.parent_scope.module)
{
import
} else {
// FIXME: This branch is used for reporting the `private_macro_use` lint
// and should eventually be removed.
if this.r.macro_use_prelude.contains_key(&ident.name) {
// Do not override already existing entries with compatibility entries.
return;
}
macro_use_import(this, span, true)
};
let import =
if this.r.is_accessible_from(binding.vis(), this.parent_scope.module) {
import
} else {
// FIXME: This branch is used for reporting the `private_macro_use` lint
// and should eventually be removed.
if this.r.macro_use_prelude.contains_key(&ident.name) {
// Do not override already existing entries with compatibility entries.
return;
}
macro_use_import(this, span, true)
};
let import_binding = this.r.import(binding, import);
this.add_macro_use_binding(ident.name, import_binding, span, allow_shadowing);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}

let child_accessible =
accessible && this.is_accessible_from(name_binding.vis, parent_scope.module);
accessible && this.is_accessible_from(name_binding.vis(), parent_scope.module);

// do not venture inside inaccessible items of other crates
if in_module_is_extern && !child_accessible {
Expand All @@ -1358,8 +1358,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

// #90113: Do not count an inaccessible reexported item as a candidate.
if let NameBindingKind::Import { binding, .. } = name_binding.kind
&& this.is_accessible_from(binding.vis, parent_scope.module)
&& !this.is_accessible_from(name_binding.vis, parent_scope.module)
&& this.is_accessible_from(binding.vis(), parent_scope.module)
&& !this.is_accessible_from(name_binding.vis(), parent_scope.module)
{
return;
}
Expand Down Expand Up @@ -2239,7 +2239,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let first = binding == first_binding;
let def_span = self.tcx.sess.source_map().guess_head_span(binding.span);
let mut note_span = MultiSpan::from_span(def_span);
if !first && binding.vis.is_public() {
if !first && binding.vis().is_public() {
let desc = match binding.kind {
NameBindingKind::Import { .. } => "re-export",
_ => "directly",
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_resolve/src/effective_visibilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
if let Some(node_id) = import.id() {
r.effective_visibilities.update_eff_vis(r.local_def_id(node_id), eff_vis, r.tcx)
}
} else if binding.ambiguity.is_some() && eff_vis.is_public_at_level(Level::Reexported) {
} else if binding.ambiguity.get().is_some()
&& eff_vis.is_public_at_level(Level::Reexported)
{
exported_ambiguities.insert(*binding);
}
}
Expand All @@ -126,9 +128,9 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
// leading to it into the table. They are used by the `ambiguous_glob_reexports`
// lint. For all bindings added to the table this way `is_ambiguity` returns true.
let is_ambiguity =
|binding: NameBinding<'ra>, warn: bool| binding.ambiguity.is_some() && !warn;
|binding: NameBinding<'ra>, warn: bool| binding.ambiguity.get().is_some() && !warn;
let mut parent_id = ParentId::Def(module_id);
let mut warn_ambiguity = binding.warn_ambiguity;
let mut warn_ambiguity = binding.warn_ambiguity.get();
while let NameBindingKind::Import { binding: nested_binding, .. } = binding.kind {
self.update_import(binding, parent_id);

Expand All @@ -141,12 +143,12 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {

parent_id = ParentId::Import(binding);
binding = nested_binding;
warn_ambiguity |= nested_binding.warn_ambiguity;
warn_ambiguity |= nested_binding.warn_ambiguity.get();
}
if !is_ambiguity(binding, warn_ambiguity)
&& let Some(def_id) = binding.res().opt_def_id().and_then(|id| id.as_local())
{
self.update_def(def_id, binding.vis.expect_local(), parent_id);
self.update_def(def_id, binding.vis().expect_local(), parent_id);
}
}
}
Expand Down Expand Up @@ -189,7 +191,7 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
}

fn update_import(&mut self, binding: NameBinding<'ra>, parent_id: ParentId<'ra>) {
let nominal_vis = binding.vis.expect_local();
let nominal_vis = binding.vis().expect_local();
let Some(cheap_private_vis) = self.may_update(nominal_vis, parent_id) else { return };
let inherited_eff_vis = self.effective_vis_or_private(parent_id);
let tcx = self.r.tcx;
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

// Items and single imports are not shadowable, if we have one, then it's determined.
if let Some(binding) = binding {
let accessible = self.is_accessible_from(binding.vis, parent_scope.module);
let accessible = self.is_accessible_from(binding.vis(), parent_scope.module);
return if accessible { Ok(binding) } else { Err(ControlFlow::Break(Determined)) };
}

Expand Down Expand Up @@ -1099,7 +1099,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// shadowing is enabled, see `macro_expanded_macro_export_errors`).
if let Some(binding) = binding {
return if binding.determined() || ns == MacroNS || shadowing == Shadowing::Restricted {
let accessible = self.is_accessible_from(binding.vis, parent_scope.module);
let accessible = self.is_accessible_from(binding.vis(), parent_scope.module);
if accessible { Ok(binding) } else { Err(ControlFlow::Break(Determined)) }
} else {
Err(ControlFlow::Break(Undetermined))
Expand Down Expand Up @@ -1157,7 +1157,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
match result {
Err(ControlFlow::Break(Determined) | ControlFlow::Continue(Determined)) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, glob_import.parent_scope.module) =>
if !self.is_accessible_from(binding.vis(), glob_import.parent_scope.module) =>
{
continue;
}
Expand Down Expand Up @@ -1188,7 +1188,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
return Err(ControlFlow::Continue(Determined));
};

if !self.is_accessible_from(binding.vis, parent_scope.module) {
if !self.is_accessible_from(binding.vis(), parent_scope.module) {
if report_private {
self.privacy_errors.push(PrivacyError {
ident,
Expand Down Expand Up @@ -1315,7 +1315,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
) {
Err(Determined) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, single_import.parent_scope.module) =>
if !self
.is_accessible_from(binding.vis(), single_import.parent_scope.module) =>
{
continue;
}
Expand Down
Loading
Loading