Skip to content

Commit ff41962

Browse files
committed
Auto merge of #110 - Amanieu:no_std_ci, r=Amanieu
Check in CI that the crate builds on targets without libstd Fixes #109
2 parents bacb169 + 3239c2b commit ff41962

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ matrix:
3434
rust: stable
3535
env: TARGET=x86_64-unknown-linux-gnu
3636
- name: "x86_64-unknown-linux-gnu (Rust 1.31.0)"
37-
rust: 1.31.0
37+
rust: 1.32.0
3838
env: TARGET=x86_64-unknown-linux-gnu
3939
- name: "i686-unknown-linux-gnu"
4040
env: TARGET=i686-unknown-linux-gnu CROSS=1
@@ -62,6 +62,10 @@ matrix:
6262
- name: "aarch64-unknown-linux-gnu"
6363
env: TARGET=aarch64-unknown-linux-gnu CROSS=1
6464

65+
# Ensure that we successfully build without libstd
66+
- name: "thumbv6m-none-eabi"
67+
env: TARGET=thumbv6m-none-eabi CROSS=1 NO_STD=1
68+
6569
install: travis_retry rustup target add "${TARGET}"
6670
script: sh ci/run.sh
6771

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build = "build.rs"
1414

1515
[dependencies]
1616
# For the default hasher
17-
ahash = { version = "0.2", optional = true }
17+
ahash = { version = "0.2.11", optional = true }
1818

1919
# For external trait impls
2020
rayon = { version = "1.0", optional = true }

ci/run.sh

+15-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ set -ex
44

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

7-
FEATURES="rayon,serde,rustc-internal-api"
7+
if [ "${NO_STD}" = "1" ]; then
8+
# Unfortunately serde currently doesn't work without std due to a cargo bug.
9+
FEATURES="rustc-internal-api"
10+
OP="build"
11+
else
12+
FEATURES="rustc-internal-api,serde,rayon"
13+
OP="test"
14+
fi
815
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then
916
FEATURES="${FEATURES},nightly"
1017
export RUSTFLAGS="$RUSTFLAGS -D warnings"
@@ -19,18 +26,17 @@ if [ "${CROSS}" = "1" ]; then
1926
CARGO=cross
2027
fi
2128

22-
export RUSTFLAGS="$RUSTFLAGS --cfg hashbrown_deny_warnings"
23-
2429
# Make sure we can compile without the default hasher
25-
"${CARGO}" -vv check --target="${TARGET}" --no-default-features
30+
"${CARGO}" -vv build --target="${TARGET}" --no-default-features
31+
"${CARGO}" -vv build --target="${TARGET}" --release --no-default-features
2632

27-
"${CARGO}" -vv test --target="${TARGET}"
28-
"${CARGO}" -vv test --target="${TARGET}" --features "${FEATURES}"
33+
"${CARGO}" -vv ${OP} --target="${TARGET}"
34+
"${CARGO}" -vv ${OP} --target="${TARGET}" --features "${FEATURES}"
2935

30-
"${CARGO}" -vv test --target="${TARGET}" --release
31-
"${CARGO}" -vv test --target="${TARGET}" --release --features "${FEATURES}"
36+
"${CARGO}" -vv ${OP} --target="${TARGET}" --release
37+
"${CARGO}" -vv ${OP} --target="${TARGET}" --release --features "${FEATURES}"
3238

33-
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then
39+
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ] && [ "${NO_STD}" != 1 ]; then
3440
# Run benchmark on native targets, build them on non-native ones:
3541
NO_RUN=""
3642
if [ "${CROSS}" = "1" ]; then

ci/tools.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ retry() {
1313
"$@"
1414
result=$?
1515
[ $result -eq 0 ] && break
16-
count=$(count + 1)
16+
count=$((count + 1))
1717
sleep 1
1818
done
1919

src/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub enum DefaultHashBuilder {}
1818

1919
/// A hash map implemented with quadratic probing and SIMD lookup.
2020
///
21-
/// The default hashing algorithm is currently [AHash], though this is
21+
/// The default hashing algorithm is currently [`AHash`], though this is
2222
/// subject to change at any point in the future. This hash function is very
2323
/// fast for all types of keys, but this algorithm will typically *not* protect
2424
/// against attacks such as HashDoS.
@@ -145,7 +145,7 @@ pub enum DefaultHashBuilder {}
145145
/// [`with_hasher`]: #method.with_hasher
146146
/// [`with_capacity_and_hasher`]: #method.with_capacity_and_hasher
147147
/// [`fnv`]: https://crates.io/crates/fnv
148-
/// [AHash]: https://crates.io/crates/ahash
148+
/// [`AHash`]: https://crates.io/crates/ahash
149149
///
150150
/// ```
151151
/// use hashbrown::HashMap;

src/raw/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,20 @@ impl Fallibility {
7373
/// Error to return on capacity overflow.
7474
#[inline]
7575
fn capacity_overflow(self) -> CollectionAllocErr {
76+
use Fallibility::*;
7677
match self {
77-
Fallibility::Fallible => CollectionAllocErr::CapacityOverflow,
78-
Fallibility::Infallible => panic!("Hash table capacity overflow"),
78+
Fallible => CollectionAllocErr::CapacityOverflow,
79+
Infallible => panic!("Hash table capacity overflow"),
7980
}
8081
}
8182

8283
/// Error to return on allocation error.
8384
#[inline]
8485
fn alloc_err(self, layout: Layout) -> CollectionAllocErr {
86+
use Fallibility::*;
8587
match self {
86-
Fallibility::Fallible => CollectionAllocErr::AllocErr { layout },
87-
Fallibility::Infallible => handle_alloc_error(layout),
88+
Fallible => CollectionAllocErr::AllocErr { layout },
89+
Infallible => handle_alloc_error(layout),
8890
}
8991
}
9092
}

0 commit comments

Comments
 (0)