Handle unusable_binding
more compactly.
This commit is contained in:
parent
b796d92da3
commit
276b946010
1 changed files with 14 additions and 17 deletions
|
@ -902,28 +902,25 @@ impl<'a> Resolver<'a> {
|
||||||
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
|
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
|
||||||
|
|
||||||
if let Some(path_span) = finalize {
|
if let Some(path_span) = finalize {
|
||||||
let Some(mut binding) = resolution.binding else {
|
|
||||||
return Err((Determined, Weak::No));
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the primary binding is unusable, search further and return the shadowed glob
|
// If the primary binding is unusable, search further and return the shadowed glob
|
||||||
// binding if it exists. What we really want here is having two separate scopes in
|
// binding if it exists. What we really want here is having two separate scopes in
|
||||||
// a module - one for non-globs and one for globs, but until that's done use this
|
// a module - one for non-globs and one for globs, but until that's done use this
|
||||||
// hack to avoid inconsistent resolution ICEs during import validation.
|
// hack to avoid inconsistent resolution ICEs during import validation.
|
||||||
if let Some(unusable_binding) = unusable_binding
|
let binding = [resolution.binding, resolution.shadowed_glob]
|
||||||
&& ptr::eq(binding, unusable_binding)
|
.into_iter()
|
||||||
|
.filter_map(|binding| match (binding, unusable_binding) {
|
||||||
|
(Some(binding), Some(unusable_binding))
|
||||||
|
if ptr::eq(binding, unusable_binding) =>
|
||||||
{
|
{
|
||||||
let Some(shadowed) = resolution.shadowed_glob else {
|
None
|
||||||
|
}
|
||||||
|
_ => binding,
|
||||||
|
})
|
||||||
|
.next();
|
||||||
|
let Some(binding) = binding else {
|
||||||
return Err((Determined, Weak::No));
|
return Err((Determined, Weak::No));
|
||||||
};
|
};
|
||||||
|
|
||||||
if ptr::eq(shadowed, unusable_binding) {
|
|
||||||
return Err((Determined, Weak::No));
|
|
||||||
}
|
|
||||||
|
|
||||||
binding = shadowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.is_accessible_from(binding.vis, parent_scope.module) {
|
if !self.is_accessible_from(binding.vis, parent_scope.module) {
|
||||||
if last_import_segment {
|
if last_import_segment {
|
||||||
return Err((Determined, Weak::No));
|
return Err((Determined, Weak::No));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue