diff --git a/src/doc/trpl/traits.md b/src/doc/trpl/traits.md index 80c45ac4f0ade..0870a6ef34147 100644 --- a/src/doc/trpl/traits.md +++ b/src/doc/trpl/traits.md @@ -390,7 +390,7 @@ fn normal>(x: &T) -> i64 { // can be called with T == i64 fn inverse() -> T - // this is using ConvertTo as if it were "ConvertFrom" + // this is using ConvertTo as if it were "ConvertTo" where i32: ConvertTo { 42.convert() } diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index ab343430296e8..d8f8ca6eae59c 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -296,7 +296,7 @@ impl Drop for Node { self.destroy(); } - self.keys = unsafe { Unique::new(0 as *mut K) }; + self.keys = unsafe { Unique::new(ptr::null_mut()) }; } } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index ec3c36d0c8137..bb752b07abeb8 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1135,7 +1135,7 @@ impl ops::Deref for Vec { fn deref(&self) -> &[T] { unsafe { let p = self.buf.ptr(); - assume(p != 0 as *mut T); + assume(!p.is_null()); slice::from_raw_parts(p, self.len) } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 06eb22278080a..d37f5169af1df 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -231,7 +231,7 @@ impl Cell { /// ``` #[inline] #[unstable(feature = "as_unsafe_cell", issue = "27708")] - pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell { + pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell { &self.value } } @@ -387,7 +387,7 @@ impl RefCell { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn borrow<'a>(&'a self) -> Ref<'a, T> { + pub fn borrow(&self) -> Ref { match BorrowRef::new(&self.borrow) { Some(b) => Ref { _value: unsafe { &*self.value.get() }, @@ -433,7 +433,7 @@ impl RefCell { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> { + pub fn borrow_mut(&self) -> RefMut { match BorrowRefMut::new(&self.borrow) { Some(b) => RefMut { _value: unsafe { &mut *self.value.get() }, @@ -450,7 +450,7 @@ impl RefCell { /// This function is `unsafe` because `UnsafeCell`'s field is public. #[inline] #[unstable(feature = "as_unsafe_cell", issue = "27708")] - pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell { + pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell { &self.value } } @@ -541,7 +541,7 @@ impl<'b, T: ?Sized> Deref for Ref<'b, T> { type Target = T; #[inline] - fn deref<'a>(&'a self) -> &'a T { + fn deref(&self) -> &T { self._value } } @@ -750,7 +750,7 @@ impl<'b, T: ?Sized> Deref for RefMut<'b, T> { type Target = T; #[inline] - fn deref<'a>(&'a self) -> &'a T { + fn deref(&self) -> &T { self._value } } @@ -758,7 +758,7 @@ impl<'b, T: ?Sized> Deref for RefMut<'b, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { #[inline] - fn deref_mut<'a>(&'a mut self) -> &'a mut T { + fn deref_mut(&mut self) -> &mut T { self._value } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 3d17b10ba3a85..97dcb2475a3cf 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1513,7 +1513,7 @@ impl Iterator for Chain where fn next(&mut self) -> Option { match self.state { ChainState::Both => match self.a.next() { - elt @ Some(..) => return elt, + elt @ Some(..) => elt, None => { self.state = ChainState::Back; self.b.next() @@ -1590,7 +1590,7 @@ impl DoubleEndedIterator for Chain where fn next_back(&mut self) -> Option { match self.state { ChainState::Both => match self.b.next_back() { - elt @ Some(..) => return elt, + elt @ Some(..) => elt, None => { self.state = ChainState::Front; self.a.next_back() @@ -1683,7 +1683,7 @@ impl Iterator for Map where F: FnMut(I::Item) -> B { #[inline] fn next(&mut self) -> Option { - self.iter.next().map(|a| (self.f)(a)) + self.iter.next().map(&mut self.f) } #[inline] @@ -1698,7 +1698,7 @@ impl DoubleEndedIterator for Map where { #[inline] fn next_back(&mut self) -> Option { - self.iter.next_back().map(|a| (self.f)(a)) + self.iter.next_back().map(&mut self.f) } } @@ -2210,7 +2210,7 @@ impl Iterator for FlatMap return Some(x) } } - match self.iter.next().map(|x| (self.f)(x)) { + match self.iter.next().map(&mut self.f) { None => return self.backiter.as_mut().and_then(|it| it.next()), next => self.frontiter = next.map(IntoIterator::into_iter), } @@ -2243,7 +2243,7 @@ impl DoubleEndedIterator for FlatMap wher return Some(y) } } - match self.iter.next_back().map(|x| (self.f)(x)) { + match self.iter.next_back().map(&mut self.f) { None => return self.frontiter.as_mut().and_then(|it| it.next_back()), next => self.backiter = next.map(IntoIterator::into_iter), } diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 2524e5662aa84..c945e4e066159 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -51,7 +51,7 @@ impl Deref for NonZero { type Target = T; #[inline] - fn deref<'a>(&'a self) -> &'a T { + fn deref(&self) -> &T { let NonZero(ref inner) = *self; inner } diff --git a/src/libcore/num/flt2dec/bignum.rs b/src/libcore/num/flt2dec/bignum.rs index ee2ffbffab654..091e9c889da47 100644 --- a/src/libcore/num/flt2dec/bignum.rs +++ b/src/libcore/num/flt2dec/bignum.rs @@ -211,7 +211,7 @@ macro_rules! define_bignum { self } - pub fn add_small<'a>(&'a mut self, other: $ty) -> &'a mut $name { + pub fn add_small(&mut self, other: $ty) -> &mut $name { use num::flt2dec::bignum::FullOps; let (mut carry, v) = self.base[0].full_add(other, false); @@ -248,7 +248,7 @@ macro_rules! define_bignum { /// Multiplies itself by a digit-sized `other` and returns its own /// mutable reference. - pub fn mul_small<'a>(&'a mut self, other: $ty) -> &'a mut $name { + pub fn mul_small(&mut self, other: $ty) -> &mut $name { use num::flt2dec::bignum::FullOps; let mut sz = self.size; @@ -267,7 +267,7 @@ macro_rules! define_bignum { } /// Multiplies itself by `2^bits` and returns its own mutable reference. - pub fn mul_pow2<'a>(&'a mut self, bits: usize) -> &'a mut $name { + pub fn mul_pow2(&mut self, bits: usize) -> &mut $name { use mem; let digitbits = mem::size_of::<$ty>() * 8; @@ -308,7 +308,7 @@ macro_rules! define_bignum { } /// Multiplies itself by `5^e` and returns its own mutable reference. - pub fn mul_pow5<'a>(&'a mut self, mut e: usize) -> &'a mut $name { + pub fn mul_pow5(&mut self, mut e: usize) -> &mut $name { use mem; use num::flt2dec::bignum::SMALL_POW5; @@ -377,7 +377,7 @@ macro_rules! define_bignum { /// Divides itself by a digit-sized `other` and returns its own /// mutable reference *and* the remainder. - pub fn div_rem_small<'a>(&'a mut self, other: $ty) -> (&'a mut $name, $ty) { + pub fn div_rem_small(&mut self, other: $ty) -> (&mut $name, $ty) { use num::flt2dec::bignum::FullOps; assert!(other > 0); diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index ab610f28e9eca..40aa2a527dbc5 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -42,7 +42,7 @@ static POW10TO256: [Digit; 27] = 0xcc5573c0, 0x65f9ef17, 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x553f7]; #[doc(hidden)] -pub fn mul_pow10<'a>(x: &'a mut Big, n: usize) -> &'a mut Big { +pub fn mul_pow10(x: &mut Big, n: usize) -> &mut Big { debug_assert!(n < 512); if n & 7 != 0 { x.mul_small(POW10[n & 7]); } if n & 8 != 0 { x.mul_small(POW10[8]); } @@ -54,7 +54,7 @@ pub fn mul_pow10<'a>(x: &'a mut Big, n: usize) -> &'a mut Big { x } -fn div_2pow10<'a>(x: &'a mut Big, mut n: usize) -> &'a mut Big { +fn div_2pow10(x: &mut Big, mut n: usize) -> &mut Big { let largest = POW10.len() - 1; while n > largest { x.div_rem_small(POW10[largest]); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 3fb720ab6c83c..07de4d0761baa 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -965,7 +965,7 @@ pub trait Index { /// The method for the indexing (`Foo[Bar]`) operation #[stable(feature = "rust1", since = "1.0.0")] - fn index<'a>(&'a self, index: Idx) -> &'a Self::Output; + fn index(&self, index: Idx) -> &Self::Output; } /// The `IndexMut` trait is used to specify the functionality of indexing @@ -1008,7 +1008,7 @@ pub trait Index { pub trait IndexMut: Index { /// The method for the indexing (`Foo[Bar]`) operation #[stable(feature = "rust1", since = "1.0.0")] - fn index_mut<'a>(&'a mut self, index: Idx) -> &'a mut Self::Output; + fn index_mut(&mut self, index: Idx) -> &mut Self::Output; } /// An unbounded range. @@ -1119,7 +1119,7 @@ pub trait Deref { /// The method called to dereference a value #[stable(feature = "rust1", since = "1.0.0")] - fn deref<'a>(&'a self) -> &'a Self::Target; + fn deref(&self) -> &Self::Target; } #[stable(feature = "rust1", since = "1.0.0")] @@ -1180,7 +1180,7 @@ impl<'a, T: ?Sized> Deref for &'a mut T { pub trait DerefMut: Deref { /// The method called to mutably dereference a value #[stable(feature = "rust1", since = "1.0.0")] - fn deref_mut<'a>(&'a mut self) -> &'a mut Self::Target; + fn deref_mut(&mut self) -> &mut Self::Target; } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a36a120689cc6..1434617baddce 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -241,7 +241,7 @@ impl Option { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn as_ref<'r>(&'r self) -> Option<&'r T> { + pub fn as_ref(&self) -> Option<&T> { match *self { Some(ref x) => Some(x), None => None, @@ -262,7 +262,7 @@ impl Option { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn as_mut<'r>(&'r mut self) -> Option<&'r mut T> { + pub fn as_mut(&mut self) -> Option<&mut T> { match *self { Some(ref mut x) => Some(x), None => None, @@ -289,7 +289,7 @@ impl Option { #[unstable(feature = "as_slice", reason = "waiting for mut conventions", issue = "27776")] - pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { + pub fn as_mut_slice(&mut self) -> &mut [T] { match *self { Some(ref mut x) => { let result: &mut [T] = slice::mut_ref_slice(x); @@ -692,7 +692,7 @@ impl Option { #[inline] #[unstable(feature = "as_slice", since = "unsure of the utility here", issue = "27776")] - pub fn as_slice<'a>(&'a self) -> &'a [T] { + pub fn as_slice(&self) -> &[T] { match *self { Some(ref x) => slice::ref_slice(x), None => { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index b7479b0c604f3..83bdaf0923e80 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -51,7 +51,7 @@ pub use intrinsics::write_bytes; /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -pub fn null() -> *const T { 0 as *const T } +pub const fn null() -> *const T { 0 as *const T } /// Creates a null mutable raw pointer. /// @@ -65,7 +65,7 @@ pub fn null() -> *const T { 0 as *const T } /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -pub fn null_mut() -> *mut T { 0 as *mut T } +pub const fn null_mut() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without /// deinitialising either. They may overlap, unlike `mem::swap` which is @@ -163,7 +163,7 @@ impl *const T { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is_null(self) -> bool where T: Sized { - self == 0 as *const T + self == null() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -212,7 +212,7 @@ impl *mut T { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn is_null(self) -> bool where T: Sized { - self == 0 as *mut T + self == null_mut() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -468,7 +468,7 @@ impl Deref for Unique { type Target = *mut T; #[inline] - fn deref<'a>(&'a self) -> &'a *mut T { + fn deref(&self) -> &*mut T { unsafe { mem::transmute(&*self.pointer) } } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index fdd5e61c8f27b..cf605f507bca6 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -69,48 +69,48 @@ use raw::Slice as RawSlice; pub trait SliceExt { type Item; - fn split_at<'a>(&'a self, mid: usize) -> (&'a [Self::Item], &'a [Self::Item]); - fn iter<'a>(&'a self) -> Iter<'a, Self::Item>; - fn split<'a, P>(&'a self, pred: P) -> Split<'a, Self::Item, P> + fn split_at(&self, mid: usize) -> (&[Self::Item], &[Self::Item]); + fn iter(&self) -> Iter; + fn split

(&self, pred: P) -> Split where P: FnMut(&Self::Item) -> bool; - fn splitn<'a, P>(&'a self, n: usize, pred: P) -> SplitN<'a, Self::Item, P> + fn splitn

(&self, n: usize, pred: P) -> SplitN where P: FnMut(&Self::Item) -> bool; - fn rsplitn<'a, P>(&'a self, n: usize, pred: P) -> RSplitN<'a, Self::Item, P> + fn rsplitn

(&self, n: usize, pred: P) -> RSplitN where P: FnMut(&Self::Item) -> bool; - fn windows<'a>(&'a self, size: usize) -> Windows<'a, Self::Item>; - fn chunks<'a>(&'a self, size: usize) -> Chunks<'a, Self::Item>; - fn get<'a>(&'a self, index: usize) -> Option<&'a Self::Item>; - fn first<'a>(&'a self) -> Option<&'a Self::Item>; - fn tail<'a>(&'a self) -> &'a [Self::Item]; - fn init<'a>(&'a self) -> &'a [Self::Item]; - fn split_first<'a>(&'a self) -> Option<(&'a Self::Item, &'a [Self::Item])>; - fn split_last<'a>(&'a self) -> Option<(&'a Self::Item, &'a [Self::Item])>; - fn last<'a>(&'a self) -> Option<&'a Self::Item>; - unsafe fn get_unchecked<'a>(&'a self, index: usize) -> &'a Self::Item; + fn windows(&self, size: usize) -> Windows; + fn chunks(&self, size: usize) -> Chunks; + fn get(&self, index: usize) -> Option<&Self::Item>; + fn first(&self) -> Option<&Self::Item>; + fn tail(&self) -> &[Self::Item]; + fn init(&self) -> &[Self::Item]; + fn split_first(&self) -> Option<(&Self::Item, &[Self::Item])>; + fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])>; + fn last(&self) -> Option<&Self::Item>; + unsafe fn get_unchecked(&self, index: usize) -> &Self::Item; fn as_ptr(&self) -> *const Self::Item; fn binary_search_by(&self, f: F) -> Result where F: FnMut(&Self::Item) -> Ordering; fn len(&self) -> usize; fn is_empty(&self) -> bool { self.len() == 0 } - fn get_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut Self::Item>; - fn iter_mut<'a>(&'a mut self) -> IterMut<'a, Self::Item>; - fn first_mut<'a>(&'a mut self) -> Option<&'a mut Self::Item>; - fn tail_mut<'a>(&'a mut self) -> &'a mut [Self::Item]; - fn init_mut<'a>(&'a mut self) -> &'a mut [Self::Item]; - fn split_first_mut<'a>(&'a mut self) -> Option<(&'a mut Self::Item, &'a mut [Self::Item])>; - fn split_last_mut<'a>(&'a mut self) -> Option<(&'a mut Self::Item, &'a mut [Self::Item])>; - fn last_mut<'a>(&'a mut self) -> Option<&'a mut Self::Item>; - fn split_mut<'a, P>(&'a mut self, pred: P) -> SplitMut<'a, Self::Item, P> + fn get_mut(&mut self, index: usize) -> Option<&mut Self::Item>; + fn iter_mut(&mut self) -> IterMut; + fn first_mut(&mut self) -> Option<&mut Self::Item>; + fn tail_mut(&mut self) -> &mut [Self::Item]; + fn init_mut(&mut self) -> &mut [Self::Item]; + fn split_first_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>; + fn split_last_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>; + fn last_mut(&mut self) -> Option<&mut Self::Item>; + fn split_mut

(&mut self, pred: P) -> SplitMut where P: FnMut(&Self::Item) -> bool; fn splitn_mut

(&mut self, n: usize, pred: P) -> SplitNMut where P: FnMut(&Self::Item) -> bool; fn rsplitn_mut

(&mut self, n: usize, pred: P) -> RSplitNMut where P: FnMut(&Self::Item) -> bool; - fn chunks_mut<'a>(&'a mut self, chunk_size: usize) -> ChunksMut<'a, Self::Item>; + fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut; fn swap(&mut self, a: usize, b: usize); - fn split_at_mut<'a>(&'a mut self, mid: usize) -> (&'a mut [Self::Item], &'a mut [Self::Item]); + fn split_at_mut(&mut self, mid: usize) -> (&mut [Self::Item], &mut [Self::Item]); fn reverse(&mut self); - unsafe fn get_unchecked_mut<'a>(&'a mut self, index: usize) -> &'a mut Self::Item; + unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut Self::Item; fn as_mut_ptr(&mut self) -> *mut Self::Item; fn position_elem(&self, t: &Self::Item) -> Option where Self::Item: PartialEq; @@ -163,7 +163,7 @@ impl SliceExt for [T] { } #[inline] - fn iter<'a>(&'a self) -> Iter<'a, T> { + fn iter(&self) -> Iter { unsafe { let p = if mem::size_of::() == 0 { 1 as *const _ @@ -182,7 +182,7 @@ impl SliceExt for [T] { } #[inline] - fn split<'a, P>(&'a self, pred: P) -> Split<'a, T, P> where P: FnMut(&T) -> bool { + fn split

(&self, pred: P) -> Split where P: FnMut(&T) -> bool { Split { v: self, pred: pred, @@ -191,7 +191,7 @@ impl SliceExt for [T] { } #[inline] - fn splitn<'a, P>(&'a self, n: usize, pred: P) -> SplitN<'a, T, P> where + fn splitn

(&self, n: usize, pred: P) -> SplitN where P: FnMut(&T) -> bool, { SplitN { @@ -204,7 +204,7 @@ impl SliceExt for [T] { } #[inline] - fn rsplitn<'a, P>(&'a self, n: usize, pred: P) -> RSplitN<'a, T, P> where + fn rsplitn

(&self, n: usize, pred: P) -> RSplitN where P: FnMut(&T) -> bool, { RSplitN { @@ -311,7 +311,7 @@ impl SliceExt for [T] { } #[inline] - fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> { + fn iter_mut(&mut self) -> IterMut { unsafe { let p = if mem::size_of::() == 0 { 1 as *mut _ @@ -368,12 +368,12 @@ impl SliceExt for [T] { } #[inline] - fn split_mut<'a, P>(&'a mut self, pred: P) -> SplitMut<'a, T, P> where P: FnMut(&T) -> bool { + fn split_mut

(&mut self, pred: P) -> SplitMut where P: FnMut(&T) -> bool { SplitMut { v: self, pred: pred, finished: false } } #[inline] - fn splitn_mut<'a, P>(&'a mut self, n: usize, pred: P) -> SplitNMut<'a, T, P> where + fn splitn_mut

(&mut self, n: usize, pred: P) -> SplitNMut where P: FnMut(&T) -> bool { SplitNMut { @@ -386,7 +386,7 @@ impl SliceExt for [T] { } #[inline] - fn rsplitn_mut<'a, P>(&'a mut self, n: usize, pred: P) -> RSplitNMut<'a, T, P> where + fn rsplitn_mut

(&mut self, n: usize, pred: P) -> RSplitNMut where P: FnMut(&T) -> bool, { RSplitNMut { @@ -1410,7 +1410,7 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} /// Converts a pointer to A into a slice of length 1 (without copying). #[unstable(feature = "ref_slice", issue = "27774")] -pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { +pub fn ref_slice(s: &A) -> &[A] { unsafe { from_raw_parts(s, 1) } @@ -1418,7 +1418,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { /// Converts a pointer to A into a slice of length 1 (without copying). #[unstable(feature = "ref_slice", issue = "27774")] -pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { +pub fn mut_ref_slice(s: &mut A) -> &mut [A] { unsafe { from_raw_parts_mut(s, 1) } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 7d32f61b3dd71..4612fc8900861 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -142,7 +142,7 @@ pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { /// that the string contains valid UTF-8. #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn from_utf8_unchecked<'a>(v: &'a [u8]) -> &'a str { +pub unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { mem::transmute(v) } @@ -1270,9 +1270,9 @@ pub trait StrExt { fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; - fn chars<'a>(&'a self) -> Chars<'a>; - fn bytes<'a>(&'a self) -> Bytes<'a>; - fn char_indices<'a>(&'a self) -> CharIndices<'a>; + fn chars(&self) -> Chars; + fn bytes(&self) -> Bytes; + fn char_indices(&self) -> CharIndices; fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P>; fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P> where P::Searcher: ReverseSearcher<'a>; @@ -1288,12 +1288,12 @@ pub trait StrExt { fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>; fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P> where P::Searcher: ReverseSearcher<'a>; - fn lines<'a>(&'a self) -> Lines<'a>; - fn lines_any<'a>(&'a self) -> LinesAny<'a>; + fn lines(&self) -> Lines; + fn lines_any(&self) -> LinesAny; fn char_len(&self) -> usize; - fn slice_chars<'a>(&'a self, begin: usize, end: usize) -> &'a str; - unsafe fn slice_unchecked<'a>(&'a self, begin: usize, end: usize) -> &'a str; - unsafe fn slice_mut_unchecked<'a>(&'a mut self, begin: usize, end: usize) -> &'a mut str; + fn slice_chars(&self, begin: usize, end: usize) -> &str; + unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str; + unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str; fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool; fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool where P::Searcher: ReverseSearcher<'a>; @@ -1307,14 +1307,14 @@ pub trait StrExt { fn char_range_at_reverse(&self, start: usize) -> CharRange; fn char_at(&self, i: usize) -> char; fn char_at_reverse(&self, i: usize) -> char; - fn as_bytes<'a>(&'a self) -> &'a [u8]; + fn as_bytes(&self) -> &[u8]; fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option; fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option where P::Searcher: ReverseSearcher<'a>; fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option; fn split_at(&self, mid: usize) -> (&str, &str); fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str); - fn slice_shift_char<'a>(&'a self) -> Option<(char, &'a str)>; + fn slice_shift_char(&self) -> Option<(char, &str)>; fn subslice_offset(&self, inner: &str) -> usize; fn as_ptr(&self) -> *const u8; fn len(&self) -> usize; diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 2187c1fb7dfa4..4517c2f915773 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -184,6 +184,7 @@ use std::io::{self, Stderr}; use std::io::prelude::*; use std::mem; use std::env; +use std::ptr; use std::rt; use std::slice; use std::sync::{Once, StaticMutex}; @@ -209,11 +210,10 @@ static LOCK: StaticMutex = StaticMutex::new(); /// logging statement should be run. static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL; -static mut DIRECTIVES: *mut Vec = - 0 as *mut Vec; +static mut DIRECTIVES: *mut Vec = ptr::null_mut(); /// Optional filter. -static mut FILTER: *mut String = 0 as *mut _; +static mut FILTER: *mut String = ptr::null_mut(); /// Debug log level pub const DEBUG: u32 = 4; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index e53d00736681a..215368754c999 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -344,7 +344,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Step 3: Mark all destructors as reachable. // - // FIXME(pcwalton): This is a conservative overapproximation, but fixing + // FIXME #10732: This is a conservative overapproximation, but fixing // this properly would result in the necessity of computing *type* // reachability, which might result in a compile time loss. fn mark_destructors_reachable(&mut self) { diff --git a/src/librustc_trans/back/archive.rs b/src/librustc_trans/back/archive.rs index 02f4bc83b7524..76bbce00f19dc 100644 --- a/src/librustc_trans/back/archive.rs +++ b/src/librustc_trans/back/archive.rs @@ -18,6 +18,7 @@ use std::io; use std::mem; use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; +use std::ptr; use std::str; use libc; @@ -449,7 +450,7 @@ impl<'a> ArchiveBuilder<'a> { } let name = try!(CString::new(child_name)); - members.push(llvm::LLVMRustArchiveMemberNew(0 as *const _, + members.push(llvm::LLVMRustArchiveMemberNew(ptr::null(), name.as_ptr(), child.raw())); strings.push(name); @@ -462,7 +463,7 @@ impl<'a> ArchiveBuilder<'a> { let name = try!(CString::new(name_in_archive)); members.push(llvm::LLVMRustArchiveMemberNew(path.as_ptr(), name.as_ptr(), - 0 as *mut _)); + ptr::null_mut())); strings.push(path); strings.push(name); } @@ -472,7 +473,7 @@ impl<'a> ArchiveBuilder<'a> { if skip(child_name) { continue } let name = try!(CString::new(child_name)); - let m = llvm::LLVMRustArchiveMemberNew(0 as *const _, + let m = llvm::LLVMRustArchiveMemberNew(ptr::null(), name.as_ptr(), child.raw()); members.push(m); diff --git a/src/librustc_trans/back/msvc/registry.rs b/src/librustc_trans/back/msvc/registry.rs index 21078641c1f53..d178565e18f59 100644 --- a/src/librustc_trans/back/msvc/registry.rs +++ b/src/librustc_trans/back/msvc/registry.rs @@ -12,6 +12,7 @@ use std::io; use std::ffi::{OsString, OsStr}; use std::os::windows::prelude::*; use std::ops::RangeFrom; +use std::ptr; use libc::{DWORD, LPCWSTR, LONG, LPDWORD, LPBYTE, ERROR_SUCCESS}; use libc::c_void; @@ -88,7 +89,7 @@ impl RegistryKey { pub fn open(&self, key: &OsStr) -> io::Result { let key = key.encode_wide().chain(Some(0)).collect::>(); - let mut ret = 0 as *mut _; + let mut ret = ptr::null_mut(); let err = unsafe { RegOpenKeyExW(self.raw(), key.as_ptr(), 0, KEY_READ | KEY_WOW64_32KEY, &mut ret) @@ -110,8 +111,8 @@ impl RegistryKey { let mut len = 0; let mut kind = 0; unsafe { - let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _, - &mut kind, 0 as *mut _, &mut len); + let err = RegQueryValueExW(self.raw(), name.as_ptr(), ptr::null_mut(), + &mut kind, ptr::null_mut(), &mut len); if err != ERROR_SUCCESS { return Err(io::Error::from_raw_os_error(err as i32)) } @@ -124,8 +125,8 @@ impl RegistryKey { // characters so we need to be sure to halve it for the capacity // passed in. let mut v = Vec::with_capacity(len as usize / 2); - let err = RegQueryValueExW(self.raw(), name.as_ptr(), 0 as *mut _, - 0 as *mut _, v.as_mut_ptr() as *mut _, + let err = RegQueryValueExW(self.raw(), name.as_ptr(), ptr::null_mut(), + ptr::null_mut(), v.as_mut_ptr() as *mut _, &mut len); if err != ERROR_SUCCESS { return Err(io::Error::from_raw_os_error(err as i32)) @@ -156,8 +157,8 @@ impl<'a> Iterator for Iter<'a> { let mut v = Vec::with_capacity(256); let mut len = v.capacity() as DWORD; let ret = RegEnumKeyExW(self.key.raw(), i, v.as_mut_ptr(), &mut len, - 0 as *mut _, 0 as *mut _, 0 as *mut _, - 0 as *mut _); + ptr::null_mut(), ptr::null_mut(), ptr::null_mut(), + ptr::null_mut()); if ret == ERROR_NO_MORE_ITEMS as LONG { None } else if ret != ERROR_SUCCESS { diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index e356f612cdef2..dfce7a9c31584 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2299,6 +2299,21 @@ extern "rust-intrinsic" { ``` "##, +E0214: r##" +A generic type was described using parentheses rather than angle brackets. For +example: + +``` +fn main() { + let v: Vec(&str) = vec!["foo"]; +} +``` + +This is not currently supported: `v` should be defined as `Vec<&str>`. +Parentheses are currently only used with generic types when defining parameters +for `Fn`-family traits. +"##, + E0220: r##" You used an associated type which isn't defined in the trait. Erroneous code example: @@ -2705,6 +2720,37 @@ fn main() { ``` "##, +E0329: r##" +An attempt was made to access an associated constant through either a generic +type parameter or `Self`. This is not supported yet. An example causing this +error is shown below: + +``` +trait Foo { + const BAR: f64; +} + +struct MyStruct; + +impl Foo for MyStruct { + const BAR: f64 = 0f64; +} + +fn get_bar_bad(t: F) -> f64 { + F::BAR +} +``` + +Currently, the value of `BAR` for a particular type can only be accessed through +a concrete type, as shown below: + +``` +fn get_bar_good() -> f64 { + ::BAR +} +``` +"##, + E0366: r##" An attempt was made to implement `Drop` on a concrete specialization of a generic type. An example is shown below: @@ -3219,7 +3265,6 @@ register_diagnostics! { // E0209, // builtin traits can only be implemented on structs or enums E0212, // cannot extract an associated type from a higher-ranked trait bound // E0213, // associated types are not accepted in this context - E0214, // parenthesized parameters may only be used with a trait // E0215, // angle-bracket notation is not stable with `Fn` // E0216, // parenthetical notation is only stable with `Fn` // E0217, // ambiguous associated type, defined in multiple supertraits @@ -3251,7 +3296,6 @@ register_diagnostics! { E0320, // recursive overflow during dropck E0321, // extended coherence rules for defaulted traits violated E0328, // cannot implement Unsize explicitly - E0329, // associated const depends on type parameter or Self. E0374, // the trait `CoerceUnsized` may only be implemented for a coercion // between structures with one field being coerced, none found E0375, // the trait `CoerceUnsized` may only be implemented for a coercion diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs index c3e309d182b95..ad17a650336c5 100644 --- a/src/libstd/io/lazy.rs +++ b/src/libstd/io/lazy.rs @@ -11,6 +11,7 @@ use prelude::v1::*; use cell::Cell; +use ptr; use rt; use sync::{StaticMutex, Arc}; @@ -26,7 +27,7 @@ impl Lazy { pub const fn new(init: fn() -> Arc) -> Lazy { Lazy { lock: StaticMutex::new(), - ptr: Cell::new(0 as *mut _), + ptr: Cell::new(ptr::null_mut()), init: init } } diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 51d5af056cb7f..1df9642d3bb74 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -185,6 +185,7 @@ mod imp { use io; use mem; + use ptr; use rand::Rng; use libc::{c_int, size_t}; @@ -207,7 +208,7 @@ mod imp { enum SecRandom {} #[allow(non_upper_case_globals)] - const kSecRandomDefault: *const SecRandom = 0 as *const SecRandom; + const kSecRandomDefault: *const SecRandom = ptr::null(); #[link(name = "Security", kind = "framework")] extern "C" { diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 17d2940a6f10c..54e5b499e537a 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -18,6 +18,7 @@ use alloc::boxed::FnBox; use boxed::Box; +use ptr; use sys_common::mutex::Mutex; use vec::Vec; @@ -28,7 +29,7 @@ type Queue = Vec>; // the thread infrastructure to be in place (useful on the borders of // initialization/destruction). static LOCK: Mutex = Mutex::new(); -static mut QUEUE: *mut Queue = 0 as *mut Queue; +static mut QUEUE: *mut Queue = ptr::null_mut(); // The maximum number of times the cleanup routines will be run. While running // the at_exit closures new ones may be registered, and this count is the number diff --git a/src/libstd/rt/unwind/seh.rs b/src/libstd/rt/unwind/seh.rs index ed44f9a8bda94..8c7937581665b 100644 --- a/src/libstd/rt/unwind/seh.rs +++ b/src/libstd/rt/unwind/seh.rs @@ -53,6 +53,7 @@ use prelude::v1::*; use any::Any; use libc::{c_ulong, DWORD, c_void}; +use ptr; use sys_common::thread_local::StaticKey; // 0x R U S T @@ -98,7 +99,7 @@ pub unsafe fn panic(data: Box) -> ! { rtassert!(PANIC_DATA.get().is_null()); PANIC_DATA.set(Box::into_raw(exception) as *mut u8); - RaiseException(RUST_PANIC, 0, 0, 0 as *const _); + RaiseException(RUST_PANIC, 0, 0, ptr::null()); rtabort!("could not unwind stack"); } @@ -108,7 +109,7 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box { rtassert!(ptr as DWORD == RUST_PANIC); let data = PANIC_DATA.get() as *mut Box; - PANIC_DATA.set(0 as *mut u8); + PANIC_DATA.set(ptr::null_mut()); rtassert!(!data.is_null()); *Box::from_raw(data) diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 67e1099c29540..4fb3134eac99c 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -16,6 +16,7 @@ use io::{self, Error, ErrorKind}; use libc::{self, c_int, c_char, c_void, socklen_t}; use mem; use net::{SocketAddr, Shutdown, IpAddr}; +use ptr; use str::from_utf8; use sys::c; use sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t}; @@ -123,9 +124,9 @@ pub fn lookup_host(host: &str) -> io::Result { init(); let c_host = try!(CString::new(host)); - let mut res = 0 as *mut _; + let mut res = ptr::null_mut(); unsafe { - try!(cvt_gai(getaddrinfo(c_host.as_ptr(), 0 as *const _, 0 as *const _, + try!(cvt_gai(getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(), &mut res))); Ok(LookupHost { original: res, cur: res }) } @@ -154,7 +155,7 @@ pub fn lookup_addr(addr: &IpAddr) -> io::Result { let data = unsafe { try!(cvt_gai(getnameinfo(inner, len, hostbuf.as_mut_ptr(), NI_MAXHOST as libc::size_t, - 0 as *mut _, 0, 0))); + ptr::null_mut(), 0, 0))); CStr::from_ptr(hostbuf.as_ptr()) }; diff --git a/src/libstd/sys/unix/backtrace/printing/libbacktrace.rs b/src/libstd/sys/unix/backtrace/printing/libbacktrace.rs index 711e241161dd7..5640eb81f2ae3 100644 --- a/src/libstd/sys/unix/backtrace/printing/libbacktrace.rs +++ b/src/libstd/sys/unix/backtrace/printing/libbacktrace.rs @@ -123,7 +123,7 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, // FIXME: We also call self_exe_name() on DragonFly BSD. I haven't // tested if this is required or not. unsafe fn init_state() -> *mut backtrace_state { - static mut STATE: *mut backtrace_state = 0 as *mut backtrace_state; + static mut STATE: *mut backtrace_state = ptr::null_mut(); static mut LAST_FILENAME: [libc::c_char; 256] = [0; 256]; if !STATE.is_null() { return STATE } let selfname = if cfg!(target_os = "freebsd") || diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index fa31ac682d40b..70be04b631ad5 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -291,7 +291,7 @@ pub fn args() -> Args { }; Args { iter: vec.into_iter(), - _dont_send_or_sync_me: 0 as *mut (), + _dont_send_or_sync_me: ptr::null_mut(), } } @@ -347,7 +347,7 @@ pub fn args() -> Args { } } - Args { iter: res.into_iter(), _dont_send_or_sync_me: 0 as *mut _ } + Args { iter: res.into_iter(), _dont_send_or_sync_me: ptr::null_mut() } } #[cfg(any(target_os = "linux", @@ -363,7 +363,7 @@ pub fn args() -> Args { let v: Vec = bytes.into_iter().map(|v| { OsStringExt::from_vec(v) }).collect(); - Args { iter: v.into_iter(), _dont_send_or_sync_me: 0 as *mut _ } + Args { iter: v.into_iter(), _dont_send_or_sync_me: ptr::null_mut() } } pub struct Env { @@ -403,7 +403,7 @@ pub fn env() -> Env { result.push(parse(CStr::from_ptr(*environ).to_bytes())); environ = environ.offset(1); } - Env { iter: result.into_iter(), _dont_send_or_sync_me: 0 as *mut _ } + Env { iter: result.into_iter(), _dont_send_or_sync_me: ptr::null_mut() } }; fn parse(input: &[u8]) -> (OsString, OsString) { @@ -481,7 +481,7 @@ pub fn home_dir() -> Option { loop { let mut buf = Vec::with_capacity(amt); let mut passwd: c::passwd = mem::zeroed(); - let mut result = 0 as *mut _; + let mut result = ptr::null_mut(); match c::getpwuid_r(me, &mut passwd, buf.as_mut_ptr(), buf.capacity() as libc::size_t, &mut result) { diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 59798e938a69b..12ca31ce5e1e4 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -405,7 +405,7 @@ fn make_envp(env: Option<&HashMap>) (ptrs.as_ptr() as *const _, tmps, ptrs) } else { - (0 as *const _, Vec::new(), Vec::new()) + (ptr::null(), Vec::new(), Vec::new()) } } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 1aa75fa18b737..baff3c6bcbb83 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -93,7 +93,7 @@ mod imp { // See comment above for why this function returns. } - static mut MAIN_ALTSTACK: *mut libc::c_void = 0 as *mut libc::c_void; + static mut MAIN_ALTSTACK: *mut libc::c_void = ptr::null_mut(); pub unsafe fn init() { PAGE_SIZE = ::sys::os::page_size(); @@ -155,7 +155,7 @@ mod imp { } pub unsafe fn make_handler() -> super::Handler { - super::Handler { _data: 0 as *mut libc::c_void } + super::Handler { _data: ptr::null_mut() } } pub unsafe fn drop_handler(_handler: &mut super::Handler) { diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs index 9c8a1f4ca40ec..4e49b6473c94b 100644 --- a/src/libstd/sys/unix/sync.rs +++ b/src/libstd/sys/unix/sync.rs @@ -59,15 +59,16 @@ extern { target_os = "openbsd"))] mod os { use libc; + use ptr; pub type pthread_mutex_t = *mut libc::c_void; pub type pthread_mutexattr_t = *mut libc::c_void; pub type pthread_cond_t = *mut libc::c_void; pub type pthread_rwlock_t = *mut libc::c_void; - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2; } @@ -213,6 +214,7 @@ mod os { #[cfg(target_os = "android")] mod os { use libc; + use ptr; #[repr(C)] pub struct pthread_mutex_t { value: libc::c_int } @@ -243,7 +245,7 @@ mod os { writerThreadId: 0, pendingReaders: 0, pendingWriters: 0, - reserved: [0 as *mut _; 4], + reserved: [ptr::null_mut(); 4], }; pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 1; } diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 8d59461f1e4e7..5a551e2b3f33f 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -72,7 +72,7 @@ impl Thread { extern fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void { unsafe { start_thread(main); } - 0 as *mut _ + ptr::null_mut() } } diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 8fb03ae79022d..30c7e5a52b7c7 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -16,6 +16,7 @@ use libc; use libc::{c_uint, c_ulong}; use libc::{DWORD, BOOL, BOOLEAN, ERROR_CALL_NOT_IMPLEMENTED, LPVOID, HANDLE}; use libc::{LPCWSTR, LONG}; +use ptr; pub use self::GET_FILEEX_INFO_LEVELS::*; pub use self::FILE_INFO_BY_HANDLE_CLASS::*; @@ -294,9 +295,9 @@ pub struct CRITICAL_SECTION { } pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { - ptr: 0 as *mut _, + ptr: ptr::null_mut(), }; -pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: 0 as *mut _ }; +pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { ptr: ptr::null_mut() }; #[repr(C)] pub struct LUID { diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index d413d536cc85b..e9d98b36a43f8 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -328,12 +328,12 @@ impl File { try!(cvt({ c::DeviceIoControl(self.handle.raw(), c::FSCTL_GET_REPARSE_POINT, - 0 as *mut _, + ptr::null_mut(), 0, space.as_mut_ptr() as *mut _, space.len() as libc::DWORD, &mut bytes, - 0 as *mut _) + ptr::null_mut()) })); Ok((bytes, &*(space.as_ptr() as *const c::REPARSE_DATA_BUFFER))) } @@ -680,15 +680,15 @@ fn directory_junctions_are_directories() { c::FSCTL_SET_REPARSE_POINT, data.as_ptr() as *mut _, (*db).ReparseDataLength + 8, - 0 as *mut _, 0, + ptr::null_mut(), 0, &mut ret, - 0 as *mut _)).map(|_| ()) + ptr::null_mut())).map(|_| ()) } } fn opendir(p: &Path, write: bool) -> io::Result { unsafe { - let mut token = 0 as *mut _; + let mut token = ptr::null_mut(); let mut tp: c::TOKEN_PRIVILEGES = mem::zeroed(); try!(cvt(c::OpenProcessToken(c::GetCurrentProcess(), c::TOKEN_ADJUST_PRIVILEGES, @@ -699,14 +699,14 @@ fn directory_junctions_are_directories() { "SeBackupPrivilege".as_ref() }; let name = name.encode_wide().chain(Some(0)).collect::>(); - try!(cvt(c::LookupPrivilegeValueW(0 as *const _, + try!(cvt(c::LookupPrivilegeValueW(ptr::null(), name.as_ptr(), &mut tp.Privileges[0].Luid))); tp.PrivilegeCount = 1; tp.Privileges[0].Attributes = c::SE_PRIVILEGE_ENABLED; let size = mem::size_of::() as libc::DWORD; try!(cvt(c::AdjustTokenPrivileges(token, libc::FALSE, &mut tp, size, - 0 as *mut _, 0 as *mut _))); + ptr::null_mut(), ptr::null_mut()))); try!(cvt(libc::CloseHandle(token))); File::open_reparse_point(p, write) @@ -726,9 +726,9 @@ fn directory_junctions_are_directories() { c::FSCTL_DELETE_REPARSE_POINT, data.as_ptr() as *mut _, (*db).ReparseDataLength + 8, - 0 as *mut _, 0, + ptr::null_mut(), 0, &mut bytes, - 0 as *mut _)).map(|_| ()) + ptr::null_mut())).map(|_| ()) } } } diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index 57e84b0c46c58..e62b2d8cb18ff 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -15,6 +15,7 @@ use mem; use net::SocketAddr; use num::One; use ops::Neg; +use ptr; use rt; use sync::Once; use sys; @@ -80,7 +81,7 @@ impl Socket { SocketAddr::V6(..) => libc::AF_INET6, }; let socket = try!(unsafe { - match c::WSASocketW(fam, ty, 0, 0 as *mut _, 0, + match c::WSASocketW(fam, ty, 0, ptr::null_mut(), 0, c::WSA_FLAG_OVERLAPPED) { INVALID_SOCKET => Err(last_error()), n => Ok(Socket(n)), diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 7e286b91f4a7f..3e2f442f073f6 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -10,6 +10,7 @@ use io; use libc; +use ptr; use sys::cvt; use sys::c; use sys::handle::Handle; @@ -26,7 +27,7 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> { let mut reader = libc::INVALID_HANDLE_VALUE; let mut writer = libc::INVALID_HANDLE_VALUE; try!(cvt(unsafe { - c::CreatePipe(&mut reader, &mut writer, 0 as *mut _, 0) + c::CreatePipe(&mut reader, &mut writer, ptr::null_mut(), 0) })); let reader = Handle::new(reader); let writer = Handle::new(writer); diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index d9b7a59712b0c..17bc7ee887693 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -58,7 +58,7 @@ pub type Dtor = unsafe extern fn(*mut u8); // the thread infrastructure to be in place (useful on the borders of // initialization/destruction). static DTOR_LOCK: Mutex = Mutex::new(); -static mut DTORS: *mut Vec<(Key, Dtor)> = 0 as *mut _; +static mut DTORS: *mut Vec<(Key, Dtor)> = ptr::null_mut(); // ------------------------------------------------------------------------- // Native bindings diff --git a/src/libstd/thread/scoped_tls.rs b/src/libstd/thread/scoped_tls.rs index bfcaabdbc17b8..87f58b4c84910 100644 --- a/src/libstd/thread/scoped_tls.rs +++ b/src/libstd/thread/scoped_tls.rs @@ -226,6 +226,7 @@ impl ScopedKey { #[doc(hidden)] mod imp { use cell::Cell; + use ptr; pub struct KeyInner { inner: Cell<*mut T> } @@ -233,7 +234,7 @@ mod imp { impl KeyInner { pub const fn new() -> KeyInner { - KeyInner { inner: Cell::new(0 as *mut _) } + KeyInner { inner: Cell::new(ptr::null_mut()) } } pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr); } pub unsafe fn get(&self) -> *mut T { self.inner.get() } diff --git a/src/test/compile-fail/allocator-dylib-is-system.rs b/src/test/compile-fail/allocator-dylib-is-system.rs index 6c21f77c9a669..35bfc0c7d4fa5 100644 --- a/src/test/compile-fail/allocator-dylib-is-system.rs +++ b/src/test/compile-fail/allocator-dylib-is-system.rs @@ -10,6 +10,7 @@ // ignore-msvc everything is the system allocator on msvc // ignore-musl no dylibs on musl yet +// ignore-bitrig no jemalloc on bitrig // aux-build:allocator-dylib.rs // no-prefer-dynamic // error-pattern: cannot link together two allocators diff --git a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs index 8ba48f6a52530..23f9efa2e6446 100644 --- a/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs +++ b/src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs @@ -10,6 +10,7 @@ // ignore-msvc everything is the system allocator on msvc // ignore-musl no dylibs on musl right now +// ignore-bitrig no jemalloc on bitrig // aux-build:allocator-dylib2.rs // error-pattern: cannot link together two allocators diff --git a/src/test/run-pass/allocator-default.rs b/src/test/run-pass/allocator-default.rs index 1bca39de6635d..1dbdc5e4a5004 100644 --- a/src/test/run-pass/allocator-default.rs +++ b/src/test/run-pass/allocator-default.rs @@ -10,9 +10,9 @@ #![feature(alloc_jemalloc, alloc_system)] -#[cfg(not(target_env = "msvc"))] +#[cfg(not(any(target_env = "msvc", target_os = "bitrig")))] extern crate alloc_jemalloc; -#[cfg(target_env = "msvc")] +#[cfg(any(target_env = "msvc", target_os = "bitrig"))] extern crate alloc_system; fn main() { diff --git a/src/test/run-pass/allocator-jemalloc.rs b/src/test/run-pass/allocator-jemalloc.rs index 77fa64ec3db07..780c5e5884fae 100644 --- a/src/test/run-pass/allocator-jemalloc.rs +++ b/src/test/run-pass/allocator-jemalloc.rs @@ -10,6 +10,7 @@ // no-prefer-dynamic // ignore-msvc no jemalloc on msvc +// ignore-bitrig no jemalloc on bitrig either #![feature(alloc_jemalloc)]