-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Extract core::ffi primitives to a separate (internal) module
#136334
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
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
@rustbot author |
This comment has been minimized.
This comment has been minimized.
|
I am having issues with the tidy verification ATM. It seems that when I move c_char and c_long to primitives.rs, I get the tidy errors: I guess it does not like that I have platform-specific configuration checks in primitive.rs. I am not too familiar with tidy and have not found much on the docs but will continue to look into how I can migrate both types to primitives.rs. |
Searching for "platform-specific cfg" points here rust/src/tools/tidy/src/pal.rs Line 114 in 6c1d960
EXCEPTION_PATHS at the top of that file.
You'll have to move (Fyi |
|
Yes, adding the tidy exception is fine. |
|
I am having issues with the type_alias macro in mod.rs during compilation. Basically, although I insert primitives.rs into mod.rs after the macro type_alias, the compiler still throws the error that the types are missing a stability attribute. I am unsure as to why, any ideas @tgross35 @jieyouxu ? mod.rs macro_rules! type_alias {
{
$Docfile:tt, $Alias:ident = $Real:ty;
$( $Cfg:tt )*
} => {
#[doc = include_str!($Docfile)]
$( $Cfg )*
#[stable(feature = "core_ffi_c", since = "1.64.0")]
pub type $Alias = $Real;
}
}
// Primitives contains listed types.
// Contained in seperate file for simple parsing.
mod primitives;
pub use self::primitives::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_ptrdiff_t, c_schar, c_short, c_size_t,
c_ssize_t, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort,
};primitives.rs type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] }
[...]error |
|
It may be complaining about wanting a stability attribute on |
|
I just did not think it was necessary to add the stability attribute when adding the primitive module as it uses the type_alias to define the stability attributes for each type. |
core::ffi primitives to a separate module
core::ffi primitives to a separate modulecore::ffi primitives to a separate (internal) module
|
In a way it is kind of weird since the module is private, but it also makes sense - already-public items may be exported in new modules, unstably. (I had to go through this thought process myself) You will probably have to split the |
|
I tried the ../ method and it doesn't seem to find the correct path when I was testing. Why could I not keep it how it is ("c_char.md") if primitives.rs is in the same directory as the md files? |
|
Oh, my bad; I was thinking this moved to a subdirectory, but you're right 👍 |
|
@rustbot ready |
tgross35
left a comment
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.
Looks great! Please squash then r=me
|
@bors r=tgross35 |
|
@ricci009: 🔑 Insufficient privileges: Not in reviewers |
|
@tgross35 not sure if I did the r=me thing correctly but squashed and ready to go! |
|
r=me is just a convention but doesn’t actually do anything, bors still checks permissions. Thanks! @bors r+ |
| } => { | ||
| #[doc = include_str!($Docfile)] | ||
| $( $Cfg )* | ||
| #[stable(feature = "core_ffi_c", since = "1.64.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.
Can we mark this as something like stable_internal for private modue?
Or just #[stable(feature = "", since = "")]
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'm not sure what you are asking for here; this is the gate for types like https://doc.rust-lang.org/stable/core/ffi/type.c_char.html, which are public.
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 see, I mean this primitives.rs is a private module, there is no need attach stable/unstable attributes on it, maybe always stable is ok, as we already add stable/unstable attributes at
https://github.com/rust-lang/rust/blob/master/library/core/src/ffi/mod.rs#L40-L47
mod primitives;
#[stable(feature = "core_ffi_c", since = "1.64.0")]
pub use self::primitives::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint,
c_ulong, c_ulonglong, c_ushort,
};
#[unstable(feature = "c_size_t", issue = "88345")]
pub use self::primitives::{c_ptrdiff_t, c_size_t, c_ssize_t};So these stable/unstable attributes is redundant, and seems in rust there is no way drop it
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.
done, I found way to deal with it
Introduce library/core/src/ffi/primitives.rs
The regex preprocessing for PR #133944 would be more robust if the relevant types from core/src/ffi/mod.rs were first moved to library/core/src/ffi/primitives.rs, then there isn't a need to deal with traits / c_str / va_list / whatever might wind up in that module in the future
r? @tgross35