-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
std: add some missing repr(transparent) #114800
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
Once #111544 is stable I think it'll be ok for |
library/core/src/ffi/c_str.rs
Outdated
// For now we just hide this from rustdoc, technically making our doc test builds rely on | ||
// unspecified layout assumptions. We are std, so we can get away with that. | ||
#[cfg_attr(not(doc), repr(transparent))] |
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.
Are you sure this affects doc tests? I tried this on a new library and it compiled, but failed the assertion:
/// ```
/// assert!(cfg!(doc));
/// ```
pub struct Foo(u32);
I do expect your cfg
will affect how rustdoc parses the source when it looks for doctests, but not the actual library or doctest build.
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.
Another way to see that doc tests are not affected:
/// ```
/// use lib::Foo;
/// use std::mem::align_of;
///
/// assert!(!cfg!(doc));
/// assert_eq!(align_of::<Foo>(), align_of::<u32>());
/// ```
#[cfg_attr(doc, repr(packed))]
pub struct Foo(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.
Oh, I guess doctests are built with cfg(doctest)
... nice! So this is actually a reasonable approach then.
@bors r+ rollup |
std: add some missing repr(transparent) For some types we don't want to stably guarantee this, so hide the `repr` from rustdoc. This nice approach was suggested by `@thomcc.`
Won't this still show up for inlined docs? Those are reading from the crate metadata of a regular compilation. |
…llaumeGomez Rollup of 10 pull requests Successful merges: - rust-lang#114711 (Infer `Lld::No` linker hint when the linker stem is a generic compiler driver) - rust-lang#114772 (Add `{Local}ModDefId` to more strongly type DefIds`) - rust-lang#114800 (std: add some missing repr(transparent)) - rust-lang#114820 (Add test for unknown_lints from another file.) - rust-lang#114825 (Upgrade std to gimli 0.28.0) - rust-lang#114827 (Only consider object candidates for object-safe dyn types in new solver) - rust-lang#114828 (Probe when assembling upcast candidates so they don't step on eachother's toes in new solver) - rust-lang#114829 (Separate `consider_unsize_to_dyn_candidate` from other unsize candidates) - rust-lang#114830 (Clean up some bad UI testing annotations) - rust-lang#114831 (Check projection args before substitution in new solver) r? `@ghost` `@rustbot` modify labels: rollup
Oh, yes it does for The rest are |
That flaw also exists for other core/std re-exports -- |
Hm, instead of reverting can we add a comment saying that the |
clarify CStr lack of layout guarnatees Follow-up to rust-lang#114800 r? `@cuviper`
clarify CStr lack of layout guarnatees Follow-up to rust-lang/rust#114800 r? `@cuviper`
For some types we don't want to stably guarantee this, so hide the
repr
from rustdoc. This nice approach was suggested by @thomcc.