Check privacy in resolve_name_in_module
.
This commit is contained in:
parent
e1c9efcba4
commit
165b0b618c
@ -1304,9 +1304,6 @@ impl<'a> Resolver<'a> {
|
||||
// Check to see whether there are type bindings, and, if
|
||||
// so, whether there is a module within.
|
||||
if let Some(module_def) = binding.module() {
|
||||
if let Some(span) = span {
|
||||
self.check_privacy(name, binding, span);
|
||||
}
|
||||
search_module = module_def;
|
||||
} else {
|
||||
let msg = format!("Not a module `{}`", name);
|
||||
@ -2614,10 +2611,7 @@ impl<'a> Resolver<'a> {
|
||||
let name = segments.last().unwrap().identifier.name;
|
||||
let result =
|
||||
self.resolve_name_in_module(containing_module, name, namespace, false, Some(span));
|
||||
result.success().map(|binding| {
|
||||
self.check_privacy(name, binding, span);
|
||||
binding
|
||||
}).ok_or(false)
|
||||
result.success().ok_or(false)
|
||||
}
|
||||
|
||||
/// Invariant: This must be called only during main resolution, not during
|
||||
@ -2656,10 +2650,7 @@ impl<'a> Resolver<'a> {
|
||||
let name = segments.last().unwrap().name();
|
||||
let result =
|
||||
self.resolve_name_in_module(containing_module, name, namespace, false, Some(span));
|
||||
result.success().map(|binding| {
|
||||
self.check_privacy(name, binding, span);
|
||||
binding
|
||||
}).ok_or(false)
|
||||
result.success().ok_or(false)
|
||||
}
|
||||
|
||||
fn with_no_errors<T, F>(&mut self, f: F) -> T
|
||||
@ -3276,12 +3267,6 @@ impl<'a> Resolver<'a> {
|
||||
vis.is_at_least(self.current_vis, self)
|
||||
}
|
||||
|
||||
fn check_privacy(&mut self, name: Name, binding: &'a NameBinding<'a>, span: Span) {
|
||||
if !self.is_accessible(binding.vis) {
|
||||
self.privacy_errors.push(PrivacyError(span, name, binding));
|
||||
}
|
||||
}
|
||||
|
||||
fn report_privacy_errors(&self) {
|
||||
if self.privacy_errors.len() == 0 { return }
|
||||
let mut reported_spans = HashSet::new();
|
||||
|
@ -165,8 +165,11 @@ impl<'a> Resolver<'a> {
|
||||
if !allow_private_imports && binding.is_import() && !binding.is_pseudo_public() {
|
||||
return Failed(None);
|
||||
}
|
||||
if record_used.is_some() {
|
||||
if let Some(span) = record_used {
|
||||
self.record_use(name, ns, binding);
|
||||
if !self.is_accessible(binding.vis) {
|
||||
self.privacy_errors.push(PrivacyError(span, name, binding));
|
||||
}
|
||||
}
|
||||
Success(binding)
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user