Skip to content

Commit 650e7f5

Browse files
committed
Silence use foo::Bar; error if Bar isn't found in foo and foo.rs has parse errors
1 parent f63ee25 commit 650e7f5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_resolve/src/imports.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
670670

671671
fn throw_unresolved_import_error(
672672
&mut self,
673-
errors: Vec<(Import<'_>, UnresolvedImportError)>,
673+
mut errors: Vec<(Import<'_>, UnresolvedImportError)>,
674674
glob_error: bool,
675675
) {
676+
errors.retain(|(_import, err)| match err.module {
677+
// Skip `use` errors for `use foo::Bar;` if `foo.rs` has unrecovered parse errors.
678+
Some(def_id) if self.mod_with_parse_errors.contains(&def_id) => false,
679+
_ => true,
680+
});
676681
if errors.is_empty() {
677682
return;
678683
}

tests/ui/resolve/parse-error-resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod parse_error;
2-
use parse_error::Canonical; //~ ERROR E0432
2+
use parse_error::Canonical; // ok, `parse_error.rs` had parse errors
33

44
fn main() {
55
let _ = "" + 1; //~ ERROR E0369

0 commit comments

Comments
 (0)