-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Unnecessary parentheses warning is printed twice #88256
Comments
I'm not an expert on the compiler, so I'm not the right person to ask. However, I would say changing the hash might not be a good idea, since I think it would be bad to lose the children, or have it be non-deterministic which diagnostic gets emitted. It's also dangerous to have the Hash implementation out of sync with PartialEq since some code may be assuming those are in sync. For this particular issue, I would investigate more why there are multiple lints getting triggered with different sets of children, and see if it is possible to avoid emitting multiple lints. Or if multiple are emitted to make sure they are the same. |
I have more debugging on this. There are two execute paths finally flow to analyze the expr, fn visit_expr(&mut self, e: &'a ast::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
run_early_pass!(cx, check_expr, e); // C1: create fir the diagnostic
ast_visit::walk_expr(cx, e); // C2: create the second diagnostic
})
} The C1 will finally call to check_expr Seems it's common in Rustc lint, since I see some code is trying to remove duplicates. Then, why there is only the first diagnostic that contains children? The child is a note for diagnostic:
This is because when lint try to add a diagnostic, let id_span_message = (msg_id, span_maybe, message.to_owned());
let fresh = self.one_time_diagnostics.borrow_mut().insert(id_span_message); |
These two test cases have similar duplicated warnings reported out: |
How do you think @estebank , do you think custom Hash is the right way for this? I'm a beginner in hacking Rust compiler, maybe you have any more idea. |
… r=estebank Fix rust-lang#88256 remove duplicated diagnostics Fix rust-lang#88256
… r=estebank Fix rust-lang#88256 remove duplicated diagnostics Fix rust-lang#88256
… r=estebank Fix rust-lang#88256 remove duplicated diagnostics Fix rust-lang#88256
This code:
Gives unnecessary parentheses warning twice:
Reproduced with stable 1.54.0 and nightly 2021-08-22 af14075 on playground.
Playground link
The text was updated successfully, but these errors were encountered: