Skip to content

[beta] Rollup backports #54907

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

Merged
merged 8 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -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)
===========================

Expand Down
52 changes: 5 additions & 47 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -203,33 +202,6 @@ impl<T> VecDeque<T> {
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.
#[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);

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());
debug_assert!(self.len() == expected_new_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).
Expand Down Expand Up @@ -1052,7 +1024,7 @@ impl<T> VecDeque<T> {
iter: Iter {
tail: drain_tail,
head: drain_head,
ring: unsafe { self.buffer_as_slice() },
ring: unsafe { self.buffer_as_mut_slice() },
},
}
}
Expand Down Expand Up @@ -1862,22 +1834,8 @@ impl<T> VecDeque<T> {
#[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();

// 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;
}
// naive impl
self.extend(other.drain(..));
}

/// Retains only the elements specified by the predicate.
Expand Down Expand Up @@ -2635,8 +2593,8 @@ impl<T> From<VecDeque<T>> for Vec<T> {
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;
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
krate: &hir::Crate)
-> Vec<ast::NodeId>
{
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::<Vec<_>>();
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/async-await.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
Expand Down
8 changes: 8 additions & 0 deletions src/test/run-pass/impl-trait/existential-minimal.stderr
Original file line number Diff line number Diff line change
@@ -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

14 changes: 14 additions & 0 deletions src/test/run-pass/impl-trait/issue-42479.stderr
Original file line number Diff line number Diff line change
@@ -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<Item = &i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

32 changes: 32 additions & 0 deletions src/test/run-pass/impl-trait/issue-49376.stderr
Original file line number Diff line number Diff line change
@@ -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 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

8 changes: 8 additions & 0 deletions src/test/run-pass/issues/issue-49556.stderr
Original file line number Diff line number Diff line change
@@ -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<Item = usize> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default

8 changes: 8 additions & 0 deletions src/test/run-pass/traits/conservative_impl_trait.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: function is never used: `batches`
--> $DIR/conservative_impl_trait.rs:14:1
|
LL | fn batches(n: &u32) -> impl Iterator<Item=&u32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default

4 changes: 4 additions & 0 deletions src/test/ui/lint/lint-dead-code-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/lint/lint-dead-code-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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