From a5934713a9a09423a2a38c84167caf46dbe3e4af Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 4 Oct 2018 11:49:29 +0200 Subject: [PATCH 1/8] Update release notes for 1.29.2 --- RELEASES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 08470e731d8e7..9bc750ddef5db 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,11 @@ +Version 1.29.2 (2018-10-11) +=========================== + +- [Workaround for an aliasing-related LLVM bug, which caused miscompilation.][54639] +- The `rls-preview` component on the windows-gnu targets has been restored. + +[54639]: https://github.com/rust-lang/rust/pull/54639 + Version 1.29.1 (2018-09-25) =========================== From 989bbc5074c4bad8409f6be8c09d8406a78ae64b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Oct 2018 09:15:39 -0700 Subject: [PATCH 2/8] Revert "Add another assert" This reverts commit 21d2a6c9868541ec9829ced9a5bae936b18741c5. --- src/liballoc/collections/vec_deque.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index c53549ab85d6d..7b6693268ae3f 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -19,7 +19,6 @@ use core::cmp::Ordering; use core::fmt; -use core::isize; use core::iter::{repeat, FromIterator, FusedIterator}; use core::mem; use core::ops::Bound::{Excluded, Included, Unbounded}; @@ -211,9 +210,6 @@ impl VecDeque { /// If so, this function never panics. #[inline] unsafe fn copy_slice(&mut self, src: &[T]) { - /// This is guaranteed by `RawVec`. - debug_assert!(self.capacity() <= isize::MAX as usize); - let expected_new_len = self.len() + src.len(); debug_assert!(self.capacity() >= expected_new_len); From 5cfc7fb6b355a951c379127bae66cc0294d43e3b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Oct 2018 09:15:44 -0700 Subject: [PATCH 3/8] Revert "Fix tidy" This reverts commit 1908892d3f60008f265dfc25ac46db387c0ad6a0. --- src/liballoc/collections/vec_deque.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 7b6693268ae3f..1bd1861db0b27 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -1870,8 +1870,7 @@ impl VecDeque { self.copy_slice(src_high); } - // Some values now exist in both `other` and `self` but are made inaccessible - // in`other`. + // Some values now exist in both `other` and `self` but are made inaccessible in `other`. other.tail = other.head; } } From 23625e2edf998d841a585c90402f209be3973da3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Oct 2018 09:15:48 -0700 Subject: [PATCH 4/8] Revert "Add docs and debug asserts" This reverts commit 1a1a7f6167edf18b8a0ab488e651f7748cc2e9d3. --- src/liballoc/collections/vec_deque.rs | 34 +++++++++------------------ 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 1bd1861db0b27..7c16258e84ef0 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -202,17 +202,10 @@ impl VecDeque { len); } - /// Copies all values from `src` to the back of `self`, wrapping around if needed. - /// - /// # Safety - /// - /// The capacity must be sufficient to hold self.len() + src.len() elements. - /// If so, this function never panics. + /// Copies all values from `src` to `self`, wrapping around if needed. + /// Assumes capacity is sufficient. #[inline] unsafe fn copy_slice(&mut self, src: &[T]) { - let expected_new_len = self.len() + src.len(); - debug_assert!(self.capacity() >= expected_new_len); - let dst_high_ptr = self.ptr().add(self.head); let dst_high_len = self.cap() - self.head; @@ -223,7 +216,6 @@ impl VecDeque { ptr::copy_nonoverlapping(src_low.as_ptr(), self.ptr(), src_low.len()); self.head = self.wrap_add(self.head, src.len()); - debug_assert!(self.len() == expected_new_len); } /// Copies a potentially wrapping block of memory len long from src to dest. @@ -1858,21 +1850,17 @@ impl VecDeque { #[inline] #[stable(feature = "append", since = "1.4.0")] pub fn append(&mut self, other: &mut Self) { - unsafe { - // Guarantees there is space in `self` for `other`. - self.reserve(other.len()); - - { - let (src_high, src_low) = other.as_slices(); + // Guarantees there is space in `self` for `other + self.reserve(other.len()); - // This is only safe because copy_slice never panics when capacity is sufficient. - self.copy_slice(src_low); - self.copy_slice(src_high); - } - - // Some values now exist in both `other` and `self` but are made inaccessible in `other`. - other.tail = other.head; + unsafe { + let (src_high, src_low) = other.as_slices(); + self.copy_slice(src_low); + self.copy_slice(src_high); } + + // Some values now exist in both `other` and `self` but are made inaccessible in `other`. + other.tail = other.head; } /// Retains only the elements specified by the predicate. From 292faf223140922c417be5b7984860e8be091b13 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Oct 2018 09:15:52 -0700 Subject: [PATCH 5/8] Revert "Optimize VecDeque::append" This reverts commit 11e488b64fed181820280d494d4fcc157ee1adc5. --- src/liballoc/collections/vec_deque.rs | 29 ++------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 7c16258e84ef0..d49cb9857740d 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -202,22 +202,6 @@ impl VecDeque { len); } - /// Copies all values from `src` to `self`, wrapping around if needed. - /// Assumes capacity is sufficient. - #[inline] - unsafe fn copy_slice(&mut self, src: &[T]) { - let dst_high_ptr = self.ptr().add(self.head); - let dst_high_len = self.cap() - self.head; - - let split = cmp::min(src.len(), dst_high_len); - let (src_high, src_low) = src.split_at(split); - - ptr::copy_nonoverlapping(src_high.as_ptr(), dst_high_ptr, src_high.len()); - ptr::copy_nonoverlapping(src_low.as_ptr(), self.ptr(), src_low.len()); - - self.head = self.wrap_add(self.head, src.len()); - } - /// Copies a potentially wrapping block of memory len long from src to dest. /// (abs(dst - src) + len) must be no larger than cap() (There must be at /// most one continuous overlapping region between src and dest). @@ -1850,17 +1834,8 @@ impl VecDeque { #[inline] #[stable(feature = "append", since = "1.4.0")] pub fn append(&mut self, other: &mut Self) { - // Guarantees there is space in `self` for `other - self.reserve(other.len()); - - unsafe { - let (src_high, src_low) = other.as_slices(); - self.copy_slice(src_low); - self.copy_slice(src_high); - } - - // Some values now exist in both `other` and `self` but are made inaccessible in `other`. - other.tail = other.head; + // naive impl + self.extend(other.drain(..)); } /// Retains only the elements specified by the predicate. From 6147caf8dd2ea06fbc9ae9b46687eced14caf5d5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Oct 2018 09:15:57 -0700 Subject: [PATCH 6/8] Revert "Slightly refactor VecDeque implementation" This reverts commit 6ce76acae455a32113116cd2f95f8076388fc2d3. --- src/liballoc/collections/vec_deque.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index d49cb9857740d..571f35a2031d2 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -1024,7 +1024,7 @@ impl VecDeque { iter: Iter { tail: drain_tail, head: drain_head, - ring: unsafe { self.buffer_as_slice() }, + ring: unsafe { self.buffer_as_mut_slice() }, }, } } @@ -2593,8 +2593,8 @@ impl From> for Vec { let mut right_offset = 0; for i in left_edge..right_edge { right_offset = (i - left_edge) % (cap - right_edge); - let src = right_edge + right_offset; - ptr::swap(buf.add(i), buf.add(src)); + let src: isize = (right_edge + right_offset) as isize; + ptr::swap(buf.add(i), buf.offset(src)); } let n_ops = right_edge - left_edge; left_edge += n_ops; From 1f80aa95ce4757b680669d7bc7a3baf0748932de Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 4 Oct 2018 12:38:06 +0200 Subject: [PATCH 7/8] Fix dead code lint for functions using impl Trait --- src/librustc/middle/dead.rs | 8 ++++- src/test/run-pass/async-await.stderr | 14 ++++++++ .../impl-trait/existential-minimal.stderr | 8 +++++ .../run-pass/impl-trait/issue-42479.stderr | 14 ++++++++ .../run-pass/impl-trait/issue-49376.stderr | 32 +++++++++++++++++++ src/test/run-pass/issues/issue-49556.stderr | 8 +++++ .../traits/conservative_impl_trait.stderr | 8 +++++ src/test/ui/lint/lint-dead-code-1.rs | 4 +++ src/test/ui/lint/lint-dead-code-1.stderr | 8 ++++- 9 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/async-await.stderr create mode 100644 src/test/run-pass/impl-trait/existential-minimal.stderr create mode 100644 src/test/run-pass/impl-trait/issue-42479.stderr create mode 100644 src/test/run-pass/impl-trait/issue-49376.stderr create mode 100644 src/test/run-pass/issues/issue-49556.stderr create mode 100644 src/test/run-pass/traits/conservative_impl_trait.stderr diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index d320173f9f47d..e9e8fc5cf27c9 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -395,7 +395,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: &hir::Crate) -> Vec { - let worklist = access_levels.map.iter().map(|(&id, _)| id).chain( + let worklist = access_levels.map.iter().filter_map(|(&id, level)| { + if level >= &privacy::AccessLevel::Reachable { + Some(id) + } else { + None + } + }).chain( // Seed entry point tcx.sess.entry_fn.borrow().map(|(id, _, _)| id) ).collect::>(); diff --git a/src/test/run-pass/async-await.stderr b/src/test/run-pass/async-await.stderr new file mode 100644 index 0000000000000..b0bdf17cecd12 --- /dev/null +++ b/src/test/run-pass/async-await.stderr @@ -0,0 +1,14 @@ +warning: struct is never constructed: `Foo` + --> $DIR/async-await.rs:122:1 + | +LL | struct Foo; + | ^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + +warning: method is never used: `async_method` + --> $DIR/async-await.rs:129:5 + | +LL | async fn async_method(x: u8) -> u8 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/run-pass/impl-trait/existential-minimal.stderr b/src/test/run-pass/impl-trait/existential-minimal.stderr new file mode 100644 index 0000000000000..dd1f749788674 --- /dev/null +++ b/src/test/run-pass/impl-trait/existential-minimal.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `foo` + --> $DIR/existential-minimal.rs:15:1 + | +LL | fn foo() -> impl std::fmt::Debug { "cake" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/run-pass/impl-trait/issue-42479.stderr b/src/test/run-pass/impl-trait/issue-42479.stderr new file mode 100644 index 0000000000000..5a6a3031d0b01 --- /dev/null +++ b/src/test/run-pass/impl-trait/issue-42479.stderr @@ -0,0 +1,14 @@ +warning: struct is never constructed: `Foo` + --> $DIR/issue-42479.rs:15:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + +warning: method is never used: `inside` + --> $DIR/issue-42479.rs:20:5 + | +LL | fn inside(&self) -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/run-pass/impl-trait/issue-49376.stderr b/src/test/run-pass/impl-trait/issue-49376.stderr new file mode 100644 index 0000000000000..f5f36002b4222 --- /dev/null +++ b/src/test/run-pass/impl-trait/issue-49376.stderr @@ -0,0 +1,32 @@ +warning: function is never used: `gen` + --> $DIR/issue-49376.rs:18:1 + | +LL | fn gen() -> impl PartialOrd + PartialEq + Debug { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + +warning: struct is never constructed: `Bar` + --> $DIR/issue-49376.rs:20:1 + | +LL | struct Bar {} + | ^^^^^^^^^^ + +warning: function is never used: `foo` + --> $DIR/issue-49376.rs:24:1 + | +LL | fn foo() -> impl Foo { + | ^^^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `test_impl_ops` + --> $DIR/issue-49376.rs:28:1 + | +LL | fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `test_impl_assign_ops` + --> $DIR/issue-49376.rs:29:1 + | +LL | fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/run-pass/issues/issue-49556.stderr b/src/test/run-pass/issues/issue-49556.stderr new file mode 100644 index 0000000000000..8657d4ac2f290 --- /dev/null +++ b/src/test/run-pass/issues/issue-49556.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `iter` + --> $DIR/issue-49556.rs:12:1 + | +LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/run-pass/traits/conservative_impl_trait.stderr b/src/test/run-pass/traits/conservative_impl_trait.stderr new file mode 100644 index 0000000000000..26c29bf2bb2b5 --- /dev/null +++ b/src/test/run-pass/traits/conservative_impl_trait.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `batches` + --> $DIR/conservative_impl_trait.rs:14:1 + | +LL | fn batches(n: &u32) -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/ui/lint/lint-dead-code-1.rs b/src/test/ui/lint/lint-dead-code-1.rs index 2fe72365bab1c..944d57b5ba8f5 100644 --- a/src/test/ui/lint/lint-dead-code-1.rs +++ b/src/test/ui/lint/lint-dead-code-1.rs @@ -109,6 +109,10 @@ fn bar() { //~ ERROR: function is never used foo(); } +fn baz() -> impl Copy { //~ ERROR: function is never used + "I'm unused, too" +} + // Code with #[allow(dead_code)] should be marked live (and thus anything it // calls is marked live) #[allow(dead_code)] diff --git a/src/test/ui/lint/lint-dead-code-1.stderr b/src/test/ui/lint/lint-dead-code-1.stderr index 9802b7e8f383b..9d8e44c25d87e 100644 --- a/src/test/ui/lint/lint-dead-code-1.stderr +++ b/src/test/ui/lint/lint-dead-code-1.stderr @@ -58,5 +58,11 @@ error: function is never used: `bar` LL | fn bar() { //~ ERROR: function is never used | ^^^^^^^^ -error: aborting due to 9 previous errors +error: function is never used: `baz` + --> $DIR/lint-dead-code-1.rs:112:1 + | +LL | fn baz() -> impl Copy { //~ ERROR: function is never used + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors From ebca923b8e87eb636e4c64197a84a6852bf062ce Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 4 Oct 2018 14:44:46 +0200 Subject: [PATCH 8/8] Call Foo::async_method in the async-await test --- src/test/run-pass/async-await.rs | 1 + src/test/run-pass/async-await.stderr | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 src/test/run-pass/async-await.stderr diff --git a/src/test/run-pass/async-await.rs b/src/test/run-pass/async-await.rs index f692f57abb9c3..2c634f3449083 100644 --- a/src/test/run-pass/async-await.rs +++ b/src/test/run-pass/async-await.rs @@ -183,6 +183,7 @@ fn main() { async_closure, async_fn, async_fn_with_internal_borrow, + Foo::async_method, |x| { async move { unsafe { await!(unsafe_async_fn(x)) } diff --git a/src/test/run-pass/async-await.stderr b/src/test/run-pass/async-await.stderr deleted file mode 100644 index b0bdf17cecd12..0000000000000 --- a/src/test/run-pass/async-await.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: struct is never constructed: `Foo` - --> $DIR/async-await.rs:122:1 - | -LL | struct Foo; - | ^^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - -warning: method is never used: `async_method` - --> $DIR/async-await.rs:129:5 - | -LL | async fn async_method(x: u8) -> u8 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -