-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Moving away from deprecated i/u suffixes in libcore #21511
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
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
If everyone is happy with this change, I'll move forward with the rest. Otherwise, let me know what needs to be done and I'll give it a go. Note: I was thinking of updating [u]int => [u]isize, but that should be a separate change. |
I started looking through these and realized commenting on each one would be pointless. |
@eddyb I've tried looking for style on this but didn't find anything. The word on IRC today was to drop the suffix when it can be inferred, which I've done. Are you sure you want to drop most suffixes? e.g.
I deliberately didn't want to change the datatypes like above, only move away from the deprecated suffixes. |
@Alfie the type only changes if it's unconstrained anywhere, which seems a bit suspicious. Do you have examples of this? I'll look through the diff again, I guess. |
@@ -846,7 +846,7 @@ macro_rules! tuple { | |||
fn fmt(&self, f: &mut Formatter) -> Result { | |||
try!(write!(f, "(")); | |||
let ($(ref $name,)*) = *self; | |||
let mut n = 0i; | |||
let mut n = 0is; |
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.
First usage that needs annotation. Even then, this is used for 3 states, which would be only 2 if we were to special-case one-element tuples. Feels saner that way IMO.
We can do it without adding another case to the macro, too, and while removing the peel
helper macro.
Something like $first, $($name),*
.
None of the 3 cases I found would actually cause a subtle change in semantics (the last one would error if |
@eddyb Ok, no problem. I've updated the patch:
I'd like for the examples to be updated because it's going to be confusing in the future once i/u are no longer valid syntax. |
'E' | 'e' if radix == 10 => 10u as $T, | ||
'P' | 'p' if radix == 16 => 2u as $T, | ||
'E' | 'e' if radix == 10 => 10.0 as $T, | ||
'P' | 'p' if radix == 16 => 2.0 as $T, |
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.
You don't need as $T
at all, the type is either f32
or f64
.
@eddyb Thanks for that. I wasn't too sure about that one. |
I think much of the documentation can have the suffixes dropped too: in most cases it doesn't matter if it's a |
@huonw No problem. Fixed. |
@@ -150,13 +150,13 @@ default_impl! { (), () } | |||
default_impl! { bool, false } | |||
default_impl! { char, '\x00' } | |||
|
|||
default_impl! { uint, 0u } | |||
default_impl! { uint, 0us } |
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.
All of these suffixed integers should be able to be just 0
.
@eddyb Thanks for the clarification. I wasn't too sure about that one. Fixed. |
Right now the only |
@eddyb Thanks for that. I wasn't sure what to replace it with, but that looks reasonable. Fixed. |
@bors: r+ 4 Looks great! |
🙀 You have the wrong number! Please try again with |
@bors: r+ 45b6d40 (Drat, a single letter is too short. 😝 ) |
⌛ Testing commit 45b6d40 with merge b64d9fe... |
💔 Test failed - auto-mac-32-opt |
Was that auto-mac-32-opt failure legit? |
@@ -1138,7 +1138,7 @@ pub trait AdditiveIterator<A> { | |||
/// ``` | |||
/// use std::iter::AdditiveIterator; | |||
/// | |||
/// let a = [1i, 2, 3, 4, 5]; | |||
/// let a = [1, 2, 3, 4, 5]; |
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 this needs a suffix (e.g. 1i32
).
@Alfie yeah, I think so. |
@huonw Thanks. Ok, will fix. Can you just clear something up for me please. These are all in comments and not code, but it still failed? Also, you said to make the following to an i32:
I thought that if an integer doesn't have a suffix, it's typed as an i32 as a default? If so, why should this need an i32 suffix? |
The I'm not sure what's happening with those examples, but inference can be a little sensitive/less-than-perfect when there's closures around, at the moment. |
@huonw Thanks for the explanation. |
@bors: r+ 42958d3 |
@@ -258,7 +258,29 @@ impl CharExt for char { | |||
#[inline] | |||
#[unstable = "pending decision about Iterator/Writer/Reader"] | |||
fn encode_utf8(self, dst: &mut [u8]) -> Option<uint> { | |||
encode_utf8_raw(self as u32, dst) | |||
// Marked #[inline] to allow llvm optimizing it away |
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.
Hm, why was this changed?
I got a conflict while rebasing onto master. I was sure I resolved it correctly. Fixing now :( |
Apologies. I resolved the conflict that the wrong way. Fixed. |
⌛ Testing commit f67e747 with merge 70b13a7... |
No description provided.