| 1 | //! This module reexports the primitive types to allow usage that is not |
| 2 | //! possibly shadowed by other declared types. |
| 3 | //! |
| 4 | //! This is normally only useful in macro generated code. |
| 5 | //! |
| 6 | //! An example of this is when generating a new struct and an impl for it: |
| 7 | //! |
| 8 | //! ```rust,compile_fail |
| 9 | //! pub struct bool; |
| 10 | //! |
| 11 | //! impl QueryId for bool { |
| 12 | //! const SOME_PROPERTY: bool = true; |
| 13 | //! } |
| 14 | //! |
| 15 | //! # trait QueryId { const SOME_PROPERTY: ::core::primitive::bool; } |
| 16 | //! ``` |
| 17 | //! |
| 18 | //! Note that the `SOME_PROPERTY` associated constant would not compile, as its |
| 19 | //! type `bool` refers to the struct, rather than to the primitive bool type. |
| 20 | //! |
| 21 | //! A correct implementation could look like: |
| 22 | //! |
| 23 | //! ```rust |
| 24 | //! # #[allow (non_camel_case_types)] |
| 25 | //! pub struct bool; |
| 26 | //! |
| 27 | //! impl QueryId for bool { |
| 28 | //! const SOME_PROPERTY: ::core::primitive::bool = true; |
| 29 | //! } |
| 30 | //! |
| 31 | //! # trait QueryId { const SOME_PROPERTY: ::core::primitive::bool; } |
| 32 | //! ``` |
| 33 | //! |
| 34 | //! We also used `::core` instead of `core`, because `core` can be |
| 35 | //! shadowed, too. Paths, starting with `::`, are searched in |
| 36 | //! the [extern prelude] since Edition 2018. |
| 37 | //! |
| 38 | //! [extern prelude]: https://doc.rust-lang.org/nightly/reference/names/preludes.html#extern-prelude |
| 39 | |
| 40 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 41 | pub use bool; |
| 42 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 43 | pub use char; |
| 44 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 45 | pub use f32; |
| 46 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 47 | pub use f64; |
| 48 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 49 | pub use i8; |
| 50 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 51 | pub use i16; |
| 52 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 53 | pub use i32; |
| 54 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 55 | pub use i64; |
| 56 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 57 | pub use i128; |
| 58 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 59 | pub use isize; |
| 60 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 61 | pub use str; |
| 62 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 63 | pub use u8; |
| 64 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 65 | pub use u16; |
| 66 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 67 | pub use u32; |
| 68 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 69 | pub use u64; |
| 70 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 71 | pub use u128; |
| 72 | #[stable (feature = "core_primitive" , since = "1.43.0" )] |
| 73 | pub use usize; |
| 74 | |