mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
fallout from feature-gating unary negation on unsigned integers.
This commit is contained in:
parent
d8e309320d
commit
3225b04c7d
@ -1123,7 +1123,7 @@ impl Iterator for ElementSwaps {
|
||||
// #[inline]
|
||||
fn next(&mut self) -> Option<(usize, usize)> {
|
||||
fn new_pos_wrapping(i: usize, s: Direction) -> usize {
|
||||
i.wrapping_add(match s { Pos => 1, Neg => -1 })
|
||||
i.wrapping_add(match s { Pos => 1, Neg => !0 /* aka -1 */ })
|
||||
}
|
||||
|
||||
fn new_pos(i: usize, s: Direction) -> usize {
|
||||
|
@ -161,7 +161,7 @@ pub const ATOMIC_USIZE_INIT: AtomicUsize =
|
||||
AtomicUsize { v: UnsafeCell { value: 0, } };
|
||||
|
||||
// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
|
||||
const UINT_TRUE: usize = -1;
|
||||
const UINT_TRUE: usize = !0;
|
||||
|
||||
impl AtomicBool {
|
||||
/// Creates a new `AtomicBool`.
|
||||
|
@ -287,7 +287,7 @@ pub enum BorrowState {
|
||||
// (will not outgrow its range since `usize` is the size of the address space)
|
||||
type BorrowFlag = usize;
|
||||
const UNUSED: BorrowFlag = 0;
|
||||
const WRITING: BorrowFlag = -1;
|
||||
const WRITING: BorrowFlag = !0;
|
||||
|
||||
impl<T> RefCell<T> {
|
||||
/// Creates a new `RefCell` containing `value`.
|
||||
|
@ -517,7 +517,7 @@ macro_rules! uint_impl {
|
||||
fn min_value() -> $T { 0 }
|
||||
|
||||
#[inline]
|
||||
fn max_value() -> $T { -1 }
|
||||
fn max_value() -> $T { !0 }
|
||||
|
||||
#[inline]
|
||||
fn count_ones(self) -> u32 {
|
||||
|
@ -482,8 +482,10 @@ pub trait Neg {
|
||||
fn neg(self) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! neg_impl {
|
||||
($($t:ty)*) => ($(
|
||||
|
||||
|
||||
macro_rules! neg_impl_core {
|
||||
($id:ident => $body:expr, $($t:ty)*) => ($(
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[allow(unsigned_negation)]
|
||||
impl Neg for $t {
|
||||
@ -492,14 +494,28 @@ macro_rules! neg_impl {
|
||||
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn neg(self) -> $t { -self }
|
||||
fn neg(self) -> $t { let $id = self; $body }
|
||||
}
|
||||
|
||||
forward_ref_unop! { impl Neg, neg for $t }
|
||||
)*)
|
||||
}
|
||||
|
||||
neg_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
|
||||
macro_rules! neg_impl_numeric {
|
||||
($($t:ty)*) => { neg_impl_core!{ x => -x, $($t)*} }
|
||||
}
|
||||
|
||||
macro_rules! neg_impl_unsigned {
|
||||
($($t:ty)*) => {
|
||||
neg_impl_core!{ x => {
|
||||
#[cfg(stage0)]
|
||||
use ::num::wrapping::WrappingOps;
|
||||
!x.wrapping_add(1)
|
||||
}, $($t)*} }
|
||||
}
|
||||
|
||||
neg_impl_unsigned! { usize u8 u16 u32 u64 }
|
||||
neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 }
|
||||
|
||||
/// The `Not` trait is used to specify the functionality of unary `!`.
|
||||
///
|
||||
|
@ -873,7 +873,7 @@ impl TwoWaySearcher {
|
||||
#[allow(dead_code)]
|
||||
#[allow(deprecated)]
|
||||
fn maximal_suffix(arr: &[u8], reversed: bool) -> (usize, usize) {
|
||||
let mut left: usize = -1; // Corresponds to i in the paper
|
||||
let mut left: usize = !0; // Corresponds to i in the paper
|
||||
let mut right = 0; // Corresponds to j in the paper
|
||||
let mut offset = 1; // Corresponds to k in the paper
|
||||
let mut period = 1; // Corresponds to p in the paper
|
||||
|
@ -4696,7 +4696,7 @@ pub mod consts {
|
||||
pub const MAP_FIXED : c_int = 0x0010;
|
||||
pub const MAP_ANON : c_int = 0x1000;
|
||||
|
||||
pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
|
||||
pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
|
||||
|
||||
pub const MCL_CURRENT : c_int = 0x0001;
|
||||
pub const MCL_FUTURE : c_int = 0x0002;
|
||||
|
@ -117,7 +117,7 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
|
||||
use libc;
|
||||
use libc::funcs::posix01::signal::signal;
|
||||
unsafe {
|
||||
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != -1);
|
||||
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0);
|
||||
}
|
||||
}
|
||||
ignore_sigpipe();
|
||||
|
Loading…
Reference in New Issue
Block a user