-
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
Primitive docs relevant #48152
Primitive docs relevant #48152
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/libcore/num/mod.rs
Outdated
``` | ||
let n = 0b01001100", stringify!($SelfT), "; | ||
|
||
assert_eq!(n.count_zeros(), 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.
This doesn't seem right; wouldn't the number of zeroes depend on the size of the type? It should be the number of bits in the type minus 3.
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.
It would indeed!
@@ -1436,33 +1446,35 @@ macro_rules! uint_impl { | |||
unsafe { intrinsics::ctlz(self as $ActualT) as u32 } |
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.
Shouldn't the example of leading_zeroes get the same treatment, rather than hardcoding u16
?
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.
(And ditto for other methods here whose docs still list specific types in their examples.)
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.
Some methods were left as is because it was hard to make the example generic.
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.
If you can't convert all the examples, I would like to see the "examples are shared between primitive integer types" notice kept on the primitive docs, since it still applies.
4f202bf
to
dcc9f74
Compare
dcc9f74
to
9a30673
Compare
Should be good now. |
Tests passed! |
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.
Just a couple notes. Thanks so much for doing this!
int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, | ||
170141183460469231731687303715884105727, "#![feature(i128_type)] | ||
#![feature(i128)] | ||
# fn main() { |
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.
Wait, does this actually need the manual fn main
? Rustdoc should move those feature flags outside its generated main function.
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.
Apparently it fails otherwise. I was quite surprised as well...
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 wonder if it has to do with line breaks. Did your previous attempt have a line break after the feature flags? I think rustdoc doesn't do anything fancier than "if the line starts with #![
, splice out the whole line".
@@ -1436,33 +1446,35 @@ macro_rules! uint_impl { | |||
unsafe { intrinsics::ctlz(self as $ActualT) as u32 } |
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.
If you can't convert all the examples, I would like to see the "examples are shared between primitive integer types" notice kept on the primitive docs, since it still applies.
57ca76a
to
57498e1
Compare
|
57498e1
to
4380672
Compare
|
4380672
to
4a42042
Compare
|
4a42042
to
d692e94
Compare
Looks like we're all set! Thanks so much! @bors r+ |
📌 Commit d692e94 has been approved by |
…uietMisdreavus Primitive docs relevant This fixes the documentation to show the right types in the examples for many integer methods. I need to check if the result is correct before we merge.
@bors r- Unfortunately this PR failed on 32-bit platforms.
|
src/libcore/num/mod.rs
Outdated
} | ||
|
||
#[cfg(target_pointer_width = "32")] | ||
#[lang = "isize"] | ||
impl isize { | ||
int_impl! { isize, i32, u32, 32 } | ||
int_impl! { isize, i32, u32, 32, "", "" } |
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 are missing -2147483648, 2147483647
here. Similar for the 16-bit code at line 1374 above.
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.
Indeed, thanks!
d692e94
to
a58409d
Compare
Fixed. @bors: r=QuietMisdreavus |
📌 Commit a58409d has been approved by |
…uietMisdreavus Primitive docs relevant This fixes the documentation to show the right types in the examples for many integer methods. I need to check if the result is correct before we merge.
This fixes the documentation to show the right types in the examples for many integer methods.
I need to check if the result is correct before we merge.