Skip to content
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

[0.2] Fix usage with rustc-dep-of-std #4167

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ test_target() {
$cmd --no-default-features
$cmd --no-default-features --features extra_traits

# Ensure the crate will build when used with `std`
if [ "$rust" = "nightly" ]; then
$cmd --no-default-features --features rustc-dep-of-std
fi

# For tier 2 freebsd targets, check with the different versions we support
# if on nightly or stable
case "$rust-$target" in
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
// Attributes needed when building as part of the standard library
#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
#![cfg_attr(libc_thread_local, feature(thread_local))]
#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
// Enable extra lints:
#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
#![deny(missing_copy_implementations, safe_packed_borrows)]
Expand Down
33 changes: 21 additions & 12 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ macro_rules! prelude {
mod prelude {
// Exports from `core`
#[allow(unused_imports)]
pub(crate) use core::clone::Clone;
pub(crate) use ::core::clone::Clone;
#[allow(unused_imports)]
pub(crate) use core::marker::{Copy, Send, Sync};
pub(crate) use ::core::marker::{Copy, Send, Sync};
#[allow(unused_imports)]
pub(crate) use core::option::Option;
pub(crate) use ::core::option::Option;
#[allow(unused_imports)]
pub(crate) use core::{fmt, hash, iter, mem};
pub(crate) use ::core::{fmt, hash, iter, mem};

// Commonly used types defined in this crate
#[allow(unused_imports)]
Expand Down Expand Up @@ -108,8 +108,11 @@ macro_rules! s {
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
#[allow(deprecated)]
$(#[$attr])*
pub struct $i { $($field)* }
Expand All @@ -127,8 +130,11 @@ macro_rules! s_paren {
pub struct $i:ident ( $($field:tt)* );
)*) => ($(
__item! {
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
$(#[$attr])*
pub struct $i ( $($field)* );
}
Expand All @@ -149,7 +155,7 @@ macro_rules! s_no_extra_traits {
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[derive(Copy, Clone)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
$(#[$attr])*
pub union $i { $($field)* }
}
Expand All @@ -158,7 +164,7 @@ macro_rules! s_no_extra_traits {
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[derive(Copy, Clone)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
$(#[$attr])*
pub struct $i { $($field)* }
}
Expand Down Expand Up @@ -186,8 +192,11 @@ macro_rules! e {
pub enum $i:ident { $($field:tt)* }
)*) => ($(
__item! {
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
#[cfg_attr(
feature = "extra_traits",
::core::prelude::v1::derive(Debug, Eq, Hash, PartialEq)
)]
#[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)]
$(#[$attr])*
pub enum $i { $($field)* }
}
Expand Down