-
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
Add primitive module to libcore #67637
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//! This module reexports the primitive types to allow usage that is not | ||
//! possibly shadowed by other declared types. | ||
//! | ||
//! This is normally only useful in macro generated code. | ||
//! | ||
//! An example of this is when generating a new struct and an impl for it: | ||
//! | ||
//! ```rust,compile_fail | ||
//! pub struct bool; | ||
//! | ||
//! impl QueryId for bool { | ||
//! const SOME_PROPERTY: bool = true; | ||
//! } | ||
//! | ||
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; } | ||
//! ``` | ||
//! | ||
//! Note that the `SOME_PROPERTY` associated constant would not compile, as its | ||
//! type `bool` refers to the struct, rather than to the primitive bool type. | ||
//! | ||
//! A correct implementation could look like: | ||
//! | ||
//! ```rust | ||
//! # #[allow(non_camel_case_types)] | ||
//! pub struct bool; | ||
//! | ||
//! impl QueryId for bool { | ||
//! const SOME_PROPERTY: core::primitive::bool = true; | ||
//! } | ||
//! | ||
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; } | ||
//! ``` | ||
|
||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use bool; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use char; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use f32; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use f64; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use i128; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use i16; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use i32; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use i64; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use i8; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use isize; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use str; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use u128; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use u16; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use u32; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use u64; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use u8; | ||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use usize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,12 +233,12 @@ | |
#![feature(allocator_internals)] | ||
#![feature(allow_internal_unsafe)] | ||
#![feature(allow_internal_unstable)] | ||
#![feature(atomic_mut_ptr)] | ||
#![feature(arbitrary_self_types)] | ||
#![feature(array_error_internals)] | ||
#![feature(asm)] | ||
#![feature(assoc_int_consts)] | ||
#![feature(associated_type_bounds)] | ||
#![feature(atomic_mut_ptr)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated (probably autorebase failure). I think the new location is technically the correct one from an alphabetic perspective though (and these seem to be alphabetized...). |
||
#![feature(box_syntax)] | ||
#![feature(c_variadic)] | ||
#![feature(cfg_target_has_atomic)] | ||
|
@@ -550,6 +550,9 @@ pub use core::{ | |
trace_macros, | ||
}; | ||
|
||
#[stable(feature = "core_primitive", since = "1.43.0")] | ||
pub use core::primitive; | ||
|
||
// Include a number of private modules that exist solely to provide | ||
// the rustdoc documentation for primitive types. Using `include!` | ||
// because rustdoc only looks for these modules at the crate level. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// check-pass | ||
|
||
mod bar { | ||
pub trait QueryId { | ||
const SOME_PROPERTY: bool; | ||
} | ||
} | ||
|
||
use bar::QueryId; | ||
|
||
#[allow(non_camel_case_types)] | ||
pub struct bool; | ||
|
||
impl QueryId for bool { | ||
const SOME_PROPERTY: core::primitive::bool = true; | ||
} | ||
|
||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could these re-exports not be merged, so the attribute doesn't have to be repeated a bunch of times?
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 consider multiline use a mistake in most cases as it breaks grepping for
use.*Identifier
, so I'm not going to change this, but I believe it is possible.