Fix panic in rustfix on overlapping suggestions#16705
Fix panic in rustfix on overlapping suggestions#16705raushan728 wants to merge 3 commits intorust-lang:masterfrom
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| } | ||
|
|
||
| #[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 |
Fixes #13030
What changed?
Updated
apply_suggestionsinrustfixto gracefully skip non-identical overlapping suggestions instead of propagating theAlreadyReplacederror.Added a unit test to verify the fix.