Skip to content
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

WIP: Add lint for String in diagnostic implementation #108461

Closed
wants to merge 1 commit into from

Conversation

clubby789
Copy link
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

@rustbot rustbot 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
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
Contributor Author

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
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
Copy link
Contributor

bors commented Mar 12, 2023

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

@Nilstrieb Nilstrieb 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
@clubby789 clubby789 closed this Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant 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.

None yet

5 participants