Skip to content

Commit

Permalink
Auto merge of #56437 - Centril:rollup, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - #56110 (Consider references and unions potentially inhabited during privacy-respecting inhabitedness checks)
 - #56305 (update miri)
 - #56366 (Stabilize self_in_typedefs feature)
 - #56372 (Refer to the second borrow as the "second borrow" in E0501.rs)
 - #56394 (Deal with EINTR in net timeout tests)
 - #56395 (Stabilize dbg!(...))
 - #56401 (Move VecDeque::resize_with out of the impl<T:Clone> block)
 - #56402 (Improve the unstable book example for #[marker] trait)
 - #56412 (Update tracking issue for `extern_crate_self`)
 - #56416 (Remove unneeded body class selector)
 - #56418 (Fix failing tidy (line endings on Windows))
 - #56419 (Remove some uses of try!)
 - #56424 (Mention raw-ident syntax)
 - #56432 (Update issue number of `shrink_to` methods to point the tracking issue)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 2, 2018
2 parents 8660eba + c03c34c commit 1a8b4e9
Show file tree
Hide file tree
Showing 66 changed files with 291 additions and 290 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,15 @@ name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "directories"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "dlmalloc"
version = "0.0.0"
Expand Down Expand Up @@ -1316,6 +1325,7 @@ dependencies = [
"cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3288,6 +3298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f57d78cf3bd45270dad4e70c21ec77a960b36c7a841ff9db76aaa775a8fb871"
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4837d77a1e157489a3933b743fd774ae75074e0e390b2b7f071530048a0d87ee"
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,13 +915,13 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()>
}
if let Ok(m) = fs::symlink_metadata(dst) {
if m.file_type().is_dir() {
try!(fs::remove_dir_all(dst));
fs::remove_dir_all(dst)?;
} else {
// handle directory junctions on windows by falling back to
// `remove_dir`.
try!(fs::remove_file(dst).or_else(|_| {
fs::remove_file(dst).or_else(|_| {
fs::remove_dir(dst)
}));
})?;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
// We're using low-level APIs to create the junction, and these are more
// picky about paths. For example, forward slashes cannot be used as a
// path separator, so we should try to canonicalize the path first.
let target = try!(fs::canonicalize(target));
let target = fs::canonicalize(target)?;

try!(fs::create_dir(junction));
fs::create_dir(junction)?;

let path = try!(to_u16s(junction));
let path = to_u16s(junction)?;

unsafe {
let h = CreateFileW(path.as_ptr(),
Expand Down
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/rustc-guide
14 changes: 8 additions & 6 deletions src/doc/unstable-book/src/language-features/marker-trait-attr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ when they'd need to do the same thing for every type anyway).
```rust
#![feature(marker_trait_attr)]

use std::fmt::{Debug, Display};
#[marker] trait CheapToClone: Clone {}

#[marker] trait MyMarker {}
impl<T: Copy> CheapToClone for T {}

impl<T: Debug> MyMarker for T {}
impl<T: Display> MyMarker for T {}
// These could potentally overlap with the blanket implementation above,
// so are only allowed because CheapToClone is a marker trait.
impl<T: CheapToClone, U: CheapToClone> CheapToClone for (T, U) {}
impl<T: CheapToClone> CheapToClone for std::ops::Range<T> {}

fn foo<T: MyMarker>(t: T) -> T {
t
fn cheap_clone<T: CheapToClone>(t: T) -> T {
t.clone()
}
```

Expand Down
24 changes: 0 additions & 24 deletions src/doc/unstable-book/src/language-features/self-in-typedefs.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<T: Ord> BinaryHeap<T> {
/// assert!(heap.capacity() >= 10);
/// ```
#[inline]
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.data.shrink_to(min_capacity)
}
Expand Down
62 changes: 28 additions & 34 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use core::cmp::Ordering;
use core::fmt;
use core::iter::{repeat, repeat_with, FromIterator, FusedIterator};
use core::iter::{repeat_with, FromIterator, FusedIterator};
use core::mem;
use core::ops::Bound::{Excluded, Included, Unbounded};
use core::ops::{Index, IndexMut, RangeBounds};
Expand Down Expand Up @@ -701,7 +701,7 @@ impl<T> VecDeque<T> {
/// buf.shrink_to(0);
/// assert!(buf.capacity() >= 4);
/// ```
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
pub fn shrink_to(&mut self, min_capacity: usize) {
assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity");

Expand Down Expand Up @@ -1886,16 +1886,16 @@ impl<T> VecDeque<T> {
debug_assert!(!self.is_full());
}
}
}

impl<T: Clone> VecDeque<T> {
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
/// either by removing excess elements from the back or by appending clones of `value`
/// to the back.
/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
/// either by removing excess elements from the back or by appending
/// elements generated by calling `generator` to the back.
///
/// # Examples
///
/// ```
/// #![feature(vec_resize_with)]
///
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
Expand All @@ -1904,32 +1904,36 @@ impl<T: Clone> VecDeque<T> {
/// buf.push_back(15);
/// assert_eq!(buf, [5, 10, 15]);
///
/// buf.resize(2, 0);
/// buf.resize_with(5, Default::default);
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
///
/// buf.resize_with(2, || unreachable!());
/// assert_eq!(buf, [5, 10]);
///
/// buf.resize(5, 20);
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
/// let mut state = 100;
/// buf.resize_with(5, || { state += 1; state });
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
/// ```
#[stable(feature = "deque_extras", since = "1.16.0")]
pub fn resize(&mut self, new_len: usize, value: T) {
#[unstable(feature = "vec_resize_with", issue = "41758")]
pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) {
let len = self.len();

if new_len > len {
self.extend(repeat(value).take(new_len - len))
self.extend(repeat_with(generator).take(new_len - len))
} else {
self.truncate(new_len);
}
}
}

/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
/// either by removing excess elements from the back or by appending
/// elements generated by calling `generator` to the back.
impl<T: Clone> VecDeque<T> {
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
/// either by removing excess elements from the back or by appending clones of `value`
/// to the back.
///
/// # Examples
///
/// ```
/// #![feature(vec_resize_with)]
///
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
Expand All @@ -1938,25 +1942,15 @@ impl<T: Clone> VecDeque<T> {
/// buf.push_back(15);
/// assert_eq!(buf, [5, 10, 15]);
///
/// buf.resize_with(5, Default::default);
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
///
/// buf.resize_with(2, || unreachable!());
/// buf.resize(2, 0);
/// assert_eq!(buf, [5, 10]);
///
/// let mut state = 100;
/// buf.resize_with(5, || { state += 1; state });
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
/// buf.resize(5, 20);
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
/// ```
#[unstable(feature = "vec_resize_with", issue = "41758")]
pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) {
let len = self.len();

if new_len > len {
self.extend(repeat_with(generator).take(new_len - len))
} else {
self.truncate(new_len);
}
#[stable(feature = "deque_extras", since = "1.16.0")]
pub fn resize(&mut self, new_len: usize, value: T) {
self.resize_with(new_len, || value.clone());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl String {
/// assert!(s.capacity() >= 3);
/// ```
#[inline]
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.vec.shrink_to(min_capacity)
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ impl<T> Vec<T> {
/// vec.shrink_to(0);
/// assert!(vec.capacity() >= 3);
/// ```
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.buf.shrink_to_fit(cmp::max(self.len, min_capacity));
}
Expand Down
14 changes: 9 additions & 5 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ macro_rules! debug_assert_ne {
/// with converting downstream errors.
///
/// The `?` operator was added to replace `try!` and should be used instead.
/// Furthermore, `try` is a reserved word in Rust 2018, so if you must use
/// it, you will need to use the [raw-identifier syntax][ris]: `r#try`.
///
/// [ris]: https://doc.rust-lang.org/nightly/rust-by-example/compatibility/raw_identifiers.html
///
/// `try!` matches the given [`Result`]. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
Expand Down Expand Up @@ -278,14 +282,14 @@ macro_rules! debug_assert_ne {
///
/// // The previous method of quick returning Errors
/// fn write_to_file_using_try() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// try!(file.write_all(b"This is a list of my best friends."));
/// let mut file = r#try!(File::create("my_best_friends.txt"));
/// r#try!(file.write_all(b"This is a list of my best friends."));
/// Ok(())
/// }
///
/// // This is equivalent to:
/// fn write_to_file_using_match() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// let mut file = r#try!(File::create("my_best_friends.txt"));
/// match file.write_all(b"This is a list of my best friends.") {
/// Ok(v) => v,
/// Err(e) => return Err(From::from(e)),
Expand All @@ -296,14 +300,14 @@ macro_rules! debug_assert_ne {
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(alias = "?")]
macro_rules! try {
macro_rules! r#try {
($expr:expr) => (match $expr {
$crate::result::Result::Ok(val) => val,
$crate::result::Result::Err(err) => {
return $crate::result::Result::Err($crate::convert::From::from(err))
}
});
($expr:expr,) => (try!($expr));
($expr:expr,) => (r#try!($expr));
}

/// Write formatted data into a buffer.
Expand Down
47 changes: 23 additions & 24 deletions src/librustc/ty/inhabitedness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,16 @@ impl<'a, 'gcx, 'tcx> VariantDef {
substs: &'tcx Substs<'tcx>,
adt_kind: AdtKind) -> DefIdForest
{
match adt_kind {
AdtKind::Union => {
DefIdForest::intersection(tcx, self.fields.iter().map(|f| {
f.uninhabited_from(visited, tcx, substs, false)
}))
},
AdtKind::Struct => {
DefIdForest::union(tcx, self.fields.iter().map(|f| {
f.uninhabited_from(visited, tcx, substs, false)
}))
},
AdtKind::Enum => {
DefIdForest::union(tcx, self.fields.iter().map(|f| {
f.uninhabited_from(visited, tcx, substs, true)
}))
},
}
let is_enum = match adt_kind {
// For now, `union`s are never considered uninhabited.
// The precise semantics of inhabitedness with respect to unions is currently undecided.
AdtKind::Union => return DefIdForest::empty(),
AdtKind::Enum => true,
AdtKind::Struct => false,
};
DefIdForest::union(tcx, self.fields.iter().map(|f| {
f.uninhabited_from(visited, tcx, substs, is_enum)
}))
}
}

Expand All @@ -194,8 +187,8 @@ impl<'a, 'gcx, 'tcx> FieldDef {
visited: &mut FxHashMap<DefId, FxHashSet<&'tcx Substs<'tcx>>>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
substs: &'tcx Substs<'tcx>,
is_enum: bool) -> DefIdForest
{
is_enum: bool,
) -> DefIdForest {
let mut data_uninhabitedness = move || {
self.ty(tcx, substs).uninhabited_from(visited, tcx)
};
Expand Down Expand Up @@ -253,14 +246,16 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
let substs_set = visited.get_mut(&def.did).unwrap();
substs_set.remove(substs);
ret
},
}

Never => DefIdForest::full(tcx),

Tuple(ref tys) => {
DefIdForest::union(tcx, tys.iter().map(|ty| {
ty.uninhabited_from(visited, tcx)
}))
},
}

Array(ty, len) => {
match len.assert_usize(tcx) {
// If the array is definitely non-empty, it's uninhabited if
Expand All @@ -269,9 +264,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
_ => DefIdForest::empty()
}
}
Ref(_, ty, _) => {
ty.uninhabited_from(visited, tcx)
}

// References to uninitialised memory is valid for any type, including
// uninhabited types, in unsafe code, so we treat all references as
// inhabited.
// The precise semantics of inhabitedness with respect to references is currently
// undecided.
Ref(..) => DefIdForest::empty(),

_ => DefIdForest::empty(),
}
Expand Down
Loading

0 comments on commit 1a8b4e9

Please sign in to comment.