Skip to content

WIP: Add lint for String in diagnostic implementation - #108461

Closed
clubby789 wants to merge 1 commit into
rust-lang:masterfrom
clubby789:lint-string-in-diag
Closed

WIP: Add lint for String in diagnostic implementation#108461
clubby789 wants to merge 1 commit into
rust-lang:masterfrom
clubby789:lint-string-in-diag

Conversation

@clubby789

Copy link
Copy Markdown
Contributor

Implementing the check described in #108162 (comment) so we can see what happens. Implemented as a lint so it can be #[allow]'d
cc @Nilstrieb

@rustbot label +A-translation
r? ghost

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic labels Feb 25, 2023
#[derive(LintDiagnostic)]
#[diag(lint_string_in_diag)]
#[note]
pub struct StringInDiagnostic;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a little disappointed that this doesn't contain a String☺️

@clubby789

Copy link
Copy Markdown
ContributorAuthor

It might be more useful to instead lint expressions constructing diagnostics so we can see if we're calling a potentially problematic function to construct the string. There's quite a few legitimate use cases here

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-llvm-14 failed! Check out the build log: (web)(plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:697bea7ddceb6696743da8f159f268aef8bfb3c6)
Complete job name: PR (x86_64-gnu-llvm-14, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
CI_JOB_NAME: x86_64-gnu-llvm-14
---
|
87 | pub us: String,
| ^^^^^^
|
= note: this could indicate incorrectly eagerly converting to a string
= note: `-D rustc::string-in-diagnostic` implied by `-D warnings`
error: use of String in diagnostic
--> compiler/rustc_session/src/errors.rs:93:13
|
93 | pub us: String,
---
error: use of String in diagnostic
--> compiler/rustc_session/src/errors.rs:255:17
|
255 | pub suffix: String,
|
= note: this could indicate incorrectly eagerly converting to a string
error: use of String in diagnostic
---
error: use of String in diagnostic
--> compiler/rustc_session/src/errors.rs:274:17
|
274 | pub suffix: String,
|
= note: this could indicate incorrectly eagerly converting to a string
error: use of String in diagnostic

@clubby789
clubby789 marked this pull request as draft March 3, 2023 11:57
@bors

bors commented Mar 12, 2023

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #108682) made this pull request unmergeable. Please resolve the merge conflicts.

@NoratriebNoratrieb added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 5, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-translationArea: Translation infrastructure, and migrating existing diagnostics to SessionDiagnosticS-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@clubby789@rust-log-analyzer@bors@Noratrieb@rustbot