mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #3084 - RalfJung:deadcode, r=RalfJung
remove some dead code and add a comment in the AVX test
This commit is contained in:
commit
efd04b6267
@ -1,5 +1,3 @@
|
||||
pub mod convert;
|
||||
|
||||
use std::cmp;
|
||||
use std::iter;
|
||||
use std::num::NonZeroUsize;
|
||||
|
@ -1,49 +0,0 @@
|
||||
use implementations::NarrowerThan;
|
||||
|
||||
/// Replacement for `as` casts going from wide integer to narrower integer.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// let x = 99_u64;
|
||||
/// let lo = x.truncate::<u16>();
|
||||
/// // lo is of type u16, equivalent to `x as u16`.
|
||||
/// ```
|
||||
pub(crate) trait Truncate: Sized {
|
||||
fn truncate<To>(self) -> To
|
||||
where
|
||||
To: NarrowerThan<Self>,
|
||||
{
|
||||
NarrowerThan::truncate_from(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Truncate for u16 {}
|
||||
impl Truncate for u32 {}
|
||||
impl Truncate for u64 {}
|
||||
impl Truncate for u128 {}
|
||||
|
||||
mod implementations {
|
||||
pub(crate) trait NarrowerThan<T> {
|
||||
fn truncate_from(wide: T) -> Self;
|
||||
}
|
||||
|
||||
macro_rules! impl_narrower_than {
|
||||
($(NarrowerThan<{$($ty:ty),*}> for $self:ty)*) => {
|
||||
$($(
|
||||
impl NarrowerThan<$ty> for $self {
|
||||
fn truncate_from(wide: $ty) -> Self {
|
||||
wide as Self
|
||||
}
|
||||
}
|
||||
)*)*
|
||||
};
|
||||
}
|
||||
|
||||
impl_narrower_than! {
|
||||
NarrowerThan<{u128, u64, u32, u16}> for u8
|
||||
NarrowerThan<{u128, u64, u32}> for u16
|
||||
NarrowerThan<{u128, u64}> for u32
|
||||
NarrowerThan<{u128}> for u64
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
// Ignore everything except x86 and x86_64
|
||||
// Any additional target are added to CI should be ignored here
|
||||
// (We cannot use `cfg`-based tricks here since the `target-feature` flags below only work on x86.)
|
||||
//@ignore-target-aarch64
|
||||
//@ignore-target-arm
|
||||
//@ignore-target-avr
|
||||
|
Loading…
Reference in New Issue
Block a user