function print_eval_check {
printf '$'
for word in "$@"; do
if [[ "$word" != *\ * ]]; then
printf ' %q' "$word"
elif [[ "$word" =~ ^[\ /0-9A-Z_a-z-]*$ ]]; then
printf ' "%s"' "$word"
else
printf ' %q' "$word"
fi
done
printf '\n'
eval $(printf '%q ' "$@")
code="$?"
if [ "$code" == "0" ]; then
return
fi
printf '\nCommand exited abnormally with code %s\n' "$code"
exit "$code"
}
print_eval_check \
rustup install "$TOOLCHAIN"
if [[ "$TOOLCHAIN" == beta* ]]; then
print_eval_check \
rustup component add --toolchain "$TOOLCHAIN" rustfmt clippy
fi
for features in \
'' gmp-mpfr-sys{,/mpfr,/mpc} \
integer{,\ float,\ complex}{,\ serde} \
rational{,\ float,\ complex}{,\ rand}{,\ serde} \
float{,\ rand}{,\ serde} \
complex{,\ rand}{,\ serde} \
rand{,\ serde} \
serde
do
if [[ "$TOOLCHAIN" == 1.18.0* ]]; then
all_targets=""
else
all_targets="--all-targets"
fi
if [[ "$features" =~ ^(()|serde)$ ]]; then
gmp=""
else
gmp="-p gmp-mpfr-sys"
fi
features="fail-on-warnings${features:+ $features}"
print_eval_check \
cargo "+$TOOLCHAIN" \
check $all_targets \
--no-default-features --features "$features" \
$gmp -p rug
done
for build in "" --release; do
print_eval_check \
cargo "+$TOOLCHAIN" \
test $build \
--features "fail-on-warnings serde" \
-p gmp-mpfr-sys -p rug
done
if [[ "$TOOLCHAIN" == beta* ]]; then
print_eval_check \
cargo "+$TOOLCHAIN" \
fmt -- --check
print_eval_check \
cargo "+$TOOLCHAIN" \
clippy --all-targets \
--features "fail-on-warnings serde"
fi