mirror of
https://gitee.com/openharmony/third_party_rust_memoffset
synced 2024-11-23 15:20:49 +00:00
commit
d3f5f23483
@ -5,6 +5,7 @@ cache:
|
||||
matrix:
|
||||
include:
|
||||
- rust: 1.19.0 # Oldest supported (first version with numeric fields in struct patterns)
|
||||
- rust: 1.31.0 # Oldest supported with allow(clippy)
|
||||
- rust: 1.36.0 # Oldest supported with MaybeUninit
|
||||
- rust: stable
|
||||
- rust: beta
|
||||
|
12
build.rs
12
build.rs
@ -7,12 +7,14 @@ fn main() {
|
||||
// Assert we haven't travelled back in time
|
||||
assert!(version.major >= 1);
|
||||
|
||||
// Check for a minimum version
|
||||
if version >= Version::from((1, 36, 0)) {
|
||||
println!("cargo:rustc-cfg=memoffset_maybe_uninit");
|
||||
// Check for a minimum version for a few features
|
||||
if version >= Version::from((1, 31, 0)) {
|
||||
println!("cargo:rustc-cfg=allow_clippy");
|
||||
}
|
||||
if version >= Version::from((1, 36, 0)) {
|
||||
println!("cargo:rustc-cfg=maybe_uninit");
|
||||
}
|
||||
|
||||
if version >= Version::from((1, 40, 0)) {
|
||||
println!("cargo:rustc-cfg=memoffset_doctests");
|
||||
println!("cargo:rustc-cfg=doctests");
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,10 @@
|
||||
#![cfg_attr(feature = "unstable_const", feature(ptr_offset_from))]
|
||||
|
||||
#[macro_use]
|
||||
#[cfg(memoffset_doctests)]
|
||||
#[cfg(doctests)]
|
||||
#[cfg(doctest)]
|
||||
extern crate doc_comment;
|
||||
#[cfg(memoffset_doctests)]
|
||||
#[cfg(doctests)]
|
||||
#[cfg(doctest)]
|
||||
doctest!("../README.md");
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
/// Macro to create a local `base_ptr` raw pointer of the given type, avoiding UB as
|
||||
/// much as is possible currently.
|
||||
#[cfg(memoffset_maybe_uninit)]
|
||||
#[cfg(maybe_uninit)]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! _memoffset__let_base_ptr {
|
||||
@ -34,7 +34,7 @@ macro_rules! _memoffset__let_base_ptr {
|
||||
let $name = uninit.as_ptr();
|
||||
};
|
||||
}
|
||||
#[cfg(not(memoffset_maybe_uninit))]
|
||||
#[cfg(not(maybe_uninit))]
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! _memoffset__let_base_ptr {
|
||||
@ -53,6 +53,7 @@ macro_rules! _memoffset__field_check {
|
||||
// Make sure the field actually exists. This line ensures that a
|
||||
// compile-time error is generated if $field is accessed through a
|
||||
// Deref impl.
|
||||
#[cfg_attr(allow_clippy, allow(clippy::unneeded_field_pattern))]
|
||||
let $type { $field: _, .. };
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user