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

Avoid reporting string_lit_as_bytes for long strings #4233

Merged
merged 2 commits into from
Jul 9, 2019

Conversation

thiagoarrais
Copy link
Contributor

Port of @jens1o code (b76f939)

Fixes #1208

changelog: bugfix for long strings as bytes

@flip1995 flip1995 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 26, 2019
@jens1o
Copy link
Contributor

jens1o commented Jul 5, 2019

Ah, thank you. And I'm terribly sorry for not continuing the work. :(

@thiagoarrais
Copy link
Contributor Author

No problem! Thanks for the initial work. This is mostly your code. I've just ported it.

@@ -173,6 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
);
} else if callsite == expanded
&& lit_content.as_str().chars().all(|c| c.is_ascii())
&& lit_content.as_str().len() <= 32
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to extract the number into a const and add a small comment to 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.

How about 7d1a944?

jens1o and others added 2 commits July 8, 2019 13:13
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

LGTM. cc @phansch?

@phansch
Copy link
Member

phansch commented Jul 9, 2019

@bors r=phansch,flip1995

thanks!

@bors
Copy link
Collaborator

bors commented Jul 9, 2019

📌 Commit 7d1a944 has been approved by phansch,flip1995

@bors
Copy link
Collaborator

bors commented Jul 9, 2019

⌛ Testing commit 7d1a944 with merge 5c921a9...

bors added a commit that referenced this pull request Jul 9, 2019
Avoid reporting string_lit_as_bytes for long strings

Port of @jens1o code ([b76f939][jens1o_commit])

Fixes #1208

[jens1o_commit]: jens1o@b76f939

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [ ] Followed [lint naming conventions][lint_naming]
- [ ] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [ ] Executed `util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `cargo fmt`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

changelog: bugfix for long strings as bytes
@bors
Copy link
Collaborator

bors commented Jul 9, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: phansch,flip1995
Pushing 5c921a9 to master...

@bors bors merged commit 7d1a944 into rust-lang:master Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint string_lit_as_bytes should not be reported for string literal of length 33 and more
5 participants