-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Emit a single error when importing a path with _
#142805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When encountering `use _;`, `use _::*'` or similar, do not emit two errors for that single mistake. This also side-steps the issue of resolve errors suggesting adding a crate named `_` to `Cargo.toml`.
rustbot has assigned @petrochenkov. Use |
@@ -711,6 +711,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | |||
|
|||
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{msg}"); | |||
|
|||
if errors.iter().all(|(_, err)| err.segment == Some(kw::Underscore)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to inconsistent behavior in code like use {_, a}
. I'd rather we filter out the errors mentioning _
like we're doing with that errors.retain
call above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And while we're at it, we probably should delay a bug in the:
if errors.is_empty() {
return;
}
on 691.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this pr touches this test, could we also rename it with some more descriptive name and put a small comment with a link on an issue related to this instead?
When encountering
use _;
,use _::*'
or similar, do not emit two errors for that single mistake. This also side-steps the issue of resolve errors suggesting adding a crate named_
toCargo.toml
.Fix #142662.