Skip to content

Commit d87625b

Browse files
committed
Auto merge of #56051 - pietroalbini:rollup, r=pietroalbini
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
2 parents 7e82eda + c11f8b3 commit d87625b

File tree

125 files changed

+1254
-592
lines changed

Some content is hidden

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

125 files changed

+1254
-592
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ install:
227227
chmod +x /usr/local/bin/sccache &&
228228
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 &&
229229
chmod +x /usr/local/bin/stamp &&
230-
travis_retry curl -f http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
231-
export CC=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang &&
232-
export CXX=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang++ &&
230+
travis_retry curl -f http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
231+
export CC=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang &&
232+
export CXX=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++ &&
233233
export AR=ar
234234
;;
235235
esac

appveyor.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
environment:
2-
SCCACHE_DIGEST: f808afabb4a4eb1d7112bcb3fa6be03b61e93412890c88e177c667eb37f46353d7ec294e559b16f9f4b5e894f2185fe7670a0df15fd064889ecbd80f0c34166c
2+
# This is required for at least an AArch64 compiler in one image, and is
3+
# otherwise recommended by AppVeyor currently for seeing if it has any
4+
# affect on our job times.
5+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview
36

47
# By default schannel checks revocation of certificates unlike some other SSL
58
# backends, but we've historically had problems on CI where a revocation
@@ -88,7 +91,6 @@ environment:
8891
DIST_REQUIRE_ALL_TOOLS: 1
8992
DEPLOY: 1
9093
CI_JOB_NAME: dist-x86_64-msvc
91-
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview
9294
- RUST_CONFIGURE_ARGS: >
9395
--build=i686-pc-windows-msvc
9496
--target=i586-pc-windows-msvc

src/Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,6 @@ dependencies = [
21912191
"graphviz 0.0.0",
21922192
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
21932193
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
2194-
"parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
21952194
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
21962195
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
21972196
"rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",

src/bootstrap/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::fs::{self, File};
2222
use std::io::BufReader;
2323
use std::io::prelude::*;
2424
use std::path::{Path, PathBuf};
25-
use std::process::{Command, Stdio};
25+
use std::process::{Command, Stdio, exit};
2626
use std::str;
2727

2828
use build_helper::{output, mtime, up_to_date};
@@ -1098,7 +1098,7 @@ pub fn run_cargo(builder: &Builder,
10981098
});
10991099

11001100
if !ok {
1101-
panic!("cargo must succeed");
1101+
exit(1);
11021102
}
11031103

11041104
// Ok now we need to actually find all the files listed in `toplevel`. We've

src/ci/docker/dist-i686-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RUN ./build-gcc.sh
6767
COPY dist-x86_64-linux/build-python.sh /tmp/
6868
RUN ./build-python.sh
6969

70-
# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
70+
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
7171
# clang/clang++ compilers.
7272
COPY dist-x86_64-linux/build-clang.sh /tmp/
7373
RUN ./build-clang.sh

src/ci/docker/dist-x86_64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ RUN ./build-gcc.sh
6767
COPY dist-x86_64-linux/build-python.sh /tmp/
6868
RUN ./build-python.sh
6969

70-
# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
70+
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
7171
# clang/clang++ compilers.
7272
COPY dist-x86_64-linux/build-clang.sh /tmp/
7373
RUN ./build-clang.sh

src/ci/docker/dist-x86_64-linux/build-clang.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -ex
1313

1414
source shared.sh
1515

16-
LLVM=6.0.0
16+
LLVM=7.0.0
1717

1818
mkdir clang
1919
cd clang

src/ci/docker/scripts/musl.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ hide_output make clean
5151

5252
cd ..
5353

54-
LLVM=60
54+
LLVM=70
5555

5656
# may have been downloaded in a previous run
5757
if [ ! -d libunwind-release_$LLVM ]; then

src/liballoc/collections/vec_deque.rs

+39-1
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, FromIterator, FusedIterator};
22+
use core::iter::{repeat, repeat_with, FromIterator, FusedIterator};
2323
use core::mem;
2424
use core::ops::Bound::{Excluded, Included, Unbounded};
2525
use core::ops::{Index, IndexMut, RangeBounds};
@@ -1920,6 +1920,44 @@ impl<T: Clone> VecDeque<T> {
19201920
self.truncate(new_len);
19211921
}
19221922
}
1923+
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.
1927+
///
1928+
/// # Examples
1929+
///
1930+
/// ```
1931+
/// #![feature(vec_resize_with)]
1932+
///
1933+
/// use std::collections::VecDeque;
1934+
///
1935+
/// let mut buf = VecDeque::new();
1936+
/// buf.push_back(5);
1937+
/// buf.push_back(10);
1938+
/// buf.push_back(15);
1939+
/// assert_eq!(buf, [5, 10, 15]);
1940+
///
1941+
/// buf.resize_with(5, Default::default);
1942+
/// assert_eq!(buf, [5, 10, 15, 0, 0]);
1943+
///
1944+
/// buf.resize_with(2, || unreachable!());
1945+
/// assert_eq!(buf, [5, 10]);
1946+
///
1947+
/// let mut state = 100;
1948+
/// buf.resize_with(5, || { state += 1; state });
1949+
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
1950+
/// ```
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+
}
1960+
}
19231961
}
19241962

19251963
/// Returns the index in the underlying buffer for a given logical element index.

src/libcore/cell.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,9 @@ impl<T: ?Sized> UnsafeCell<T> {
15091509
#[inline]
15101510
#[stable(feature = "rust1", since = "1.0.0")]
15111511
pub const fn get(&self) -> *mut T {
1512-
&self.value as *const T as *mut T
1512+
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of
1513+
// #[repr(transparent)]
1514+
self as *const UnsafeCell<T> as *const T as *mut T
15131515
}
15141516
}
15151517

src/libcore/tests/num/mod.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,28 @@ fn from_str_issue7588() {
8282

8383
#[test]
8484
fn test_int_from_str_overflow() {
85-
let mut i8_val: i8 = 127;
86-
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
85+
assert_eq!("127".parse::<i8>().ok(), Some(127i8));
8786
assert_eq!("128".parse::<i8>().ok(), None);
8887

89-
i8_val = i8_val.wrapping_add(1);
90-
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
88+
assert_eq!("-128".parse::<i8>().ok(), Some(-128i8));
9189
assert_eq!("-129".parse::<i8>().ok(), None);
9290

93-
let mut i16_val: i16 = 32_767;
94-
assert_eq!("32767".parse::<i16>().ok(), Some(i16_val));
91+
assert_eq!("32767".parse::<i16>().ok(), Some(32_767i16));
9592
assert_eq!("32768".parse::<i16>().ok(), None);
9693

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

101-
let mut i32_val: i32 = 2_147_483_647;
102-
assert_eq!("2147483647".parse::<i32>().ok(), Some(i32_val));
97+
assert_eq!("2147483647".parse::<i32>().ok(), Some(2_147_483_647i32));
10398
assert_eq!("2147483648".parse::<i32>().ok(), None);
10499

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

109-
let mut i64_val: i64 = 9_223_372_036_854_775_807;
110-
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(i64_val));
103+
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(9_223_372_036_854_775_807i64));
111104
assert_eq!("9223372036854775808".parse::<i64>().ok(), None);
112105

113-
i64_val = i64_val.wrapping_add(1);
114-
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(i64_val));
106+
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(-9_223_372_036_854_775_808i64));
115107
assert_eq!("-9223372036854775809".parse::<i64>().ok(), None);
116108
}
117109

src/librustc/cfg/graphviz.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
106106
type Node = Node<'a>;
107107
type Edge = Edge<'a>;
108108
fn nodes(&'a self) -> dot::Nodes<'a, Node<'a>> {
109-
let mut v = Vec::new();
110-
self.graph.each_node(|i, nd| { v.push((i, nd)); true });
109+
let v: Vec<_> = self.graph.enumerated_nodes().collect();
111110
v.into()
112111
}
113112
fn edges(&'a self) -> dot::Edges<'a, Edge<'a>> {

src/librustc/hir/lowering.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,7 @@ impl<'a> LoweringContext<'a> {
10621062
attrs
10631063
.iter()
10641064
.map(|a| self.lower_attr(a))
1065-
.collect::<Vec<_>>()
1066-
.into()
1065+
.collect()
10671066
}
10681067

10691068
fn lower_attr(&mut self, attr: &Attribute) -> Attribute {

src/librustc/ich/impls_ty.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrow
216216
}
217217
}
218218

219-
impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
219+
impl_stable_hash_for!(struct ty::UpvarPath { hir_id });
220+
221+
impl_stable_hash_for!(struct ty::UpvarId { var_path, closure_expr_id });
220222

221223
impl_stable_hash_for!(enum ty::BorrowKind {
222224
ImmBorrow,
@@ -387,10 +389,10 @@ impl_stable_hash_for!(enum mir::interpret::ErrorHandled {
387389
TooGeneric
388390
});
389391

390-
impl_stable_hash_for!(struct mir::interpret::FrameInfo {
391-
span,
392+
impl_stable_hash_for!(struct mir::interpret::FrameInfo<'tcx> {
393+
call_site,
392394
lint_root,
393-
location
395+
instance
394396
});
395397

396398
impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
@@ -451,7 +453,7 @@ impl_stable_hash_for!(
451453
FunctionRetMismatch(a, b),
452454
NoMirFor(s),
453455
UnterminatedCString(ptr),
454-
PointerOutOfBounds { ptr, access, allocation_size },
456+
PointerOutOfBounds { ptr, check, allocation_size },
455457
InvalidBoolOp(bop),
456458
Unimplemented(s),
457459
BoundsCheck { len, index },
@@ -471,6 +473,11 @@ impl_stable_hash_for!(
471473
}
472474
);
473475

476+
impl_stable_hash_for!(enum mir::interpret::InboundsCheck {
477+
Live,
478+
MaybeDead
479+
});
480+
474481
impl_stable_hash_for!(enum mir::interpret::Lock {
475482
NoLock,
476483
WriteLock(dl),

src/librustc/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13151315
format!(" for lifetime parameter `{}` in coherence check", name)
13161316
}
13171317
infer::UpvarRegion(ref upvar_id, _) => {
1318-
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
1318+
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
13191319
let var_name = self.tcx.hir.name(var_node_id);
13201320
format!(" for capture of `{}` by closure", var_name)
13211321
}

src/librustc/infer/error_reporting/note.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
4141
"...so that reference does not outlive borrowed content");
4242
}
4343
infer::ReborrowUpvar(span, ref upvar_id) => {
44-
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
44+
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
4545
let var_name = self.tcx.hir.name(var_node_id);
4646
err.span_note(span,
4747
&format!("...so that closure can access `{}`", var_name));
@@ -174,7 +174,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
174174
err
175175
}
176176
infer::ReborrowUpvar(span, ref upvar_id) => {
177-
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
177+
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
178178
let var_name = self.tcx.hir.name(var_node_id);
179179
let mut err = struct_span_err!(self.tcx.sess,
180180
span,

src/librustc/infer/outlives/obligations.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -389,22 +389,38 @@ where
389389
// rule might not apply (but another rule might). For now, we err
390390
// on the side of adding too few edges into the graph.
391391

392+
// Compute the bounds we can derive from the trait definition.
393+
// These are guaranteed to apply, no matter the inference
394+
// results.
395+
let trait_bounds: Vec<_> = self.verify_bound
396+
.projection_declared_bounds_from_trait(projection_ty)
397+
.collect();
398+
392399
// Compute the bounds we can derive from the environment. This
393400
// is an "approximate" match -- in some cases, these bounds
394401
// may not apply.
395-
let approx_env_bounds = self.verify_bound
402+
let mut approx_env_bounds = self.verify_bound
396403
.projection_approx_declared_bounds_from_env(projection_ty);
397404
debug!(
398405
"projection_must_outlive: approx_env_bounds={:?}",
399406
approx_env_bounds
400407
);
401408

402-
// Compute the bounds we can derive from the trait definition.
403-
// These are guaranteed to apply, no matter the inference
404-
// results.
405-
let trait_bounds: Vec<_> = self.verify_bound
406-
.projection_declared_bounds_from_trait(projection_ty)
407-
.collect();
409+
// Remove outlives bounds that we get from the environment but
410+
// which are also deducable from the trait. This arises (cc
411+
// #55756) in cases where you have e.g. `<T as Foo<'a>>::Item:
412+
// 'a` in the environment but `trait Foo<'b> { type Item: 'b
413+
// }` in the trait definition.
414+
approx_env_bounds.retain(|bound| {
415+
match bound.0.sty {
416+
ty::Projection(projection_ty) => {
417+
self.verify_bound.projection_declared_bounds_from_trait(projection_ty)
418+
.all(|r| r != bound.1)
419+
}
420+
421+
_ => panic!("expected only projection types from env, not {:?}", bound.0),
422+
}
423+
});
408424

409425
// If declared bounds list is empty, the only applicable rule is
410426
// OutlivesProjectionComponent. If there are inference variables,

src/librustc/middle/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
938938
let var_hir_id = self.tcx().hir.node_to_hir_id(freevar.var_id());
939939
let closure_def_id = self.tcx().hir.local_def_id(closure_expr.id);
940940
let upvar_id = ty::UpvarId {
941-
var_id: var_hir_id,
941+
var_path: ty::UpvarPath { hir_id: var_hir_id },
942942
closure_expr_id: closure_def_id.to_local(),
943943
};
944944
let upvar_capture = self.mc.tables.upvar_capture(upvar_id);

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
818818
let closure_expr_def_id = self.tcx.hir.local_def_id(fn_node_id);
819819
let var_hir_id = self.tcx.hir.node_to_hir_id(var_id);
820820
let upvar_id = ty::UpvarId {
821-
var_id: var_hir_id,
821+
var_path: ty::UpvarPath { hir_id: var_hir_id },
822822
closure_expr_id: closure_expr_def_id.to_local(),
823823
};
824824

src/librustc/mir/interpret/allocation.rs

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ use mir;
1919
use std::ops::{Deref, DerefMut};
2020
use rustc_data_structures::sorted_map::SortedMap;
2121

22+
/// Used by `check_bounds` to indicate whether the pointer needs to be just inbounds
23+
/// or also inbounds of a *live* allocation.
24+
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
25+
pub enum InboundsCheck {
26+
Live,
27+
MaybeDead,
28+
}
29+
2230
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
2331
pub struct Allocation<Tag=(),Extra=()> {
2432
/// The actual bytes of the allocation.

0 commit comments

Comments
 (0)