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

Special treatment empty tuple when suggest adding a string literal in format macro. #131430

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

surechen
Copy link
Contributor

@surechen surechen commented Oct 9, 2024

For example:

let s = "123";
println!({}, "sss", s);

Suggest:
println!("{:?} {} {}", {}, "sss", s);

fixes #130170

@rustbot
Copy link
Collaborator

rustbot commented Oct 9, 2024

r? @Nadrieril

rustbot has assigned @Nadrieril.
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 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. labels Oct 9, 2024
compiler/rustc_builtin_macros/src/format.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/format.rs Outdated Show resolved Hide resolved
tests/ui/macros/format-issue-130170.rs Outdated Show resolved Hide resolved
tests/ui/macros/format-issue-130170.rs Outdated Show resolved Hide resolved
@surechen surechen force-pushed the fix_130495 branch 2 times, most recently from 689cf08 to c1771b9 Compare October 9, 2024 07:17
@surechen surechen requested a review from jieyouxu October 9, 2024 07:19
@Nadrieril
Copy link
Member

r? @jieyouxu

@rustbot rustbot assigned jieyouxu and unassigned Nadrieril Oct 12, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, some last minor nits then r=me.

compiler/rustc_builtin_macros/src/format.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/format.rs Outdated Show resolved Hide resolved
compiler/rustc_builtin_macros/src/format.rs Outdated Show resolved Hide resolved
@jieyouxu jieyouxu 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 Oct 12, 2024
… format macro.

For example:
```rust
let s = "123";
println!({}, "sss", s);
```
Suggest:
`println!("{:?} {} {}", {}, "sss", s);`

fixes rust-lang#130170
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, r=me after PR CI is green.

@surechen
Copy link
Contributor Author

Thanks, r=me after PR CI is green.

Done. Thank you.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 14, 2024
@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 14, 2024

📌 Commit ceced53 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 14, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 14, 2024
Special treatment empty tuple when suggest adding a string literal in format macro.

For example:
```rust
let s = "123";
println!({}, "sss", s);
```
Suggest:
`println!("{:?} {} {}", {}, "sss", s);`

fixes rust-lang#130170
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129424 (Stabilize `Pin::as_deref_mut()`)
 - rust-lang#131332 (Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assembly)
 - rust-lang#131384 (Update precondition tests (especially for zero-size access to null))
 - rust-lang#131430 (Special treatment empty tuple when suggest adding a string literal in format macro.)
 - rust-lang#131550 (Make some tweaks to extern block diagnostics)
 - rust-lang#131667 (Fix AArch64InlineAsmReg::emit)
 - rust-lang#131679 (compiletest: Document various parts of compiletest's `lib.rs`)
 - rust-lang#131682 (Tag PRs affecting compiletest with `A-compiletest`)

Failed merges:

 - rust-lang#131496 (Stabilise `const_make_ascii`.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129424 (Stabilize `Pin::as_deref_mut()`)
 - rust-lang#131332 (Fix clobber_abi and disallow SVE-related registers in Arm64EC inline assembly)
 - rust-lang#131384 (Update precondition tests (especially for zero-size access to null))
 - rust-lang#131430 (Special treatment empty tuple when suggest adding a string literal in format macro.)
 - rust-lang#131550 (Make some tweaks to extern block diagnostics)
 - rust-lang#131667 (Fix AArch64InlineAsmReg::emit)
 - rust-lang#131679 (compiletest: Document various parts of compiletest's `lib.rs`)
 - rust-lang#131682 (Tag PRs affecting compiletest with `A-compiletest`)

Failed merges:

 - rust-lang#131496 (Stabilise `const_make_ascii`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 75231f8 into rust-lang:master Oct 14, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2024
Rollup merge of rust-lang#131430 - surechen:fix_130495, r=jieyouxu

Special treatment empty tuple when suggest adding a string literal in format macro.

For example:
```rust
let s = "123";
println!({}, "sss", s);
```
Suggest:
`println!("{:?} {} {}", {}, "sss", s);`

fixes rust-lang#130170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

does not detect {} not being in quotes when looking for a string literal, instead offers an incorrect solution
5 participants