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 14 pull requests #56437

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c343bbd
update miri
RalfJung Nov 28, 2018
682f0f8
Consider references and unions potentially inhabited during privacy-r…
varkor Nov 20, 2018
d2b3407
Add a test for uninhabitedness changes
varkor Nov 20, 2018
32a8dec
Clarify undecided semantics
varkor Nov 20, 2018
46ef9f8
Fix broken tests
varkor Nov 20, 2018
1cdf5df
Fix error message after rebase
varkor Nov 29, 2018
113ae0f
update miri
RalfJung Nov 30, 2018
1560a75
Refer to the second borrow as the "second borrow".
wildarch Nov 30, 2018
aa5a4ef
Removed feature gate.
alexreg Nov 30, 2018
7bc1255
Removed chapter from Unstable Book.
alexreg Nov 30, 2018
d609fdf
Updated ui tests.
alexreg Nov 30, 2018
f107514
Deal with EINTR in net timeout tests
cuviper Nov 30, 2018
f4cde5b
stabilize std::dbg!(...)
Centril Dec 1, 2018
4c2c523
Move VecDeque::resize_with out of the impl<T:Clone> block
scottmcm Dec 1, 2018
a3b7a21
Improve the unstable book example for `#[marker]`
scottmcm Dec 1, 2018
df0ab06
Update tracking issue for `extern_crate_self`
petrochenkov Dec 1, 2018
08a6cf3
Remove unneeded body class selector
GuillaumeGomez Dec 1, 2018
12c9b79
Fix failing tidy (line endings on Windows)
petrochenkov Dec 1, 2018
e7e9692
remove some uses of try!
mark-i-m Dec 1, 2018
074f975
Explain raw identifer syntax
mark-i-m Dec 2, 2018
1fca907
link to raw identifiers
mark-i-m Dec 2, 2018
1e18cc9
Update issue number of `shrink_to` methods to point the tracking issue
ordovicia Dec 2, 2018
63b7bf8
Rollup merge of #56110 - varkor:inhabitedness-union-enum, r=cramertj
Centril Dec 2, 2018
07504b2
Rollup merge of #56305 - RalfJung:miri, r=oli-obk
Centril Dec 2, 2018
1e8c93c
Rollup merge of #56366 - alexreg:stabilise-self_in_typedefs, r=Centril
Centril Dec 2, 2018
05aedcb
Rollup merge of #56372 - wildarch:issue-55314-second-borrow-ref, r=da…
Centril Dec 2, 2018
4e94bec
Rollup merge of #56394 - cuviper:interrupted-timeout, r=sfackler
Centril Dec 2, 2018
aa92cc9
Rollup merge of #56395 - Centril:stabilize-dbg-macro, r=SimonSapin
Centril Dec 2, 2018
f352eec
Rollup merge of #56401 - scottmcm:vecdeque-resize-with, r=dtolnay
Centril Dec 2, 2018
101e116
Rollup merge of #56402 - scottmcm:better-marker-trait-example, r=Centril
Centril Dec 2, 2018
3993dc9
Rollup merge of #56412 - petrochenkov:extself, r=Centril
Centril Dec 2, 2018
298e681
Rollup merge of #56416 - GuillaumeGomez:css-body, r=QuietMisdreavus
Centril Dec 2, 2018
6311bde
Rollup merge of #56418 - petrochenkov:wintidy, r=nagisa
Centril Dec 2, 2018
705da41
Rollup merge of #56419 - mark-i-m:remove-try, r=Centril
Centril Dec 2, 2018
e292b3c
Rollup merge of #56424 - mark-i-m:explain-raw, r=Centril
Centril Dec 2, 2018
c03c34c
Rollup merge of #56432 - ordovicia:shrink-to-issue, r=Centril
Centril Dec 2, 2018
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 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