Skip to content

Avoid having both primary and secondary underlines on the same spans by supporting multiple primary errors. #41850

Closed
@Nickforall

Description

@Nickforall

While working on #41256, @jonathandturner proposed a specific syntax for having multiple primary errors on one line, like the example below. This required changes to the way the DiagnosticBuilder works and since I don't have enough knowledge of the codebase I am writing this follow-up issue.

An error with multiple unused arguments will look like the example below after merging #41256.

error: multiple unused formatting arguments
  -->  /Users/nickvernij/Programming/rust/src/test/ui/macros/format-foreign.rs:12:5
   |
12 |     println!("%.*3$s %s!/n", "Hello,", "World", 4);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^
   |                              |         |        |
   |                              |         |        unused
   |                              |         unused
   |                              unused
   |

This example is having the same kind of error multiple times in one expression, and would ultimately look something like the example below since we try to avoid having both primary and secondary underlines on the same spans:

error: multiple unused formatting arguments
  -->  /Users/nickvernij/Programming/rust/src/test/ui/macros/format-foreign.rs:12:5
   |
12 |     println!("%.*3$s %s!/n", "Hello,", "World", 4);
   |                              ^^^^^^^^  ^^^^^^^  ^  
   |                              |         |        |
   |                              ------------------------- unused

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions