Skip to content
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c6b0fcc
Add long diagnostics for E0329
AlisdairO Sep 2, 2015
865d6c3
Fix mistake in trait.md
xiaochuanyu Sep 3, 2015
3903ea9
Make `null()` and `null_mut()` const functions
petrochenkov Sep 2, 2015
6fcdead
Bash output fix to match real 'ruby embed.rb' call
thomas07vt Sep 3, 2015
06fb196
Use `null()`/`null_mut()` instead of `0 as *const T`/`0 as *mut T`
petrochenkov Sep 3, 2015
fcad49e
remove totally useless struct-field index
Sep 1, 2015
cde09e7
rewrite metadata indexing
Sep 2, 2015
b6a3978
clippy improvements to iterators
llogiq Sep 3, 2015
a520568
Elide lifetimes in libcore
Manishearth Sep 3, 2015
e1f8919
take mapped function by mutable reference
llogiq Sep 3, 2015
9e9c83b
Auto merge of #28176 - arielb1:fast-index, r=eddyb
bors Sep 3, 2015
e5e4744
Fixes #27886 -- bitrig does not use jemalloc (yet)
Sep 3, 2015
9e79fc2
Add an issue number to this FIXME
steveklabnik Sep 3, 2015
7732ad8
Move lints to HIR
Manishearth Sep 3, 2015
0762f58
Auto merge of #28192 - Manishearth:lint-hir, r=eddyb
bors Sep 3, 2015
2a40e46
Rollup merge of #28164 - AlisdairO:diagnostics329, r=Manishearth
Manishearth Sep 3, 2015
0c29243
Rollup merge of #28184 - xiaochuanyu:patch-1, r=alexcrichton
Manishearth Sep 3, 2015
67616f7
Rollup merge of #28186 - thomas07vt:thomas07vt-patch-trpl-rust-inside…
Manishearth Sep 3, 2015
9ea8f3e
Rollup merge of #28187 - petrochenkov:null, r=aturon
Manishearth Sep 3, 2015
cac4a1c
Rollup merge of #28188 - Manishearth:elide-core, r=alexcrichton
Manishearth Sep 3, 2015
3c4d6d6
Rollup merge of #28191 - llogiq:iter, r=Manishearth
Manishearth Sep 3, 2015
75ca401
Rollup merge of #28193 - dhuseby:fixing_bitrig_alloc_crate_tests, r=a…
Manishearth Sep 3, 2015
956c597
Rollup merge of #28194 - steveklabnik:add_fixme, r=alexcrichton
Manishearth Sep 3, 2015
94807b2
Rollup merge of #28195 - AlisdairO:diagnostics214, r=Manishearth
Manishearth Sep 3, 2015
e6e175b
Add ptr import (fixup #28187)
Manishearth Sep 3, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/doc/trpl/rust-inside-other-languages.md
Original file line number Diff line number Diff line change
@@ -217,6 +217,17 @@ And finally, we can try running it:

```bash
$ ruby embed.rb
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
Thread finished with count=5000000
done!
done!
$
```
2 changes: 1 addition & 1 deletion src/doc/trpl/traits.md
Original file line number Diff line number Diff line change
@@ -390,7 +390,7 @@ fn normal<T: ConvertTo<i64>>(x: &T) -> i64 {

// can be called with T == i64
fn inverse<T>() -> T
// this is using ConvertTo as if it were "ConvertFrom<i32>"
// this is using ConvertTo as if it were "ConvertTo<i64>"
where i32: ConvertTo<T> {
42.convert()
}
2 changes: 1 addition & 1 deletion src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
@@ -296,7 +296,7 @@ impl<K, V> Drop for Node<K, V> {
self.destroy();
}

self.keys = unsafe { Unique::new(0 as *mut K) };
self.keys = unsafe { Unique::new(ptr::null_mut()) };
}
}

2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
@@ -1135,7 +1135,7 @@ impl<T> ops::Deref for Vec<T> {
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)
}
}
14 changes: 7 additions & 7 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ impl<T:Copy> Cell<T> {
/// ```
#[inline]
#[unstable(feature = "as_unsafe_cell", issue = "27708")]
pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
&self.value
}
}
@@ -387,7 +387,7 @@ impl<T: ?Sized> RefCell<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
pub fn borrow(&self) -> Ref<T> {
match BorrowRef::new(&self.borrow) {
Some(b) => Ref {
_value: unsafe { &*self.value.get() },
@@ -433,7 +433,7 @@ impl<T: ?Sized> RefCell<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
pub fn borrow_mut(&self) -> RefMut<T> {
match BorrowRefMut::new(&self.borrow) {
Some(b) => RefMut {
_value: unsafe { &mut *self.value.get() },
@@ -450,7 +450,7 @@ impl<T: ?Sized> RefCell<T> {
/// 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<T> {
pub unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T> {
&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,15 +750,15 @@ 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
}
}

#[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
}
}
12 changes: 6 additions & 6 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
@@ -1513,7 +1513,7 @@ impl<A, B> Iterator for Chain<A, B> where
fn next(&mut self) -> Option<A::Item> {
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<A, B> DoubleEndedIterator for Chain<A, B> where
fn next_back(&mut self) -> Option<A::Item> {
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<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {

#[inline]
fn next(&mut self) -> Option<B> {
self.iter.next().map(|a| (self.f)(a))
self.iter.next().map(&mut self.f)
}

#[inline]
@@ -1698,7 +1698,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where
{
#[inline]
fn next_back(&mut self) -> Option<B> {
self.iter.next_back().map(|a| (self.f)(a))
self.iter.next_back().map(&mut self.f)
}
}

@@ -2210,7 +2210,7 @@ impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
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<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F> 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),
}
2 changes: 1 addition & 1 deletion src/libcore/nonzero.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ impl<T: Zeroable> Deref for NonZero<T> {
type Target = T;

#[inline]
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
let NonZero(ref inner) = *self;
inner
}
10 changes: 5 additions & 5 deletions src/libcore/num/flt2dec/bignum.rs
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions src/libcore/num/flt2dec/strategy/dragon.rs
Original file line number Diff line number Diff line change
@@ -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]);
8 changes: 4 additions & 4 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
@@ -965,7 +965,7 @@ pub trait Index<Idx: ?Sized> {

/// 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<Idx: ?Sized> {
pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
/// 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")]
8 changes: 4 additions & 4 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ impl<T> Option<T> {
/// ```
#[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<T> Option<T> {
/// ```
#[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<T> Option<T> {
#[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<T> Option<T> {
#[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 => {
10 changes: 5 additions & 5 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ pub use intrinsics::write_bytes;
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn null<T>() -> *const T { 0 as *const T }
pub const fn null<T>() -> *const T { 0 as *const T }

/// Creates a null mutable raw pointer.
///
@@ -65,7 +65,7 @@ pub fn null<T>() -> *const T { 0 as *const T }
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn null_mut<T>() -> *mut T { 0 as *mut T }
pub const fn null_mut<T>() -> *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<T: ?Sized> *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<T: ?Sized> *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<T:?Sized> Deref for Unique<T> {
type Target = *mut T;

#[inline]
fn deref<'a>(&'a self) -> &'a *mut T {
fn deref(&self) -> &*mut T {
unsafe { mem::transmute(&*self.pointer) }
}
}
74 changes: 37 additions & 37 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
@@ -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<Self::Item>;
fn split<P>(&self, pred: P) -> Split<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
fn splitn<'a, P>(&'a self, n: usize, pred: P) -> SplitN<'a, Self::Item, P>
fn splitn<P>(&self, n: usize, pred: P) -> SplitN<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
fn rsplitn<'a, P>(&'a self, n: usize, pred: P) -> RSplitN<'a, Self::Item, P>
fn rsplitn<P>(&self, n: usize, pred: P) -> RSplitN<Self::Item, P>
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<Self::Item>;
fn chunks(&self, size: usize) -> Chunks<Self::Item>;
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<F>(&self, f: F) -> Result<usize, usize> 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<Self::Item>;
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<P>(&mut self, pred: P) -> SplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
fn splitn_mut<P>(&mut self, n: usize, pred: P) -> SplitNMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
fn rsplitn_mut<P>(&mut self, n: usize, pred: P) -> RSplitNMut<Self::Item, P>
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<Self::Item>;
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<usize> where Self::Item: PartialEq;
@@ -163,7 +163,7 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn iter<'a>(&'a self) -> Iter<'a, T> {
fn iter(&self) -> Iter<T> {
unsafe {
let p = if mem::size_of::<T>() == 0 {
1 as *const _
@@ -182,7 +182,7 @@ impl<T> SliceExt for [T] {
}

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

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

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

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

#[inline]
fn rsplitn_mut<'a, P>(&'a mut self, n: usize, pred: P) -> RSplitNMut<'a, T, P> where
fn rsplitn_mut<P>(&mut self, n: usize, pred: P) -> RSplitNMut<T, P> where
P: FnMut(&T) -> bool,
{
RSplitNMut {
@@ -1410,15 +1410,15 @@ 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<A>(s: &A) -> &[A] {
unsafe {
from_raw_parts(s, 1)
}
}

/// 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<A>(s: &mut A) -> &mut [A] {
unsafe {
from_raw_parts_mut(s, 1)
}
22 changes: 11 additions & 11 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
@@ -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<usize>;
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
where P::Searcher: ReverseSearcher<'a>;
fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
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;
6 changes: 3 additions & 3 deletions src/liblog/lib.rs
Original file line number Diff line number Diff line change
@@ -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<directive::LogDirective> =
0 as *mut Vec<directive::LogDirective>;
static mut DIRECTIVES: *mut Vec<directive::LogDirective> = 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;
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,6 @@
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(scoped_tls)]
#![feature(slice_bytes)]
#![feature(slice_splits)]
#![feature(slice_patterns)]
#![feature(staged_api)]
91 changes: 44 additions & 47 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
@@ -37,12 +37,14 @@ use std::cell::RefCell;
use std::cmp;
use std::mem;
use syntax::ast_util::IdVisitingOperation;
use syntax::attr::AttrMetaMethods;
use syntax::attr;
use rustc_front::attr::{self, AttrMetaMethods};
use rustc_front::util;
use syntax::codemap::Span;
use syntax::visit::{Visitor, FnKind};
use syntax::parse::token::InternedString;
use syntax::{ast, ast_util, visit};
use syntax::ast;
use rustc_front::hir;
use rustc_front::visit::{self, Visitor, FnKind};
use syntax::visit::Visitor as SyntaxVisitor;
use syntax::diagnostic;

/// Information about the registered lints.
@@ -252,7 +254,7 @@ pub struct Context<'a, 'tcx: 'a> {
pub tcx: &'a ty::ctxt<'tcx>,

/// The crate being checked.
pub krate: &'a ast::Crate,
pub krate: &'a hir::Crate,

/// Items exported from the crate being checked.
pub exported_items: &'a ExportedItems,
@@ -284,7 +286,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
/// Parse the lint attributes into a vector, with `Err`s for malformed lint
/// attributes. Writing this as an iterator is an enormous mess.
// See also the hir version just below.
pub fn gather_attrs(attrs: &[ast::Attribute])
pub fn gather_attrs(attrs: &[hir::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
for attr in attrs {
@@ -297,7 +299,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])

let meta = &attr.node.value;
let metas = match meta.node {
ast::MetaList(_, ref metas) => metas,
hir::MetaList(_, ref metas) => metas,
_ => {
out.push(Err(meta.span));
continue;
@@ -306,7 +308,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])

for meta in metas {
out.push(match meta.node {
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
hir::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
_ => Err(meta.span),
});
}
@@ -398,7 +400,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,

impl<'a, 'tcx> Context<'a, 'tcx> {
fn new(tcx: &'a ty::ctxt<'tcx>,
krate: &'a ast::Crate,
krate: &'a hir::Crate,
exported_items: &'a ExportedItems) -> Context<'a, 'tcx> {
// We want to own the lint store, so move it out of the session.
let lint_store = mem::replace(&mut *tcx.sess.lint_store.borrow_mut(),
@@ -452,7 +454,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
/// current lint context, call the provided function, then reset the
/// lints in effect to their previous state.
fn with_lint_attrs<F>(&mut self,
attrs: &[ast::Attribute],
attrs: &[hir::Attribute],
f: F) where
F: FnOnce(&mut Context),
{
@@ -519,9 +521,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
}

fn visit_ids<F>(&mut self, f: F) where
F: FnOnce(&mut ast_util::IdVisitor<Context>)
F: FnOnce(&mut util::IdVisitor<Context>)
{
let mut v = ast_util::IdVisitor {
let mut v = util::IdVisitor {
operation: self,
pass_through_items: false,
visited_outermost: false,
@@ -531,68 +533,68 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
}

impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
fn visit_item(&mut self, it: &ast::Item) {
fn visit_item(&mut self, it: &hir::Item) {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_item, it);
cx.visit_ids(|v| v.visit_item(it));
visit::walk_item(cx, it);
})
}

fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
fn visit_foreign_item(&mut self, it: &hir::ForeignItem) {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_foreign_item, it);
visit::walk_foreign_item(cx, it);
})
}

fn visit_pat(&mut self, p: &ast::Pat) {
fn visit_pat(&mut self, p: &hir::Pat) {
run_lints!(self, check_pat, p);
visit::walk_pat(self, p);
}

fn visit_expr(&mut self, e: &ast::Expr) {
fn visit_expr(&mut self, e: &hir::Expr) {
run_lints!(self, check_expr, e);
visit::walk_expr(self, e);
}

fn visit_stmt(&mut self, s: &ast::Stmt) {
fn visit_stmt(&mut self, s: &hir::Stmt) {
run_lints!(self, check_stmt, s);
visit::walk_stmt(self, s);
}

fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v ast::FnDecl,
body: &'v ast::Block, span: Span, id: ast::NodeId) {
fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v hir::FnDecl,
body: &'v hir::Block, span: Span, id: ast::NodeId) {
run_lints!(self, check_fn, fk, decl, body, span, id);
visit::walk_fn(self, fk, decl, body, span);
}

fn visit_struct_def(&mut self,
s: &ast::StructDef,
s: &hir::StructDef,
ident: ast::Ident,
g: &ast::Generics,
g: &hir::Generics,
id: ast::NodeId) {
run_lints!(self, check_struct_def, s, ident, g, id);
visit::walk_struct_def(self, s);
run_lints!(self, check_struct_def_post, s, ident, g, id);
}

fn visit_struct_field(&mut self, s: &ast::StructField) {
fn visit_struct_field(&mut self, s: &hir::StructField) {
self.with_lint_attrs(&s.node.attrs, |cx| {
run_lints!(cx, check_struct_field, s);
visit::walk_struct_field(cx, s);
})
}

fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics) {
fn visit_variant(&mut self, v: &hir::Variant, g: &hir::Generics) {
self.with_lint_attrs(&v.node.attrs, |cx| {
run_lints!(cx, check_variant, v, g);
visit::walk_variant(cx, v, g);
run_lints!(cx, check_variant_post, v, g);
})
}

fn visit_ty(&mut self, t: &ast::Ty) {
fn visit_ty(&mut self, t: &hir::Ty) {
run_lints!(self, check_ty, t);
visit::walk_ty(self, t);
}
@@ -601,84 +603,79 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
run_lints!(self, check_ident, sp, id);
}

fn visit_mod(&mut self, m: &ast::Mod, s: Span, n: ast::NodeId) {
fn visit_mod(&mut self, m: &hir::Mod, s: Span, n: ast::NodeId) {
run_lints!(self, check_mod, m, s, n);
visit::walk_mod(self, m);
}

fn visit_local(&mut self, l: &ast::Local) {
fn visit_local(&mut self, l: &hir::Local) {
run_lints!(self, check_local, l);
visit::walk_local(self, l);
}

fn visit_block(&mut self, b: &ast::Block) {
fn visit_block(&mut self, b: &hir::Block) {
run_lints!(self, check_block, b);
visit::walk_block(self, b);
}

fn visit_arm(&mut self, a: &ast::Arm) {
fn visit_arm(&mut self, a: &hir::Arm) {
run_lints!(self, check_arm, a);
visit::walk_arm(self, a);
}

fn visit_decl(&mut self, d: &ast::Decl) {
fn visit_decl(&mut self, d: &hir::Decl) {
run_lints!(self, check_decl, d);
visit::walk_decl(self, d);
}

fn visit_expr_post(&mut self, e: &ast::Expr) {
fn visit_expr_post(&mut self, e: &hir::Expr) {
run_lints!(self, check_expr_post, e);
}

fn visit_generics(&mut self, g: &ast::Generics) {
fn visit_generics(&mut self, g: &hir::Generics) {
run_lints!(self, check_generics, g);
visit::walk_generics(self, g);
}

fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
self.with_lint_attrs(&trait_item.attrs, |cx| {
run_lints!(cx, check_trait_item, trait_item);
cx.visit_ids(|v| v.visit_trait_item(trait_item));
visit::walk_trait_item(cx, trait_item);
});
}

fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
self.with_lint_attrs(&impl_item.attrs, |cx| {
run_lints!(cx, check_impl_item, impl_item);
cx.visit_ids(|v| v.visit_impl_item(impl_item));
visit::walk_impl_item(cx, impl_item);
});
}

fn visit_opt_lifetime_ref(&mut self, sp: Span, lt: &Option<ast::Lifetime>) {
fn visit_opt_lifetime_ref(&mut self, sp: Span, lt: &Option<hir::Lifetime>) {
run_lints!(self, check_opt_lifetime_ref, sp, lt);
}

fn visit_lifetime_ref(&mut self, lt: &ast::Lifetime) {
fn visit_lifetime_ref(&mut self, lt: &hir::Lifetime) {
run_lints!(self, check_lifetime_ref, lt);
}

fn visit_lifetime_def(&mut self, lt: &ast::LifetimeDef) {
fn visit_lifetime_def(&mut self, lt: &hir::LifetimeDef) {
run_lints!(self, check_lifetime_def, lt);
}

fn visit_explicit_self(&mut self, es: &ast::ExplicitSelf) {
fn visit_explicit_self(&mut self, es: &hir::ExplicitSelf) {
run_lints!(self, check_explicit_self, es);
visit::walk_explicit_self(self, es);
}

fn visit_mac(&mut self, mac: &ast::Mac) {
run_lints!(self, check_mac, mac);
visit::walk_mac(self, mac);
}

fn visit_path(&mut self, p: &ast::Path, id: ast::NodeId) {
fn visit_path(&mut self, p: &hir::Path, id: ast::NodeId) {
run_lints!(self, check_path, p, id);
visit::walk_path(self, p);
}

fn visit_attribute(&mut self, attr: &ast::Attribute) {
fn visit_attribute(&mut self, attr: &hir::Attribute) {
run_lints!(self, check_attribute, attr);
}
}
@@ -709,9 +706,9 @@ impl LintPass for GatherNodeLevels {
lint_array!()
}

fn check_item(&mut self, cx: &Context, it: &ast::Item) {
fn check_item(&mut self, cx: &Context, it: &hir::Item) {
match it.node {
ast::ItemEnum(..) => {
hir::ItemEnum(..) => {
let lint_id = LintId::of(builtin::VARIANT_SIZE_DIFFERENCES);
let lvlsrc = cx.lints.get_level_source(lint_id);
match lvlsrc {
@@ -731,7 +728,7 @@ impl LintPass for GatherNodeLevels {
///
/// Consumes the `lint_store` field of the `Session`.
pub fn check_crate(tcx: &ty::ctxt,
krate: &ast::Crate,
krate: &hir::Crate,
exported_items: &ExportedItems) {

let mut cx = Context::new(tcx, krate, exported_items);
63 changes: 32 additions & 31 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -34,8 +34,9 @@ pub use self::LintSource::*;
use std::hash;
use std::ascii::AsciiExt;
use syntax::codemap::Span;
use syntax::visit::FnKind;
use rustc_front::visit::FnKind;
use syntax::ast;
use rustc_front::hir;

pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_attrs,
gather_attrs_from_hir, GatherNodeLevels};
@@ -125,46 +126,46 @@ pub trait LintPass {
/// `Lint`, make it a private `static` item in its own module.
fn get_lints(&self) -> LintArray;

fn check_crate(&mut self, _: &Context, _: &ast::Crate) { }
fn check_crate(&mut self, _: &Context, _: &hir::Crate) { }
fn check_ident(&mut self, _: &Context, _: Span, _: ast::Ident) { }
fn check_mod(&mut self, _: &Context, _: &ast::Mod, _: Span, _: ast::NodeId) { }
fn check_foreign_item(&mut self, _: &Context, _: &ast::ForeignItem) { }
fn check_item(&mut self, _: &Context, _: &ast::Item) { }
fn check_local(&mut self, _: &Context, _: &ast::Local) { }
fn check_block(&mut self, _: &Context, _: &ast::Block) { }
fn check_stmt(&mut self, _: &Context, _: &ast::Stmt) { }
fn check_arm(&mut self, _: &Context, _: &ast::Arm) { }
fn check_pat(&mut self, _: &Context, _: &ast::Pat) { }
fn check_decl(&mut self, _: &Context, _: &ast::Decl) { }
fn check_expr(&mut self, _: &Context, _: &ast::Expr) { }
fn check_expr_post(&mut self, _: &Context, _: &ast::Expr) { }
fn check_ty(&mut self, _: &Context, _: &ast::Ty) { }
fn check_generics(&mut self, _: &Context, _: &ast::Generics) { }
fn check_mod(&mut self, _: &Context, _: &hir::Mod, _: Span, _: ast::NodeId) { }
fn check_foreign_item(&mut self, _: &Context, _: &hir::ForeignItem) { }
fn check_item(&mut self, _: &Context, _: &hir::Item) { }
fn check_local(&mut self, _: &Context, _: &hir::Local) { }
fn check_block(&mut self, _: &Context, _: &hir::Block) { }
fn check_stmt(&mut self, _: &Context, _: &hir::Stmt) { }
fn check_arm(&mut self, _: &Context, _: &hir::Arm) { }
fn check_pat(&mut self, _: &Context, _: &hir::Pat) { }
fn check_decl(&mut self, _: &Context, _: &hir::Decl) { }
fn check_expr(&mut self, _: &Context, _: &hir::Expr) { }
fn check_expr_post(&mut self, _: &Context, _: &hir::Expr) { }
fn check_ty(&mut self, _: &Context, _: &hir::Ty) { }
fn check_generics(&mut self, _: &Context, _: &hir::Generics) { }
fn check_fn(&mut self, _: &Context,
_: FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId) { }
fn check_trait_item(&mut self, _: &Context, _: &ast::TraitItem) { }
fn check_impl_item(&mut self, _: &Context, _: &ast::ImplItem) { }
_: FnKind, _: &hir::FnDecl, _: &hir::Block, _: Span, _: ast::NodeId) { }
fn check_trait_item(&mut self, _: &Context, _: &hir::TraitItem) { }
fn check_impl_item(&mut self, _: &Context, _: &hir::ImplItem) { }
fn check_struct_def(&mut self, _: &Context,
_: &ast::StructDef, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
_: &hir::StructDef, _: ast::Ident, _: &hir::Generics, _: ast::NodeId) { }
fn check_struct_def_post(&mut self, _: &Context,
_: &ast::StructDef, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
fn check_struct_field(&mut self, _: &Context, _: &ast::StructField) { }
fn check_variant(&mut self, _: &Context, _: &ast::Variant, _: &ast::Generics) { }
fn check_variant_post(&mut self, _: &Context, _: &ast::Variant, _: &ast::Generics) { }
fn check_opt_lifetime_ref(&mut self, _: &Context, _: Span, _: &Option<ast::Lifetime>) { }
fn check_lifetime_ref(&mut self, _: &Context, _: &ast::Lifetime) { }
fn check_lifetime_def(&mut self, _: &Context, _: &ast::LifetimeDef) { }
fn check_explicit_self(&mut self, _: &Context, _: &ast::ExplicitSelf) { }
_: &hir::StructDef, _: ast::Ident, _: &hir::Generics, _: ast::NodeId) { }
fn check_struct_field(&mut self, _: &Context, _: &hir::StructField) { }
fn check_variant(&mut self, _: &Context, _: &hir::Variant, _: &hir::Generics) { }
fn check_variant_post(&mut self, _: &Context, _: &hir::Variant, _: &hir::Generics) { }
fn check_opt_lifetime_ref(&mut self, _: &Context, _: Span, _: &Option<hir::Lifetime>) { }
fn check_lifetime_ref(&mut self, _: &Context, _: &hir::Lifetime) { }
fn check_lifetime_def(&mut self, _: &Context, _: &hir::LifetimeDef) { }
fn check_explicit_self(&mut self, _: &Context, _: &hir::ExplicitSelf) { }
fn check_mac(&mut self, _: &Context, _: &ast::Mac) { }
fn check_path(&mut self, _: &Context, _: &ast::Path, _: ast::NodeId) { }
fn check_attribute(&mut self, _: &Context, _: &ast::Attribute) { }
fn check_path(&mut self, _: &Context, _: &hir::Path, _: ast::NodeId) { }
fn check_attribute(&mut self, _: &Context, _: &hir::Attribute) { }

/// Called when entering a syntax node that can have lint attributes such
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
fn enter_lint_attrs(&mut self, _: &Context, _: &[ast::Attribute]) { }
fn enter_lint_attrs(&mut self, _: &Context, _: &[hir::Attribute]) { }

/// Counterpart to `enter_lint_attrs`.
fn exit_lint_attrs(&mut self, _: &Context, _: &[ast::Attribute]) { }
fn exit_lint_attrs(&mut self, _: &Context, _: &[hir::Attribute]) { }
}

/// A lint pass boxed up as a trait object.
8 changes: 1 addition & 7 deletions src/librustc/metadata/common.rs
Original file line number Diff line number Diff line change
@@ -45,13 +45,7 @@ pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;

pub const tag_index: usize = 0x2a;

pub const tag_index_buckets: usize = 0x2b;

pub const tag_index_buckets_bucket: usize = 0x2c;

pub const tag_index_buckets_bucket_elt: usize = 0x2d;

pub const tag_index_table: usize = 0x2e;
// GAP 0x2b, 0x2c, 0x2d, 0x2e

pub const tag_meta_item_name_value: usize = 0x2f;

3 changes: 2 additions & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
@@ -304,6 +304,7 @@ impl<'a> CrateReader<'a> {
let cmeta = Rc::new(cstore::crate_metadata {
name: name.to_string(),
local_path: RefCell::new(SmallVector::zero()),
index: decoder::load_index(metadata.as_slice()),
data: metadata,
cnum_map: RefCell::new(cnum_map),
cnum: cnum,
@@ -521,7 +522,7 @@ impl<'a> CrateReader<'a> {
}

let registrar = decoder::get_plugin_registrar_fn(ekrate.metadata.as_slice())
.map(|id| decoder::get_symbol(ekrate.metadata.as_slice(), id));
.map(|id| decoder::get_symbol_from_buf(ekrate.metadata.as_slice(), id));

match (ekrate.dylib.as_ref(), registrar) {
(Some(dylib), Some(reg)) => Some((dylib.to_path_buf(), reg)),
36 changes: 3 additions & 33 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
@@ -11,23 +11,18 @@
// Searching for information from the cstore

use front::map as ast_map;
use metadata::common::*;
use metadata::cstore;
use metadata::decoder;
use metadata::inline::InlinedItem;
use middle::def_id::DefId;
use middle::lang_items;
use middle::ty;
use util::nodemap::FnvHashMap;

use rbml;
use rbml::reader;
use std::rc::Rc;
use syntax::ast;
use rustc_front::attr;
use rustc_front::hir;
use syntax::diagnostic::expect;

use std::collections::hash_map::HashMap;

#[derive(Copy, Clone)]
pub struct MethodInfo {
@@ -38,7 +33,7 @@ pub struct MethodInfo {

pub fn get_symbol(cstore: &cstore::CStore, def: DefId) -> String {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_symbol(cdata.data(), def.node)
decoder::get_symbol(&cdata, def.node)
}

/// Iterates over all the language items in the given crate.
@@ -201,7 +196,7 @@ pub fn get_struct_field_names(cstore: &cstore::CStore, def: DefId) -> Vec<ast::N
decoder::get_struct_field_names(&cstore.intr, &*cdata, def.node)
}

pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> HashMap<ast::NodeId,
pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> FnvHashMap<ast::NodeId,
Vec<hir::Attribute>> {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_struct_field_attrs(&*cdata)
@@ -243,31 +238,6 @@ pub fn get_super_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
decoder::get_super_predicates(&*cdata, def.node, tcx)
}

pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: DefId,
def: DefId) -> ty::TypeScheme<'tcx> {
let cstore = &tcx.sess.cstore;
let cdata = cstore.get_crate_data(class_id.krate);
let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
let class_doc = expect(tcx.sess.diagnostic(),
decoder::maybe_find_item(class_id.node, all_items),
|| {
(format!("get_field_type: class ID {:?} not found",
class_id)).to_string()
});
let the_field = expect(tcx.sess.diagnostic(),
decoder::maybe_find_item(def.node, class_doc),
|| {
(format!("get_field_type: in class {:?}, field ID {:?} not found",
class_id,
def)).to_string()
});
let ty = decoder::item_type(def, the_field, tcx, &*cdata);
ty::TypeScheme {
generics: ty::Generics::empty(),
ty: ty,
}
}

pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
def: DefId)
-> Option<hir::ImplPolarity>
3 changes: 2 additions & 1 deletion src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ pub use self::LinkagePreference::*;
pub use self::NativeLibraryKind::*;

use back::svh::Svh;
use metadata::{creader, decoder, loader};
use metadata::{creader, decoder, index, loader};
use session::search_paths::PathKind;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};

@@ -65,6 +65,7 @@ pub struct crate_metadata {
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
pub span: codemap::Span,
pub staged_api: bool,
pub index: index::Index,

/// Flag if this crate is required by an rlib version of this crate, or in
/// other words whether it was explicitly linked to. An example of a crate
187 changes: 73 additions & 114 deletions src/librustc/metadata/decoder.rs

Large diffs are not rendered by default.

193 changes: 63 additions & 130 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ use metadata::common::*;
use metadata::cstore;
use metadata::decoder;
use metadata::tyencode;
use metadata::index::{self, IndexEntry};
use metadata::inline::InlinedItemRef;
use middle::def;
use middle::def_id::{DefId, LOCAL_CRATE};
@@ -29,7 +30,6 @@ use util::nodemap::{FnvHashMap, NodeMap, NodeSet};

use serialize::Encodable;
use std::cell::RefCell;
use std::hash::{Hash, Hasher, SipHasher};
use std::io::prelude::*;
use std::io::{Cursor, SeekFrom};
use std::rc::Rc;
@@ -86,12 +86,6 @@ fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
rbml_w.wr_tagged_u64(tag_def_id, def_to_u64(id));
}

#[derive(Clone)]
struct entry<T> {
val: T,
pos: u64
}

fn encode_trait_ref<'a, 'tcx>(rbml_w: &mut Encoder,
ecx: &EncodeContext<'a, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
@@ -279,16 +273,25 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
rbml_w: &mut Encoder,
id: NodeId,
vis: ast::Visibility,
index: &mut Vec<entry<i64>>) {
index: &mut Vec<IndexEntry>) {
debug!("encode_enum_variant_info(id={})", id);

let mut disr_val = 0;
let def = ecx.tcx.lookup_adt_def(DefId::local(id));
for variant in &def.variants {
let vid = variant.did;
assert!(vid.is_local());
index.push(entry {
val: vid.node as i64,

if let ty::VariantKind::Dict = variant.kind() {
// tuple-like enum variant fields aren't really items so
// don't try to encode them.
for field in &variant.fields {
encode_field(ecx, rbml_w, field, index);
}
}

index.push(IndexEntry {
node: vid.node,
pos: rbml_w.mark_stable_position(),
});
rbml_w.start_tag(tag_items_data_item);
@@ -308,11 +311,6 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
let stab = stability::lookup(ecx.tcx, vid);
encode_stability(rbml_w, stab);

if let ty::VariantKind::Dict = variant.kind() {
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
encode_index(rbml_w, idx, write_i64);
}

encode_struct_fields(rbml_w, variant, vid);

let specified_disr_val = variant.disr_val;
@@ -618,51 +616,39 @@ fn encode_provided_source(rbml_w: &mut Encoder,
}
}

/* Returns an index of items in this class */
fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
rbml_w: &mut Encoder,
variant: ty::VariantDef<'tcx>,
global_index: &mut Vec<entry<i64>>)
-> Vec<entry<i64>> {
/* Each class has its own index, since different classes
may have fields with the same name */
let mut index = Vec::new();
/* We encode both private and public fields -- need to include
private fields to get the offsets right */
for field in &variant.fields {
let nm = field.name;
let id = field.did.node;

let pos = rbml_w.mark_stable_position();
index.push(entry {val: id as i64, pos: pos});
global_index.push(entry {
val: id as i64,
pos: pos,
});
rbml_w.start_tag(tag_items_data_item);
debug!("encode_info_for_struct: doing {} {}",
nm, id);
encode_struct_field_family(rbml_w, field.vis);
encode_name(rbml_w, nm);
encode_bounds_and_type_for_item(rbml_w, ecx, id);
encode_def_id(rbml_w, DefId::local(id));

let stab = stability::lookup(ecx.tcx, field.did);
encode_stability(rbml_w, stab);
fn encode_field<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
rbml_w: &mut Encoder,
field: ty::FieldDef<'tcx>,
global_index: &mut Vec<IndexEntry>) {
let nm = field.name;
let id = field.did.node;

rbml_w.end_tag();
}
index
let pos = rbml_w.mark_stable_position();
global_index.push(IndexEntry {
node: id,
pos: pos,
});
rbml_w.start_tag(tag_items_data_item);
debug!("encode_field: encoding {} {}", nm, id);
encode_struct_field_family(rbml_w, field.vis);
encode_name(rbml_w, nm);
encode_bounds_and_type_for_item(rbml_w, ecx, id);
encode_def_id(rbml_w, DefId::local(id));

let stab = stability::lookup(ecx.tcx, field.did);
encode_stability(rbml_w, stab);

rbml_w.end_tag();
}

fn encode_info_for_struct_ctor(ecx: &EncodeContext,
rbml_w: &mut Encoder,
name: Name,
ctor_id: NodeId,
index: &mut Vec<entry<i64>>,
index: &mut Vec<IndexEntry>,
struct_id: NodeId) {
index.push(entry {
val: ctor_id as i64,
index.push(IndexEntry {
node: ctor_id,
pos: rbml_w.mark_stable_position(),
});

@@ -997,15 +983,15 @@ fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<&attr::Stability>) {
fn encode_info_for_item(ecx: &EncodeContext,
rbml_w: &mut Encoder,
item: &ast::Item,
index: &mut Vec<entry<i64>>,
index: &mut Vec<IndexEntry>,
path: PathElems,
vis: ast::Visibility) {
let tcx = ecx.tcx;

fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
index: &mut Vec<entry<i64>>) {
index.push(entry {
val: item.id as i64,
index: &mut Vec<IndexEntry>) {
index.push(IndexEntry {
node: item.id,
pos: rbml_w.mark_stable_position(),
});
}
@@ -1146,11 +1132,9 @@ fn encode_info_for_item(ecx: &EncodeContext,
let def = ecx.tcx.lookup_adt_def(def_id);
let variant = def.struct_variant();

/* First, encode the fields
These come first because we need to write them to make
the index, and the index needs to be in the item for the
class itself */
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
for field in &variant.fields {
encode_field(ecx, rbml_w, field, index);
}

/* Index the class*/
add_to_index(item, rbml_w, index);
@@ -1179,8 +1163,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
// Encode inherent implementations for this structure.
encode_inherent_implementations(ecx, rbml_w, def_id);

/* Each class has its own index -- encode it */
encode_index(rbml_w, idx, write_i64);
rbml_w.end_tag();

// If this is a tuple-like struct, encode the type of the constructor.
@@ -1273,8 +1255,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
None
};

index.push(entry {
val: trait_item_def_id.def_id().node as i64,
index.push(IndexEntry {
node: trait_item_def_id.def_id().node,
pos: rbml_w.mark_stable_position(),
});

@@ -1364,8 +1346,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
for (i, &item_def_id) in r.iter().enumerate() {
assert_eq!(item_def_id.def_id().krate, LOCAL_CRATE);

index.push(entry {
val: item_def_id.def_id().node as i64,
index.push(IndexEntry {
node: item_def_id.def_id().node,
pos: rbml_w.mark_stable_position(),
});

@@ -1486,11 +1468,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
fn encode_info_for_foreign_item(ecx: &EncodeContext,
rbml_w: &mut Encoder,
nitem: &ast::ForeignItem,
index: &mut Vec<entry<i64>>,
index: &mut Vec<IndexEntry>,
path: PathElems,
abi: abi::Abi) {
index.push(entry {
val: nitem.id as i64,
index.push(IndexEntry {
node: nitem.id,
pos: rbml_w.mark_stable_position(),
});

@@ -1534,7 +1516,7 @@ fn my_visit_expr(_e: &ast::Expr) { }
fn my_visit_item(i: &ast::Item,
rbml_w: &mut Encoder,
ecx: &EncodeContext,
index: &mut Vec<entry<i64>>) {
index: &mut Vec<IndexEntry>) {
ecx.tcx.map.with_path(i.id, |path| {
encode_info_for_item(ecx, rbml_w, i, index, path, i.vis);
});
@@ -1543,7 +1525,7 @@ fn my_visit_item(i: &ast::Item,
fn my_visit_foreign_item(ni: &ast::ForeignItem,
rbml_w: &mut Encoder,
ecx: &EncodeContext,
index: &mut Vec<entry<i64>>) {
index: &mut Vec<IndexEntry>) {
debug!("writing foreign item {}::{}",
ecx.tcx.map.path_to_string(ni.id),
ni.ident);
@@ -1559,7 +1541,7 @@ fn my_visit_foreign_item(ni: &ast::ForeignItem,
struct EncodeVisitor<'a, 'b:'a, 'c:'a, 'tcx:'c> {
rbml_w_for_visit_item: &'a mut Encoder<'b>,
ecx: &'a EncodeContext<'c,'tcx>,
index: &'a mut Vec<entry<i64>>,
index: &'a mut Vec<IndexEntry>,
}

impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for EncodeVisitor<'a, 'b, 'c, 'tcx> {
@@ -1586,11 +1568,11 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for EncodeVisitor<'a, 'b, 'c, 'tcx> {
fn encode_info_for_items(ecx: &EncodeContext,
rbml_w: &mut Encoder,
krate: &ast::Crate)
-> Vec<entry<i64>> {
-> Vec<IndexEntry> {
let mut index = Vec::new();
rbml_w.start_tag(tag_items_data);
index.push(entry {
val: CRATE_NODE_ID as i64,
index.push(IndexEntry {
node: CRATE_NODE_ID,
pos: rbml_w.mark_stable_position(),
});
encode_info_for_mod(ecx,
@@ -1613,62 +1595,13 @@ fn encode_info_for_items(ecx: &EncodeContext,
}


// Path and definition ID indexing

fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn: F) where
F: FnMut(&mut Cursor<Vec<u8>>, &T),
T: Hash,
{
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
for elt in index {
let mut s = SipHasher::new();
elt.val.hash(&mut s);
let h = s.finish() as usize;
(&mut buckets[h % 256]).push(elt);
}

fn encode_index(rbml_w: &mut Encoder, index: Vec<IndexEntry>)
{
rbml_w.start_tag(tag_index);
let mut bucket_locs = Vec::new();
rbml_w.start_tag(tag_index_buckets);
for bucket in &buckets {
bucket_locs.push(rbml_w.mark_stable_position());
rbml_w.start_tag(tag_index_buckets_bucket);
for elt in bucket {
rbml_w.start_tag(tag_index_buckets_bucket_elt);
assert!(elt.pos < 0xffff_ffff);
{
let wr: &mut Cursor<Vec<u8>> = rbml_w.writer;
write_be_u32(wr, elt.pos as u32);
}
write_fn(rbml_w.writer, &elt.val);
rbml_w.end_tag();
}
rbml_w.end_tag();
}
rbml_w.end_tag();
rbml_w.start_tag(tag_index_table);
for pos in &bucket_locs {
assert!(*pos < 0xffff_ffff);
let wr: &mut Cursor<Vec<u8>> = rbml_w.writer;
write_be_u32(wr, *pos as u32);
}
index::write_index(index, rbml_w.writer);
rbml_w.end_tag();
rbml_w.end_tag();
}

fn write_i64(writer: &mut Cursor<Vec<u8>>, &n: &i64) {
let wr: &mut Cursor<Vec<u8>> = writer;
assert!(n < 0x7fff_ffff);
write_be_u32(wr, n as u32);
}

fn write_be_u32(w: &mut Write, u: u32) {
w.write_all(&[
(u >> 24) as u8,
(u >> 16) as u8,
(u >> 8) as u8,
(u >> 0) as u8,
]);
}

fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
@@ -2172,11 +2105,11 @@ fn encode_metadata_inner(wr: &mut Cursor<Vec<u8>>,
i = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap();
let items_index = encode_info_for_items(&ecx, &mut rbml_w, krate);
stats.item_bytes = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap() - i;
rbml_w.end_tag();

i = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap();
encode_index(&mut rbml_w, items_index, write_i64);
encode_index(&mut rbml_w, items_index);
stats.index_bytes = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap() - i;
rbml_w.end_tag();

encode_struct_field_attrs(&mut rbml_w, krate);

208 changes: 208 additions & 0 deletions src/librustc/metadata/index.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::io::{Cursor, Write};
use std::slice;
use std::u32;
use syntax::ast::NodeId;

#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct IndexEntry {
pub node: NodeId,
pub pos: u64
}

#[derive(Debug)]
pub struct IndexArrayEntry {
bits: u32,
first_pos: u32
}

impl IndexArrayEntry {
fn encode_to<W: Write>(&self, b: &mut W) {
write_be_u32(b, self.bits);
write_be_u32(b, self.first_pos);
}

fn decode_from(b: &[u32]) -> Self {
IndexArrayEntry {
bits: b[0].to_be(),
first_pos: b[1].to_be()
}
}
}

/// The Item Index
///
/// This index maps the NodeId of each item to its location in the
/// metadata.
///
/// The index is a sparse bit-vector consisting of a index-array
/// and a position-array. Each entry in the index-array handles 32 nodes.
/// The first word is a bit-array consisting of the nodes that hold items,
/// the second is the index of the first of the items in the position-array.
/// If there is a large set of non-item trailing nodes, they can be omitted
/// from the index-array.
///
/// The index is serialized as an array of big-endian 32-bit words.
/// The first word is the number of items in the position-array.
/// Then, for each item, its position in the metadata follows.
/// After that the index-array is stored.
///
/// struct index {
/// u32 item_count;
/// u32 items[self.item_count];
/// struct { u32 bits; u32 offset; } positions[..];
/// }
pub struct Index {
position_start: usize,
index_start: usize,
index_end: usize,
}

pub fn write_index(mut entries: Vec<IndexEntry>, buf: &mut Cursor<Vec<u8>>) {
assert!(entries.len() < u32::MAX as usize);
entries.sort();

let mut last_entry = IndexArrayEntry { bits: 0, first_pos: 0 };

write_be_u32(buf, entries.len() as u32);
for &IndexEntry { pos, .. } in &entries {
assert!(pos < u32::MAX as u64);
write_be_u32(buf, pos as u32);
}

let mut pos_in_index_array = 0;
for (i, &IndexEntry { node, .. }) in entries.iter().enumerate() {
let (x, s) = (node / 32 as u32, node % 32 as u32);
while x > pos_in_index_array {
pos_in_index_array += 1;
last_entry.encode_to(buf);
last_entry = IndexArrayEntry { bits: 0, first_pos: i as u32 };
}
last_entry.bits |= 1<<s;
}
last_entry.encode_to(buf);

info!("write_index: {} items, {} array entries",
entries.len(), pos_in_index_array);
}

impl Index {
fn lookup_index(&self, index: &[u32], i: u32) -> Option<IndexArrayEntry> {
let ix = (i as usize)*2;
if ix >= index.len() {
None
} else {
Some(IndexArrayEntry::decode_from(&index[ix..ix+2]))
}
}

fn item_from_pos(&self, positions: &[u32], pos: u32) -> u32 {
positions[pos as usize].to_be()
}

#[inline(never)]
pub fn lookup_item(&self, buf: &[u8], node: NodeId) -> Option<u32> {
let index = bytes_to_words(&buf[self.index_start..self.index_end]);
let positions = bytes_to_words(&buf[self.position_start..self.index_start]);
let (x, s) = (node / 32 as u32, node % 32 as u32);
let result = match self.lookup_index(index, x) {
Some(IndexArrayEntry { bits, first_pos }) => {
let bit = 1<<s;
if bits & bit == 0 {
None
} else {
let prev_nodes_for_entry = (bits&(bit-1)).count_ones();
Some(self.item_from_pos(
positions,
first_pos+prev_nodes_for_entry))
}
}
None => None // trailing zero
};
debug!("lookup_item({:?}) = {:?}", node, result);
result
}

pub fn from_buf(buf: &[u8], start: usize, end: usize) -> Self {
let buf = bytes_to_words(&buf[start..end]);
let position_count = buf[0].to_be() as usize;
let position_len = position_count*4;
info!("loaded index - position: {}-{}-{}", start, start+position_len, end);
debug!("index contents are {:?}",
buf.iter().map(|b| format!("{:08x}", b)).collect::<Vec<_>>().concat());
assert!(end-4-start >= position_len);
assert_eq!((end-4-start-position_len)%8, 0);
Index {
position_start: start+4,
index_start: start+position_len+4,
index_end: end
}
}
}

fn write_be_u32<W: Write>(w: &mut W, u: u32) {
let _ = w.write_all(&[
(u >> 24) as u8,
(u >> 16) as u8,
(u >> 8) as u8,
(u >> 0) as u8,
]);
}

fn bytes_to_words(b: &[u8]) -> &[u32] {
assert!(b.len() % 4 == 0);
unsafe { slice::from_raw_parts(b.as_ptr() as *const u32, b.len()/4) }
}

#[test]
fn test_index() {
let entries = vec![
IndexEntry { node: 0, pos: 17 },
IndexEntry { node: 31, pos: 29 },
IndexEntry { node: 32, pos: 1175 },
IndexEntry { node: 191, pos: 21 },
IndexEntry { node: 128, pos: 34 },
IndexEntry { node: 145, pos: 70 },
IndexEntry { node: 305, pos: 93214 },
IndexEntry { node: 138, pos: 64 },
IndexEntry { node: 129, pos: 53 },
IndexEntry { node: 192, pos: 33334 },
IndexEntry { node: 200, pos: 80123 },
];
let mut c = Cursor::new(vec![]);
write_index(entries.clone(), &mut c);
let mut buf = c.into_inner();
let expected: &[u8] = &[
0, 0, 0, 11, // # entries
// values:
0,0,0,17, 0,0,0,29, 0,0,4,151, 0,0,0,34,
0,0,0,53, 0,0,0,64, 0,0,0,70, 0,0,0,21,
0,0,130,54, 0,1,56,251, 0,1,108,30,
// index:
128,0,0,1,0,0,0,0, 0,0,0,1,0,0,0,2,
0,0,0,0,0,0,0,3, 0,0,0,0,0,0,0,3,
0,2,4,3,0,0,0,3, 128,0,0,0,0,0,0,7,
0,0,1,1,0,0,0,8, 0,0,0,0,0,0,0,10,
0,0,0,0,0,0,0,10, 0,2,0,0,0,0,0,10
];
assert_eq!(buf, expected);

// insert some junk padding
for i in 0..17 { buf.insert(0, i); buf.push(i) }
let index = Index::from_buf(&buf, 17, buf.len()-17);

// test round-trip
for i in 0..4096 {
assert_eq!(index.lookup_item(&buf, i),
entries.iter().find(|e| e.node == i).map(|n| n.pos as u32));
}
}
1 change: 1 addition & 0 deletions src/librustc/metadata/mod.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ pub mod decoder;
pub mod creader;
pub mod cstore;
pub mod csearch;
pub mod index;
pub mod loader;
pub mod filesearch;
pub mod macro_import;
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
@@ -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) {
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -761,7 +761,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: Session,
&tcx.sess, lib_features_used));

time(time_passes, "lint checking", ||
lint::check_crate(tcx, ast_crate, &exported_items));
lint::check_crate(tcx, &lower_crate(ast_crate), &exported_items));

// The above three passes generate errors w/o aborting
tcx.sess.abort_if_errors();
490 changes: 242 additions & 248 deletions src/librustc_lint/builtin.rs

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/librustc_trans/back/archive.rs
Original file line number Diff line number Diff line change
@@ -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);
15 changes: 8 additions & 7 deletions src/librustc_trans/back/msvc/registry.rs
Original file line number Diff line number Diff line change
@@ -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<RegistryKey> {
let key = key.encode_wide().chain(Some(0)).collect::<Vec<_>>();
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 {
32 changes: 31 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -2720,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<F: Foo>(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 {
<MyStruct as Foo>::BAR
}
```
"##,

E0366: r##"
An attempt was made to implement `Drop` on a concrete specialization of a
generic type. An example is shown below:
@@ -3265,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
3 changes: 2 additions & 1 deletion src/libstd/io/lazy.rs
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
use prelude::v1::*;

use cell::Cell;
use ptr;
use rt;
use sync::{StaticMutex, Arc};

@@ -26,7 +27,7 @@ impl<T: Send + Sync + 'static> Lazy<T> {
pub const fn new(init: fn() -> Arc<T>) -> Lazy<T> {
Lazy {
lock: StaticMutex::new(),
ptr: Cell::new(0 as *mut _),
ptr: Cell::new(ptr::null_mut()),
init: init
}
}
3 changes: 2 additions & 1 deletion src/libstd/rand/os.rs
Original file line number Diff line number Diff line change
@@ -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" {
3 changes: 2 additions & 1 deletion src/libstd/rt/at_exit_imp.rs
Original file line number Diff line number Diff line change
@@ -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<Box<FnBox()>>;
// 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
5 changes: 3 additions & 2 deletions src/libstd/rt/unwind/seh.rs
Original file line number Diff line number Diff line change
@@ -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<Any + Send + 'static>) -> ! {
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<Any + Send + 'static> {
rtassert!(ptr as DWORD == RUST_PANIC);

let data = PANIC_DATA.get() as *mut Box<Any + Send + 'static>;
PANIC_DATA.set(0 as *mut u8);
PANIC_DATA.set(ptr::null_mut());
rtassert!(!data.is_null());

*Box::from_raw(data)
7 changes: 4 additions & 3 deletions src/libstd/sys/common/net.rs
Original file line number Diff line number Diff line change
@@ -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<LookupHost> {
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<String> {
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())
};
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/backtrace/printing/libbacktrace.rs
Original file line number Diff line number Diff line change
@@ -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") ||
10 changes: 5 additions & 5 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
@@ -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<OsString> = 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<PathBuf> {
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) {
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/process.rs
Original file line number Diff line number Diff line change
@@ -405,7 +405,7 @@ fn make_envp(env: Option<&HashMap<OsString, OsString>>)

(ptrs.as_ptr() as *const _, tmps, ptrs)
} else {
(0 as *const _, Vec::new(), Vec::new())
(ptr::null(), Vec::new(), Vec::new())
}
}

6 changes: 3 additions & 3 deletions src/libstd/sys/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
@@ -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();
@@ -146,7 +146,7 @@ mod imp {
target_os = "netbsd",
target_os = "openbsd")))]
mod imp {
use libc;
use ptr;

pub unsafe fn init() {
}
@@ -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) {
10 changes: 6 additions & 4 deletions src/libstd/sys/unix/sync.rs
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/thread.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}

5 changes: 3 additions & 2 deletions src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
@@ -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 {
18 changes: 9 additions & 9 deletions src/libstd/sys/windows/fs.rs
Original file line number Diff line number Diff line change
@@ -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<File> {
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::<Vec<_>>();
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::<c::TOKEN_PRIVILEGES>() 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(|_| ())
}
}
}
3 changes: 2 additions & 1 deletion src/libstd/sys/windows/net.rs
Original file line number Diff line number Diff line change
@@ -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)),
3 changes: 2 additions & 1 deletion src/libstd/sys/windows/pipe.rs
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/thread_local.rs
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/libstd/thread/scoped_tls.rs
Original file line number Diff line number Diff line change
@@ -226,14 +226,15 @@ impl<T> ScopedKey<T> {
#[doc(hidden)]
mod imp {
use cell::Cell;
use ptr;

pub struct KeyInner<T> { inner: Cell<*mut T> }

unsafe impl<T> ::marker::Sync for KeyInner<T> { }

impl<T> KeyInner<T> {
pub const fn new() -> KeyInner<T> {
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() }
6 changes: 3 additions & 3 deletions src/test/auxiliary/lint_for_crate.rs
Original file line number Diff line number Diff line change
@@ -13,12 +13,12 @@
#![feature(plugin_registrar, rustc_private)]
#![feature(box_syntax)]

extern crate syntax;
#[macro_use] extern crate rustc;
extern crate rustc_front;

use syntax::{ast, attr};
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
use rustc::plugin::Registry;
use rustc_front::{hir, attr};

declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");

@@ -29,7 +29,7 @@ impl LintPass for Pass {
lint_array!(CRATE_NOT_OKAY)
}

fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) {
fn check_crate(&mut self, cx: &Context, krate: &hir::Crate) {
if !attr::contains_name(&krate.attrs, "crate_okay") {
cx.span_lint(CRATE_NOT_OKAY, krate.span,
"crate is not marked with #![crate_okay]");
6 changes: 3 additions & 3 deletions src/test/auxiliary/lint_group_plugin_test.rs
Original file line number Diff line number Diff line change
@@ -13,13 +13,13 @@
#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]

extern crate syntax;
extern crate rustc_front;

// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;

use syntax::ast;
use rustc_front::hir;
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
use rustc::plugin::Registry;

@@ -34,7 +34,7 @@ impl LintPass for Pass {
lint_array!(TEST_LINT, PLEASE_LINT)
}

fn check_item(&mut self, cx: &Context, it: &ast::Item) {
fn check_item(&mut self, cx: &Context, it: &hir::Item) {
match &*it.ident.name.as_str() {
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
7 changes: 3 additions & 4 deletions src/test/auxiliary/lint_plugin_test.rs
Original file line number Diff line number Diff line change
@@ -13,16 +13,15 @@
#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]

extern crate syntax;
extern crate rustc_front;

// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;

use syntax::ast;
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
use rustc::plugin::Registry;

use rustc_front::hir;
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

struct Pass;
@@ -32,7 +31,7 @@ impl LintPass for Pass {
lint_array!(TEST_LINT)
}

fn check_item(&mut self, cx: &Context, it: &ast::Item) {
fn check_item(&mut self, cx: &Context, it: &hir::Item) {
if it.ident.name == "lintme" {
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
}
1 change: 1 addition & 0 deletions src/test/compile-fail/allocator-dylib-is-system.rs
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/test/run-pass/allocator-default.rs
Original file line number Diff line number Diff line change
@@ -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() {
1 change: 1 addition & 0 deletions src/test/run-pass/allocator-jemalloc.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

// no-prefer-dynamic
// ignore-msvc no jemalloc on msvc
// ignore-bitrig no jemalloc on bitrig either

#![feature(alloc_jemalloc)]