fix: treat intra-suggestion overlaps as InternalError instead of panicking#16705
fix: treat intra-suggestion overlaps as InternalError instead of panicking#16705raushan728 wants to merge 4 commits intorust-lang:masterfrom
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
crates/rustfix/src/lib.rs
Outdated
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
There was a problem hiding this comment.
Our contrib guide asks for tests to be added in a prior commit, reproducing the current problem (with the tests passing). The fix would then update the tests to show the new behavior
There was a problem hiding this comment.
Note I was just focusing on process. As there isn't an end-to-end test because this is fixing a theoretical problem and not a real problem, I don't feel qualified to review this.
|
r? ehuss Would you be up for this considering this is a fix for a theoretical problem? I don't have much context for the actual problem to be able to tell if this addresses it. |
|
From #13030 (comment)
It requires a multi-suggestion that is Machine Applicable but because we can't support that (at the UX level), the compiler shouldn't emit it. |
|
@weihanglo @epage about the e2e test making a real-world snapshot test is pretty hard bcz we'd have to force rustc to emit multiple exclusive that's exactly y i added a unit test to mock this edge case directly in let me know what u guys think or if u want me to try a diff approach |
|
We do have a mock rustc for cargo's test suite in https://github.com/rust-lang/cargo/blob/master/tests/testsuite/fix_n_times.rs |
|
hi @epage added an e2e test in while digging in, realized the real issue was in LMK what you think! |
A benefit to the panic that came up during office hours is that if the compiler developer tests their fix, they will see the panic and know that they shouldn't do this. If we silently ignore it, there will be no feedback look for the compiler developer. |
|
Yes. I also want to "leave" panic there. I don't think without a real world example this is going to anywhere. |
|
@epage @weihanglo Makes total sense! I get the need for a loud feedback loop. Quick thought before I close this: Should we catch this specific overlap and throw a targeted panic instead of the generic one? e.g., This keeps the panic but tells the compiler dev exactly what went wrong. Let me know if u want this |
|
I could see it being helpful to have a more specific panic or error message. In particular, Cargo has an |
|
@epage updated the PR It now returns an |
| } | ||
|
|
||
| #[cargo_test] | ||
| fn fix_exclusive_suggestions() { |
There was a problem hiding this comment.
Tests should be in commits before the change
|
Please clean up the commits to reflect how this should be reviewed and merged and not how this was developed. |
Fixed #13030
Rustc sometimes gives multiple overlapping
MachineApplicablesuggestions for the exact same span. Before, this would either panic or quietly skip them. Now we catch this case properly and throw a clearcargo::util::internalerror with a message asking the user to report it as a compiler bug.Also added an end-to-end test in
tests/testsuite/fix_n_times.rsto make sure the new error message looks right.