Skip to content

Commit 0c999ed

Browse files
committed
Auto merge of #56451 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests Successful merges: - #56141 ([std] Osstr len clarity) - #56366 (Stabilize self_in_typedefs feature) - #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!) - #56432 (Update issue number of `shrink_to` methods to point the tracking issue) - #56433 (Add description about `crate` for parse_visibility's comment) - #56435 (make the C part of compiler-builtins opt-out) - #56438 (Remove not used `DotEq` token) Failed merges: r? @ghost
2 parents 9cd3bef + ac363d8 commit 0c999ed

Some content is hidden

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

50 files changed

+140
-224
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ macro_rules! debug_assert_ne {
278278
///
279279
/// // The previous method of quick returning Errors
280280
/// 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."));
281+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
282+
/// r#try!(file.write_all(b"This is a list of my best friends."));
283283
/// Ok(())
284284
/// }
285285
///
286286
/// // This is equivalent to:
287287
/// fn write_to_file_using_match() -> Result<(), MyError> {
288-
/// let mut file = try!(File::create("my_best_friends.txt"));
288+
/// let mut file = r#try!(File::create("my_best_friends.txt"));
289289
/// match file.write_all(b"This is a list of my best friends.") {
290290
/// Ok(v) => v,
291291
/// Err(e) => return Err(From::from(e)),
@@ -296,14 +296,14 @@ macro_rules! debug_assert_ne {
296296
#[macro_export]
297297
#[stable(feature = "rust1", since = "1.0.0")]
298298
#[doc(alias = "?")]
299-
macro_rules! try {
299+
macro_rules! r#try {
300300
($expr:expr) => (match $expr {
301301
$crate::result::Result::Ok(val) => val,
302302
$crate::result::Result::Err(err) => {
303303
return $crate::result::Result::Err($crate::convert::From::from(err))
304304
}
305305
});
306-
($expr:expr,) => (try!($expr));
306+
($expr:expr,) => (r#try!($expr));
307307
}
308308

309309
/// Write formatted data into a buffer.

src/librustc/ich/impls_syntax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>(
314314
token::Token::DotDot |
315315
token::Token::DotDotDot |
316316
token::Token::DotDotEq |
317-
token::Token::DotEq |
318317
token::Token::Comma |
319318
token::Token::Semi |
320319
token::Token::Colon |

src/librustc_incremental/persist/fs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
659659
let mut session_directories = FxHashSet::default();
660660
let mut lock_files = FxHashSet::default();
661661

662-
for dir_entry in try!(crate_directory.read_dir()) {
662+
for dir_entry in crate_directory.read_dir()? {
663663
let dir_entry = match dir_entry {
664664
Ok(dir_entry) => dir_entry,
665665
_ => {
@@ -887,7 +887,7 @@ fn all_except_most_recent(deletion_candidates: Vec<(SystemTime, PathBuf, Option<
887887
/// into the '\\?\' format, which supports much longer paths.
888888
fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
889889
if p.exists() {
890-
let canonicalized = try!(p.canonicalize());
890+
let canonicalized = p.canonicalize()?;
891891
std_fs::remove_dir_all(canonicalized)
892892
} else {
893893
Ok(())
@@ -896,7 +896,7 @@ fn safe_remove_dir_all(p: &Path) -> io::Result<()> {
896896

897897
fn safe_remove_file(p: &Path) -> io::Result<()> {
898898
if p.exists() {
899-
let canonicalized = try!(p.canonicalize());
899+
let canonicalized = p.canonicalize()?;
900900
std_fs::remove_file(canonicalized)
901901
} else {
902902
Ok(())

src/librustc_mir/dataflow/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
128128
proj: &PlaceProjection<'tcx>)
129129
-> Result<MovePathIndex, MoveError<'tcx>>
130130
{
131-
let base = try!(self.move_path_for(&proj.base));
131+
let base = self.move_path_for(&proj.base)?;
132132
let mir = self.builder.mir;
133133
let tcx = self.builder.tcx;
134134
let place_ty = proj.base.ty(mir, tcx).to_ty(tcx);

src/librustc_resolve/lib.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -2373,13 +2373,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
23732373
self.with_current_self_item(item, |this| {
23742374
this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
23752375
let item_def_id = this.definitions.local_def_id(item.id);
2376-
if this.session.features_untracked().self_in_typedefs {
2377-
this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| {
2378-
visit::walk_item(this, item);
2379-
});
2380-
} else {
2376+
this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| {
23812377
visit::walk_item(this, item);
2382-
}
2378+
});
23832379
});
23842380
});
23852381
}
@@ -3185,16 +3181,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
31853181
if is_self_type(path, ns) {
31863182
__diagnostic_used!(E0411);
31873183
err.code(DiagnosticId::Error("E0411".into()));
3188-
let available_in = if this.session.features_untracked().self_in_typedefs {
3189-
"impls, traits, and type definitions"
3190-
} else {
3191-
"traits and impls"
3192-
};
3193-
err.span_label(span, format!("`Self` is only available in {}", available_in));
3194-
if this.current_self_item.is_some() && nightly_options::is_nightly_build() {
3195-
err.help("add #![feature(self_in_typedefs)] to the crate attributes \
3196-
to enable");
3197-
}
3184+
err.span_label(span, format!("`Self` is only available in impls, traits, \
3185+
and type definitions"));
31983186
return (err, Vec::new());
31993187
}
32003188
if is_self_value(path, ns) {

src/librustc_target/spec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ impl Target {
995995

996996
key!(is_builtin, bool);
997997
key!(linker, optional);
998-
try!(key!(lld_flavor, LldFlavor));
998+
key!(lld_flavor, LldFlavor)?;
999999
key!(pre_link_args, link_args);
10001000
key!(pre_link_args_crt, link_args);
10011001
key!(pre_link_objects_exe, list);
@@ -1038,7 +1038,7 @@ impl Target {
10381038
key!(no_default_libraries, bool);
10391039
key!(position_independent_executables, bool);
10401040
key!(needs_plt, bool);
1041-
try!(key!(relro_level, RelroLevel));
1041+
key!(relro_level, RelroLevel)?;
10421042
key!(archive_format);
10431043
key!(allow_asm, bool);
10441044
key!(custom_unwind_resume, bool);
@@ -1048,7 +1048,7 @@ impl Target {
10481048
key!(max_atomic_width, Option<u64>);
10491049
key!(min_atomic_width, Option<u64>);
10501050
key!(atomic_cas, bool);
1051-
try!(key!(panic_strategy, PanicStrategy));
1051+
key!(panic_strategy, PanicStrategy)?;
10521052
key!(crt_static_allows_dylibs, bool);
10531053
key!(crt_static_default, bool);
10541054
key!(crt_static_respected, bool);

src/librustdoc/html/highlight.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'a> Classifier<'a> {
346346
token::Lifetime(..) => Class::Lifetime,
347347

348348
token::Eof | token::Interpolated(..) |
349-
token::Tilde | token::At | token::DotEq | token::SingleQuote => Class::None,
349+
token::Tilde | token::At| token::SingleQuote => Class::None,
350350
};
351351

352352
// Anything that didn't return above is the simple case where we the

0 commit comments

Comments
 (0)