Skip to content

Commit

Permalink
cargo: fix alloc-only build
Browse files Browse the repository at this point in the history
I was lured into a false sense of confidence with CI testing. Because
tests unconditionally enable `std`, this

    cargo test --lib --no-default-features --features alloc

doesn't actually fail when there is an errant `std` reference. But this
does:

    cargo build --no-default-features --features alloc

We fix our `test` script to catch this case and also fix the build
errors.

Fixes #108
  • Loading branch information
BurntSushi committed Aug 19, 2024
1 parent c728b90 commit 96fc32c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/duration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::time::Duration as UnsignedDuration;
use core::time::Duration as UnsignedDuration;

use crate::{
error::{err, ErrorContext},
Expand Down
2 changes: 1 addition & 1 deletion src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ impl Timestamp {
.expect("absolute value of seconds fits in u64");
let nanosecond = u32::try_from(self.subsec_nanosecond().abs())
.expect("nanosecond always fit in a u32");
(self.signum(), std::time::Duration::new(second, nanosecond))
(self.signum(), core::time::Duration::new(second, nanosecond))
}
}

Expand Down
1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ features=(
)
for f in "${features[@]}"; do
echo "===== FEATURE: $f ====="
cargo build --no-default-features --features "$f"
cargo test --lib --no-default-features --features "$f"
cargo test --test integration --no-default-features --features "$f"
done

0 comments on commit 96fc32c

Please sign in to comment.