rust-lang / rust-lang/rust

Tracking Issue for improving suggestion rendering in diagnostics

Open
#141,973 1 comment 2 reactions 1 assignee View on GitHub

@estebank is already working on this.

Since Jun 3, 2025.

A-diagnostics A-suggestion-diagnostics C-tracking-issue T-compiler WG-diagnostics
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for the prioritizing "verbose" or "hidden" suggestions over "inline" (the default given by span_suggestion suggestions.

Inline suggestions have several issues that make them less readable than verbose ones:

  • I've seen people get confused by them
  • Small differences caused by typos are much better seen on the verbose output, where the highlighting now points at the exact character, instead of having to visually notice the different text in non-aligned places
  • The inline output was the original implementation, but since we've introduced the diff output which is clearer on what we expect the user to write
  • For additions, things like "add a type parameter: " are even more unclear
  • Relying on the inline suggestions have lead us to use worse spans on purpose because otherwise the rendering would be bad (like skipping whitespace in some cases) and has a tendency to make suggestion mistakes harder to notice (broken suggestions making it in because we couldn't tell during review)
  • When a single suggestion is in the diagnostic, the default renders inline, but if there are two, then both get rendered as verbose, which makes the output sometimes sensitive to what was emitted and can cause two similar errors to look very different.
About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
  • Audit all cases of span_suggestion uses.
  • Adjust individual cases to be either span_suggestion_verbose, span_suggestion_hidden or span_suggestion_tool_only
  • Change span_suggestion to span_suggestion_inline and span_suggestion_verbose to span_suggestion
Implementation history

https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/Why.20are.20we.20making.20suggestions.20verbose.3F

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.