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

Add suggestion to quote inlined format argument as string literal #114507

Merged
merged 1 commit into from Aug 11, 2023
Merged

Add suggestion to quote inlined format argument as string literal #114507

merged 1 commit into from Aug 11, 2023

Conversation

sebastiantoh
Copy link
Contributor

Fixes #114235

@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2023

r? @jackh726

(rustbot has picked a reviewer for you, use r? to override)

@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 Aug 5, 2023
Copy link
Contributor

@darklyspaced darklyspaced left a comment

Choose a reason for hiding this comment

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

all in all, this looks great. just a minor nit and a tentative proposal. thanks!

(unexpanded_fmt_span.shrink_to_hi(), "\"".to_string()),
(unexpanded_fmt_span.shrink_to_lo(), "\"".to_string()),
],
Applicability::MaybeIncorrect,
Copy link
Contributor

Choose a reason for hiding this comment

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

i can't think of any situations where this suggestion would ever produce code that wouldn't compile. i'm not exactly sure of the exact use cases for Applicability::MachineApplicable and how rigorously provable the suggestions must be, but due to the relatively simplicity of the suggestion and the general unambiguity surrounding the purpose of println! and associated macros, I think its fair to annotate this suggestion as MachineApplicable. let me know if i'm overlooking something obvious though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the original you might be missing a string literal to format with suggestion, I can't think of cases where the suggestion would produce code that wouldn't compile too. Yet, it uses Applicability::MaybeIncorrect. This is why I used Applicability::MaybeIncorrect in this new suggestion. Do you think I should change both to Applicability::MachineApplicable?

Copy link
Member

Choose a reason for hiding this comment

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

I think keeping MaybeIncorrect is probably best for now.

|
help: you might be missing a string literal to format with
|
LL | eprintln!("{}", {1});
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: removing the braces when there is only one distinct 'statement' would be nice, if you're up for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the suggestion! will look into it outside of this PR 😄

@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 10, 2023

📌 Commit d003fd9 has been approved by jackh726

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 Aug 10, 2023
@bors
Copy link
Contributor

bors commented Aug 11, 2023

⌛ Testing commit d003fd9 with merge e286f25...

@bors
Copy link
Contributor

bors commented Aug 11, 2023

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing e286f25 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 11, 2023
@bors bors merged commit e286f25 into rust-lang:master Aug 11, 2023
12 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Aug 11, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e286f25): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.6% [3.6%, 3.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 631.684s -> 632.934s (0.20%)

@sebastiantoh sebastiantoh deleted the issue-114235 branch August 11, 2023 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

format argument must be a string literal could suggest inline args
6 participants