-
Notifications
You must be signed in to change notification settings - Fork 73
Omit suggestions when spans overlap #929
Copy link
Copy link
Closed
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
Description
Activity
Metadata
Metadata
Assignees
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
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:
rust-lang/rust@436c2eb
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:
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.You can read more about Major Change Proposals on forge.