-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Remove unnecessary calls to Str::as_slice #22561
Conversation
r? @gankro (rust_highfive has picked a reviewer for you, use r? to override) |
7539298
to
2095799
Compare
Ok, I think I got everything, but no doubt I missed something in a test, on a platform I don't have to test on. A bors run would be helpful. there were cases where Deref coercions would have worked, but I opted for |
7829834
to
dc54f08
Compare
Following up from IRC, the places where I left More than happy to go back and fix them all |
@@ -443,6 +443,6 @@ mod tests { | |||
#[test] | |||
fn test_format() { | |||
let s = fmt::format(format_args!("Hello, {}!", "world")); | |||
assert_eq!(s.as_slice(), "Hello, world!"); | |||
assert_eq!(s.as_str(), "Hello, world!"); |
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.
Places like these I think should be fine to drop the as_str from, clarity-wise.
Yeah going over this the as_str's don't really seem to add anything outside of a generic context. I would just drop 'em where you can. |
Thanks for all the feedback! I'll revise when I get a chance. |
Could you also leave |
(Sadly, needs a rebase.) |
4c81487
to
40e4262
Compare
I redid this patch from scratch (I had some fairly lurky attempts to fix tests from the last time). Running make check now |
1f64c1f
to
f1357cd
Compare
r? @gankro I believe this is good to go out. the lldb tests are failing locally for me, but I believe it's because I have a wedged lldb install (Error in case it's not something I've done is |
Aaaaaand all tests pass on linux \o/ |
@@ -96,11 +96,11 @@ impl<S: Str> SliceConcatExt<str, String> for [S] { | |||
} | |||
|
|||
// `len` calculation may overflow but push_str will check boundaries | |||
let len = s.iter().map(|s| s.as_slice().len()).sum(); | |||
let len = s.iter().map(|s| s.as_str().len()).sum(); |
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.
This could be replaced with &s[..]
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.
There are a bunch of warnings about places I could use slice syntax, I figured I'd do this in two passes to make landing it feasible, although this was less churn than I expected.
I also wasn't sure if the syntax was dependant on a snapshot.
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 the slicing syntax should definitely be usable as-is today, thankfully it's been around for awhile!
It's still a little unclear to me whether we want to do this or not. I think that if generic conversion traits land then there's no real need for the I think it'd be totally fine, however, to land as much removal of |
Ok, I'll probably have a PR for that subset of this one in the next few days. |
Thanks @richo! |
Thanks to totally unforeseen organisation on my part, the rebase to only remove |
Nice! I updated the title and removed the |
@bors: r+ 5a930fd7ba381551a00f287c1506937ebb612d1f |
Great catch, cheers! |
⌛ Testing commit 5a930fd with merge 3f61b5d... |
💔 Test failed - auto-linux-64-x-android-t |
|
Test fixed, r? |
@bors: r+ |
@Manishearth you might want to remove this from the rollup, I was just eyeballing it and spotted a few things that look off, I think it got mangled in the rebase. I have make check running here, but I don't want to toast another rollup :( |
(already was removed 😄 ) |
Ok, make check passes. I'm planning to hand hold this through bors, since I don't have access to an android test environment. (Fingers crossed I caught everything this time though) |
This may not be quite ready to go out, I fixed some docs but suspect I missed a bunch. I also wound up fixing a bunch of redundant `[]` suffixes, but on closer inspection I don't believe that can land until after a snapshot.
This may not be quite ready to go out, I fixed some docs but suspect I missed a bunch.
I also wound up fixing a bunch of redundant
[]
suffixes, but on closer inspection I don't believe that can land until after a snapshot.