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 30 pull requests #35666

Merged
merged 67 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e91b625
Fix typo (privledge->privilege)
Jul 20, 2016
1403df7
Implement From for Cell, RefCell and UnsafeCell
malbarbo Aug 5, 2016
9d6fa40
Add regression test for #22894.
frewsxcv Aug 8, 2016
1a6fac7
E0248 Change in issue format
shyamsundarb-arch Aug 7, 2016
5c2c19a
Update error message for E0253 #35512
lukehinds Aug 9, 2016
5dac93d
[emscripten] Disable jemalloc for emscripten
badboy Aug 6, 2016
ad91873
[emscripten] Ignore tests
badboy Aug 8, 2016
60599df
[emscripten] Disable code paths that don't work on emscripten
badboy Aug 8, 2016
c974749
Update E0253.rs
lukehinds Aug 10, 2016
ae58a87
add -mrelax-relocations=no to i686-musl and i586-gnu
Aug 10, 2016
16cc8a7
Implemented a smarter concatenation system that will hopefully produc…
cgswords Aug 2, 2016
92f7e85
Update E0138 to new format
wdv4758h Aug 10, 2016
4b54dd7
Use an existing constant name as an example.
Antti Aug 11, 2016
c0ff3c1
fix match
Aug 11, 2016
b707a12
Allow compiling against a custom LLVM 3.9 installation
shepmaster Aug 11, 2016
4209f94
Add label to E0254
tvladyslav Aug 10, 2016
045c8c8
std: Optimize panic::catch_unwind slightly
alexcrichton Jul 9, 2016
c99c2ea
doc: a value of type `&str` is called a "string slice"
tshepang Aug 11, 2016
071410b
string: remove needless binding
tshepang Aug 11, 2016
c761184
Fix tidy tests
tvladyslav Aug 11, 2016
d099e30
Introduce `as_slice` method on `std::vec::IntoIter` struct.
frewsxcv Aug 7, 2016
01a766e
Introduce `as_mut_slice` method on `std::vec::IntoIter` struct.
frewsxcv Aug 7, 2016
fc97b5c
Change stabilization version of no_std from 1.0 to 1.6.
Mark-Simulacrum Aug 11, 2016
629f2aa
Fix typo
Aug 11, 2016
4224737
Improve &-ptr printing
Aug 12, 2016
f76a737
Correct span for pub_restricted field
sanxiyn Aug 8, 2016
3042fba
book: fix the hidden find() functions in error-handling.md
cvubrugier Aug 12, 2016
bfca761
fix small typos in std::convert documentation
matthew-piziak Aug 12, 2016
4ab00e4
updated E0070 to new error format
clementmiao Aug 12, 2016
302a423
Update E0301 to the new format
krzysztofgarczynski Aug 12, 2016
5402d28
Update E0302 to the new format
krzysztofgarczynski Aug 13, 2016
08e470f
compiletest: Remove dead code.
ahmedcharles Aug 13, 2016
bd90a16
updated E0067 to new error format
clementmiao Aug 13, 2016
85388f0
E0094 error message updated
theypsilon Aug 13, 2016
6fbff4f
Ensure that attributes are spelled properly.
ahmedcharles Aug 13, 2016
ab00b94
Predicates haven't existed in almost 5 years.
ahmedcharles Aug 13, 2016
10fce6e
Fix a couple of typos in RawVec
IvanUkhov Aug 14, 2016
9d1900b
Rollup merge of #34941 - qolop:patch-2, r=apasel422
eddyb Aug 14, 2016
fa57f35
Rollup merge of #35392 - malbarbo:cell-from, r=brson
eddyb Aug 14, 2016
41e0f2d
Rollup merge of #35444 - alexcrichton:optimize-catch-unwind, r=brson
eddyb Aug 14, 2016
6d8af8c
Rollup merge of #35447 - frewsxcv:vec-into-iter-as-slice, r=alexcrichton
eddyb Aug 14, 2016
c35d8db
Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakis
eddyb Aug 14, 2016
b1ec5b2
Rollup merge of #35533 - frewsxcv:22984, r=brson
eddyb Aug 14, 2016
9fb4fa8
Rollup merge of #35539 - cgswords:ts_concat, r=nrc
eddyb Aug 14, 2016
9c347b9
Rollup merge of #35558 - lukehinds:master, r=nikomatsakis
eddyb Aug 14, 2016
c3cede2
Rollup merge of #35573 - wdv4758h:E0138, r=jonathandturner
eddyb Aug 14, 2016
8ade28e
Rollup merge of #35574 - badboy:emscripten-test-fixes, r=brson
eddyb Aug 14, 2016
da2328b
Rollup merge of #35577 - japaric:relax, r=alexcrichton
eddyb Aug 14, 2016
b65ff08
Rollup merge of #35586 - shyaamsundhar:SqushCom, r=jonathandturner
eddyb Aug 14, 2016
955458e
Rollup merge of #35588 - Antti:fix-atomics-docs, r=alexcrichton
eddyb Aug 14, 2016
e3a94b4
Rollup merge of #35594 - shepmaster:configure-llvm-39, r=alexcrichton
eddyb Aug 14, 2016
812a8c1
Rollup merge of #35596 - crypto-universe:E0254_style_and_tests, r=jon…
eddyb Aug 14, 2016
322aa6e
Rollup merge of #35597 - tshepang:it-is-a-slice, r=steveklabnik
eddyb Aug 14, 2016
b975a12
Rollup merge of #35598 - tshepang:needless-binding, r=steveklabnik
eddyb Aug 14, 2016
7aaa83a
Rollup merge of #35606 - Mark-Simulacrum:no-std-fix, r=brson
eddyb Aug 14, 2016
80510b8
Rollup merge of #35611 - jonathandturner:ptr-helper, r=nikomatsakis
eddyb Aug 14, 2016
c5a9228
Rollup merge of #35615 - clementmiao:E0070_new_error_format, r=jonath…
eddyb Aug 14, 2016
15f66ad
Rollup merge of #35616 - clementmiao:E0067_new_error_format, r=jonath…
eddyb Aug 14, 2016
5766b42
Rollup merge of #35620 - cvubrugier:master, r=Manishearth
eddyb Aug 14, 2016
2294fc4
Rollup merge of #35622 - matthew-piziak:convert-docs-typos, r=apasel422
eddyb Aug 14, 2016
42b3df2
Rollup merge of #35640 - ahmedcharles:dead, r=alexcrichton
eddyb Aug 14, 2016
f91d242
Rollup merge of #35643 - garekkream:update-E0301-new-error-format, r=…
eddyb Aug 14, 2016
50aa568
Rollup merge of #35644 - garekkream:update-E0302-new-error-format, r=…
eddyb Aug 14, 2016
f73f128
Rollup merge of #35646 - theypsilon:master, r=jonathandturner
eddyb Aug 14, 2016
c63adb1
Rollup merge of #35647 - ahmedcharles:spelling, r=alexcrichton
eddyb Aug 14, 2016
43cd345
Rollup merge of #35648 - ahmedcharles:pred, r=alexcrichton
eddyb Aug 14, 2016
bcee2ed
Rollup merge of #35661 - IvanUkhov:raw-vec, r=alexcrichton
eddyb Aug 14, 2016
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
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ then
LLVM_VERSION=$($LLVM_CONFIG --version)

case $LLVM_VERSION in
(3.[7-8]*)
(3.[7-9]*)
msg "found ok version of LLVM: $LLVM_VERSION"
;;
(*)
Expand Down
4 changes: 2 additions & 2 deletions mk/cfg/i586-unknown-linux-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) -march=pentium
CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32
CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
Expand Down
4 changes: 2 additions & 2 deletions mk/cfg/i686-unknown-linux-musl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1
CFG_LIB_NAME_i686-unknown-linux-musl=lib$(1).so
CFG_STATIC_LIB_NAME_i686-unknown-linux-musl=lib$(1).a
CFG_LIB_GLOB_i686-unknown-linux-musl=lib$(1)-*.so
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
CFG_GCCISH_CXXFLAGS_i686-unknown-linux-musl :=
CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-musl :=
CFG_GCCISH_DEF_FLAG_i686-unknown-linux-musl :=
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,13 @@ impl Build {
// This is a hack, because newer binutils broke things on some vms/distros
// (i.e., linking against unknown relocs disabled by the following flag)
// See: https://github.com/rust-lang/rust/issues/34978
if target == "x86_64-unknown-linux-musl" {
base.push("-Wa,-mrelax-relocations=no".into());
match target {
"i586-unknown-linux-gnu" |
"i686-unknown-linux-musl" |
"x86_64-unknown-linux-musl" => {
base.push("-Wa,-mrelax-relocations=no".into());
},
_ => {},
}
return base
}
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ pub fn check(build: &mut Build) {
if target.contains("rumprun") ||
target.contains("bitrig") ||
target.contains("openbsd") ||
target.contains("msvc") {
target.contains("msvc") ||
target.contains("emscripten") {
build.config.use_jemalloc = false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/doc/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ story. The other half is *using* the `find` function we've written. Let's try
to use it to find the extension in a file name.

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
fn main() {
let file_name = "foobar.rs";
match find(file_name, '.') {
Expand Down Expand Up @@ -223,7 +223,7 @@ Getting the extension of a file name is a pretty common operation, so it makes
sense to put it into a function:

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
// Returns the extension of the given file name, where the extension is defined
// as all characters following the first `.`.
// If `file_name` has no `.`, then `None` is returned.
Expand Down Expand Up @@ -272,7 +272,7 @@ Armed with our new combinator, we can rewrite our `extension_explicit` method
to get rid of the case analysis:

```rust
# fn find(_: &str, _: char) -> Option<usize> { None }
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
// Returns the extension of the given file name, where the extension is defined
// as all characters following the first `.`.
// If `file_name` has no `.`, then `None` is returned.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/variable-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ warning, but it will still print "Hello, world!":

```text
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)]
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variables)]
on by default
src/main.rs:2 let x: i32;
^
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::boxed::Box;
use core::ops::Drop;
use core::cmp;

/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
/// a buffer of memory on the heap without having to worry about all the corner cases
/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
/// In particular:
Expand Down Expand Up @@ -534,8 +534,8 @@ impl<T> RawVec<T> {
/// Converts the entire buffer into `Box<[T]>`.
///
/// While it is not *strictly* Undefined Behavior to call
/// this procedure while some of the RawVec is unintialized,
/// it cetainly makes it trivial to trigger it.
/// this procedure while some of the RawVec is uninitialized,
/// it certainly makes it trivial to trigger it.
///
/// Note that this will correctly reconstitute any `cap` changes
/// that may have been performed. (see description of type for details)
Expand Down
5 changes: 2 additions & 3 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ impl String {
self.vec.set_len(len + amt);
}

/// Inserts a string into this `String` at a byte position.
/// Inserts a string slice into this `String` at a byte position.
///
/// This is an `O(n)` operation as it requires copying every element in the
/// buffer.
Expand Down Expand Up @@ -1182,8 +1182,7 @@ impl String {
reason = "recent addition",
issue = "35553")]
pub fn insert_str(&mut self, idx: usize, string: &str) {
let len = self.len();
assert!(idx <= len);
assert!(idx <= self.len());
assert!(self.is_char_boundary(idx));

unsafe {
Expand Down
63 changes: 51 additions & 12 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,12 @@ impl<T> IntoIterator for Vec<T> {
#[inline]
fn into_iter(mut self) -> IntoIter<T> {
unsafe {
let ptr = self.as_mut_ptr();
assume(!ptr.is_null());
let begin = ptr as *const T;
let begin = self.as_mut_ptr();
assume(!begin.is_null());
let end = if mem::size_of::<T>() == 0 {
arith_offset(ptr as *const i8, self.len() as isize) as *const T
arith_offset(begin as *const i8, self.len() as isize) as *const T
} else {
ptr.offset(self.len() as isize) as *const T
begin.offset(self.len() as isize) as *const T
};
let buf = ptr::read(&self.buf);
mem::forget(self);
Expand Down Expand Up @@ -1710,10 +1709,52 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> {
_buf: RawVec<T>,
ptr: *const T,
ptr: *mut T,
end: *const T,
}

impl<T> IntoIter<T> {
/// Returns the remaining items of this iterator as a slice.
///
/// # Examples
///
/// ```rust
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
/// let _ = into_iter.next().unwrap();
/// assert_eq!(into_iter.as_slice(), &['b', 'c']);
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
pub fn as_slice(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.ptr, self.len())
}
}

/// Returns the remaining items of this iterator as a mutable slice.
///
/// # Examples
///
/// ```rust
/// # #![feature(vec_into_iter_as_slice)]
/// let vec = vec!['a', 'b', 'c'];
/// let mut into_iter = vec.into_iter();
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
/// into_iter.as_mut_slice()[2] = 'z';
/// assert_eq!(into_iter.next().unwrap(), 'a');
/// assert_eq!(into_iter.next().unwrap(), 'b');
/// assert_eq!(into_iter.next().unwrap(), 'z');
/// ```
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
pub fn as_mut_slice(&self) -> &mut [T] {
unsafe {
slice::from_raw_parts_mut(self.ptr, self.len())
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<T: Send> Send for IntoIter<T> {}
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -1726,14 +1767,14 @@ impl<T> Iterator for IntoIter<T> {
#[inline]
fn next(&mut self) -> Option<T> {
unsafe {
if self.ptr == self.end {
if self.ptr as *const _ == self.end {
None
} else {
if mem::size_of::<T>() == 0 {
// purposefully don't use 'ptr.offset' because for
// vectors with 0-size elements this would return the
// same pointer.
self.ptr = arith_offset(self.ptr as *const i8, 1) as *const T;
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;

// Use a non-null pointer value
Some(ptr::read(EMPTY as *mut T))
Expand Down Expand Up @@ -1776,7 +1817,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
} else {
if mem::size_of::<T>() == 0 {
// See above for why 'ptr.offset' isn't used
self.end = arith_offset(self.end as *const i8, -1) as *const T;
self.end = arith_offset(self.end as *const i8, -1) as *mut T;

// Use a non-null pointer value
Some(ptr::read(EMPTY as *mut T))
Expand All @@ -1796,9 +1837,7 @@ impl<T> ExactSizeIterator for IntoIter<T> {}
#[stable(feature = "vec_into_iter_clone", since = "1.8.0")]
impl<T: Clone> Clone for IntoIter<T> {
fn clone(&self) -> IntoIter<T> {
unsafe {
slice::from_raw_parts(self.ptr, self.len()).to_owned().into_iter()
}
self.as_slice().to_owned().into_iter()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(vec_deque_contains)]
#![feature(vec_into_iter_as_slice)]

extern crate collections;
extern crate test;
Expand Down
23 changes: 23 additions & 0 deletions src/libcollectionstest/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,29 @@ fn test_split_off() {
assert_eq!(vec2, [5, 6]);
}

#[test]
fn test_into_iter_as_slice() {
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
let _ = into_iter.next().unwrap();
assert_eq!(into_iter.as_slice(), &['b', 'c']);
let _ = into_iter.next().unwrap();
let _ = into_iter.next().unwrap();
assert_eq!(into_iter.as_slice(), &[]);
}

#[test]
fn test_into_iter_as_mut_slice() {
let vec = vec!['a', 'b', 'c'];
let mut into_iter = vec.into_iter();
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
into_iter.as_mut_slice()[0] = 'x';
into_iter.as_mut_slice()[1] = 'y';
assert_eq!(into_iter.next().unwrap(), 'x');
assert_eq!(into_iter.as_slice(), &['y', 'c']);
}

#[test]
fn test_into_iter_count() {
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
Expand Down
22 changes: 22 additions & 0 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@

use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use convert::From;
use default::Default;
use fmt::{self, Debug, Display};
use marker::{Copy, PhantomData, Send, Sync, Sized, Unsize};
Expand Down Expand Up @@ -329,6 +330,13 @@ impl<T:Ord + Copy> Ord for Cell<T> {
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T: Copy> From<T> for Cell<T> {
fn from(t: T) -> Cell<T> {
Cell::new(t)
}
}

/// A mutable memory location with dynamically checked borrow rules
///
/// See the [module-level documentation](index.html) for more.
Expand Down Expand Up @@ -742,6 +750,13 @@ impl<T: ?Sized + Ord> Ord for RefCell<T> {
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T> From<T> for RefCell<T> {
fn from(t: T) -> RefCell<T> {
RefCell::new(t)
}
}

struct BorrowRef<'b> {
borrow: &'b Cell<BorrowFlag>,
}
Expand Down Expand Up @@ -1064,3 +1079,10 @@ impl<T: Default> Default for UnsafeCell<T> {
UnsafeCell::new(Default::default())
}
}

#[stable(feature = "cell_from", since = "1.12.0")]
impl<T> From<T> for UnsafeCell<T> {
fn from(t: T) -> UnsafeCell<T> {
UnsafeCell::new(t)
}
}
8 changes: 4 additions & 4 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ use result::Result;
///
/// # Generic Impls
///
/// - `AsRef` auto-dereference if the inner type is a reference or a mutable
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsRef<T: ?Sized> {
Expand All @@ -88,8 +88,8 @@ pub trait AsRef<T: ?Sized> {
///
/// # Generic Impls
///
/// - `AsMut` auto-dereference if the inner type is a reference or a mutable
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsMut<T: ?Sized> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//! atomically-reference-counted shared pointer).
//!
//! Most atomic types may be stored in static variables, initialized using
//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics
//! the provided static initializers like `ATOMIC_BOOL_INIT`. Atomic statics
//! are often used for lazy global initialization.
//!
//!
Expand Down
9 changes: 7 additions & 2 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
if ctxt.start_fn.is_none() {
ctxt.start_fn = Some((item.id, item.span));
} else {
span_err!(ctxt.session, item.span, E0138,
"multiple 'start' functions");
struct_span_err!(
ctxt.session, item.span, E0138,
"multiple 'start' functions")
.span_label(ctxt.start_fn.unwrap().1,
&format!("previous `start` function here"))
.span_label(item.span, &format!("multiple `start` functions"))
.emit();
}
},
EntryPointType::None => ()
Expand Down
19 changes: 18 additions & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,24 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::TyArray(_, n) => format!("array of {} elements", n),
ty::TySlice(_) => "slice".to_string(),
ty::TyRawPtr(_) => "*-ptr".to_string(),
ty::TyRef(_, _) => "&-ptr".to_string(),
ty::TyRef(region, tymut) => {
let tymut_string = tymut.to_string();
if tymut_string == "_" || //unknown type name,
tymut_string.len() > 10 || //name longer than saying "reference",
region.to_string() != "" //... or a complex type
{
match tymut {
ty::TypeAndMut{mutbl, ..} => {
format!("{}reference", match mutbl {
hir::Mutability::MutMutable => "mutable ",
_ => ""
})
}
}
} else {
format!("&{}", tymut_string)
}
}
ty::TyFnDef(..) => format!("fn item"),
ty::TyFnPtr(_) => "fn pointer".to_string(),
ty::TyTrait(ref inner) => {
Expand Down
Loading