Skip to content

Commit d76b3c8

Browse files
authored
Merge pull request #4158 from tgross35/fix-rustc-dep-of-std
Fix usage with `rustc-dep-of-std`
2 parents 6c26c2a + 9839a9a commit d76b3c8

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

ci/verify-build.sh

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ test_target() {
6969
$cmd --no-default-features
7070
$cmd --no-default-features --features extra_traits
7171

72+
# Ensure the crate will build when used with `std`
73+
if [ "$rust" = "nightly" ]; then
74+
$cmd --no-default-features --features rustc-dep-of-std
75+
fi
76+
7277
# For tier 2 freebsd targets, check with the different versions we support
7378
# if on nightly or stable
7479
case "$rust-$target" in

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![cfg_attr(libc_deny_warnings, deny(warnings))]
2121
// Attributes needed when building as part of the standard library
2222
#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
23+
#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
2324
// Enable extra lints:
2425
#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
2526
#![deny(missing_copy_implementations, safe_packed_borrows)]

src/macros.rs

+21-12
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ macro_rules! prelude {
7070
mod prelude {
7171
// Exports from `core`
7272
#[allow(unused_imports)]
73-
pub(crate) use core::clone::Clone;
73+
pub(crate) use ::core::clone::Clone;
7474
#[allow(unused_imports)]
75-
pub(crate) use core::marker::{Copy, Send, Sync};
75+
pub(crate) use ::core::marker::{Copy, Send, Sync};
7676
#[allow(unused_imports)]
77-
pub(crate) use core::option::Option;
77+
pub(crate) use ::core::option::Option;
7878
#[allow(unused_imports)]
79-
pub(crate) use core::{fmt, hash, iter, mem};
79+
pub(crate) use ::core::{fmt, hash, iter, mem};
8080

8181
// Commonly used types defined in this crate
8282
#[allow(unused_imports)]
@@ -108,8 +108,11 @@ macro_rules! s {
108108
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
109109
__item! {
110110
#[repr(C)]
111-
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
112-
#[derive(Copy, Clone)]
111+
#[cfg_attr(
112+
feature = "extra_traits",
113+
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
114+
)]
115+
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
113116
#[allow(deprecated)]
114117
$(#[$attr])*
115118
pub struct $i { $($field)* }
@@ -127,8 +130,11 @@ macro_rules! s_paren {
127130
pub struct $i:ident ( $($field:tt)* );
128131
)*) => ($(
129132
__item! {
130-
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
131-
#[derive(Copy, Clone)]
133+
#[cfg_attr(
134+
feature = "extra_traits",
135+
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
136+
)]
137+
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
132138
$(#[$attr])*
133139
pub struct $i ( $($field)* );
134140
}
@@ -149,7 +155,7 @@ macro_rules! s_no_extra_traits {
149155
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
150156
__item! {
151157
#[repr(C)]
152-
#[derive(Copy, Clone)]
158+
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
153159
$(#[$attr])*
154160
pub union $i { $($field)* }
155161
}
@@ -158,7 +164,7 @@ macro_rules! s_no_extra_traits {
158164
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
159165
__item! {
160166
#[repr(C)]
161-
#[derive(Copy, Clone)]
167+
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
162168
$(#[$attr])*
163169
pub struct $i { $($field)* }
164170
}
@@ -186,8 +192,11 @@ macro_rules! e {
186192
pub enum $i:ident { $($field:tt)* }
187193
)*) => ($(
188194
__item! {
189-
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
190-
#[derive(Copy, Clone)]
195+
#[cfg_attr(
196+
feature = "extra_traits",
197+
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
198+
)]
199+
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
191200
$(#[$attr])*
192201
pub enum $i { $($field)* }
193202
}

0 commit comments

Comments
 (0)