-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Document std::os::raw. #46962
Document std::os::raw. #46962
Conversation
r? @Kimundi (rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/os/raw/mod.rs
Outdated
/// and `*mut c_void` is equivalent to C's `void*`. That said, this is | ||
/// *not* the same as C's `void` return type, which is Rust's `()` type. | ||
/// | ||
/// [pointer]: ../primitive.pointer.html |
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.
Broken link. Needs two ../
I guess.
[01:21:17] std/os/raw/index.html:66: broken link - std/os/primitive.pointer.html
[01:21:17] std/os/raw/enum.c_void.html:56: broken link - std/os/primitive.pointer.html
[01:21:26] thread 'main' panicked at 'found some broken links', /checkout/src/tools/linkchecker/main.rs:49:8
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 double-checked every link but this one. ><
src/libstd/os/raw/char.md
Outdated
|
||
[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. In practice, this type will always be either [`i8`] or [`u8`], but you're technically not supposed to rely on this behaviour, as the standard only defines a char as being at least eight bits long. | ||
|
||
C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with a zero. See [`CStr`] for more information. |
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.
C strings mark the end of a string with a zero
This is slightly misleading as someone might think it means 0
the character, not the literal integer value 0.
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.
Would clarifying "the character '\0' " be sufficient?
src/libstd/os/raw/long.md
Outdated
@@ -0,0 +1,8 @@ | |||
Equivalent to C's `signed long` (`long`) type. | |||
|
|||
This type will usually be [`i64`], but is sometimes [`i32`] \(i.e. [`isize`]\) on 32-bit systems. Technically, the standard only requires that it be at least 32 bits, or at least the size of an [`int`]. |
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.
Also note that it is equivalent to i32
even on 64bit Windows.
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 was not aware of this; I'll remove the remarks about isize
and usize
in these docs.
Made revisions per comments |
src/libstd/os/raw/schar.md
Outdated
@@ -0,0 +1,6 @@ | |||
Equivalent to C's `signed char` type. | |||
|
|||
This type will almost always be [`i8`], but its size is technically equal to the size of a C [`char`], which isn't very clear-cut. |
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.
The use of "isn't very clear-cut" throughout the number docs feels awkward. Is there any guidance we can paraphrase here? If not, i'd rather we use a phrase like "which is left under-specified" to make it feel marginally less wishy-washy.
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.
Fair; I was trying to avoid duplicating the docs too much, although it's mostly wishy-washy because C's definitions are incredibly wishy-washy.
I'll probably replace it with "which does not have a strict definition like Rust does" or something a bit more eloquent.
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 don't see how C doesn't have a strict definition of size of signed char
😄. In C a char
's size is defined to be 1 byte, always (although 1 byte is not defined to be 8 bits) (C11 §6.5.3.4/4).
Unless Rust is going to support non-8-bit-byte system, a signed char
is always an i8
.
Hi @clarcharr, just checking if this PR is still actively worked on. Could you rephrase the sentence in #46962 (review)? Thanks! |
@kennytm will do in a bit! |
Ping from triage, @clarcharr ! We haven't heard from you in a week; will you still be able to make the most recent set of changes? |
@shepmaster + @kennytm + @QuietMisdreavus my laptop was out of commission for a bit and I'm working on rewording things right now. |
7137420
to
b95498f
Compare
I've pushed the latest version; let me know if things are okay! |
b95498f
to
2cab068
Compare
src/libstd/os/raw/uint.md
Outdated
@@ -0,0 +1,7 @@ | |||
Equivalent to C's `unsigned int` type. | |||
|
|||
This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. |
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.
Is that first u16
supposed to be a 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.
...yes
Ping from triage @QuietMisdreavus! |
I was still waiting on one last change, but it was small enough that i put it in myself. (Sorry @clarcharr! @bors r+ |
📌 Commit fefd5e9 has been approved by |
@QuietMisdreavus I actually think I have the commit on my machine but I forgot to push >< |
@bors rollup |
…eavus Document std::os::raw. This adds a brief explanation to each type and its definition according to C. This also helps clarify that the definitions of the types, as described by rustdoc, are not necessarily the same from platform to platform.
This adds a brief explanation to each type and its definition according to C. This also helps clarify that the definitions of the types, as described by rustdoc, are not necessarily the same from platform to platform.