-
Notifications
You must be signed in to change notification settings - Fork 13k
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
A few cleanups and minor improvements to typeck #54591
Conversation
r? @zackmdavis (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace-only changes could have been a separate commit; bulleted list in PR description could have gone in commit messages (code archeology often benefits from having information in the repository itself, as well as on GitHub).
@@ -75,7 +75,7 @@ impl<'a, 'tcx> CheckVisitor<'a, 'tcx> { | |||
let msg = if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { | |||
format!("unused import: `{}`", snippet) | |||
} else { | |||
"unused import".to_string() | |||
"unused import".to_owned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer .to_owned
over .to_string
for literals (the former indicates that we're getting ownership of something which is already a string in some sense of the word, whereas the latter could be anything Display
-able), but it's possible that we're in the minority insofar as The Book recommends .to_string
or String::from
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think The Book just recommends the solution that is simplest to grasp and remember; to_string
calls String::from
which, in turn, calls to_owned()
, so everything boils down to to_owned
anyways.
"missing associated type `{}` value", assoc_item.ident)) | ||
.emit(); | ||
struct_span_err!(tcx.sess, span, E0191, "the value of the associated type `{}` \ | ||
(from the trait `{}`) must be specified", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someday we should probably get rustfmt
working on this codebase (which might require some special tooling; compare #53896). I unambiguously agree with most of the spacing changes in this PR, but where my personal æsthetics happen to disagree (here, I would treat the format varargs the same as the other arguments to struct_span_err!
rather than aligning them to the format string), I tend to doubt that that degree of bikeshedding is part of my duty as a reviewer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess at one point whitespace tidying will become automated; just I adjust some spots as I go to what I feel looks more readable and hope I'm not the one who feels that way 😜.
📌 Commit c8c3395 has been approved by |
…davis A few cleanups and minor improvements to typeck This PR complements rust-lang#54533, which was limited to `check`. - change a few `push` loops to `extend`s - prefer `to_owned` to `to_string` for string literals - prefer `if let` to `match` where only one branch matters - a few other minor improvements - whitespace fixes
@zackmdavis thanks for the review! I'll try to be a bit more specific with my commits in the future. |
⌛ Testing commit c8c3395 with merge 321da78633faaf2b6f2f88277deba5b53c7f766d... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The error seems spurious. |
@bors: retry |
☔ The latest upstream changes (presumably #54278) made this pull request unmergeable. Please resolve the merge conflicts. |
c8c3395
to
608c395
Compare
Rebased. |
@bors r+ |
📌 Commit 608c395 has been approved by |
A few cleanups and minor improvements to typeck This PR complements #54533, which was limited to `check`. - change a few `push` loops to `extend`s - prefer `to_owned` to `to_string` for string literals - prefer `if let` to `match` where only one branch matters - a few other minor improvements - whitespace fixes
☀️ Test successful - status-appveyor, status-travis |
This PR complements #54533, which was limited to
check
.push
loops toextend
sto_owned
toto_string
for string literalsif let
tomatch
where only one branch matters