Skip to content

Commit

Permalink
Auto merge of rust-lang#72054 - Mark-Simulacrum:beta-next, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

[beta] backports

This backport rollup includes the following:
 * [beta] Update cargo rust-lang#71967
 * Backport 1.43.1 release notes to master rust-lang#71914
 * Update the `cc` crate rust-lang#71882
 * resolve: Relax fresh binding disambiguation slightly to fix regression rust-lang#71846
 * Do not try to find binop method on RHS `TyErr` rust-lang#71810
 * Quick and dirty fix of the unused_braces lint rust-lang#71517
 * Update stdarch submodule rust-lang#71495
 * normalize field projection ty to fix broken MIR issue rust-lang#71488
 * Update openssl-src to 1.1.1g rust-lang#71430
 * fix error code in E0751.md rust-lang#71426
 * Don't fuse Chain in its second iterator rust-lang#71404
 * Remove some `Vec` allocations to improve performance rust-lang#71268
 * [CI] Use the latest Python available on Windows rust-lang#71995

It also switches the bootstrap compiler to 1.43.1.
  • Loading branch information
bors committed May 11, 2020
2 parents b1162ed + d0703f9 commit 0f0d700
Show file tree
Hide file tree
Showing 57 changed files with 321 additions and 256 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.50"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d"
dependencies = [
"jobserver",
]
Expand Down Expand Up @@ -2298,9 +2298,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"

[[package]]
name = "openssl-src"
version = "111.8.1+1.1.1f"
version = "111.9.0+1.1.1g"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04f0299a91de598dde58d2e99101895498dcf3d58896a3297798f28b27c8b72"
checksum = "a2dbe10ddd1eb335aba3780eb2eaa13e1b7b441d2562fd962398740927f39ec4"
dependencies = [
"cc",
]
Expand Down
20 changes: 16 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 1.43.1 (2020-05-07)
===========================

* [Updated openssl-src to 1.1.1g for CVE-2020-1967.][71430]
* [Fixed the stabilization of AVX-512 features.][71473]
* [Fixed `cargo package --list` not working with unpublished dependencies.][cargo/8151]

[71430]: https://github.com/rust-lang/rust/pull/71430
[71473]: https://github.com/rust-lang/rust/issues/71473
[cargo/8151]: https://github.com/rust-lang/cargo/issues/8151


Version 1.43.0 (2020-04-23)
==========================

Expand All @@ -14,7 +26,7 @@ Language
- [Merge `fn` syntax + cleanup item parsing.][68728]
- [`item` macro fragments can be interpolated into `trait`s, `impl`s, and `extern` blocks.][69366]
For example, you may now write:
```rust
```rust
macro_rules! mac_trait {
($i:item) => {
trait T { $i }
Expand Down Expand Up @@ -82,7 +94,7 @@ Misc
- [Certain checks in the `const_err` lint were deemed unrelated to const
evaluation][69185], and have been moved to the `unconditional_panic` and
`arithmetic_overflow` lints.

Compatibility Notes
-------------------

Expand Down Expand Up @@ -173,7 +185,7 @@ Language
(e.g. `type Foo: Ord;`).
- `...` (the C-variadic type) may occur syntactically directly as the type of
any function parameter.

These are still rejected *semantically*, so you will likely receive an error
but these changes can be seen and parsed by procedural macros and
conditional compilation.
Expand Down Expand Up @@ -465,7 +477,7 @@ Compatibility Notes
- [Using `#[inline]` on function prototypes and consts now emits a warning under
`unused_attribute` lint.][65294] Using `#[inline]` anywhere else inside traits
or `extern` blocks now correctly emits a hard error.

[65294]: https://github.com/rust-lang/rust/pull/65294/
[66103]: https://github.com/rust-lang/rust/pull/66103/
[65843]: https://github.com/rust-lang/rust/pull/65843/
Expand Down
12 changes: 10 additions & 2 deletions src/ci/scripts/install-msys2-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ if isWindows; then
pacman -S --noconfirm --needed base-devel ca-certificates make diffutils tar \
binutils

# Detect the native Python version installed on the agent. On GitHub
# Actions, the C:\hostedtoolcache\windows\Python directory contains a
# subdirectory for each installed Python version.
#
# The -V flag of the sort command sorts the input by version number.
native_python_version="$(ls /c/hostedtoolcache/windows/Python | sort -Vr | head -n 1)"

# Make sure we use the native python interpreter instead of some msys equivalent
# one way or another. The msys interpreters seem to have weird path conversions
# baked in which break LLVM's build system one way or another, so let's use the
# native version which keeps everything as native as possible.
python_home="C:/hostedtoolcache/windows/Python/3.7.6/x64"
python_home="/c/hostedtoolcache/windows/Python/${native_python_version}/x64"
cp "${python_home}/python.exe" "${python_home}/python3.exe"
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\3.7.6\\x64"
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64"
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts"
fi
32 changes: 22 additions & 10 deletions src/libcore/iter/adapters/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub struct Chain<A, B> {
// adapter because its specialization for `FusedIterator` unconditionally descends into the
// iterator, and that could be expensive to keep revisiting stuff like nested chains. It also
// hurts compiler performance to add more iterator layers to `Chain`.
//
// Only the "first" iterator is actually set `None` when exhausted, depending on whether you
// iterate forward or backward. If you mix directions, then both sides may be `None`.
a: Option<A>,
b: Option<B>,
}
Expand All @@ -43,6 +46,17 @@ macro_rules! fuse {
};
}

/// Try an iterator method without fusing,
/// like an inline `.as_mut().and_then(...)`
macro_rules! maybe {
($self:ident . $iter:ident . $($call:tt)+) => {
match $self.$iter {
Some(ref mut iter) => iter.$($call)+,
None => None,
}
};
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B> Iterator for Chain<A, B>
where
Expand All @@ -54,7 +68,7 @@ where
#[inline]
fn next(&mut self) -> Option<A::Item> {
match fuse!(self.a.next()) {
None => fuse!(self.b.next()),
None => maybe!(self.b.next()),
item => item,
}
}
Expand Down Expand Up @@ -85,7 +99,7 @@ where
}
if let Some(ref mut b) = self.b {
acc = b.try_fold(acc, f)?;
self.b = None;
// we don't fuse the second iterator
}
Try::from_ok(acc)
}
Expand Down Expand Up @@ -114,7 +128,7 @@ where
}
self.a = None;
}
fuse!(self.b.nth(n))
maybe!(self.b.nth(n))
}

#[inline]
Expand All @@ -123,7 +137,7 @@ where
P: FnMut(&Self::Item) -> bool,
{
match fuse!(self.a.find(&mut predicate)) {
None => fuse!(self.b.find(predicate)),
None => maybe!(self.b.find(predicate)),
item => item,
}
}
Expand Down Expand Up @@ -174,7 +188,7 @@ where
#[inline]
fn next_back(&mut self) -> Option<A::Item> {
match fuse!(self.b.next_back()) {
None => fuse!(self.a.next_back()),
None => maybe!(self.a.next_back()),
item => item,
}
}
Expand All @@ -190,7 +204,7 @@ where
}
self.b = None;
}
fuse!(self.a.nth_back(n))
maybe!(self.a.nth_back(n))
}

#[inline]
Expand All @@ -199,7 +213,7 @@ where
P: FnMut(&Self::Item) -> bool,
{
match fuse!(self.b.rfind(&mut predicate)) {
None => fuse!(self.a.rfind(predicate)),
None => maybe!(self.a.rfind(predicate)),
item => item,
}
}
Expand All @@ -216,7 +230,7 @@ where
}
if let Some(ref mut a) = self.a {
acc = a.try_rfold(acc, f)?;
self.a = None;
// we don't fuse the second iterator
}
Try::from_ok(acc)
}
Expand All @@ -236,8 +250,6 @@ where
}

// Note: *both* must be fused to handle double-ended iterators.
// Now that we "fuse" both sides, we *could* implement this unconditionally,
// but we should be cautious about committing to that in the public API.
#[stable(feature = "fused", since = "1.26.0")]
impl<A, B> FusedIterator for Chain<A, B>
where
Expand Down
64 changes: 39 additions & 25 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,50 +207,64 @@ fn test_iterator_chain_find() {
assert_eq!(iter.next(), None);
}

#[test]
fn test_iterator_chain_size_hint() {
struct Iter {
is_empty: bool,
}
struct Toggle {
is_empty: bool,
}

impl Iterator for Iter {
type Item = ();
impl Iterator for Toggle {
type Item = ();

// alternates between `None` and `Some(())`
fn next(&mut self) -> Option<Self::Item> {
if self.is_empty {
self.is_empty = false;
None
} else {
self.is_empty = true;
Some(())
}
// alternates between `None` and `Some(())`
fn next(&mut self) -> Option<Self::Item> {
if self.is_empty {
self.is_empty = false;
None
} else {
self.is_empty = true;
Some(())
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
if self.is_empty { (0, Some(0)) } else { (1, Some(1)) }
}
fn size_hint(&self) -> (usize, Option<usize>) {
if self.is_empty { (0, Some(0)) } else { (1, Some(1)) }
}
}

impl DoubleEndedIterator for Iter {
fn next_back(&mut self) -> Option<Self::Item> {
self.next()
}
impl DoubleEndedIterator for Toggle {
fn next_back(&mut self) -> Option<Self::Item> {
self.next()
}
}

#[test]
fn test_iterator_chain_size_hint() {
// this chains an iterator of length 0 with an iterator of length 1,
// so after calling `.next()` once, the iterator is empty and the
// state is `ChainState::Back`. `.size_hint()` should now disregard
// the size hint of the left iterator
let mut iter = Iter { is_empty: true }.chain(once(()));
let mut iter = Toggle { is_empty: true }.chain(once(()));
assert_eq!(iter.next(), Some(()));
assert_eq!(iter.size_hint(), (0, Some(0)));

let mut iter = once(()).chain(Iter { is_empty: true });
let mut iter = once(()).chain(Toggle { is_empty: true });
assert_eq!(iter.next_back(), Some(()));
assert_eq!(iter.size_hint(), (0, Some(0)));
}

#[test]
fn test_iterator_chain_unfused() {
// Chain shouldn't be fused in its second iterator, depending on direction
let mut iter = NonFused::new(empty()).chain(Toggle { is_empty: true });
iter.next().unwrap_none();
iter.next().unwrap();
iter.next().unwrap_none();

let mut iter = Toggle { is_empty: true }.chain(NonFused::new(empty()));
iter.next_back().unwrap_none();
iter.next_back().unwrap();
iter.next_back().unwrap_none();
}

#[test]
fn test_zip_nth() {
let xs = [0, 1, 2, 4, 5];
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#![feature(unwrap_infallible)]
#![feature(leading_trailing_ones)]
#![feature(const_forget)]
#![feature(option_unwrap_none)]

extern crate test;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes/E0751.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ There are both a positive and negative trait implementation for the same type.

Erroneous code example:

```compile_fail,E0748
```compile_fail,E0751
trait MyTrait {}
impl MyTrait for i32 { }
impl !MyTrait for i32 { }
Expand Down
9 changes: 3 additions & 6 deletions src/librustc_infer/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
// like `T` and `T::Item`. It may not work as well for things
// like `<T as Foo<'a>>::Item`.
let c_b = self.param_env.caller_bounds;
let param_bounds = self.collect_outlives_from_predicate_list(&compare_ty, c_b);
let param_bounds = self.collect_outlives_from_predicate_list(&compare_ty, c_b.into_iter());

// Next, collect regions we scraped from the well-formedness
// constraints in the fn signature. To do that, we walk the list
Expand Down Expand Up @@ -315,15 +315,12 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
let tcx = self.tcx;
let assoc_item = tcx.associated_item(assoc_item_def_id);
let trait_def_id = assoc_item.container.assert_trait();
let trait_predicates =
tcx.predicates_of(trait_def_id).predicates.iter().map(|(p, _)| *p).collect();
let trait_predicates = tcx.predicates_of(trait_def_id).predicates.iter().map(|(p, _)| *p);
let identity_substs = InternalSubsts::identity_for_item(tcx, assoc_item_def_id);
let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs);
self.collect_outlives_from_predicate_list(
move |ty| ty == identity_proj,
traits::elaborate_predicates(tcx, trait_predicates)
.map(|o| o.predicate)
.collect::<Vec<_>>(),
traits::elaborate_predicates(tcx, trait_predicates).map(|o| o.predicate),
)
.map(|b| b.1)
}
Expand Down
17 changes: 7 additions & 10 deletions src/librustc_infer/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,22 @@ pub fn elaborate_trait_ref<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> Elaborator<'tcx> {
elaborate_predicates(tcx, vec![trait_ref.without_const().to_predicate()])
elaborate_predicates(tcx, std::iter::once(trait_ref.without_const().to_predicate()))
}

pub fn elaborate_trait_refs<'tcx>(
tcx: TyCtxt<'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> Elaborator<'tcx> {
let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate()).collect();
let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate());
elaborate_predicates(tcx, predicates)
}

pub fn elaborate_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
mut predicates: Vec<ty::Predicate<'tcx>>,
predicates: impl IntoIterator<Item = ty::Predicate<'tcx>>,
) -> Elaborator<'tcx> {
let mut visited = PredicateSet::new(tcx);
predicates.retain(|pred| visited.insert(pred));
let obligations: Vec<_> =
let obligations =
predicates.into_iter().map(|predicate| predicate_obligation(predicate, None)).collect();
elaborate_obligations(tcx, obligations)
}
Expand Down Expand Up @@ -151,21 +149,20 @@ impl Elaborator<'tcx> {
// Get predicates declared on the trait.
let predicates = tcx.super_predicates_of(data.def_id());

let obligations = predicates.predicates.iter().map(|(pred, span)| {
let obligations = predicates.predicates.into_iter().map(|(pred, span)| {
predicate_obligation(
pred.subst_supertrait(tcx, &data.to_poly_trait_ref()),
Some(*span),
)
});
debug!("super_predicates: data={:?} predicates={:?}", data, &obligations);
debug!("super_predicates: data={:?}", data);

// Only keep those bounds that we haven't already seen.
// This is necessary to prevent infinite recursion in some
// cases. One common case is when people define
// `trait Sized: Sized { }` rather than `trait Sized { }`.
let visited = &mut self.visited;
let obligations =
obligations.filter(|obligation| visited.insert(&obligation.predicate));
let obligations = obligations.filter(|o| visited.insert(&o.predicate));

self.stack.extend(obligations);
}
Expand Down
Loading

0 comments on commit 0f0d700

Please sign in to comment.