Silence use foo::Bar;
error if Bar
isn't found in foo
and `foo.… · rust-lang/rust@27420c6 (original) (raw)
File tree
3 files changed
lines changed
- compiler/rustc_resolve/src
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -670,9 +670,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | ||
670 | 670 | |
671 | 671 | fn throw_unresolved_import_error( |
672 | 672 | &mut self, |
673 | -errors: Vec<(Import<'_>, UnresolvedImportError)>, | |
673 | +mut errors: Vec<(Import<'_>, UnresolvedImportError)>, | |
674 | 674 | glob_error: bool, |
675 | 675 | ) { |
676 | + errors.retain(|(_import, err) | |
677 | +// Skip `use` errors for `use foo::Bar;` if `foo.rs` has unrecovered parse errors. | |
678 | +Some(def_id) if self.mods_with_parse_errors.contains(&def_id) => false, | |
679 | + _ => true, | |
680 | +}); | |
676 | 681 | if errors.is_empty() { |
677 | 682 | return; |
678 | 683 | } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | 1 | mod parse_error; |
2 | -use parse_error::Canonical; //~ ERROR E0432 | |
2 | +use parse_error::Canonical; // ok, `parse_error.rs` had parse errors | |
3 | 3 | |
4 | 4 | fn main() { |
5 | 5 | let _ = "" + 1; //~ ERROR E0369 |
| Original file line number | Diff line number | Diff line change | |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------- | |
| @@ -9,12 +9,6 @@ help: you might have meant to end the type parameters here | | | |
| 9 | 9 | LL | impl<S: Into<std::borrow::Cow<'static, str>>> From for Canonical { | |
| 10 | 10 | | + | |
| 11 | 11 | | |
| 12 | | -error[E0432]: unresolved import `parse_error::Canonical` | |
| 13 | | - --> $DIR/parse-error-resolve.rs:2:5 | |
| 14 | | - | | |
| 15 | | -LL | use parse_error::Canonical; | |
| 16 | | - | ^^^^^^^^^^^^^^^^^^^^^^ no `Canonical` in `parse_error` | |
| 17 | | - | |
| 18 | 12 | error[E0369]: cannot add `{integer}` to `&str` | |
| 19 | 13 | --> $DIR/parse-error-resolve.rs:5:16 | |
| 20 | 14 | | | |
| @@ -23,7 +17,6 @@ LL | let _ = "" + 1; | | | |
| 23 | 17 | | | |
| 24 | 18 | | &str | |
| 25 | 19 | | |
| 26 | | -error: aborting due to 3 previous errors | |
| | 20 | +error: aborting due to 2 previous errors | | |
| 27 | 21 | | |
| 28 | | -Some errors have detailed explanations: E0369, E0432. | |
| 29 | | -For more information about an error, try `rustc --explain E0369`. | |
| | 22 | +For more information about this error, try `rustc --explain E0369`. | | |