Skip to content

Omit suggestions when spans overlap #929

Closed

Description

@jdonszelmann

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:

  • File an issue describing the proposal.
  • A compiler team member who is knowledgeable in the area can second by writing @rustbot second or kickoff a team FCP with @rfcbot fcp $RESOLUTION.
  • 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.

Activity

  1. added
    T-compiler
    major-change
    on Oct 18, 2025
  2. rustbot commented on Oct 18, 2025

    @rustbot
    Collaborator

    Important

    This issue is not meant to be used for technical discussion. There is a Zulip stream for that.
    Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

    Concerns or objections can formally be registered here by adding a comment.

    @rustbot concern reason-for-concern
    <description of the concern>
    

    Concerns can be lifted with:

    @rustbot resolve reason-for-concern
    

    See documentation at https://forge.rust-lang.org

    cc @rust-lang/compiler
  3. added
    to-announce
    on Oct 18, 2025
  4. davidtwco commented on Oct 28, 2025

    @davidtwco
    Member

    @rustbot second

  5. added
    final-comment-period
    on Oct 28, 2025
  6. removed
    to-announce
    on Nov 7, 2025
  7. rustbot commented on Nov 7, 2025

    @rustbot
    Collaborator

    The final comment period is now complete, this major change is now accepted. 🎉

    As the automated representative, I want to express gratitude to the author for their work and everyone else who contributed to this major change proposal.

    If you think this major change shouldn't have been accepted, feel free to remove the major-change-accepted label and reopen this issue.

    Note

    Further progress is now tracked over at rust-lang/rust#148645.

  8. added
    major-change-accepted
    and removed
    final-comment-period
    on Nov 7, 2025
  9. added
    to-announce
    on Nov 7, 2025
  10. removed
    to-announce
    on Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilermajor-changemajor-change-accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions