Skip to content

Commit 1a8b4e9

Browse files
committed
Auto merge of #56437 - Centril:rollup, r=Centril
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
2 parents 8660eba + c03c34c commit 1a8b4e9

File tree

66 files changed

+291
-290
lines changed

Some content is hidden

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

66 files changed

+291
-290
lines changed

Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,15 @@ name = "difference"
624624
version = "2.0.0"
625625
source = "registry+https://github.com/rust-lang/crates.io-index"
626626

627+
[[package]]
628+
name = "directories"
629+
version = "1.0.2"
630+
source = "registry+https://github.com/rust-lang/crates.io-index"
631+
dependencies = [
632+
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
633+
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
634+
]
635+
627636
[[package]]
628637
name = "dlmalloc"
629638
version = "0.0.0"
@@ -1316,6 +1325,7 @@ dependencies = [
13161325
"cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
13171326
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
13181327
"compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
1328+
"directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
13191329
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
13201330
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
13211331
"vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3288,6 +3298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
32883298
"checksum derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f57d78cf3bd45270dad4e70c21ec77a960b36c7a841ff9db76aaa775a8fb871"
32893299
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
32903300
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
3301+
"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
32913302
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
32923303
"checksum elasticlunr-rs 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4837d77a1e157489a3933b743fd774ae75074e0e390b2b7f071530048a0d87ee"
32933304
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"

src/bootstrap/doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -915,13 +915,13 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()>
915915
}
916916
if let Ok(m) = fs::symlink_metadata(dst) {
917917
if m.file_type().is_dir() {
918-
try!(fs::remove_dir_all(dst));
918+
fs::remove_dir_all(dst)?;
919919
} else {
920920
// handle directory junctions on windows by falling back to
921921
// `remove_dir`.
922-
try!(fs::remove_file(dst).or_else(|_| {
922+
fs::remove_file(dst).or_else(|_| {
923923
fs::remove_dir(dst)
924-
}));
924+
})?;
925925
}
926926
}
927927

src/bootstrap/util.rs

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

208-
try!(fs::create_dir(junction));
208+
fs::create_dir(junction)?;
209209

210-
let path = try!(to_u16s(junction));
210+
let path = to_u16s(junction)?;
211211

212212
unsafe {
213213
let h = CreateFileW(path.as_ptr(),

src/doc/edition-guide

src/doc/rustc-guide

src/doc/unstable-book/src/language-features/marker-trait-attr.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ when they'd need to do the same thing for every type anyway).
1717
```rust
1818
#![feature(marker_trait_attr)]
1919

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

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

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

27-
fn foo<T: MyMarker>(t: T) -> T {
28-
t
29+
fn cheap_clone<T: CheapToClone>(t: T) -> T {
30+
t.clone()
2931
}
3032
```
3133

src/doc/unstable-book/src/language-features/self-in-typedefs.md

-24
This file was deleted.

src/liballoc/collections/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl<T: Ord> BinaryHeap<T> {
529529
/// assert!(heap.capacity() >= 10);
530530
/// ```
531531
#[inline]
532-
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
532+
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
533533
pub fn shrink_to(&mut self, min_capacity: usize) {
534534
self.data.shrink_to(min_capacity)
535535
}

src/liballoc/collections/vec_deque.rs

+28-34
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

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

@@ -1886,16 +1886,16 @@ impl<T> VecDeque<T> {
18861886
debug_assert!(!self.is_full());
18871887
}
18881888
}
1889-
}
18901889

1891-
impl<T: Clone> VecDeque<T> {
1892-
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
1893-
/// either by removing excess elements from the back or by appending clones of `value`
1894-
/// to the back.
1890+
/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
1891+
/// either by removing excess elements from the back or by appending
1892+
/// elements generated by calling `generator` to the back.
18951893
///
18961894
/// # Examples
18971895
///
18981896
/// ```
1897+
/// #![feature(vec_resize_with)]
1898+
///
18991899
/// use std::collections::VecDeque;
19001900
///
19011901
/// let mut buf = VecDeque::new();
@@ -1904,32 +1904,36 @@ impl<T: Clone> VecDeque<T> {
19041904
/// buf.push_back(15);
19051905
/// assert_eq!(buf, [5, 10, 15]);
19061906
///
1907-
/// buf.resize(2, 0);
1907+
/// buf.resize_with(5, Default::default);
1908+
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
1909+
///
1910+
/// buf.resize_with(2, || unreachable!());
19081911
/// assert_eq!(buf, [5, 10]);
19091912
///
1910-
/// buf.resize(5, 20);
1911-
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
1913+
/// let mut state = 100;
1914+
/// buf.resize_with(5, || { state += 1; state });
1915+
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
19121916
/// ```
1913-
#[stable(feature = "deque_extras", since = "1.16.0")]
1914-
pub fn resize(&mut self, new_len: usize, value: T) {
1917+
#[unstable(feature = "vec_resize_with", issue = "41758")]
1918+
pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) {
19151919
let len = self.len();
19161920

19171921
if new_len > len {
1918-
self.extend(repeat(value).take(new_len - len))
1922+
self.extend(repeat_with(generator).take(new_len - len))
19191923
} else {
19201924
self.truncate(new_len);
19211925
}
19221926
}
1927+
}
19231928

1924-
/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
1925-
/// either by removing excess elements from the back or by appending
1926-
/// elements generated by calling `generator` to the back.
1929+
impl<T: Clone> VecDeque<T> {
1930+
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
1931+
/// either by removing excess elements from the back or by appending clones of `value`
1932+
/// to the back.
19271933
///
19281934
/// # Examples
19291935
///
19301936
/// ```
1931-
/// #![feature(vec_resize_with)]
1932-
///
19331937
/// use std::collections::VecDeque;
19341938
///
19351939
/// let mut buf = VecDeque::new();
@@ -1938,25 +1942,15 @@ impl<T: Clone> VecDeque<T> {
19381942
/// buf.push_back(15);
19391943
/// assert_eq!(buf, [5, 10, 15]);
19401944
///
1941-
/// buf.resize_with(5, Default::default);
1942-
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
1943-
///
1944-
/// buf.resize_with(2, || unreachable!());
1945+
/// buf.resize(2, 0);
19451946
/// assert_eq!(buf, [5, 10]);
19461947
///
1947-
/// let mut state = 100;
1948-
/// buf.resize_with(5, || { state += 1; state });
1949-
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
1948+
/// buf.resize(5, 20);
1949+
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
19501950
/// ```
1951-
#[unstable(feature = "vec_resize_with", issue = "41758")]
1952-
pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) {
1953-
let len = self.len();
1954-
1955-
if new_len > len {
1956-
self.extend(repeat_with(generator).take(new_len - len))
1957-
} else {
1958-
self.truncate(new_len);
1959-
}
1951+
#[stable(feature = "deque_extras", since = "1.16.0")]
1952+
pub fn resize(&mut self, new_len: usize, value: T) {
1953+
self.resize_with(new_len, || value.clone());
19601954
}
19611955
}
19621956

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl String {
10501050
/// assert!(s.capacity() >= 3);
10511051
/// ```
10521052
#[inline]
1053-
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
1053+
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
10541054
pub fn shrink_to(&mut self, min_capacity: usize) {
10551055
self.vec.shrink_to(min_capacity)
10561056
}

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl<T> Vec<T> {
613613
/// vec.shrink_to(0);
614614
/// assert!(vec.capacity() >= 3);
615615
/// ```
616-
#[unstable(feature = "shrink_to", reason = "new API", issue="0")]
616+
#[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
617617
pub fn shrink_to(&mut self, min_capacity: usize) {
618618
self.buf.shrink_to_fit(cmp::max(self.len, min_capacity));
619619
}

src/libcore/macros.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ macro_rules! debug_assert_ne {
238238
/// with converting downstream errors.
239239
///
240240
/// The `?` operator was added to replace `try!` and should be used instead.
241+
/// Furthermore, `try` is a reserved word in Rust 2018, so if you must use
242+
/// it, you will need to use the [raw-identifier syntax][ris]: `r#try`.
243+
///
244+
/// [ris]: https://doc.rust-lang.org/nightly/rust-by-example/compatibility/raw_identifiers.html
241245
///
242246
/// `try!` matches the given [`Result`]. In case of the `Ok` variant, the
243247
/// expression has the value of the wrapped value.
@@ -278,14 +282,14 @@ macro_rules! debug_assert_ne {
278282
///
279283
/// // The previous method of quick returning Errors
280284
/// fn write_to_file_using_try() -> Result<(), MyError> {
281-
/// let mut file = try!(File::create("my_best_friends.txt"));
282-
/// try!(file.write_all(b"This is a list of my best friends."));
285+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
286+
/// r#try!(file.write_all(b"This is a list of my best friends."));
283287
/// Ok(())
284288
/// }
285289
///
286290
/// // This is equivalent to:
287291
/// fn write_to_file_using_match() -> Result<(), MyError> {
288-
/// let mut file = try!(File::create("my_best_friends.txt"));
292+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
289293
/// match file.write_all(b"This is a list of my best friends.") {
290294
/// Ok(v) => v,
291295
/// Err(e) => return Err(From::from(e)),
@@ -296,14 +300,14 @@ macro_rules! debug_assert_ne {
296300
#[macro_export]
297301
#[stable(feature = "rust1", since = "1.0.0")]
298302
#[doc(alias = "?")]
299-
macro_rules! try {
303+
macro_rules! r#try {
300304
($expr:expr) => (match $expr {
301305
$crate::result::Result::Ok(val) => val,
302306
$crate::result::Result::Err(err) => {
303307
return $crate::result::Result::Err($crate::convert::From::from(err))
304308
}
305309
});
306-
($expr:expr,) => (try!($expr));
310+
($expr:expr,) => (r#try!($expr));
307311
}
308312

309313
/// Write formatted data into a buffer.

src/librustc/ty/inhabitedness/mod.rs

+23-24
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,16 @@ impl<'a, 'gcx, 'tcx> VariantDef {
167167
substs: &'tcx Substs<'tcx>,
168168
adt_kind: AdtKind) -> DefIdForest
169169
{
170-
match adt_kind {
171-
AdtKind::Union => {
172-
DefIdForest::intersection(tcx, self.fields.iter().map(|f| {
173-
f.uninhabited_from(visited, tcx, substs, false)
174-
}))
175-
},
176-
AdtKind::Struct => {
177-
DefIdForest::union(tcx, self.fields.iter().map(|f| {
178-
f.uninhabited_from(visited, tcx, substs, false)
179-
}))
180-
},
181-
AdtKind::Enum => {
182-
DefIdForest::union(tcx, self.fields.iter().map(|f| {
183-
f.uninhabited_from(visited, tcx, substs, true)
184-
}))
185-
},
186-
}
170+
let is_enum = match adt_kind {
171+
// For now, `union`s are never considered uninhabited.
172+
// The precise semantics of inhabitedness with respect to unions is currently undecided.
173+
AdtKind::Union => return DefIdForest::empty(),
174+
AdtKind::Enum => true,
175+
AdtKind::Struct => false,
176+
};
177+
DefIdForest::union(tcx, self.fields.iter().map(|f| {
178+
f.uninhabited_from(visited, tcx, substs, is_enum)
179+
}))
187180
}
188181
}
189182

@@ -194,8 +187,8 @@ impl<'a, 'gcx, 'tcx> FieldDef {
194187
visited: &mut FxHashMap<DefId, FxHashSet<&'tcx Substs<'tcx>>>,
195188
tcx: TyCtxt<'a, 'gcx, 'tcx>,
196189
substs: &'tcx Substs<'tcx>,
197-
is_enum: bool) -> DefIdForest
198-
{
190+
is_enum: bool,
191+
) -> DefIdForest {
199192
let mut data_uninhabitedness = move || {
200193
self.ty(tcx, substs).uninhabited_from(visited, tcx)
201194
};
@@ -253,14 +246,16 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
253246
let substs_set = visited.get_mut(&def.did).unwrap();
254247
substs_set.remove(substs);
255248
ret
256-
},
249+
}
257250

258251
Never => DefIdForest::full(tcx),
252+
259253
Tuple(ref tys) => {
260254
DefIdForest::union(tcx, tys.iter().map(|ty| {
261255
ty.uninhabited_from(visited, tcx)
262256
}))
263-
},
257+
}
258+
264259
Array(ty, len) => {
265260
match len.assert_usize(tcx) {
266261
// If the array is definitely non-empty, it's uninhabited if
@@ -269,9 +264,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
269264
_ => DefIdForest::empty()
270265
}
271266
}
272-
Ref(_, ty, _) => {
273-
ty.uninhabited_from(visited, tcx)
274-
}
267+
268+
// References to uninitialised memory is valid for any type, including
269+
// uninhabited types, in unsafe code, so we treat all references as
270+
// inhabited.
271+
// The precise semantics of inhabitedness with respect to references is currently
272+
// undecided.
273+
Ref(..) => DefIdForest::empty(),
275274

276275
_ => DefIdForest::empty(),
277276
}

0 commit comments

Comments
 (0)