-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Proposal
Currently, there are two cases in which suggestions in diagnostics are invalid: their spans span more than one file, or their span overlaps. In the former case, we skip the suggestion silently, in the latter we ICE.
This is the code that skips suggestions when they span multiple files: https://github.com/rust-lang/rust/blob/c8a31b780d5415358566a20b94912620a3f27067/compiler/rustc_errors/src/lib.rs#L371
This usually is good! It often means a broken diagnostic. However, this code shows that because users can change the spans on tokens, they can cause spans to overlap, and diagnostics to ICE:
Currently, we ICE here because when running rustfix, it crashes when suggestions overlap.
My proposal is to, instead of ICEing, omit suggestions with invalid spans, but not silently.
This means we also don't emit these suggestions in JSON output; that way rustfix doesn't stumble over them.
This pull request shows what that would look like: rust-lang/rust#147849, and specifically here:
https://github.com/jdonszelmann/rust/blob/b876dd753e0dcc6be5c0b6c1ed6844b67266dc25/tests/ui/parser/attribute/invalid-delimeter-ice-146808.stderr#L8
is an example of what "non silent omission" could look like.
I think this is better than either crashing or silently omitting suggestions.
Mentors or Reviewers
If you have a reviewer or mentor in mind for this work, mention them here. You can put your own name here if you are planning to mentor the work.
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member who is knowledgeable in the area can second by writing
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.- Refer to Proposals, Approvals and Stabilization docs for when a second is sufficient, or when a full team FCP is required.
- Once an MCP is seconded, the Final Comment Period begins.
- Final Comment Period lasts for 10 days after all outstanding concerns are solved.
- Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
- If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.
You can read more about Major Change Proposals on forge.