fix(resolve): replace bindings to dummy for unresolved imports
This commit is contained in:
parent
24c180c438
commit
f34678c097
5 changed files with 29 additions and 6 deletions
|
@ -405,11 +405,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define a dummy resolution containing a `Res::Err` as a placeholder for a failed resolution,
|
// Define a dummy resolution containing a `Res::Err` as a placeholder for a failed
|
||||||
// also mark such failed imports as used to avoid duplicate diagnostics.
|
// or indeterminate resolution, also mark such failed imports as used to avoid duplicate diagnostics.
|
||||||
fn import_dummy_binding(&mut self, import: &'a Import<'a>) {
|
fn import_dummy_binding(&mut self, import: &'a Import<'a>, is_indeterminate: bool) {
|
||||||
if let ImportKind::Single { target, ref target_bindings, .. } = import.kind {
|
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
|
return; // Has resolution, do not create the dummy binding
|
||||||
}
|
}
|
||||||
let dummy_binding = self.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
|
// If this import is unresolved then create a dummy import
|
||||||
// resolution for it so that later resolve stages won't complain.
|
// 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 Some(err) = unresolved_import_error {
|
||||||
if let ImportKind::Single { source, ref source_bindings, .. } = import.kind {
|
if let ImportKind::Single { source, ref source_bindings, .. } = import.kind {
|
||||||
|
|
|
@ -85,6 +85,7 @@ pub mod rustdoc;
|
||||||
|
|
||||||
fluent_messages! { "../messages.ftl" }
|
fluent_messages! { "../messages.ftl" }
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Weak {
|
enum Weak {
|
||||||
Yes,
|
Yes,
|
||||||
No,
|
No,
|
||||||
|
|
|
@ -421,7 +421,7 @@ pub enum TrimmedDefPaths {
|
||||||
GoodPath,
|
GoodPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Hash)]
|
#[derive(Clone, Hash, Debug)]
|
||||||
pub enum ResolveDocLinks {
|
pub enum ResolveDocLinks {
|
||||||
/// Do not resolve doc links.
|
/// Do not resolve doc links.
|
||||||
None,
|
None,
|
||||||
|
|
10
tests/ui/imports/issue-109343.rs
Normal file
10
tests/ui/imports/issue-109343.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
pub mod f {}
|
||||||
|
pub use unresolved::f;
|
||||||
|
//~^ ERROR unresolved import `unresolved`
|
||||||
|
|
||||||
|
/// [g]
|
||||||
|
pub use f as g;
|
||||||
|
|
||||||
|
fn main() {}
|
11
tests/ui/imports/issue-109343.stderr
Normal file
11
tests/ui/imports/issue-109343.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0432]: unresolved import `unresolved`
|
||||||
|
--> $DIR/issue-109343.rs:4:9
|
||||||
|
|
|
||||||
|
LL | pub use unresolved::f;
|
||||||
|
| ^^^^^^^^^^ maybe a missing crate `unresolved`?
|
||||||
|
|
|
||||||
|
= help: consider adding `extern crate unresolved` to use the `unresolved` crate
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
Loading…
Add table
Add a link
Reference in a new issue