Skip to content

Check in CI that the crate builds on targets without libstd #110

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

Merged
merged 5 commits into from
Aug 13, 2019
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
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ matrix:
- name: "x86_64-unknown-linux-gnu (stable)"
rust: stable
env: TARGET=x86_64-unknown-linux-gnu
- name: "x86_64-unknown-linux-gnu (Rust 1.31.0)"
rust: 1.31.0
- name: "x86_64-unknown-linux-gnu (Rust 1.32.0)"
rust: 1.32.0
env: TARGET=x86_64-unknown-linux-gnu
- name: "i686-unknown-linux-gnu"
env: TARGET=i686-unknown-linux-gnu CROSS=1
Expand Down Expand Up @@ -62,6 +62,14 @@ matrix:
- name: "aarch64-unknown-linux-gnu"
env: TARGET=aarch64-unknown-linux-gnu CROSS=1

# Ensure that we successfully build without libstd
- name: "thumbv6m-none-eabi"
env: TARGET=thumbv6m-none-eabi NO_STD=1
script:
# cross doesn't seem to work with thumb targets...
- rustup target install $TARGET
- sh ci/run.sh

install: travis_retry rustup target add "${TARGET}"
script: sh ci/run.sh

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build = "build.rs"

[dependencies]
# For the default hasher
ahash = { version = "0.2", optional = true }
ahash = { version = "0.2.11", optional = true }

# For external trait impls
rayon = { version = "1.0", optional = true }
Expand Down
24 changes: 15 additions & 9 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ set -ex

: "${TARGET?The TARGET environment variable must be set.}"

FEATURES="rayon,serde,rustc-internal-api"
if [ "${NO_STD}" = "1" ]; then
# Unfortunately serde currently doesn't work without std due to a cargo bug.
FEATURES="rustc-internal-api"
OP="build"
else
FEATURES="rustc-internal-api,serde,rayon"
OP="test"
fi
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then
FEATURES="${FEATURES},nightly"
export RUSTFLAGS="$RUSTFLAGS -D warnings"
Expand All @@ -19,18 +26,17 @@ if [ "${CROSS}" = "1" ]; then
CARGO=cross
fi

export RUSTFLAGS="$RUSTFLAGS --cfg hashbrown_deny_warnings"

# Make sure we can compile without the default hasher
"${CARGO}" -vv check --target="${TARGET}" --no-default-features
"${CARGO}" -vv build --target="${TARGET}" --no-default-features
"${CARGO}" -vv build --target="${TARGET}" --release --no-default-features

"${CARGO}" -vv test --target="${TARGET}"
"${CARGO}" -vv test --target="${TARGET}" --features "${FEATURES}"
"${CARGO}" -vv ${OP} --target="${TARGET}"
"${CARGO}" -vv ${OP} --target="${TARGET}" --features "${FEATURES}"

"${CARGO}" -vv test --target="${TARGET}" --release
"${CARGO}" -vv test --target="${TARGET}" --release --features "${FEATURES}"
"${CARGO}" -vv ${OP} --target="${TARGET}" --release
"${CARGO}" -vv ${OP} --target="${TARGET}" --release --features "${FEATURES}"

if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ] && [ "${NO_STD}" != 1 ]; then
# Run benchmark on native targets, build them on non-native ones:
NO_RUN=""
if [ "${CROSS}" = "1" ]; then
Expand Down
2 changes: 1 addition & 1 deletion ci/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ retry() {
"$@"
result=$?
[ $result -eq 0 ] && break
count=$(count + 1)
count=$((count + 1))
sleep 1
done

Expand Down
4 changes: 2 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum DefaultHashBuilder {}

/// A hash map implemented with quadratic probing and SIMD lookup.
///
/// The default hashing algorithm is currently [AHash], though this is
/// The default hashing algorithm is currently [`AHash`], though this is
/// subject to change at any point in the future. This hash function is very
/// fast for all types of keys, but this algorithm will typically *not* protect
/// against attacks such as HashDoS.
Expand Down Expand Up @@ -145,7 +145,7 @@ pub enum DefaultHashBuilder {}
/// [`with_hasher`]: #method.with_hasher
/// [`with_capacity_and_hasher`]: #method.with_capacity_and_hasher
/// [`fnv`]: https://crates.io/crates/fnv
/// [AHash]: https://crates.io/crates/ahash
/// [`AHash`]: https://crates.io/crates/ahash
///
/// ```
/// use hashbrown::HashMap;
Expand Down
10 changes: 6 additions & 4 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ impl Fallibility {
/// Error to return on capacity overflow.
#[inline]
fn capacity_overflow(self) -> CollectionAllocErr {
use Fallibility::*;
match self {
Fallibility::Fallible => CollectionAllocErr::CapacityOverflow,
Fallibility::Infallible => panic!("Hash table capacity overflow"),
Fallible => CollectionAllocErr::CapacityOverflow,
Infallible => panic!("Hash table capacity overflow"),
}
}

/// Error to return on allocation error.
#[inline]
fn alloc_err(self, layout: Layout) -> CollectionAllocErr {
use Fallibility::*;
match self {
Fallibility::Fallible => CollectionAllocErr::AllocErr { layout },
Fallibility::Infallible => handle_alloc_error(layout),
Fallible => CollectionAllocErr::AllocErr { layout },
Infallible => handle_alloc_error(layout),
}
}
}
Expand Down