1
Fork 0

Silence use foo::Bar; error if Bar isn't found in foo and foo.rs has parse errors

This commit is contained in:
Esteban Küber 2024-12-05 21:47:06 +00:00
parent 69fb612608
commit 27420c69d8
3 changed files with 9 additions and 11 deletions

View file

@ -670,9 +670,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
fn throw_unresolved_import_error(
&mut self,
errors: Vec<(Import<'_>, UnresolvedImportError)>,
mut errors: Vec<(Import<'_>, UnresolvedImportError)>,
glob_error: bool,
) {
errors.retain(|(_import, err)| match err.module {
// Skip `use` errors for `use foo::Bar;` if `foo.rs` has unrecovered parse errors.
Some(def_id) if self.mods_with_parse_errors.contains(&def_id) => false,
_ => true,
});
if errors.is_empty() {
return;
}

View file

@ -1,5 +1,5 @@
mod parse_error;
use parse_error::Canonical; //~ ERROR E0432
use parse_error::Canonical; // ok, `parse_error.rs` had parse errors
fn main() {
let _ = "" + 1; //~ ERROR E0369

View file

@ -9,12 +9,6 @@ help: you might have meant to end the type parameters here
LL | impl<S: Into<std::borrow::Cow<'static, str>>> From<S> for Canonical {
| +
error[E0432]: unresolved import `parse_error::Canonical`
--> $DIR/parse-error-resolve.rs:2:5
|
LL | use parse_error::Canonical;
| ^^^^^^^^^^^^^^^^^^^^^^ no `Canonical` in `parse_error`
error[E0369]: cannot add `{integer}` to `&str`
--> $DIR/parse-error-resolve.rs:5:16
|
@ -23,7 +17,6 @@ LL | let _ = "" + 1;
| |
| &str
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0369, E0432.
For more information about an error, try `rustc --explain E0369`.
For more information about this error, try `rustc --explain E0369`.