From 46cd4103818c573ca0ca9cf450ae1a006dca27bf Mon Sep 17 00:00:00 2001 From: tinaun Date: Fri, 13 Oct 2017 02:00:45 -0400 Subject: [PATCH 01/12] remove duplicate stubs --- src/doc/unstable-book/src/library-features/proc-macro.md | 7 ------- src/tools/tidy/src/unstable_book.rs | 4 +++- src/tools/unstable-book-gen/src/main.rs | 6 +++++- 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 src/doc/unstable-book/src/library-features/proc-macro.md diff --git a/src/doc/unstable-book/src/library-features/proc-macro.md b/src/doc/unstable-book/src/library-features/proc-macro.md deleted file mode 100644 index 19e7f663c7ac3..0000000000000 --- a/src/doc/unstable-book/src/library-features/proc-macro.md +++ /dev/null @@ -1,7 +0,0 @@ -# `proc_macro` - -The tracking issue for this feature is: [#38356] - -[#38356]: https://github.com/rust-lang/rust/issues/38356 - ------------------------- diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index ff032b14ad1d5..e8eac0b87033a 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -87,7 +87,9 @@ pub fn check(path: &path::Path, bad: &mut bool) { // Library features let lang_features = collect_lang_features(path); - let lib_features = collect_lib_features(path); + let lib_features = collect_lib_features(path).iter().filter(|(name, _) { + !lang_features.contains_key(name) + }).collect(); let unstable_lib_feature_names = collect_unstable_feature_names(&lib_features); let unstable_book_lib_features_section_file_names = diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 5c2bd1e3e087d..189f69ab7cb63 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -129,7 +129,11 @@ fn main() { let dest_path = Path::new(&dest_path_str).join("src"); let lang_features = collect_lang_features(src_path); - let lib_features = collect_lib_features(src_path); + let lib_features = collect_lib_features(src_path) + .iter() + .filter(|(name, _) { + !lang_features.contains_key(name) + }).collect(); let doc_src_path = src_path.join(PATH_STR); From d7cdd56df49436f59cecd08fef8d8114db7cb76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Mon, 1 Jan 2018 14:03:49 +0700 Subject: [PATCH 02/12] memchr: fix variable name in docstrings --- src/libcore/slice/memchr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs index 00183be97e751..69c9cb37dcfd3 100644 --- a/src/libcore/slice/memchr.rs +++ b/src/libcore/slice/memchr.rs @@ -56,7 +56,7 @@ fn repeat_byte(b: u8) -> usize { rep } -/// Return the first index matching the byte `a` in `text`. +/// Return the first index matching the byte `x` in `text`. pub fn memchr(x: u8, text: &[u8]) -> Option { // Scan for a single byte value by reading two `usize` words at a time. // @@ -101,7 +101,7 @@ pub fn memchr(x: u8, text: &[u8]) -> Option { text[offset..].iter().position(|elt| *elt == x).map(|i| offset + i) } -/// Return the last index matching the byte `a` in `text`. +/// Return the last index matching the byte `x` in `text`. pub fn memrchr(x: u8, text: &[u8]) -> Option { // Scan for a single byte value by reading two `usize` words at a time. // From 31a4cba01077b3f27622e1b42878407c65964d71 Mon Sep 17 00:00:00 2001 From: matthewjasper Date: Mon, 1 Jan 2018 17:51:37 +0000 Subject: [PATCH 03/12] Delay panic from incoherent drop implementation --- src/librustc_typeck/check/dropck.rs | 10 ++++++---- src/test/compile-fail/issue-41974.rs | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/test/compile-fail/issue-41974.rs diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 55700c452e57b..4aed688027f76 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -59,11 +59,13 @@ pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } _ => { // Destructors only work on nominal types. This was - // already checked by coherence, so we can panic here. + // already checked by coherence, but compilation may + // not have been terminated. let span = tcx.def_span(drop_impl_did); - span_bug!(span, - "should have been rejected by coherence check: {}", - dtor_self_type); + tcx.sess.delay_span_bug(span, + &format!("should have been rejected by coherence check: {}", + dtor_self_type)); + Err(ErrorReported) } } } diff --git a/src/test/compile-fail/issue-41974.rs b/src/test/compile-fail/issue-41974.rs new file mode 100644 index 0000000000000..5c9077783c794 --- /dev/null +++ b/src/test/compile-fail/issue-41974.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +struct Flags; + +trait A { +} + +impl Drop for T where T: A { //~ ERROR E0119 + //~^ ERROR E0120 + //~| ERROR E0210 + fn drop(&mut self) { + } +} + +fn main() {} From 05cbe6d7db043c18b99a306ace7bbf3ff59c82e8 Mon Sep 17 00:00:00 2001 From: Who? Me?! Date: Mon, 1 Jan 2018 13:17:25 -0600 Subject: [PATCH 04/12] Fix typo --- src/librustc/mir/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/mir/README.md b/src/librustc/mir/README.md index fb0c7ce1df23d..cac86be0fcb75 100644 --- a/src/librustc/mir/README.md +++ b/src/librustc/mir/README.md @@ -59,7 +59,7 @@ ensure that, before the MIR at a particular phase in the processing pipeline is stolen, anyone who may want to read from it has already done so. Concretely, this means that if you have some query `foo(D)` that wants to access the result of `mir_const(D)` or -`mir_validated(D)`, you need to have the successor pass either "force" +`mir_validated(D)`, you need to have the successor pass "force" `foo(D)` using `ty::queries::foo::force(...)`. This will force a query to execute even though you don't directly require its result. From 5c25b0c5948d730d7fa7f6e581e8b91d4467753e Mon Sep 17 00:00:00 2001 From: tinaun Date: Mon, 1 Jan 2018 19:32:44 -0500 Subject: [PATCH 05/12] prevent generating duplicate stubs --- src/tools/tidy/src/unstable_book.rs | 2 +- src/tools/unstable-book-gen/src/main.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index e8eac0b87033a..a4a35a706fd91 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -87,7 +87,7 @@ pub fn check(path: &path::Path, bad: &mut bool) { // Library features let lang_features = collect_lang_features(path); - let lib_features = collect_lib_features(path).iter().filter(|(name, _) { + let lib_features = collect_lib_features(path).into_iter().filter(|&(ref name, _)| { !lang_features.contains_key(name) }).collect(); diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 189f69ab7cb63..f66a18547c3b5 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -129,11 +129,9 @@ fn main() { let dest_path = Path::new(&dest_path_str).join("src"); let lang_features = collect_lang_features(src_path); - let lib_features = collect_lib_features(src_path) - .iter() - .filter(|(name, _) { - !lang_features.contains_key(name) - }).collect(); + let lib_features = collect_lib_features(src_path).into_iter().filter(|&(ref name, _)| { + !lang_features.contains_key(name) + }).collect(); let doc_src_path = src_path.join(PATH_STR); From 301e457989ea80926a98f3279dc2e42da47e466d Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 1 Jan 2018 19:06:59 -0800 Subject: [PATCH 06/12] Fix panic condition docs for Vec::insert. Fixes https://github.com/rust-lang/rust/issues/47065. --- src/liballoc/vec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 93d7e66b7b203..301e44632b823 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -715,7 +715,7 @@ impl Vec { /// /// # Panics /// - /// Panics if `index` is out of bounds. + /// Panics if `index > len`. /// /// # Examples /// From 9957cf60232d05db250e6c3b89210850bc7b1839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 2 Jan 2018 01:46:50 +0200 Subject: [PATCH 07/12] Consistently use chunk_size as the field name for Chunks and ChunksMut Previously Chunks used size and ChunksMut used chunk_size --- src/liballoc/slice.rs | 12 ++++++------ src/libcore/slice/mod.rs | 30 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index ab574c9f7e769..b880616833a4e 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -606,14 +606,14 @@ impl [T] { core_slice::SliceExt::windows(self, size) } - /// Returns an iterator over `size` elements of the slice at a - /// time. The chunks are slices and do not overlap. If `size` does + /// Returns an iterator over `chunk_size` elements of the slice at a + /// time. The chunks are slices and do not overlap. If `chunk_size` does /// not divide the length of the slice, then the last chunk will - /// not have length `size`. + /// not have length `chunk_size`. /// /// # Panics /// - /// Panics if `size` is 0. + /// Panics if `chunk_size` is 0. /// /// # Examples /// @@ -627,8 +627,8 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn chunks(&self, size: usize) -> Chunks { - core_slice::SliceExt::chunks(self, size) + pub fn chunks(&self, chunk_size: usize) -> Chunks { + core_slice::SliceExt::chunks(self, chunk_size) } /// Returns an iterator over `chunk_size` elements of the slice at a time. diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 20d586a402170..817e309cf7766 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -348,9 +348,9 @@ impl SliceExt for [T] { } #[inline] - fn chunks(&self, size: usize) -> Chunks { - assert!(size != 0); - Chunks { v: self, size: size } + fn chunks(&self, chunk_size: usize) -> Chunks { + assert!(chunk_size != 0); + Chunks { v: self, chunk_size: chunk_size } } #[inline] @@ -2117,7 +2117,7 @@ impl<'a, T> ExactSizeIterator for Windows<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Windows<'a, T> {} -/// An iterator over a slice in (non-overlapping) chunks (`size` elements at a +/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a /// time). /// /// When the slice len is not evenly divided by the chunk size, the last slice @@ -2131,7 +2131,7 @@ impl<'a, T> FusedIterator for Windows<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] pub struct Chunks<'a, T:'a> { v: &'a [T], - size: usize + chunk_size: usize } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` @@ -2140,7 +2140,7 @@ impl<'a, T> Clone for Chunks<'a, T> { fn clone(&self) -> Chunks<'a, T> { Chunks { v: self.v, - size: self.size, + chunk_size: self.chunk_size, } } } @@ -2154,7 +2154,7 @@ impl<'a, T> Iterator for Chunks<'a, T> { if self.v.is_empty() { None } else { - let chunksz = cmp::min(self.v.len(), self.size); + let chunksz = cmp::min(self.v.len(), self.chunk_size); let (fst, snd) = self.v.split_at(chunksz); self.v = snd; Some(fst) @@ -2166,8 +2166,8 @@ impl<'a, T> Iterator for Chunks<'a, T> { if self.v.is_empty() { (0, Some(0)) } else { - let n = self.v.len() / self.size; - let rem = self.v.len() % self.size; + let n = self.v.len() / self.chunk_size; + let rem = self.v.len() % self.chunk_size; let n = if rem > 0 { n+1 } else { n }; (n, Some(n)) } @@ -2180,12 +2180,12 @@ impl<'a, T> Iterator for Chunks<'a, T> { #[inline] fn nth(&mut self, n: usize) -> Option { - let (start, overflow) = n.overflowing_mul(self.size); + let (start, overflow) = n.overflowing_mul(self.chunk_size); if start >= self.v.len() || overflow { self.v = &[]; None } else { - let end = match start.checked_add(self.size) { + let end = match start.checked_add(self.chunk_size) { Some(sum) => cmp::min(self.v.len(), sum), None => self.v.len(), }; @@ -2200,7 +2200,7 @@ impl<'a, T> Iterator for Chunks<'a, T> { if self.v.is_empty() { None } else { - let start = (self.v.len() - 1) / self.size * self.size; + let start = (self.v.len() - 1) / self.chunk_size * self.chunk_size; Some(&self.v[start..]) } } @@ -2213,8 +2213,8 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { if self.v.is_empty() { None } else { - let remainder = self.v.len() % self.size; - let chunksz = if remainder != 0 { remainder } else { self.size }; + let remainder = self.v.len() % self.chunk_size; + let chunksz = if remainder != 0 { remainder } else { self.chunk_size }; let (fst, snd) = self.v.split_at(self.v.len() - chunksz); self.v = fst; Some(snd) @@ -2228,7 +2228,7 @@ impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Chunks<'a, T> {} -/// An iterator over a slice in (non-overlapping) mutable chunks (`size` +/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` /// elements at a time). When the slice len is not evenly divided by the chunk /// size, the last slice of the iteration will be the remainder. /// From c096b3a451b38a84d3168bd2f4ce10a37d61e1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 2 Jan 2018 01:57:46 +0200 Subject: [PATCH 08/12] Use assert!(chunk_size != 0) instead of > 0 for usize value --- src/libcore/slice/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 817e309cf7766..6b6ec7147b306 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -532,7 +532,7 @@ impl SliceExt for [T] { #[inline] fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut { - assert!(chunk_size > 0); + assert!(chunk_size != 0); ChunksMut { v: self, chunk_size: chunk_size } } From d5acd235658bd8d52db53aa10452620642b715dc Mon Sep 17 00:00:00 2001 From: David Ross Date: Mon, 1 Jan 2018 19:14:32 -0800 Subject: [PATCH 09/12] Mention SliceConcatExt's stability in its docs SliceConcatExt's status as an unstable trait with stable methods is documented in the compiler error for using it, and in https://doc.rust-lang.org/std/prelude/, but it is not mentioned in the trait itself. Mentioning the methods can be used in stable rust today should help users who are looking for a `join` method while working on stable rust. --- src/liballoc/slice.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index ab574c9f7e769..fecea3339d2b9 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -1725,6 +1725,14 @@ impl [u8] { reason = "trait should not have to exist", issue = "27747")] /// An extension trait for concatenating slices +/// +/// While this trait is unstable, the methods are stable. `SliceConcatExt` is +/// included in the [standard library prelude], so you can use [`join()`] and +/// [`concat()`] as if they existed on `[T]` itself. +/// +/// [standard library prelude]: ../../std/prelude/index.html +/// [`join()`]: #tymethod.join +/// [`concat()`]: #tymethod.concat pub trait SliceConcatExt { #[unstable(feature = "slice_concat_ext", reason = "trait should not have to exist", From 0772b6faed23d736f5e63738dcd8839193cf0660 Mon Sep 17 00:00:00 2001 From: Johannes Boczek Date: Tue, 2 Jan 2018 19:47:44 +0100 Subject: [PATCH 10/12] Defocus search bar in rustdoc pages Escape now removes focus from the search bar --- src/librustdoc/html/static/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 559f8494fc3c0..5e4a02994b116 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -258,6 +258,7 @@ addClass(search, "hidden"); removeClass(document.getElementById("main"), "hidden"); } + defocusSearchBar(); break; case "s": @@ -1884,3 +1885,8 @@ function focusSearchBar() { document.getElementsByClassName('search-input')[0].focus(); } + +// Removes the focus from the search bar +function defocusSearchBar() { + document.getElementsByClassName('search-input')[0].blur(); +} \ No newline at end of file From 3153d23bb79b2ce7a822acb4859823a713adbc35 Mon Sep 17 00:00:00 2001 From: Johannes Boczek Date: Tue, 2 Jan 2018 19:58:06 +0100 Subject: [PATCH 11/12] Indentation fix Fixed intentaion (tabs -> spaces) Added trailing newline --- src/librustdoc/html/static/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 5e4a02994b116..c128a812b93b0 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -258,7 +258,7 @@ addClass(search, "hidden"); removeClass(document.getElementById("main"), "hidden"); } - defocusSearchBar(); + defocusSearchBar(); break; case "s": @@ -1889,4 +1889,4 @@ function focusSearchBar() { // Removes the focus from the search bar function defocusSearchBar() { document.getElementsByClassName('search-input')[0].blur(); -} \ No newline at end of file +} From f3ef077b910c9dada20eb106e8469ec071c27dad Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 2 Jan 2018 13:30:44 -0800 Subject: [PATCH 12/12] Document when LineWriter flushes; document errors for into_inner. Fixes https://github.com/rust-lang/rust/issues/42468. --- src/libstd/io/buffered.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 8308ab48d9ceb..7001d8e042196 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -486,6 +486,10 @@ impl BufWriter { /// /// The buffer is written out before returning the writer. /// + /// # Errors + /// + /// An `Err` will be returned if an error occurs while flushing the buffer. + /// /// # Examples /// /// ```no_run @@ -650,6 +654,9 @@ impl fmt::Display for IntoInnerError { /// completed, rather than the entire buffer at once. Enter `LineWriter`. It /// does exactly that. /// +/// Like [`BufWriter`], a `LineWriter`’s buffer will also be flushed when the +/// `LineWriter` goes out of scope or when its internal buffer is full. +/// /// [bufwriter]: struct.BufWriter.html /// /// If there's still a partial line in the buffer when the `LineWriter` is @@ -785,6 +792,10 @@ impl LineWriter { /// /// The internal buffer is written out before returning the writer. /// + // # Errors + /// + /// An `Err` will be returned if an error occurs while flushing the buffer. + /// /// # Examples /// /// ```