Skip to content

Commit 13ff307

Browse files
authored
Auto merge of #35666 - eddyb:rollup, r=eddyb
Rollup of 30 pull requests - Successful merges: #34941, #35392, #35444, #35447, #35491, #35533, #35539, #35558, #35573, #35574, #35577, #35586, #35588, #35594, #35596, #35597, #35598, #35606, #35611, #35615, #35616, #35620, #35622, #35640, #35643, #35644, #35646, #35647, #35648, #35661 - Failed merges: #35395, #35415
2 parents 1d5b758 + bcee2ed commit 13ff307

File tree

127 files changed

+532
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+532
-217
lines changed

Diff for: configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ then
10131013
LLVM_VERSION=$($LLVM_CONFIG --version)
10141014

10151015
case $LLVM_VERSION in
1016-
(3.[7-8]*)
1016+
(3.[7-9]*)
10171017
msg "found ok version of LLVM: $LLVM_VERSION"
10181018
;;
10191019
(*)

Diff for: mk/cfg/i586-unknown-linux-gnu.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ CFG_LIB_NAME_i586-unknown-linux-gnu=lib$(1).so
77
CFG_STATIC_LIB_NAME_i586-unknown-linux-gnu=lib$(1).a
88
CFG_LIB_GLOB_i586-unknown-linux-gnu=lib$(1)-*.so
99
CFG_LIB_DSYM_GLOB_i586-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
10-
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium
11-
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium
10+
CFG_JEMALLOC_CFLAGS_i586-unknown-linux-gnu := -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
11+
CFG_GCCISH_CFLAGS_i586-unknown-linux-gnu := -g -fPIC -m32 $(CFLAGS) -march=pentium -Wa,-mrelax-relocations=no
1212
CFG_GCCISH_CXXFLAGS_i586-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) -march=pentium
1313
CFG_GCCISH_LINK_FLAGS_i586-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32
1414
CFG_GCCISH_DEF_FLAG_i586-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=

Diff for: mk/cfg/i686-unknown-linux-musl.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ CFG_INSTALL_ONLY_RLIB_i686-unknown-linux-musl = 1
77
CFG_LIB_NAME_i686-unknown-linux-musl=lib$(1).so
88
CFG_STATIC_LIB_NAME_i686-unknown-linux-musl=lib$(1).a
99
CFG_LIB_GLOB_i686-unknown-linux-musl=lib$(1)-*.so
10-
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386
11-
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386
10+
CFG_JEMALLOC_CFLAGS_i686-unknown-linux-musl := -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
11+
CFG_GCCISH_CFLAGS_i686-unknown-linux-musl := -g -fPIC -m32 -Wl,-melf_i386 -Wa,-mrelax-relocations=no
1212
CFG_GCCISH_CXXFLAGS_i686-unknown-linux-musl :=
1313
CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-musl :=
1414
CFG_GCCISH_DEF_FLAG_i686-unknown-linux-musl :=

Diff for: src/bootstrap/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,13 @@ impl Build {
870870
// This is a hack, because newer binutils broke things on some vms/distros
871871
// (i.e., linking against unknown relocs disabled by the following flag)
872872
// See: https://github.com/rust-lang/rust/issues/34978
873-
if target == "x86_64-unknown-linux-musl" {
874-
base.push("-Wa,-mrelax-relocations=no".into());
873+
match target {
874+
"i586-unknown-linux-gnu" |
875+
"i686-unknown-linux-musl" |
876+
"x86_64-unknown-linux-musl" => {
877+
base.push("-Wa,-mrelax-relocations=no".into());
878+
},
879+
_ => {},
875880
}
876881
return base
877882
}

Diff for: src/bootstrap/sanity.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ pub fn check(build: &mut Build) {
9898
if target.contains("rumprun") ||
9999
target.contains("bitrig") ||
100100
target.contains("openbsd") ||
101-
target.contains("msvc") {
101+
target.contains("msvc") ||
102+
target.contains("emscripten") {
102103
build.config.use_jemalloc = false;
103104
}
104105

Diff for: src/doc/book/error-handling.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ story. The other half is *using* the `find` function we've written. Let's try
166166
to use it to find the extension in a file name.
167167

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

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

274274
```rust
275-
# fn find(_: &str, _: char) -> Option<usize> { None }
275+
# fn find(haystack: &str, needle: char) -> Option<usize> { haystack.find(needle) }
276276
// Returns the extension of the given file name, where the extension is defined
277277
// as all characters following the first `.`.
278278
// If `file_name` has no `.`, then `None` is returned.

Diff for: src/doc/book/variable-bindings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ warning, but it will still print "Hello, world!":
125125

126126
```text
127127
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
128-
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)]
128+
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variables)]
129129
on by default
130130
src/main.rs:2 let x: i32;
131131
^

Diff for: src/liballoc/raw_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use super::boxed::Box;
1717
use core::ops::Drop;
1818
use core::cmp;
1919

20-
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
20+
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
2121
/// a buffer of memory on the heap without having to worry about all the corner cases
2222
/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
2323
/// In particular:
@@ -534,8 +534,8 @@ impl<T> RawVec<T> {
534534
/// Converts the entire buffer into `Box<[T]>`.
535535
///
536536
/// While it is not *strictly* Undefined Behavior to call
537-
/// this procedure while some of the RawVec is unintialized,
538-
/// it cetainly makes it trivial to trigger it.
537+
/// this procedure while some of the RawVec is uninitialized,
538+
/// it certainly makes it trivial to trigger it.
539539
///
540540
/// Note that this will correctly reconstitute any `cap` changes
541541
/// that may have been performed. (see description of type for details)

Diff for: src/libcollections/string.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ impl String {
11521152
self.vec.set_len(len + amt);
11531153
}
11541154

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

11891188
unsafe {

Diff for: src/libcollections/vec.rs

+51-12
Original file line numberDiff line numberDiff line change
@@ -1446,13 +1446,12 @@ impl<T> IntoIterator for Vec<T> {
14461446
#[inline]
14471447
fn into_iter(mut self) -> IntoIter<T> {
14481448
unsafe {
1449-
let ptr = self.as_mut_ptr();
1450-
assume(!ptr.is_null());
1451-
let begin = ptr as *const T;
1449+
let begin = self.as_mut_ptr();
1450+
assume(!begin.is_null());
14521451
let end = if mem::size_of::<T>() == 0 {
1453-
arith_offset(ptr as *const i8, self.len() as isize) as *const T
1452+
arith_offset(begin as *const i8, self.len() as isize) as *const T
14541453
} else {
1455-
ptr.offset(self.len() as isize) as *const T
1454+
begin.offset(self.len() as isize) as *const T
14561455
};
14571456
let buf = ptr::read(&self.buf);
14581457
mem::forget(self);
@@ -1710,10 +1709,52 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
17101709
#[stable(feature = "rust1", since = "1.0.0")]
17111710
pub struct IntoIter<T> {
17121711
_buf: RawVec<T>,
1713-
ptr: *const T,
1712+
ptr: *mut T,
17141713
end: *const T,
17151714
}
17161715

1716+
impl<T> IntoIter<T> {
1717+
/// Returns the remaining items of this iterator as a slice.
1718+
///
1719+
/// # Examples
1720+
///
1721+
/// ```rust
1722+
/// # #![feature(vec_into_iter_as_slice)]
1723+
/// let vec = vec!['a', 'b', 'c'];
1724+
/// let mut into_iter = vec.into_iter();
1725+
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
1726+
/// let _ = into_iter.next().unwrap();
1727+
/// assert_eq!(into_iter.as_slice(), &['b', 'c']);
1728+
/// ```
1729+
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
1730+
pub fn as_slice(&self) -> &[T] {
1731+
unsafe {
1732+
slice::from_raw_parts(self.ptr, self.len())
1733+
}
1734+
}
1735+
1736+
/// Returns the remaining items of this iterator as a mutable slice.
1737+
///
1738+
/// # Examples
1739+
///
1740+
/// ```rust
1741+
/// # #![feature(vec_into_iter_as_slice)]
1742+
/// let vec = vec!['a', 'b', 'c'];
1743+
/// let mut into_iter = vec.into_iter();
1744+
/// assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
1745+
/// into_iter.as_mut_slice()[2] = 'z';
1746+
/// assert_eq!(into_iter.next().unwrap(), 'a');
1747+
/// assert_eq!(into_iter.next().unwrap(), 'b');
1748+
/// assert_eq!(into_iter.next().unwrap(), 'z');
1749+
/// ```
1750+
#[unstable(feature = "vec_into_iter_as_slice", issue = "35601")]
1751+
pub fn as_mut_slice(&self) -> &mut [T] {
1752+
unsafe {
1753+
slice::from_raw_parts_mut(self.ptr, self.len())
1754+
}
1755+
}
1756+
}
1757+
17171758
#[stable(feature = "rust1", since = "1.0.0")]
17181759
unsafe impl<T: Send> Send for IntoIter<T> {}
17191760
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1726,14 +1767,14 @@ impl<T> Iterator for IntoIter<T> {
17261767
#[inline]
17271768
fn next(&mut self) -> Option<T> {
17281769
unsafe {
1729-
if self.ptr == self.end {
1770+
if self.ptr as *const _ == self.end {
17301771
None
17311772
} else {
17321773
if mem::size_of::<T>() == 0 {
17331774
// purposefully don't use 'ptr.offset' because for
17341775
// vectors with 0-size elements this would return the
17351776
// same pointer.
1736-
self.ptr = arith_offset(self.ptr as *const i8, 1) as *const T;
1777+
self.ptr = arith_offset(self.ptr as *const i8, 1) as *mut T;
17371778

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

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

Diff for: src/libcollectionstest/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![feature(unboxed_closures)]
2929
#![feature(unicode)]
3030
#![feature(vec_deque_contains)]
31+
#![feature(vec_into_iter_as_slice)]
3132

3233
extern crate collections;
3334
extern crate test;

Diff for: src/libcollectionstest/vec.rs

+23
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,29 @@ fn test_split_off() {
478478
assert_eq!(vec2, [5, 6]);
479479
}
480480

481+
#[test]
482+
fn test_into_iter_as_slice() {
483+
let vec = vec!['a', 'b', 'c'];
484+
let mut into_iter = vec.into_iter();
485+
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
486+
let _ = into_iter.next().unwrap();
487+
assert_eq!(into_iter.as_slice(), &['b', 'c']);
488+
let _ = into_iter.next().unwrap();
489+
let _ = into_iter.next().unwrap();
490+
assert_eq!(into_iter.as_slice(), &[]);
491+
}
492+
493+
#[test]
494+
fn test_into_iter_as_mut_slice() {
495+
let vec = vec!['a', 'b', 'c'];
496+
let mut into_iter = vec.into_iter();
497+
assert_eq!(into_iter.as_slice(), &['a', 'b', 'c']);
498+
into_iter.as_mut_slice()[0] = 'x';
499+
into_iter.as_mut_slice()[1] = 'y';
500+
assert_eq!(into_iter.next().unwrap(), 'x');
501+
assert_eq!(into_iter.as_slice(), &['y', 'c']);
502+
}
503+
481504
#[test]
482505
fn test_into_iter_count() {
483506
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);

Diff for: src/libcore/cell.rs

+22
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146

147147
use clone::Clone;
148148
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
149+
use convert::From;
149150
use default::Default;
150151
use fmt::{self, Debug, Display};
151152
use marker::{Copy, PhantomData, Send, Sync, Sized, Unsize};
@@ -329,6 +330,13 @@ impl<T:Ord + Copy> Ord for Cell<T> {
329330
}
330331
}
331332

333+
#[stable(feature = "cell_from", since = "1.12.0")]
334+
impl<T: Copy> From<T> for Cell<T> {
335+
fn from(t: T) -> Cell<T> {
336+
Cell::new(t)
337+
}
338+
}
339+
332340
/// A mutable memory location with dynamically checked borrow rules
333341
///
334342
/// See the [module-level documentation](index.html) for more.
@@ -742,6 +750,13 @@ impl<T: ?Sized + Ord> Ord for RefCell<T> {
742750
}
743751
}
744752

753+
#[stable(feature = "cell_from", since = "1.12.0")]
754+
impl<T> From<T> for RefCell<T> {
755+
fn from(t: T) -> RefCell<T> {
756+
RefCell::new(t)
757+
}
758+
}
759+
745760
struct BorrowRef<'b> {
746761
borrow: &'b Cell<BorrowFlag>,
747762
}
@@ -1064,3 +1079,10 @@ impl<T: Default> Default for UnsafeCell<T> {
10641079
UnsafeCell::new(Default::default())
10651080
}
10661081
}
1082+
1083+
#[stable(feature = "cell_from", since = "1.12.0")]
1084+
impl<T> From<T> for UnsafeCell<T> {
1085+
fn from(t: T) -> UnsafeCell<T> {
1086+
UnsafeCell::new(t)
1087+
}
1088+
}

Diff for: src/libcore/convert.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ use result::Result;
7171
///
7272
/// # Generic Impls
7373
///
74-
/// - `AsRef` auto-dereference if the inner type is a reference or a mutable
75-
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
74+
/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable
75+
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
7676
///
7777
#[stable(feature = "rust1", since = "1.0.0")]
7878
pub trait AsRef<T: ?Sized> {
@@ -88,8 +88,8 @@ pub trait AsRef<T: ?Sized> {
8888
///
8989
/// # Generic Impls
9090
///
91-
/// - `AsMut` auto-dereference if the inner type is a reference or a mutable
92-
/// reference (eg: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
91+
/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
92+
/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type `&mut Foo` or `&&mut Foo`)
9393
///
9494
#[stable(feature = "rust1", since = "1.0.0")]
9595
pub trait AsMut<T: ?Sized> {

Diff for: src/libcore/sync/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//! atomically-reference-counted shared pointer).
3333
//!
3434
//! Most atomic types may be stored in static variables, initialized using
35-
//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics
35+
//! the provided static initializers like `ATOMIC_BOOL_INIT`. Atomic statics
3636
//! are often used for lazy global initialization.
3737
//!
3838
//!

Diff for: src/librustc/middle/entry.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
132132
if ctxt.start_fn.is_none() {
133133
ctxt.start_fn = Some((item.id, item.span));
134134
} else {
135-
span_err!(ctxt.session, item.span, E0138,
136-
"multiple 'start' functions");
135+
struct_span_err!(
136+
ctxt.session, item.span, E0138,
137+
"multiple 'start' functions")
138+
.span_label(ctxt.start_fn.unwrap().1,
139+
&format!("previous `start` function here"))
140+
.span_label(item.span, &format!("multiple `start` functions"))
141+
.emit();
137142
}
138143
},
139144
EntryPointType::None => ()

Diff for: src/librustc/ty/error.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,24 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
222222
ty::TyArray(_, n) => format!("array of {} elements", n),
223223
ty::TySlice(_) => "slice".to_string(),
224224
ty::TyRawPtr(_) => "*-ptr".to_string(),
225-
ty::TyRef(_, _) => "&-ptr".to_string(),
225+
ty::TyRef(region, tymut) => {
226+
let tymut_string = tymut.to_string();
227+
if tymut_string == "_" || //unknown type name,
228+
tymut_string.len() > 10 || //name longer than saying "reference",
229+
region.to_string() != "" //... or a complex type
230+
{
231+
match tymut {
232+
ty::TypeAndMut{mutbl, ..} => {
233+
format!("{}reference", match mutbl {
234+
hir::Mutability::MutMutable => "mutable ",
235+
_ => ""
236+
})
237+
}
238+
}
239+
} else {
240+
format!("&{}", tymut_string)
241+
}
242+
}
226243
ty::TyFnDef(..) => format!("fn item"),
227244
ty::TyFnPtr(_) => "fn pointer".to_string(),
228245
ty::TyTrait(ref inner) => {

0 commit comments

Comments
 (0)