Skip to content

Commit

Permalink
Auto merge of #56051 - pietroalbini:rollup, r=pietroalbini
Browse files Browse the repository at this point in the history
Rollup of 25 pull requests

Successful merges:

 - #55562 (Add powerpc- and powerpc64-unknown-linux-musl targets)
 - #55564 (test/linkage-visibility: Ignore on musl targets)
 - #55827 (A few tweaks to iterations/collecting)
 - #55834 (Forward the ABI of the non-zero sized fields of an union if they have the same ABI)
 - #55857 (remove unused dependency)
 - #55862 (in which the E0618 "expected function" diagnostic gets a makeover)
 - #55867 (do not panic just because cargo failed)
 - #55894 (miri enum discriminant handling: Fix treatment of pointers, better error when it is undef)
 - #55916 (Make miri value visitor usfeful for mutation)
 - #55919 (core/tests/num: Simplify `test_int_from_str_overflow()` test code)
 - #55923 (reword #[test] attribute error on fn items)
 - #55935 (appveyor: Use VS2017 for all our images)
 - #55949 (ty: return impl Iterator from Predicate::walk_tys)
 - #55952 (Update to Clang 7 on CI.)
 - #55953 (#53488 Refactoring UpvarId)
 - #55962 (rustdoc: properly calculate spans for intra-doc link resolution errors)
 - #55963 (Stress test for MPSC)
 - #55968 (Clean up some non-mod-rs stuff.)
 - #55970 (Miri backtrace improvements)
 - #56007 (CTFE: dynamically make sure we do not call non-const-fn)
 - #56011 (Replace data.clone() by Arc::clone(&data) in mutex doc.)
 - #56012 (avoid shared ref in UnsafeCell::get)
 - #56016 (Add VecDeque::resize_with)
 - #56027 (docs: Add missing backtick in object_safety.rs docs)
 - #56043 (remove "approx env bounds" if we already know from trait)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Nov 19, 2018
2 parents 7e82eda + c11f8b3 commit d87625b
Show file tree
Hide file tree
Showing 125 changed files with 1,254 additions and 592 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ install:
chmod +x /usr/local/bin/sccache &&
travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
chmod +x /usr/local/bin/stamp &&
travis_retry curl -f http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
export CC=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang &&
export CXX=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang++ &&
travis_retry curl -f http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
export CC=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang &&
export CXX=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++ &&
export AR=ar
;;
esac
Expand Down
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
environment:
SCCACHE_DIGEST: f808afabb4a4eb1d7112bcb3fa6be03b61e93412890c88e177c667eb37f46353d7ec294e559b16f9f4b5e894f2185fe7670a0df15fd064889ecbd80f0c34166c
# This is required for at least an AArch64 compiler in one image, and is
# otherwise recommended by AppVeyor currently for seeing if it has any
# affect on our job times.
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview

# By default schannel checks revocation of certificates unlike some other SSL
# backends, but we've historically had problems on CI where a revocation
Expand Down Expand Up @@ -88,7 +91,6 @@ environment:
DIST_REQUIRE_ALL_TOOLS: 1
DEPLOY: 1
CI_JOB_NAME: dist-x86_64-msvc
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview
- RUST_CONFIGURE_ARGS: >
--build=i686-pc-windows-msvc
--target=i586-pc-windows-msvc
Expand Down
1 change: 0 additions & 1 deletion src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,6 @@ dependencies = [
"graphviz 0.0.0",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::fs::{self, File};
use std::io::BufReader;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::process::{Command, Stdio, exit};
use std::str;

use build_helper::{output, mtime, up_to_date};
Expand Down Expand Up @@ -1098,7 +1098,7 @@ pub fn run_cargo(builder: &Builder,
});

if !ok {
panic!("cargo must succeed");
exit(1);
}

// Ok now we need to actually find all the files listed in `toplevel`. We've
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-i686-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RUN ./build-gcc.sh
COPY dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh

# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
# clang/clang++ compilers.
COPY dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RUN ./build-gcc.sh
COPY dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh

# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
# clang/clang++ compilers.
COPY dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-x86_64-linux/build-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set -ex

source shared.sh

LLVM=6.0.0
LLVM=7.0.0

mkdir clang
cd clang
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/scripts/musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ hide_output make clean

cd ..

LLVM=60
LLVM=70

# may have been downloaded in a previous run
if [ ! -d libunwind-release_$LLVM ]; then
Expand Down
40 changes: 39 additions & 1 deletion src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use core::cmp::Ordering;
use core::fmt;
use core::iter::{repeat, FromIterator, FusedIterator};
use core::iter::{repeat, repeat_with, FromIterator, FusedIterator};
use core::mem;
use core::ops::Bound::{Excluded, Included, Unbounded};
use core::ops::{Index, IndexMut, RangeBounds};
Expand Down Expand Up @@ -1920,6 +1920,44 @@ impl<T: Clone> VecDeque<T> {
self.truncate(new_len);
}
}

/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
/// either by removing excess elements from the back or by appending
/// elements generated by calling `generator` to the back.
///
/// # Examples
///
/// ```
/// #![feature(vec_resize_with)]
///
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
/// buf.push_back(5);
/// buf.push_back(10);
/// buf.push_back(15);
/// assert_eq!(buf, [5, 10, 15]);
///
/// buf.resize_with(5, Default::default);
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
///
/// buf.resize_with(2, || unreachable!());
/// assert_eq!(buf, [5, 10]);
///
/// let mut state = 100;
/// buf.resize_with(5, || { state += 1; state });
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
/// ```
#[unstable(feature = "vec_resize_with", issue = "41758")]
pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) {
let len = self.len();

if new_len > len {
self.extend(repeat_with(generator).take(new_len - len))
} else {
self.truncate(new_len);
}
}
}

/// Returns the index in the underlying buffer for a given logical element index.
Expand Down
4 changes: 3 additions & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,9 @@ impl<T: ?Sized> UnsafeCell<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn get(&self) -> *mut T {
&self.value as *const T as *mut T
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]
self as *const UnsafeCell<T> as *const T as *mut T
}
}

Expand Down
24 changes: 8 additions & 16 deletions src/libcore/tests/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,28 @@ fn from_str_issue7588() {

#[test]
fn test_int_from_str_overflow() {
let mut i8_val: i8 = 127;
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
assert_eq!("127".parse::<i8>().ok(), Some(127i8));
assert_eq!("128".parse::<i8>().ok(), None);

i8_val = i8_val.wrapping_add(1);
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
assert_eq!("-128".parse::<i8>().ok(), Some(-128i8));
assert_eq!("-129".parse::<i8>().ok(), None);

let mut i16_val: i16 = 32_767;
assert_eq!("32767".parse::<i16>().ok(), Some(i16_val));
assert_eq!("32767".parse::<i16>().ok(), Some(32_767i16));
assert_eq!("32768".parse::<i16>().ok(), None);

i16_val = i16_val.wrapping_add(1);
assert_eq!("-32768".parse::<i16>().ok(), Some(i16_val));
assert_eq!("-32768".parse::<i16>().ok(), Some(-32_768i16));
assert_eq!("-32769".parse::<i16>().ok(), None);

let mut i32_val: i32 = 2_147_483_647;
assert_eq!("2147483647".parse::<i32>().ok(), Some(i32_val));
assert_eq!("2147483647".parse::<i32>().ok(), Some(2_147_483_647i32));
assert_eq!("2147483648".parse::<i32>().ok(), None);

i32_val = i32_val.wrapping_add(1);
assert_eq!("-2147483648".parse::<i32>().ok(), Some(i32_val));
assert_eq!("-2147483648".parse::<i32>().ok(), Some(-2_147_483_648i32));
assert_eq!("-2147483649".parse::<i32>().ok(), None);

let mut i64_val: i64 = 9_223_372_036_854_775_807;
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(i64_val));
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(9_223_372_036_854_775_807i64));
assert_eq!("9223372036854775808".parse::<i64>().ok(), None);

i64_val = i64_val.wrapping_add(1);
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(i64_val));
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(-9_223_372_036_854_775_808i64));
assert_eq!("-9223372036854775809".parse::<i64>().ok(), None);
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc/cfg/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
type Node = Node<'a>;
type Edge = Edge<'a>;
fn nodes(&'a self) -> dot::Nodes<'a, Node<'a>> {
let mut v = Vec::new();
self.graph.each_node(|i, nd| { v.push((i, nd)); true });
let v: Vec<_> = self.graph.enumerated_nodes().collect();
v.into()
}
fn edges(&'a self) -> dot::Edges<'a, Edge<'a>> {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,7 @@ impl<'a> LoweringContext<'a> {
attrs
.iter()
.map(|a| self.lower_attr(a))
.collect::<Vec<_>>()
.into()
.collect()
}

fn lower_attr(&mut self, attr: &Attribute) -> Attribute {
Expand Down
17 changes: 12 additions & 5 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrow
}
}

impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
impl_stable_hash_for!(struct ty::UpvarPath { hir_id });

impl_stable_hash_for!(struct ty::UpvarId { var_path, closure_expr_id });

impl_stable_hash_for!(enum ty::BorrowKind {
ImmBorrow,
Expand Down Expand Up @@ -387,10 +389,10 @@ impl_stable_hash_for!(enum mir::interpret::ErrorHandled {
TooGeneric
});

impl_stable_hash_for!(struct mir::interpret::FrameInfo {
span,
impl_stable_hash_for!(struct mir::interpret::FrameInfo<'tcx> {
call_site,
lint_root,
location
instance
});

impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
Expand Down Expand Up @@ -451,7 +453,7 @@ impl_stable_hash_for!(
FunctionRetMismatch(a, b),
NoMirFor(s),
UnterminatedCString(ptr),
PointerOutOfBounds { ptr, access, allocation_size },
PointerOutOfBounds { ptr, check, allocation_size },
InvalidBoolOp(bop),
Unimplemented(s),
BoundsCheck { len, index },
Expand All @@ -471,6 +473,11 @@ impl_stable_hash_for!(
}
);

impl_stable_hash_for!(enum mir::interpret::InboundsCheck {
Live,
MaybeDead
});

impl_stable_hash_for!(enum mir::interpret::Lock {
NoLock,
WriteLock(dl),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
format!(" for lifetime parameter `{}` in coherence check", name)
}
infer::UpvarRegion(ref upvar_id, _) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id);
format!(" for capture of `{}` by closure", var_name)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
"...so that reference does not outlive borrowed content");
}
infer::ReborrowUpvar(span, ref upvar_id) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id);
err.span_note(span,
&format!("...so that closure can access `{}`", var_name));
Expand Down Expand Up @@ -174,7 +174,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err
}
infer::ReborrowUpvar(span, ref upvar_id) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id);
let mut err = struct_span_err!(self.tcx.sess,
span,
Expand Down
30 changes: 23 additions & 7 deletions src/librustc/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,38 @@ where
// rule might not apply (but another rule might). For now, we err
// on the side of adding too few edges into the graph.

// Compute the bounds we can derive from the trait definition.
// These are guaranteed to apply, no matter the inference
// results.
let trait_bounds: Vec<_> = self.verify_bound
.projection_declared_bounds_from_trait(projection_ty)
.collect();

// Compute the bounds we can derive from the environment. This
// is an "approximate" match -- in some cases, these bounds
// may not apply.
let approx_env_bounds = self.verify_bound
let mut approx_env_bounds = self.verify_bound
.projection_approx_declared_bounds_from_env(projection_ty);
debug!(
"projection_must_outlive: approx_env_bounds={:?}",
approx_env_bounds
);

// Compute the bounds we can derive from the trait definition.
// These are guaranteed to apply, no matter the inference
// results.
let trait_bounds: Vec<_> = self.verify_bound
.projection_declared_bounds_from_trait(projection_ty)
.collect();
// Remove outlives bounds that we get from the environment but
// which are also deducable from the trait. This arises (cc
// #55756) in cases where you have e.g. `<T as Foo<'a>>::Item:
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
// }` in the trait definition.
approx_env_bounds.retain(|bound| {
match bound.0.sty {
ty::Projection(projection_ty) => {
self.verify_bound.projection_declared_bounds_from_trait(projection_ty)
.all(|r| r != bound.1)
}

_ => panic!("expected only projection types from env, not {:?}", bound.0),
}
});

// If declared bounds list is empty, the only applicable rule is
// OutlivesProjectionComponent. If there are inference variables,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
let var_hir_id = self.tcx().hir.node_to_hir_id(freevar.var_id());
let closure_def_id = self.tcx().hir.local_def_id(closure_expr.id);
let upvar_id = ty::UpvarId {
var_id: var_hir_id,
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_def_id.to_local(),
};
let upvar_capture = self.mc.tables.upvar_capture(upvar_id);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let closure_expr_def_id = self.tcx.hir.local_def_id(fn_node_id);
let var_hir_id = self.tcx.hir.node_to_hir_id(var_id);
let upvar_id = ty::UpvarId {
var_id: var_hir_id,
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: closure_expr_def_id.to_local(),
};

Expand Down
8 changes: 8 additions & 0 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ use mir;
use std::ops::{Deref, DerefMut};
use rustc_data_structures::sorted_map::SortedMap;

/// Used by `check_bounds` to indicate whether the pointer needs to be just inbounds
/// or also inbounds of a *live* allocation.
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
pub enum InboundsCheck {
Live,
MaybeDead,
}

#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub struct Allocation<Tag=(),Extra=()> {
/// The actual bytes of the allocation.
Expand Down
Loading

0 comments on commit d87625b

Please sign in to comment.