mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Auto merge of #131078 - tgross35:rollup-66to2u9, r=tgross35
Rollup of 5 pull requests Successful merges: - #129638 (Hook up std::net to wasi-libc on wasm32-wasip2 target) - #130877 (rustc_target: Add RISC-V atomic-related features) - #130914 (Mark some more types as having insignificant dtor) - #130961 (Enable `f16` tests on x86 Apple platforms) - #130966 (make ptr metadata functions callable from stable const fn) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c87004a1f5
@ -264,6 +264,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
|
|||||||
("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => {
|
("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => {
|
||||||
Some(LLVMFeature::new("fast-unaligned-access"))
|
Some(LLVMFeature::new("fast-unaligned-access"))
|
||||||
}
|
}
|
||||||
|
// Filter out features that are not supported by the current LLVM version
|
||||||
|
("riscv32" | "riscv64", "zaamo") if get_version().0 < 19 => None,
|
||||||
|
("riscv32" | "riscv64", "zabha") if get_version().0 < 19 => None,
|
||||||
|
("riscv32" | "riscv64", "zalrsc") if get_version().0 < 19 => None,
|
||||||
// Enable the evex512 target feature if an avx512 target feature is enabled.
|
// Enable the evex512 target feature if an avx512 target feature is enabled.
|
||||||
("x86", s) if s.starts_with("avx512") => {
|
("x86", s) if s.starts_with("avx512") => {
|
||||||
Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
|
Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
|
||||||
|
@ -373,7 +373,7 @@ const MIPS_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
|||||||
|
|
||||||
const RISCV_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
const RISCV_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
||||||
// tidy-alphabetical-start
|
// tidy-alphabetical-start
|
||||||
("a", Stable, &[]),
|
("a", Stable, &["zaamo", "zalrsc"]),
|
||||||
("c", Stable, &[]),
|
("c", Stable, &[]),
|
||||||
("d", Unstable(sym::riscv_target_feature), &["f"]),
|
("d", Unstable(sym::riscv_target_feature), &["f"]),
|
||||||
("e", Unstable(sym::riscv_target_feature), &[]),
|
("e", Unstable(sym::riscv_target_feature), &[]),
|
||||||
@ -382,6 +382,9 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
|||||||
("relax", Unstable(sym::riscv_target_feature), &[]),
|
("relax", Unstable(sym::riscv_target_feature), &[]),
|
||||||
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
|
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]),
|
||||||
("v", Unstable(sym::riscv_target_feature), &[]),
|
("v", Unstable(sym::riscv_target_feature), &[]),
|
||||||
|
("zaamo", Unstable(sym::riscv_target_feature), &[]),
|
||||||
|
("zabha", Unstable(sym::riscv_target_feature), &["zaamo"]),
|
||||||
|
("zalrsc", Unstable(sym::riscv_target_feature), &[]),
|
||||||
("zba", Stable, &[]),
|
("zba", Stable, &[]),
|
||||||
("zbb", Stable, &[]),
|
("zbb", Stable, &[]),
|
||||||
("zbc", Stable, &[]),
|
("zbc", Stable, &[]),
|
||||||
|
@ -228,6 +228,7 @@ mod thin;
|
|||||||
#[lang = "owned_box"]
|
#[lang = "owned_box"]
|
||||||
#[fundamental]
|
#[fundamental]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[rustc_insignificant_dtor]
|
||||||
// The declaration of the `Box` struct must be kept in sync with the
|
// The declaration of the `Box` struct must be kept in sync with the
|
||||||
// compiler or ICEs will happen.
|
// compiler or ICEs will happen.
|
||||||
pub struct Box<
|
pub struct Box<
|
||||||
|
@ -696,6 +696,7 @@ impl CString {
|
|||||||
// memory-unsafe code from working by accident. Inline
|
// memory-unsafe code from working by accident. Inline
|
||||||
// to prevent LLVM from optimizing it away in debug builds.
|
// to prevent LLVM from optimizing it away in debug builds.
|
||||||
#[stable(feature = "cstring_drop", since = "1.13.0")]
|
#[stable(feature = "cstring_drop", since = "1.13.0")]
|
||||||
|
#[rustc_insignificant_dtor]
|
||||||
impl Drop for CString {
|
impl Drop for CString {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
@ -237,6 +237,7 @@ macro_rules! acquire {
|
|||||||
/// [rc_examples]: crate::rc#examples
|
/// [rc_examples]: crate::rc#examples
|
||||||
#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")]
|
#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[rustc_insignificant_dtor]
|
||||||
pub struct Arc<
|
pub struct Arc<
|
||||||
T: ?Sized,
|
T: ?Sized,
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
|
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
|
||||||
|
@ -3165,7 +3165,7 @@ pub const fn type_id<T: ?Sized + 'static>() -> u128 {
|
|||||||
/// change the possible layouts of pointers.
|
/// change the possible layouts of pointers.
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_intrinsic_must_be_overridden]
|
#[rustc_intrinsic_must_be_overridden]
|
||||||
pub const fn aggregate_raw_ptr<P: AggregateRawPtr<D, Metadata = M>, D, M>(_data: D, _meta: M) -> P {
|
pub const fn aggregate_raw_ptr<P: AggregateRawPtr<D, Metadata = M>, D, M>(_data: D, _meta: M) -> P {
|
||||||
@ -3190,7 +3190,7 @@ impl<P: ?Sized, T: ptr::Thin> AggregateRawPtr<*mut T> for *mut P {
|
|||||||
/// This is used to implement functions like `ptr::metadata`.
|
/// This is used to implement functions like `ptr::metadata`.
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[unstable(feature = "core_intrinsics", issue = "none")]
|
#[unstable(feature = "core_intrinsics", issue = "none")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_intrinsic_must_be_overridden]
|
#[rustc_intrinsic_must_be_overridden]
|
||||||
pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *const P) -> M {
|
pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *const P) -> M {
|
||||||
|
@ -92,7 +92,7 @@ impl<T: ?Sized> *const T {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
||||||
#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn with_metadata_of<U>(self, meta: *const U) -> *const U
|
pub const fn with_metadata_of<U>(self, meta: *const U) -> *const U
|
||||||
@ -412,7 +412,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||||
@ -495,7 +494,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -645,7 +643,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||||
@ -873,7 +870,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||||
@ -956,7 +952,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||||
@ -1039,7 +1034,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1120,7 +1114,6 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1554,7 +1547,6 @@ impl<T> *const [T] {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
pub const fn len(self) -> usize {
|
pub const fn len(self) -> usize {
|
||||||
metadata(self)
|
metadata(self)
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ pub trait Thin = Pointee<Metadata = ()>;
|
|||||||
///
|
///
|
||||||
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
/// assert_eq!(std::ptr::metadata("foo"), 3_usize);
|
||||||
/// ```
|
/// ```
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
||||||
ptr_metadata(ptr)
|
ptr_metadata(ptr)
|
||||||
@ -106,7 +106,7 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
|
|||||||
///
|
///
|
||||||
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
|
||||||
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts<T: ?Sized>(
|
pub const fn from_raw_parts<T: ?Sized>(
|
||||||
data_pointer: *const impl Thin,
|
data_pointer: *const impl Thin,
|
||||||
@ -120,7 +120,7 @@ pub const fn from_raw_parts<T: ?Sized>(
|
|||||||
///
|
///
|
||||||
/// See the documentation of [`from_raw_parts`] for more details.
|
/// See the documentation of [`from_raw_parts`] for more details.
|
||||||
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
#[unstable(feature = "ptr_metadata", issue = "81513")]
|
||||||
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn from_raw_parts_mut<T: ?Sized>(
|
pub const fn from_raw_parts_mut<T: ?Sized>(
|
||||||
data_pointer: *mut impl Thin,
|
data_pointer: *mut impl Thin,
|
||||||
|
@ -599,7 +599,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_null"]
|
#[rustc_diagnostic_item = "ptr_null"]
|
||||||
pub const fn null<T: ?Sized + Thin>() -> *const T {
|
pub const fn null<T: ?Sized + Thin>() -> *const T {
|
||||||
from_raw_parts(without_provenance::<()>(0), ())
|
from_raw_parts(without_provenance::<()>(0), ())
|
||||||
@ -625,7 +624,6 @@ pub const fn null<T: ?Sized + Thin>() -> *const T {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
#[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_null_mut"]
|
#[rustc_diagnostic_item = "ptr_null_mut"]
|
||||||
pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
|
pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
|
||||||
from_raw_parts_mut(without_provenance_mut::<()>(0), ())
|
from_raw_parts_mut(without_provenance_mut::<()>(0), ())
|
||||||
@ -949,7 +947,6 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
|
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
|
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts"]
|
#[rustc_diagnostic_item = "ptr_slice_from_raw_parts"]
|
||||||
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
|
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
|
||||||
from_raw_parts(data, len)
|
from_raw_parts(data, len)
|
||||||
|
@ -74,7 +74,7 @@ impl<T: ?Sized> *mut T {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
#[unstable(feature = "set_ptr_value", issue = "75091")]
|
||||||
#[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")]
|
#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn with_metadata_of<U>(self, meta: *const U) -> *mut U
|
pub const fn with_metadata_of<U>(self, meta: *const U) -> *mut U
|
||||||
@ -412,7 +412,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||||
@ -492,7 +491,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -808,7 +806,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||||
@ -954,7 +951,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||||
@ -1037,7 +1033,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||||
@ -1118,7 +1113,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1197,7 +1191,6 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||||
}
|
}
|
||||||
@ -1804,7 +1797,6 @@ impl<T> *mut [T] {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
#[stable(feature = "slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
pub const fn len(self) -> usize {
|
pub const fn len(self) -> usize {
|
||||||
metadata(self)
|
metadata(self)
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,6 @@ impl<T: ?Sized> NonNull<T> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||||
@ -651,7 +650,6 @@ impl<T: ?Sized> NonNull<T> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
|
||||||
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
|
||||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||||
|
@ -111,7 +111,6 @@ impl<T> [T] {
|
|||||||
#[lang = "slice_len_fn"]
|
#[lang = "slice_len_fn"]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
#[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")]
|
||||||
#[rustc_allow_const_fn_unstable(ptr_metadata)]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn len(&self) -> usize {
|
pub const fn len(&self) -> usize {
|
||||||
|
@ -102,9 +102,6 @@ fn main() {
|
|||||||
("arm64ec", _) => false,
|
("arm64ec", _) => false,
|
||||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||||
("x86_64", "windows") => false,
|
("x86_64", "windows") => false,
|
||||||
// Apple has a special ABI for `f16` that we do not yet support
|
|
||||||
// FIXME(builtins): fixed by <https://github.com/rust-lang/compiler-builtins/pull/675>
|
|
||||||
("x86" | "x86_64", _) if target_vendor == "apple" => false,
|
|
||||||
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
|
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
|
||||||
("csky", _) => false,
|
("csky", _) => false,
|
||||||
("hexagon", _) => false,
|
("hexagon", _) => false,
|
||||||
|
@ -1018,6 +1018,7 @@ mod test_extract_if {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn drop_panic_leak() {
|
fn drop_panic_leak() {
|
||||||
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
||||||
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
||||||
@ -1047,6 +1048,7 @@ mod test_extract_if {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn pred_panic_leak() {
|
fn pred_panic_leak() {
|
||||||
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
||||||
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
||||||
@ -1076,6 +1078,7 @@ mod test_extract_if {
|
|||||||
|
|
||||||
// Same as above, but attempt to use the iterator again after the panic in the predicate
|
// Same as above, but attempt to use the iterator again after the panic in the predicate
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn pred_panic_reuse() {
|
fn pred_panic_reuse() {
|
||||||
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
static PREDS: AtomicUsize = AtomicUsize::new(0);
|
||||||
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
static DROPS: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
@ -429,6 +429,7 @@ fn test_extract_if() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn test_extract_if_drop_panic_leak() {
|
fn test_extract_if_drop_panic_leak() {
|
||||||
static PREDS: AtomicU32 = AtomicU32::new(0);
|
static PREDS: AtomicU32 = AtomicU32::new(0);
|
||||||
static DROPS: AtomicU32 = AtomicU32::new(0);
|
static DROPS: AtomicU32 = AtomicU32::new(0);
|
||||||
@ -459,6 +460,7 @@ fn test_extract_if_drop_panic_leak() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn test_extract_if_pred_panic_leak() {
|
fn test_extract_if_pred_panic_leak() {
|
||||||
static PREDS: AtomicU32 = AtomicU32::new(0);
|
static PREDS: AtomicU32 = AtomicU32::new(0);
|
||||||
static DROPS: AtomicU32 = AtomicU32::new(0);
|
static DROPS: AtomicU32 = AtomicU32::new(0);
|
||||||
|
2
library/std/src/env/tests.rs
vendored
2
library/std/src/env/tests.rs
vendored
@ -1,7 +1,7 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(any(target_os = "emscripten", target_env = "sgx"), ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"), ignore)]
|
||||||
fn test_self_exe_path() {
|
fn test_self_exe_path() {
|
||||||
let path = current_exe();
|
let path = current_exe();
|
||||||
assert!(path.is_ok());
|
assert!(path.is_ok());
|
||||||
|
@ -8,7 +8,15 @@
|
|||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))]
|
#[cfg(all(
|
||||||
|
test,
|
||||||
|
not(any(
|
||||||
|
target_os = "emscripten",
|
||||||
|
target_os = "wasi",
|
||||||
|
target_env = "sgx",
|
||||||
|
target_os = "xous"
|
||||||
|
))
|
||||||
|
))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
|
@ -164,6 +164,7 @@ fn test_buffered_reader_stream_position() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn test_buffered_reader_stream_position_panic() {
|
fn test_buffered_reader_stream_position_panic() {
|
||||||
let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
|
let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
|
||||||
let mut reader = BufReader::with_capacity(4, io::Cursor::new(inner));
|
let mut reader = BufReader::with_capacity(4, io::Cursor::new(inner));
|
||||||
@ -487,7 +488,7 @@ fn dont_panic_in_drop_on_panicked_flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn panic_in_write_doesnt_flush_in_drop() {
|
fn panic_in_write_doesnt_flush_in_drop() {
|
||||||
static WRITES: AtomicUsize = AtomicUsize::new(0);
|
static WRITES: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ const TAG_SIMPLE: usize = 0b11;
|
|||||||
/// is_unwind_safe::<std::io::Error>();
|
/// is_unwind_safe::<std::io::Error>();
|
||||||
/// ```
|
/// ```
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
#[rustc_insignificant_dtor]
|
||||||
pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>);
|
pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>);
|
||||||
|
|
||||||
// All the types `Repr` stores internally are Send + Sync, and so is it.
|
// All the types `Repr` stores internally are Send + Sync, and so is it.
|
||||||
|
@ -25,7 +25,7 @@ fn stderrlock_unwind_safe() {
|
|||||||
fn assert_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
|
fn assert_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn panic_doesnt_poison() {
|
fn panic_doesnt_poison() {
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
let _a = stdin();
|
let _a = stdin();
|
||||||
@ -48,17 +48,17 @@ fn panic_doesnt_poison() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn test_lock_stderr() {
|
fn test_lock_stderr() {
|
||||||
test_lock(stderr, || stderr().lock());
|
test_lock(stderr, || stderr().lock());
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn test_lock_stdin() {
|
fn test_lock_stdin() {
|
||||||
test_lock(stdin, || stdin().lock());
|
test_lock(stdin, || stdin().lock());
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn test_lock_stdout() {
|
fn test_lock_stdout() {
|
||||||
test_lock(stdout, || stdout().lock());
|
test_lock(stdout, || stdout().lock());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Tests for this module
|
// Tests for this module
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", all(target_os = "wasi", target_env = "p1")))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[stable(feature = "ip_addr", since = "1.7.0")]
|
#[stable(feature = "ip_addr", since = "1.7.0")]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Tests for this module
|
// Tests for this module
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", all(target_os = "wasi", target_env = "p1")))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "xous"))))]
|
#[cfg(all(
|
||||||
|
test,
|
||||||
|
not(any(
|
||||||
|
target_os = "emscripten",
|
||||||
|
all(target_os = "wasi", target_env = "p1"),
|
||||||
|
target_os = "xous"
|
||||||
|
))
|
||||||
|
))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
|
@ -57,6 +57,7 @@ fn connect_timeout_error() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn listen_localhost() {
|
fn listen_localhost() {
|
||||||
let socket_addr = next_test_ip4();
|
let socket_addr = next_test_ip4();
|
||||||
let listener = t!(TcpListener::bind(&socket_addr));
|
let listener = t!(TcpListener::bind(&socket_addr));
|
||||||
@ -73,6 +74,7 @@ fn listen_localhost() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn connect_loopback() {
|
fn connect_loopback() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -94,6 +96,7 @@ fn connect_loopback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn smoke_test() {
|
fn smoke_test() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -114,6 +117,7 @@ fn smoke_test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn read_eof() {
|
fn read_eof() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -133,6 +137,7 @@ fn read_eof() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn write_close() {
|
fn write_close() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -161,6 +166,7 @@ fn write_close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn multiple_connect_serial() {
|
fn multiple_connect_serial() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let max = 10;
|
let max = 10;
|
||||||
@ -183,6 +189,7 @@ fn multiple_connect_serial() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn multiple_connect_interleaved_greedy_schedule() {
|
fn multiple_connect_interleaved_greedy_schedule() {
|
||||||
const MAX: usize = 10;
|
const MAX: usize = 10;
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
@ -220,6 +227,7 @@ fn multiple_connect_interleaved_greedy_schedule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn multiple_connect_interleaved_lazy_schedule() {
|
fn multiple_connect_interleaved_lazy_schedule() {
|
||||||
const MAX: usize = 10;
|
const MAX: usize = 10;
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
@ -255,6 +263,7 @@ fn multiple_connect_interleaved_lazy_schedule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn socket_and_peer_name() {
|
fn socket_and_peer_name() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
@ -270,6 +279,7 @@ fn socket_and_peer_name() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn partial_read() {
|
fn partial_read() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
@ -291,6 +301,7 @@ fn partial_read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn read_buf() {
|
fn read_buf() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let srv = t!(TcpListener::bind(&addr));
|
let srv = t!(TcpListener::bind(&addr));
|
||||||
@ -389,6 +400,7 @@ fn double_bind() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn tcp_clone_smoke() {
|
fn tcp_clone_smoke() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -420,6 +432,7 @@ fn tcp_clone_smoke() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn tcp_clone_two_read() {
|
fn tcp_clone_two_read() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -454,6 +467,7 @@ fn tcp_clone_two_read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn tcp_clone_two_write() {
|
fn tcp_clone_two_write() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let acceptor = t!(TcpListener::bind(&addr));
|
let acceptor = t!(TcpListener::bind(&addr));
|
||||||
@ -483,6 +497,7 @@ fn tcp_clone_two_write() {
|
|||||||
#[test]
|
#[test]
|
||||||
// FIXME: https://github.com/fortanix/rust-sgx/issues/110
|
// FIXME: https://github.com/fortanix/rust-sgx/issues/110
|
||||||
#[cfg_attr(target_env = "sgx", ignore)]
|
#[cfg_attr(target_env = "sgx", ignore)]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn shutdown_smoke() {
|
fn shutdown_smoke() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let a = t!(TcpListener::bind(&addr));
|
let a = t!(TcpListener::bind(&addr));
|
||||||
@ -505,6 +520,7 @@ fn shutdown_smoke() {
|
|||||||
#[test]
|
#[test]
|
||||||
// FIXME: https://github.com/fortanix/rust-sgx/issues/110
|
// FIXME: https://github.com/fortanix/rust-sgx/issues/110
|
||||||
#[cfg_attr(target_env = "sgx", ignore)]
|
#[cfg_attr(target_env = "sgx", ignore)]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn close_readwrite_smoke() {
|
fn close_readwrite_smoke() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let a = t!(TcpListener::bind(&addr));
|
let a = t!(TcpListener::bind(&addr));
|
||||||
@ -547,6 +563,7 @@ fn close_readwrite_smoke() {
|
|||||||
#[cfg_attr(target_env = "sgx", ignore)]
|
#[cfg_attr(target_env = "sgx", ignore)]
|
||||||
// On windows, shutdown will not wake up blocking I/O operations.
|
// On windows, shutdown will not wake up blocking I/O operations.
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn close_read_wakes_up() {
|
fn close_read_wakes_up() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
@ -574,6 +591,7 @@ fn close_read_wakes_up() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn clone_while_reading() {
|
fn clone_while_reading() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let accept = t!(TcpListener::bind(&addr));
|
let accept = t!(TcpListener::bind(&addr));
|
||||||
@ -614,6 +632,7 @@ fn clone_while_reading() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn clone_accept_smoke() {
|
fn clone_accept_smoke() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let a = t!(TcpListener::bind(&addr));
|
let a = t!(TcpListener::bind(&addr));
|
||||||
@ -632,6 +651,7 @@ fn clone_accept_smoke() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn clone_accept_concurrent() {
|
fn clone_accept_concurrent() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let a = t!(TcpListener::bind(&addr));
|
let a = t!(TcpListener::bind(&addr));
|
||||||
@ -670,10 +690,10 @@ fn debug() {
|
|||||||
addr.to_string()
|
addr.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(unix, target_os = "wasi"))]
|
||||||
|
use crate::os::fd::AsRawFd;
|
||||||
#[cfg(target_env = "sgx")]
|
#[cfg(target_env = "sgx")]
|
||||||
use crate::os::fortanix_sgx::io::AsRawFd;
|
use crate::os::fortanix_sgx::io::AsRawFd;
|
||||||
#[cfg(unix)]
|
|
||||||
use crate::os::unix::io::AsRawFd;
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn render_inner(addr: &dyn AsRawFd) -> impl fmt::Debug {
|
fn render_inner(addr: &dyn AsRawFd) -> impl fmt::Debug {
|
||||||
addr.as_raw_fd()
|
addr.as_raw_fd()
|
||||||
@ -714,6 +734,7 @@ fn debug() {
|
|||||||
ignore
|
ignore
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
#[test]
|
#[test]
|
||||||
fn timeouts() {
|
fn timeouts() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
@ -742,6 +763,7 @@ fn timeouts() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
fn test_read_timeout() {
|
fn test_read_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
@ -763,6 +785,7 @@ fn test_read_timeout() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
fn test_read_with_timeout() {
|
fn test_read_with_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
@ -810,6 +833,7 @@ fn test_timeout_zero_duration() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_env = "sgx", ignore)]
|
#[cfg_attr(target_env = "sgx", ignore)]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // linger not supported
|
||||||
fn linger() {
|
fn linger() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
let _listener = t!(TcpListener::bind(&addr));
|
let _listener = t!(TcpListener::bind(&addr));
|
||||||
@ -879,6 +903,7 @@ fn set_nonblocking() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn peek() {
|
fn peek() {
|
||||||
each_ip(&mut |addr| {
|
each_ip(&mut |addr| {
|
||||||
let (txdone, rxdone) = channel();
|
let (txdone, rxdone) = channel();
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))]
|
#[cfg(all(
|
||||||
|
test,
|
||||||
|
not(any(
|
||||||
|
target_os = "emscripten",
|
||||||
|
all(target_os = "wasi", target_env = "p1"),
|
||||||
|
target_env = "sgx",
|
||||||
|
target_os = "xous"
|
||||||
|
))
|
||||||
|
))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
|
@ -27,6 +27,7 @@ fn bind_error() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn socket_smoke_test_ip4() {
|
fn socket_smoke_test_ip4() {
|
||||||
each_ip(&mut |server_ip, client_ip| {
|
each_ip(&mut |server_ip, client_ip| {
|
||||||
let (tx1, rx1) = channel();
|
let (tx1, rx1) = channel();
|
||||||
@ -69,6 +70,7 @@ fn socket_peer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn udp_clone_smoke() {
|
fn udp_clone_smoke() {
|
||||||
each_ip(&mut |addr1, addr2| {
|
each_ip(&mut |addr1, addr2| {
|
||||||
let sock1 = t!(UdpSocket::bind(&addr1));
|
let sock1 = t!(UdpSocket::bind(&addr1));
|
||||||
@ -98,6 +100,7 @@ fn udp_clone_smoke() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn udp_clone_two_read() {
|
fn udp_clone_two_read() {
|
||||||
each_ip(&mut |addr1, addr2| {
|
each_ip(&mut |addr1, addr2| {
|
||||||
let sock1 = t!(UdpSocket::bind(&addr1));
|
let sock1 = t!(UdpSocket::bind(&addr1));
|
||||||
@ -130,6 +133,7 @@ fn udp_clone_two_read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // no threads
|
||||||
fn udp_clone_two_write() {
|
fn udp_clone_two_write() {
|
||||||
each_ip(&mut |addr1, addr2| {
|
each_ip(&mut |addr1, addr2| {
|
||||||
let sock1 = t!(UdpSocket::bind(&addr1));
|
let sock1 = t!(UdpSocket::bind(&addr1));
|
||||||
@ -183,6 +187,7 @@ fn debug() {
|
|||||||
any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks", target_os = "nto"),
|
any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks", target_os = "nto"),
|
||||||
ignore
|
ignore
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
#[test]
|
#[test]
|
||||||
fn timeouts() {
|
fn timeouts() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
@ -208,6 +213,7 @@ fn timeouts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
fn test_read_timeout() {
|
fn test_read_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
@ -232,6 +238,7 @@ fn test_read_timeout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported
|
||||||
fn test_read_with_timeout() {
|
fn test_read_with_timeout() {
|
||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
@ -291,6 +298,7 @@ fn connect_send_recv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // peek not supported
|
||||||
fn connect_send_peek_recv() {
|
fn connect_send_peek_recv() {
|
||||||
each_ip(&mut |addr, _| {
|
each_ip(&mut |addr, _| {
|
||||||
let socket = t!(UdpSocket::bind(&addr));
|
let socket = t!(UdpSocket::bind(&addr));
|
||||||
@ -313,6 +321,7 @@ fn connect_send_peek_recv() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(target_os = "wasi", ignore)] // peek_from not supported
|
||||||
fn peek_from() {
|
fn peek_from() {
|
||||||
each_ip(&mut |addr, _| {
|
each_ip(&mut |addr, _| {
|
||||||
let socket = t!(UdpSocket::bind(&addr));
|
let socket = t!(UdpSocket::bind(&addr));
|
||||||
|
@ -139,7 +139,7 @@ fn test_pathbuf_leak() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(any(unix, target_os = "wasi"))]
|
||||||
pub fn test_decompositions_unix() {
|
pub fn test_decompositions_unix() {
|
||||||
t!("",
|
t!("",
|
||||||
iter: [],
|
iter: [],
|
||||||
@ -1201,7 +1201,10 @@ pub fn test_push() {
|
|||||||
});
|
});
|
||||||
);
|
);
|
||||||
|
|
||||||
if cfg!(unix) || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) {
|
if cfg!(unix)
|
||||||
|
|| cfg!(target_os = "wasi")
|
||||||
|
|| cfg!(all(target_env = "sgx", target_vendor = "fortanix"))
|
||||||
|
{
|
||||||
tp!("", "foo", "foo");
|
tp!("", "foo", "foo");
|
||||||
tp!("foo", "bar", "foo/bar");
|
tp!("foo", "bar", "foo/bar");
|
||||||
tp!("foo/", "bar", "foo/bar");
|
tp!("foo/", "bar", "foo/bar");
|
||||||
@ -1358,7 +1361,10 @@ pub fn test_set_file_name() {
|
|||||||
tfn!("foo", "bar", "bar");
|
tfn!("foo", "bar", "bar");
|
||||||
tfn!("foo", "", "");
|
tfn!("foo", "", "");
|
||||||
tfn!("", "foo", "foo");
|
tfn!("", "foo", "foo");
|
||||||
if cfg!(unix) || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) {
|
if cfg!(unix)
|
||||||
|
|| cfg!(target_os = "wasi")
|
||||||
|
|| cfg!(all(target_env = "sgx", target_vendor = "fortanix"))
|
||||||
|
{
|
||||||
tfn!(".", "foo", "./foo");
|
tfn!(".", "foo", "./foo");
|
||||||
tfn!("foo/", "bar", "bar");
|
tfn!("foo/", "bar", "bar");
|
||||||
tfn!("foo/.", "bar", "bar");
|
tfn!("foo/.", "bar", "bar");
|
||||||
@ -1758,7 +1764,7 @@ fn test_components_debug() {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(any(unix, target_os = "wasi"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter_debug() {
|
fn test_iter_debug() {
|
||||||
let path = Path::new("/tmp");
|
let path = Path::new("/tmp");
|
||||||
@ -1859,7 +1865,7 @@ fn test_ord() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(any(unix, target_os = "wasi"))]
|
||||||
fn test_unix_absolute() {
|
fn test_unix_absolute() {
|
||||||
use crate::path::absolute;
|
use crate::path::absolute;
|
||||||
|
|
||||||
|
@ -148,7 +148,15 @@
|
|||||||
#![stable(feature = "process", since = "1.0.0")]
|
#![stable(feature = "process", since = "1.0.0")]
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))]
|
#[cfg(all(
|
||||||
|
test,
|
||||||
|
not(any(
|
||||||
|
target_os = "emscripten",
|
||||||
|
target_os = "wasi",
|
||||||
|
target_env = "sgx",
|
||||||
|
target_os = "xous"
|
||||||
|
))
|
||||||
|
))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::convert::Infallible;
|
use crate::convert::Infallible;
|
||||||
|
@ -3,7 +3,7 @@ use crate::sync::{Arc, Barrier};
|
|||||||
use crate::thread;
|
use crate::thread;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn test_barrier() {
|
fn test_barrier() {
|
||||||
const N: usize = 10;
|
const N: usize = 10;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ fn smoke() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn notify_one() {
|
fn notify_one() {
|
||||||
let m = Arc::new(Mutex::new(()));
|
let m = Arc::new(Mutex::new(()));
|
||||||
let m2 = m.clone();
|
let m2 = m.clone();
|
||||||
@ -29,7 +29,7 @@ fn notify_one() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn notify_all() {
|
fn notify_all() {
|
||||||
const N: usize = 10;
|
const N: usize = 10;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ fn notify_all() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn wait_while() {
|
fn wait_while() {
|
||||||
let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
let pair2 = pair.clone();
|
let pair2 = pair.clone();
|
||||||
@ -87,7 +87,7 @@ fn wait_while() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported
|
||||||
fn wait_timeout_wait() {
|
fn wait_timeout_wait() {
|
||||||
let m = Arc::new(Mutex::new(()));
|
let m = Arc::new(Mutex::new(()));
|
||||||
let c = Arc::new(Condvar::new());
|
let c = Arc::new(Condvar::new());
|
||||||
@ -106,7 +106,7 @@ fn wait_timeout_wait() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported
|
||||||
fn wait_timeout_while_wait() {
|
fn wait_timeout_while_wait() {
|
||||||
let m = Arc::new(Mutex::new(()));
|
let m = Arc::new(Mutex::new(()));
|
||||||
let c = Arc::new(Condvar::new());
|
let c = Arc::new(Condvar::new());
|
||||||
@ -118,7 +118,7 @@ fn wait_timeout_while_wait() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported
|
||||||
fn wait_timeout_while_instant_satisfy() {
|
fn wait_timeout_while_instant_satisfy() {
|
||||||
let m = Arc::new(Mutex::new(()));
|
let m = Arc::new(Mutex::new(()));
|
||||||
let c = Arc::new(Condvar::new());
|
let c = Arc::new(Condvar::new());
|
||||||
@ -130,7 +130,7 @@ fn wait_timeout_while_instant_satisfy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn wait_timeout_while_wake() {
|
fn wait_timeout_while_wake() {
|
||||||
let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
let pair_copy = pair.clone();
|
let pair_copy = pair.clone();
|
||||||
@ -153,7 +153,7 @@ fn wait_timeout_while_wake() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn wait_timeout_wake() {
|
fn wait_timeout_wake() {
|
||||||
let m = Arc::new(Mutex::new(()));
|
let m = Arc::new(Mutex::new(()));
|
||||||
let c = Arc::new(Condvar::new());
|
let c = Arc::new(Condvar::new());
|
||||||
|
@ -34,6 +34,7 @@ fn lazy_default() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn lazy_poisoning() {
|
fn lazy_poisoning() {
|
||||||
let x: LazyCell<String> = LazyCell::new(|| panic!("kaboom"));
|
let x: LazyCell<String> = LazyCell::new(|| panic!("kaboom"));
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
@ -43,7 +44,7 @@ fn lazy_poisoning() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn sync_lazy_new() {
|
fn sync_lazy_new() {
|
||||||
static CALLED: AtomicUsize = AtomicUsize::new(0);
|
static CALLED: AtomicUsize = AtomicUsize::new(0);
|
||||||
static SYNC_LAZY: LazyLock<i32> = LazyLock::new(|| {
|
static SYNC_LAZY: LazyLock<i32> = LazyLock::new(|| {
|
||||||
@ -90,7 +91,7 @@ fn sync_lazy_default() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn static_sync_lazy() {
|
fn static_sync_lazy() {
|
||||||
static XS: LazyLock<Vec<i32>> = LazyLock::new(|| {
|
static XS: LazyLock<Vec<i32>> = LazyLock::new(|| {
|
||||||
let mut xs = Vec::new();
|
let mut xs = Vec::new();
|
||||||
@ -123,6 +124,7 @@ fn static_sync_lazy_via_fn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn sync_lazy_poisoning() {
|
fn sync_lazy_poisoning() {
|
||||||
let x: LazyLock<String> = LazyLock::new(|| panic!("kaboom"));
|
let x: LazyLock<String> = LazyLock::new(|| panic!("kaboom"));
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
|
@ -137,10 +137,10 @@
|
|||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod sync_tests;
|
mod sync_tests;
|
||||||
|
|
||||||
// MPSC channels are built as a wrapper around MPMC channels, which
|
// MPSC channels are built as a wrapper around MPMC channels, which
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::cell::UnsafeCell;
|
use crate::cell::UnsafeCell;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//! This primitive is meant to be used to run one-time initialization. An
|
//! This primitive is meant to be used to run one-time initialization. An
|
||||||
//! example use case would be for initializing an FFI library.
|
//! example use case would be for initializing an FFI library.
|
||||||
|
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
|
@ -9,7 +9,7 @@ fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn sync_once_cell() {
|
fn sync_once_cell() {
|
||||||
static ONCE_CELL: OnceLock<i32> = OnceLock::new();
|
static ONCE_CELL: OnceLock<i32> = OnceLock::new();
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ fn sync_once_cell_get_unchecked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn sync_once_cell_drop() {
|
fn sync_once_cell_drop() {
|
||||||
static DROP_CNT: AtomicUsize = AtomicUsize::new(0);
|
static DROP_CNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
struct Dropper;
|
struct Dropper;
|
||||||
@ -81,6 +81,7 @@ fn clone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
|
||||||
fn get_or_try_init() {
|
fn get_or_try_init() {
|
||||||
let cell: OnceLock<String> = OnceLock::new();
|
let cell: OnceLock<String> = OnceLock::new();
|
||||||
assert!(cell.get().is_none());
|
assert!(cell.get().is_none());
|
||||||
@ -154,7 +155,7 @@ fn eval_once_macro() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
fn sync_once_cell_does_not_leak_partially_constructed_boxes() {
|
fn sync_once_cell_does_not_leak_partially_constructed_boxes() {
|
||||||
static ONCE_CELL: OnceLock<String> = OnceLock::new();
|
static ONCE_CELL: OnceLock<String> = OnceLock::new();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::cell::UnsafeCell;
|
use crate::cell::UnsafeCell;
|
||||||
|
@ -20,7 +20,6 @@ pub mod futex;
|
|||||||
#[path = "../wasi/io.rs"]
|
#[path = "../wasi/io.rs"]
|
||||||
pub mod io;
|
pub mod io;
|
||||||
|
|
||||||
#[path = "../wasi/net.rs"]
|
|
||||||
pub mod net;
|
pub mod net;
|
||||||
#[path = "../wasi/os.rs"]
|
#[path = "../wasi/os.rs"]
|
||||||
pub mod os;
|
pub mod os;
|
||||||
|
379
library/std/src/sys/pal/wasip2/net.rs
Normal file
379
library/std/src/sys/pal/wasip2/net.rs
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
|
use libc::{c_int, c_void, size_t};
|
||||||
|
|
||||||
|
use super::fd::WasiFd;
|
||||||
|
use crate::ffi::CStr;
|
||||||
|
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
|
||||||
|
use crate::net::{Shutdown, SocketAddr};
|
||||||
|
use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
|
||||||
|
use crate::sys::unsupported;
|
||||||
|
use crate::sys_common::net::{TcpListener, getsockopt, setsockopt, sockaddr_to_addr};
|
||||||
|
use crate::sys_common::{AsInner, FromInner, IntoInner};
|
||||||
|
use crate::time::{Duration, Instant};
|
||||||
|
use crate::{cmp, mem, str};
|
||||||
|
|
||||||
|
pub extern crate libc as netc;
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub type wrlen_t = size_t;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub trait IsMinusOne {
|
||||||
|
fn is_minus_one(&self) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! impl_is_minus_one {
|
||||||
|
($($t:ident)*) => ($(impl IsMinusOne for $t {
|
||||||
|
fn is_minus_one(&self) -> bool {
|
||||||
|
*self == -1
|
||||||
|
}
|
||||||
|
})*)
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_is_minus_one! { i8 i16 i32 i64 isize }
|
||||||
|
|
||||||
|
pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
|
||||||
|
if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
|
||||||
|
where
|
||||||
|
T: IsMinusOne,
|
||||||
|
F: FnMut() -> T,
|
||||||
|
{
|
||||||
|
loop {
|
||||||
|
match cvt(f()) {
|
||||||
|
Err(ref e) if e.is_interrupted() => {}
|
||||||
|
other => return other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cvt_gai(err: c_int) -> io::Result<()> {
|
||||||
|
if err == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == netc::EAI_SYSTEM {
|
||||||
|
return Err(io::Error::last_os_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
let detail = unsafe {
|
||||||
|
str::from_utf8(CStr::from_ptr(netc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
|
Err(io::Error::new(
|
||||||
|
io::ErrorKind::Uncategorized,
|
||||||
|
&format!("failed to lookup address information: {detail}")[..],
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init() {}
|
||||||
|
|
||||||
|
pub struct Socket(WasiFd);
|
||||||
|
|
||||||
|
impl Socket {
|
||||||
|
pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> {
|
||||||
|
let fam = match *addr {
|
||||||
|
SocketAddr::V4(..) => netc::AF_INET,
|
||||||
|
SocketAddr::V6(..) => netc::AF_INET6,
|
||||||
|
};
|
||||||
|
Socket::new_raw(fam, ty)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_raw(fam: c_int, ty: c_int) -> io::Result<Socket> {
|
||||||
|
let fd = cvt(unsafe { netc::socket(fam, ty, 0) })?;
|
||||||
|
Ok(unsafe { Self::from_raw_fd(fd) })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> {
|
||||||
|
let (addr, len) = addr.into_inner();
|
||||||
|
cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> {
|
||||||
|
self.set_nonblocking(true)?;
|
||||||
|
let r = self.connect(addr);
|
||||||
|
self.set_nonblocking(false)?;
|
||||||
|
|
||||||
|
match r {
|
||||||
|
Ok(_) => return Ok(()),
|
||||||
|
// there's no ErrorKind for EINPROGRESS
|
||||||
|
Err(ref e) if e.raw_os_error() == Some(netc::EINPROGRESS) => {}
|
||||||
|
Err(e) => return Err(e),
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut pollfd = netc::pollfd { fd: self.as_raw_fd(), events: netc::POLLOUT, revents: 0 };
|
||||||
|
|
||||||
|
if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 {
|
||||||
|
return Err(io::Error::ZERO_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let elapsed = start.elapsed();
|
||||||
|
if elapsed >= timeout {
|
||||||
|
return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let timeout = timeout - elapsed;
|
||||||
|
let mut timeout = timeout
|
||||||
|
.as_secs()
|
||||||
|
.saturating_mul(1_000)
|
||||||
|
.saturating_add(timeout.subsec_nanos() as u64 / 1_000_000);
|
||||||
|
if timeout == 0 {
|
||||||
|
timeout = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
let timeout = cmp::min(timeout, c_int::MAX as u64) as c_int;
|
||||||
|
|
||||||
|
match unsafe { netc::poll(&mut pollfd, 1, timeout) } {
|
||||||
|
-1 => {
|
||||||
|
let err = io::Error::last_os_error();
|
||||||
|
if !err.is_interrupted() {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0 => {}
|
||||||
|
_ => {
|
||||||
|
// WASI poll does not return POLLHUP or POLLERR in revents. Check if the
|
||||||
|
// connnection actually succeeded and return ok only when the socket is
|
||||||
|
// ready and no errors were found.
|
||||||
|
if let Some(e) = self.take_error()? {
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn accept(
|
||||||
|
&self,
|
||||||
|
storage: *mut netc::sockaddr,
|
||||||
|
len: *mut netc::socklen_t,
|
||||||
|
) -> io::Result<Socket> {
|
||||||
|
let fd = cvt_r(|| unsafe { netc::accept(self.as_raw_fd(), storage, len) })?;
|
||||||
|
Ok(unsafe { Self::from_raw_fd(fd) })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn duplicate(&self) -> io::Result<Socket> {
|
||||||
|
unsupported()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: c_int) -> io::Result<()> {
|
||||||
|
let ret = cvt(unsafe {
|
||||||
|
netc::recv(
|
||||||
|
self.as_raw_fd(),
|
||||||
|
buf.as_mut().as_mut_ptr() as *mut c_void,
|
||||||
|
buf.capacity(),
|
||||||
|
flags,
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
unsafe {
|
||||||
|
buf.advance_unchecked(ret as usize);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
|
let mut buf = BorrowedBuf::from(buf);
|
||||||
|
self.recv_with_flags(buf.unfilled(), 0)?;
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
|
let mut buf = BorrowedBuf::from(buf);
|
||||||
|
self.recv_with_flags(buf.unfilled(), netc::MSG_PEEK)?;
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> {
|
||||||
|
self.recv_with_flags(buf, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||||
|
io::default_read_vectored(|b| self.read(b), bufs)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_read_vectored(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn recv_from_with_flags(
|
||||||
|
&self,
|
||||||
|
buf: &mut [u8],
|
||||||
|
flags: c_int,
|
||||||
|
) -> io::Result<(usize, SocketAddr)> {
|
||||||
|
let mut storage: netc::sockaddr_storage = unsafe { mem::zeroed() };
|
||||||
|
let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t;
|
||||||
|
|
||||||
|
let n = cvt(unsafe {
|
||||||
|
netc::recvfrom(
|
||||||
|
self.as_raw_fd(),
|
||||||
|
buf.as_mut_ptr() as *mut c_void,
|
||||||
|
buf.len(),
|
||||||
|
flags,
|
||||||
|
core::ptr::addr_of_mut!(storage) as *mut _,
|
||||||
|
&mut addrlen,
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
|
||||||
|
self.recv_from_with_flags(buf, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
|
||||||
|
self.recv_from_with_flags(buf, netc::MSG_PEEK)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||||
|
let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
|
||||||
|
let ret = cvt(unsafe {
|
||||||
|
netc::send(self.as_raw(), buf.as_ptr() as *const c_void, len, netc::MSG_NOSIGNAL)
|
||||||
|
})?;
|
||||||
|
Ok(ret as usize)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||||
|
io::default_write_vectored(|b| self.write(b), bufs)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_write_vectored(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_timeout(&self, dur: Option<Duration>, kind: c_int) -> io::Result<()> {
|
||||||
|
let timeout = match dur {
|
||||||
|
Some(dur) => {
|
||||||
|
if dur.as_secs() == 0 && dur.subsec_nanos() == 0 {
|
||||||
|
return Err(io::Error::ZERO_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
let secs = dur.as_secs().try_into().unwrap_or(netc::time_t::MAX);
|
||||||
|
let mut timeout = netc::timeval {
|
||||||
|
tv_sec: secs,
|
||||||
|
tv_usec: dur.subsec_micros() as netc::suseconds_t,
|
||||||
|
};
|
||||||
|
if timeout.tv_sec == 0 && timeout.tv_usec == 0 {
|
||||||
|
timeout.tv_usec = 1;
|
||||||
|
}
|
||||||
|
timeout
|
||||||
|
}
|
||||||
|
None => netc::timeval { tv_sec: 0, tv_usec: 0 },
|
||||||
|
};
|
||||||
|
setsockopt(self, netc::SOL_SOCKET, kind, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timeout(&self, kind: c_int) -> io::Result<Option<Duration>> {
|
||||||
|
let raw: netc::timeval = getsockopt(self, netc::SOL_SOCKET, kind)?;
|
||||||
|
if raw.tv_sec == 0 && raw.tv_usec == 0 {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
let sec = raw.tv_sec as u64;
|
||||||
|
let nsec = (raw.tv_usec as u32) * 1000;
|
||||||
|
Ok(Some(Duration::new(sec, nsec)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
|
||||||
|
let how = match how {
|
||||||
|
Shutdown::Write => netc::SHUT_WR,
|
||||||
|
Shutdown::Read => netc::SHUT_RD,
|
||||||
|
Shutdown::Both => netc::SHUT_RDWR,
|
||||||
|
};
|
||||||
|
cvt(unsafe { netc::shutdown(self.as_raw_fd(), how) })?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_linger(&self, _linger: Option<Duration>) -> io::Result<()> {
|
||||||
|
unsupported()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn linger(&self) -> io::Result<Option<Duration>> {
|
||||||
|
unsupported()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
|
||||||
|
setsockopt(self, netc::IPPROTO_TCP, netc::TCP_NODELAY, nodelay as c_int)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn nodelay(&self) -> io::Result<bool> {
|
||||||
|
let raw: c_int = getsockopt(self, netc::IPPROTO_TCP, netc::TCP_NODELAY)?;
|
||||||
|
Ok(raw != 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||||
|
let mut nonblocking = nonblocking as c_int;
|
||||||
|
cvt(unsafe { netc::ioctl(self.as_raw_fd(), netc::FIONBIO, &mut nonblocking) }).map(drop)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
|
||||||
|
let raw: c_int = getsockopt(self, netc::SOL_SOCKET, netc::SO_ERROR)?;
|
||||||
|
if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is used by sys_common code to abstract over Windows and Unix.
|
||||||
|
pub fn as_raw(&self) -> RawFd {
|
||||||
|
self.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsInner<WasiFd> for Socket {
|
||||||
|
#[inline]
|
||||||
|
fn as_inner(&self) -> &WasiFd {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoInner<WasiFd> for Socket {
|
||||||
|
fn into_inner(self) -> WasiFd {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromInner<WasiFd> for Socket {
|
||||||
|
fn from_inner(inner: WasiFd) -> Socket {
|
||||||
|
Socket(inner)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsFd for Socket {
|
||||||
|
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||||
|
self.0.as_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRawFd for Socket {
|
||||||
|
#[inline]
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.0.as_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoRawFd for Socket {
|
||||||
|
fn into_raw_fd(self) -> RawFd {
|
||||||
|
self.0.into_raw_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromRawFd for Socket {
|
||||||
|
unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
|
||||||
|
unsafe { Self(FromRawFd::from_raw_fd(raw_fd)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsInner<Socket> for TcpListener {
|
||||||
|
#[inline]
|
||||||
|
fn as_inner(&self) -> &Socket {
|
||||||
|
&self.socket()
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 };
|
pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 };
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(dead_code)] // not used on emscripten
|
#[allow(dead_code)] // not used on emscripten and wasi
|
||||||
pub mod test {
|
pub mod test {
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ cfg_if::cfg_if! {
|
|||||||
all(unix, not(target_os = "l4re")),
|
all(unix, not(target_os = "l4re")),
|
||||||
windows,
|
windows,
|
||||||
target_os = "hermit",
|
target_os = "hermit",
|
||||||
target_os = "solid_asp3"
|
target_os = "solid_asp3",
|
||||||
|
all(target_os = "wasi", target_env = "p2")
|
||||||
))] {
|
))] {
|
||||||
pub mod net;
|
pub mod net;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#![unstable(feature = "thread_local_internals", issue = "none")]
|
#![unstable(feature = "thread_local_internals", issue = "none")]
|
||||||
|
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -155,7 +155,7 @@
|
|||||||
// Under `test`, `__FastLocalKeyInner` seems unused.
|
// Under `test`, `__FastLocalKeyInner` seems unused.
|
||||||
#![cfg_attr(test, allow(dead_code))]
|
#![cfg_attr(test, allow(dead_code))]
|
||||||
|
|
||||||
#[cfg(all(test, not(target_os = "emscripten")))]
|
#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::any::Any;
|
use crate::any::Any;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))]
|
#![cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"))))]
|
||||||
|
|
||||||
//! Note that this test changes the current directory so
|
//! Note that this test changes the current directory so
|
||||||
//! should not be in the same process as other tests.
|
//! should not be in the same process as other tests.
|
||||||
|
@ -5,7 +5,7 @@ use std::{env, fs, process, str};
|
|||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(miri, ignore)] // Process spawning not supported by Miri
|
#[cfg_attr(any(miri, target_os = "wasi"), ignore)] // Process spawning not supported by Miri and wasi
|
||||||
fn issue_15149() {
|
fn issue_15149() {
|
||||||
// If we're the parent, copy our own binary to a new directory.
|
// If we're the parent, copy our own binary to a new directory.
|
||||||
let my_path = env::current_exe().unwrap();
|
let my_path = env::current_exe().unwrap();
|
||||||
|
@ -4,7 +4,7 @@ use std::thread;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
|
||||||
#[cfg_attr(miri, ignore)] // Miri does not like the thread leak
|
#[cfg_attr(miri, ignore)] // Miri does not like the thread leak
|
||||||
fn sleep_very_long() {
|
fn sleep_very_long() {
|
||||||
let finished = Arc::new(Mutex::new(false));
|
let finished = Arc::new(Mutex::new(false));
|
||||||
|
@ -1370,7 +1370,7 @@ Executed at: {executed_at}"#,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if target.starts_with("wasm") && target.contains("wasi") {
|
if target.starts_with("wasm") && target.contains("wasi") {
|
||||||
self.default_wasi_runner()
|
self.default_wasi_runner(target)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -1379,7 +1379,7 @@ Executed at: {executed_at}"#,
|
|||||||
/// When a `runner` configuration is not provided and a WASI-looking target
|
/// When a `runner` configuration is not provided and a WASI-looking target
|
||||||
/// is being tested this is consulted to prove the environment to see if
|
/// is being tested this is consulted to prove the environment to see if
|
||||||
/// there's a runtime already lying around that seems reasonable to use.
|
/// there's a runtime already lying around that seems reasonable to use.
|
||||||
fn default_wasi_runner(&self) -> Option<String> {
|
fn default_wasi_runner(&self, target: TargetSelection) -> Option<String> {
|
||||||
let mut finder = crate::core::sanity::Finder::new();
|
let mut finder = crate::core::sanity::Finder::new();
|
||||||
|
|
||||||
// Look for Wasmtime, and for its default options be sure to disable
|
// Look for Wasmtime, and for its default options be sure to disable
|
||||||
@ -1395,6 +1395,11 @@ Executed at: {executed_at}"#,
|
|||||||
// inherit the entire environment rather than just this single
|
// inherit the entire environment rather than just this single
|
||||||
// environment variable.
|
// environment variable.
|
||||||
path.push_str(" --env RUSTC_BOOTSTRAP");
|
path.push_str(" --env RUSTC_BOOTSTRAP");
|
||||||
|
|
||||||
|
if target.contains("wasip2") {
|
||||||
|
path.push_str(" --wasi inherit-network --wasi allow-ip-name-lookup");
|
||||||
|
}
|
||||||
|
|
||||||
return Some(path);
|
return Some(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra`
|
|||||||
LL | cfg!(target_feature = "zebra");
|
LL | cfg!(target_feature = "zebra");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 241 more
|
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 244 more
|
||||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||||
|
|
||||||
warning: 27 warnings emitted
|
warning: 27 warnings emitted
|
||||||
|
@ -174,7 +174,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
|||||||
LL | target_feature = "_UNEXPECTED_VALUE",
|
LL | target_feature = "_UNEXPECTED_VALUE",
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
|
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zaamo`, `zabha`, `zalrsc`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
|
||||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||||
|
|
||||||
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
||||||
|
13
tests/ui/consts/auxiliary/unstable_but_const_stable.rs
Normal file
13
tests/ui/consts/auxiliary/unstable_but_const_stable.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#![feature(staged_api, rustc_attrs, intrinsics)]
|
||||||
|
#![stable(since="1.0.0", feature = "stable")]
|
||||||
|
|
||||||
|
extern "rust-intrinsic" {
|
||||||
|
#[unstable(feature = "unstable", issue = "42")]
|
||||||
|
#[rustc_const_stable(feature = "stable", since = "1.0.0")]
|
||||||
|
#[rustc_nounwind]
|
||||||
|
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "unstable", issue = "42")]
|
||||||
|
#[rustc_const_stable(feature = "stable", since = "1.0.0")]
|
||||||
|
pub const fn some_unstable_fn() {}
|
14
tests/ui/consts/unstable-const-stable.rs
Normal file
14
tests/ui/consts/unstable-const-stable.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//@ aux-build:unstable_but_const_stable.rs
|
||||||
|
|
||||||
|
extern crate unstable_but_const_stable;
|
||||||
|
use unstable_but_const_stable::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
some_unstable_fn(); //~ERROR use of unstable library feature
|
||||||
|
unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn const_main() {
|
||||||
|
some_unstable_fn(); //~ERROR use of unstable library feature
|
||||||
|
unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature
|
||||||
|
}
|
43
tests/ui/consts/unstable-const-stable.stderr
Normal file
43
tests/ui/consts/unstable-const-stable.stderr
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
error[E0658]: use of unstable library feature 'unstable'
|
||||||
|
--> $DIR/unstable-const-stable.rs:7:5
|
||||||
|
|
|
||||||
|
LL | some_unstable_fn();
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
|
||||||
|
= help: add `#![feature(unstable)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0658]: use of unstable library feature 'unstable'
|
||||||
|
--> $DIR/unstable-const-stable.rs:8:14
|
||||||
|
|
|
||||||
|
LL | unsafe { write_bytes(4 as *mut u8, 0, 0) };
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
|
||||||
|
= help: add `#![feature(unstable)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0658]: use of unstable library feature 'unstable'
|
||||||
|
--> $DIR/unstable-const-stable.rs:12:5
|
||||||
|
|
|
||||||
|
LL | some_unstable_fn();
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
|
||||||
|
= help: add `#![feature(unstable)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0658]: use of unstable library feature 'unstable'
|
||||||
|
--> $DIR/unstable-const-stable.rs:13:14
|
||||||
|
|
|
||||||
|
LL | unsafe { write_bytes(4 as *mut u8, 0, 0) };
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
|
||||||
|
= help: add `#![feature(unstable)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Reference in New Issue
Block a user