Auto merge of #109602 - bvanjoi:fix-issue-109343, r=petrochenkov
fix(resolve): replace bindings to dummy for unresolved imports close #109343 In #109343, `f` in `pub use f as g` points to: |namespace| binding| |-|-| |type| `external crate f`| |value| `None` | |macro| `None` | When resolve `value_ns` during `resolve_doc_links`, the value of the binding of single_import `pub use f as g` goes to `pub use inner::f`, and since it does not satisfy [!self.is_accessible_from(binding.vis, single_import.parent_scope.module)](https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/ident.rs#L971) and returns `Err(Undetermined)`, which eventually goes to `PathResult::Indeterminate => unreachable!`. This PR replace all namespace binding to `dummy_binding` for indeterminate import, so, the bindings of `pub use f as g` had been changed to followings after finalize: |namespace| binding| |-|-| |type| `dummy`| |value| `dummy` | |macro| `dummy` | r?`@petrochenkov`
This commit is contained in:
commit
92f5dea0eb
5 changed files with 29 additions and 6 deletions
|
@ -405,11 +405,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
t
|
||||
}
|
||||
|
||||
// Define a dummy resolution containing a `Res::Err` as a placeholder for a failed resolution,
|
||||
// also mark such failed imports as used to avoid duplicate diagnostics.
|
||||
fn import_dummy_binding(&mut self, import: &'a Import<'a>) {
|
||||
// Define a dummy resolution containing a `Res::Err` as a placeholder for a failed
|
||||
// or indeterminate resolution, also mark such failed imports as used to avoid duplicate diagnostics.
|
||||
fn import_dummy_binding(&mut self, import: &'a Import<'a>, is_indeterminate: bool) {
|
||||
if let ImportKind::Single { target, ref target_bindings, .. } = import.kind {
|
||||
if target_bindings.iter().any(|binding| binding.get().is_some()) {
|
||||
if !(is_indeterminate || target_bindings.iter().all(|binding| binding.get().is_none()))
|
||||
{
|
||||
return; // Has resolution, do not create the dummy binding
|
||||
}
|
||||
let dummy_binding = self.dummy_binding;
|
||||
|
@ -474,7 +475,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
// If this import is unresolved then create a dummy import
|
||||
// resolution for it so that later resolve stages won't complain.
|
||||
self.import_dummy_binding(import);
|
||||
self.import_dummy_binding(import, is_indeterminate);
|
||||
|
||||
if let Some(err) = unresolved_import_error {
|
||||
if let ImportKind::Single { source, ref source_bindings, .. } = import.kind {
|
||||
|
|
|
@ -85,6 +85,7 @@ pub mod rustdoc;
|
|||
|
||||
fluent_messages! { "../messages.ftl" }
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Weak {
|
||||
Yes,
|
||||
No,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue