Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #28200

Merged
merged 25 commits into from
Sep 4, 2015
Merged
Show file tree
Hide file tree
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
Expand Up @@ -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!
$
```
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) };
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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() },
Expand Down Expand Up @@ -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() },
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/num/flt2dec/bignum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/flt2dec/strategy/dragon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]); }
Expand All @@ -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]);
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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 => {
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) }
}
}
Expand Down
Loading