assert!(end >= start);
let mut startptr = a.as_ptr();
startptr = unsafe { startptr.add(start) };
- let len = end - start;
- // The docs for from_raw_parts do not mention any requirements that the pointer be valid if the
+ let len: usize = end - start;
+ // We should use alloc::slice::from_raw_parts here, but sadly it was only stabilized as const
+ // in 1.64, whereas we need an MSRV of 1.63. Instead we rely on that which "you should not rely
+ // on" - that slices are laid out as a simple tuple of pointer + length.
+ //
+ // The Rust language reference doesn't specify the layout of slices at all, but does give us a
+ // hint, saying
+ // Note: Though you should not rely on this, all pointers to DSTs are currently twice the
+ // size of the size of usize and have the same alignment.
+ // This leaves only two possibilities (for today's rust) - `(length, pointer)` and
+ // `(pointer, length)`. Today, in practice, this seems to always be `(pointer, length)`, so we
+ // just assume it and hope to move to a later MSRV soon.
+ unsafe { core::mem::transmute((startptr, len)) }
+ /*// The docs for from_raw_parts do not mention any requirements that the pointer be valid if the
// length is zero, aside from requiring proper alignment (which is met here). Thus,
// one-past-the-end should be an acceptable pointer for a 0-length slice.
- unsafe { alloc::slice::from_raw_parts(startptr, len) }
+ unsafe { alloc::slice::from_raw_parts(startptr, len) }*/
}
/// Const version of `dest[dest_start..dest_end].copy_from_slice(source)`
#![deny(missing_docs)]
-// const_slice_from_raw_parts was stabilized in 1.64, however we support building on 1.63 as well.
-// Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled.
-#![cfg_attr(all(feature = "validation", rust_1_63), feature(const_slice_from_raw_parts))]
-
#![allow(clippy::new_without_default)] // why is this even a lint
#![allow(clippy::result_unit_err)] // Why in the hell is this a lint?
#![allow(clippy::get_first)] // Sometimes this improves readability
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]
-// const_slice_from_raw_parts was stabilized in 1.64, however we support building on 1.63 as well.
-// Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled.
-#![cfg_attr(rust_1_63, feature(const_slice_from_raw_parts))]
-
#![allow(clippy::new_without_default)] // why is this even a lint
#![allow(clippy::result_unit_err)] // Why in the hell is this a lint?
#![allow(clippy::get_first)] // Sometimes this improves readability
#!/bin/sh
set -eox
-RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
-if [ "$RUSTC_MINOR_VERSION" = 63 ]; then
- export RUSTC_BOOTSTRAP=1
- export RUSTFLAGS=--cfg=rust_1_63
-fi
-
cargo test --no-default-features
cargo test
cargo test --no-default-features --features std
cargo build --bin http_proof_gen --features build_server
cargo doc --features std,tokio,validation
cd fuzz
-RUSTFLAGS="$RUSTFLAGS --cfg=fuzzing" RUSTC_BOOTSTRAP=1 cargo build --features stdin_fuzz
-RUSTFLAGS="$RUSTFLAGS --cfg=fuzzing" RUSTC_BOOTSTRAP=1 cargo test
+RUSTFLAGS="--cfg=fuzzing" RUSTC_BOOTSTRAP=1 cargo build --features stdin_fuzz
+RUSTFLAGS="--cfg=fuzzing" RUSTC_BOOTSTRAP=1 cargo test
cd ../bench
-RUSTFLAGS="$RUSTFLAGS --cfg=dnssec_validate_bench" cargo bench
+RUSTFLAGS="--cfg=dnssec_validate_bench" cargo bench