Skip to content

Configure snippets renderer to match rustc/Cargo style #15689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

kornelski
Copy link
Contributor

Renderer::styled() defaults to green labels for note and help, but Cargo and rustc use cyan.

@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-console-output Area: Terminal output, colors, progress bar, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 21, 2025
@@ -415,7 +415,11 @@ impl Shell {
writeln!(
self.err(),
"{}",
Renderer::styled().term_width(term_width).render(message)
Renderer::styled()
.note(NOTE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a pr to annotate snippets if there is a discrepancy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand.

shell.render_message(Level::Note.title("foo")) uses a wrong color. The snippets don't specify a color themselves by design, the color is imposed on the snippets by the stylesheet initialized by styled().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. I thought the CI test failure was a false positive:

     Summary semver requires new major version: 1 major and 0 minor checks failed
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/constructible_struct_adds_field.ron

but there's also a UI test failing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation is that annotate-snippets defaults are rustc's defaults. If annotate-snippets is not matching rustc, then that is a bug with annotate-snippers that should be resolved. We should not work around that bug in Cargo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, i would recommend being pretty sure about a resolution when marking things resolved, otherwise leave it to the original person. While this is a smaller PR and so its less likely to be lost, in larger PRs that can easily make it so misunderstood feedback gets lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants