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

Do not suggest char literal for zero-length strings #92715

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

chordtoll
Copy link
Contributor

PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided.

The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint.

This PR adds the missing check, and a test case to confirm the new behavior.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 10, 2022
@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2022
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This looks great, apologies for the delay in reviewing, I've left one comment in the existing thread, after that we can merge this :)

compiler/rustc_infer/src/infer/error_reporting/mod.rs Outdated Show resolved Hide resolved
@davidtwco davidtwco 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 Jan 16, 2022
@davidtwco
Copy link
Member

@bors r+ rollup

@JohnCSimon
Copy link
Member

Triage:
@chordtoll this looks like it's ready for review

@rustbot ready

@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 Feb 6, 2022
@davidtwco
Copy link
Member

Looks like bors just missed my comment and I didn't notice, oops:

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 8, 2022

📌 Commit 9622a42 has been approved by davidtwco

@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 Feb 8, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 8, 2022
Do not suggest char literal for zero-length strings

PR rust-lang#92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided.

The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint.

This PR adds the missing check, and a test case to confirm the new behavior.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 9, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#91950 (Point at type when a `static` `#[global_allocator]` doesn't `impl` `GlobalAlloc`)
 - rust-lang#92715 (Do not suggest char literal for zero-length strings)
 - rust-lang#92917 (Don't constrain projection predicates with inference vars in GAT substs)
 - rust-lang#93206 (Use `NtCreateFile` instead of `NtOpenFile` to open a file)
 - rust-lang#93732 (add fut/back compat tests for implied trait bounds)
 - rust-lang#93764 (:arrow_up: rust-analyzer)
 - rust-lang#93767 (deduplicate `lcnr` in mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8429dcd into rust-lang:master Feb 9, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 9, 2022
@chordtoll chordtoll deleted the empty-string branch February 9, 2022 04:06
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.

9 participants