Skip to content
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

Rollup of 13 pull requests #52324

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4d9b6c9
Change RangeInclusive to a three-field struct.
kennytm Jun 18, 2018
0fa94e7
Fix some RangeInclusive test cases.
kennytm Jun 19, 2018
37fbf68
Upgrade implementation of StepBy<RangeInclusive<_>>.
kennytm Jun 22, 2018
5e3bd09
Include is_empty() in PartialEq and Hash.
kennytm Jun 30, 2018
de2ecea
Provide llvm-strip in llvm-tools component
crlf0710 Jul 1, 2018
6035534
Implement `Option::replace` in the core library
Kerollmops Jul 4, 2018
2c2add6
Update std::ascii::ASCIIExt deprecation notes
zajlerke Jul 8, 2018
af87a35
Add a basic test to `Option::replace`
Jul 9, 2018
c8f0e6f
Fix the documentation of `Option::replace`
Jul 9, 2018
560d807
Deny bare trait objects in `src/libstd`.
ljedrz Jul 10, 2018
b29a6fb
Add missing `dyn` for cloudabi, redox, unix and wasm
ljedrz Jul 10, 2018
1915cd1
Add missing dyn in tests
ljedrz Jul 11, 2018
f45d5eb
llvm-tools-preview: fix build-manifest
japaric Jul 12, 2018
0d7b2e6
Deny bare trait objects in src/librustc_save_analysis
ljedrz Jul 12, 2018
f29ac5a
Deny bare trait objects in librustc_typeck
ljedrz Jul 12, 2018
0878453
Deny bare trait objects in src/libserialize
ljedrz Jul 12, 2018
5058af7
Deny bare trait objects in the rest of rust
ljedrz Jul 12, 2018
4c340a2
Backport 1.27.1 release notes to master
Mark-Simulacrum Jul 12, 2018
72f096b
Resolve FIXME(#27942)
ljedrz Jul 12, 2018
9ead0d8
Update llvm-rebuild-trigger in light of LLVM 7 upgrade
varkor Jul 12, 2018
66602ac
Rollup merge of #51622 - kennytm:three-field-range-inclusive, r=Simon…
kennytm Jul 12, 2018
10443c8
Rollup merge of #51962 - crlf0710:patch-2, r=alexcrichton
kennytm Jul 12, 2018
e2683f2
Rollup merge of #52003 - Kerollmops:option-replace, r=Kimundi
kennytm Jul 12, 2018
530ddcd
Rollup merge of #52156 - zajlerke:update-deprecation-notice, r=Kimundi
kennytm Jul 12, 2018
efad6f1
Rollup merge of #52221 - ljedrz:dyn_libstd, r=Kimundi
kennytm Jul 12, 2018
360412e
Rollup merge of #52280 - japaric:llvm-tools-preview, r=kennytm
kennytm Jul 12, 2018
15925fc
Rollup merge of #52290 - ljedrz:dyn_librustc_save_analysis, r=cramertj
kennytm Jul 12, 2018
36a4b20
Rollup merge of #52293 - ljedrz:dyn_librustc_typeck, r=estebank
kennytm Jul 12, 2018
739056d
Rollup merge of #52299 - ljedrz:dyn_libserialize, r=cramertj
kennytm Jul 12, 2018
c1d7d38
Rollup merge of #52302 - ljedrz:dyn_futureproofing, r=cramertj
kennytm Jul 12, 2018
cd78a44
Rollup merge of #52310 - Mark-Simulacrum:release-notes-backport-from-…
kennytm Jul 12, 2018
f8039bf
Rollup merge of #52315 - ljedrz:FIXME_#27942, r=petrochenkov
kennytm Jul 12, 2018
754f60f
Rollup merge of #52322 - varkor:llvm-7-rebuild-trigger, r=alexcrichton
kennytm Jul 12, 2018
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
23 changes: 23 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ Compatibility Notes
[`{Any + Send + Sync}::downcast_ref`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref-2
[`{Any + Send + Sync}::is`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.is-2

Version 1.27.1 (2018-07-10)
===========================

Security Notes
--------------

- rustdoc would execute plugins in the /tmp/rustdoc/plugins directory
when running, which enabled executing code as some other user on a
given machine. This release fixes that vulnerability; you can read
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].

Thank you to Red Hat for responsibily disclosing this vulnerability to us.

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

- The borrow checker was fixed to avoid an additional potential unsoundness when using
match ergonomics: [#51415][51415], [#49534][49534].

[51415]: https://github.com/rust-lang/rust/issues/51415
[49534]: https://github.com/rust-lang/rust/issues/49534
[rustdoc-sec]: https://blog.rust-lang.org/2018/07/06/security-advisory-for-rustdoc.html
[CVE-2018-1000622]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=%20CVE-2018-1000622

Version 1.27.0 (2018-06-21)
==========================
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ const LLVM_TOOLS: &[&str] = &[
"llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume
"llvm-objdump", // used to disassemble programs
"llvm-profdata", // used to inspect and merge files generated by profiles
"llvm-size", // prints the size of the linker sections of a program
"llvm-size", // used to prints the size of the linker sections of a program
"llvm-strip", // used to discard symbols from binary files to reduce their size
];

/// A structure representing a Rust compiler.
Expand Down
2 changes: 2 additions & 0 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(bare_trait_objects)]

use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_jemalloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![no_std]
#![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_jemalloc",
reason = "implementation detail of std, does not provide any public API",
issue = "0")]
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![no_std]
#![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \
form or name",
Expand Down
1 change: 1 addition & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![cfg_attr(test, feature(test))]

#![allow(deprecated)]
#![deny(bare_trait_objects)]

extern crate alloc;
extern crate rustc_data_structures;
Expand Down
8 changes: 5 additions & 3 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,17 +787,19 @@ where
#[inline]
fn spec_next(&mut self) -> Option<Self::Item> {
self.first_take = false;
if !(self.iter.start <= self.iter.end) {
if self.iter.is_empty() {
self.iter.is_iterating = Some(false);
return None;
}
// add 1 to self.step to get original step size back
// it was decremented for the general case on construction
if let Some(n) = self.iter.start.add_usize(self.step+1) {
self.iter.is_iterating = Some(n <= self.iter.end);
let next = mem::replace(&mut self.iter.start, n);
Some(next)
} else {
let last = self.iter.start.replace_one();
self.iter.end.replace_zero();
let last = self.iter.start.clone();
self.iter.is_iterating = Some(false);
Some(last)
}
}
Expand Down
100 changes: 30 additions & 70 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use convert::TryFrom;
use mem;
use ops::{self, Add, Sub, Try};
use ops::{self, Add, Sub};
use usize;

use super::{FusedIterator, TrustedLen};
Expand Down Expand Up @@ -330,23 +330,23 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {

#[inline]
fn next(&mut self) -> Option<A> {
if self.start <= self.end {
if self.start < self.end {
let n = self.start.add_one();
Some(mem::replace(&mut self.start, n))
} else {
let last = self.start.replace_one();
self.end.replace_zero();
Some(last)
}
if self.is_empty() {
self.is_iterating = Some(false);
return None;
}
if self.start < self.end {
let n = self.start.add_one();
self.is_iterating = Some(true);
Some(mem::replace(&mut self.start, n))
} else {
None
self.is_iterating = Some(false);
Some(self.start.clone())
}
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
if !(self.start <= self.end) {
if self.is_empty() {
return (0, Some(0));
}

Expand All @@ -358,25 +358,29 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {

#[inline]
fn nth(&mut self, n: usize) -> Option<A> {
if self.is_empty() {
self.is_iterating = Some(false);
return None;
}

if let Some(plus_n) = self.start.add_usize(n) {
use cmp::Ordering::*;

match plus_n.partial_cmp(&self.end) {
Some(Less) => {
self.is_iterating = Some(true);
self.start = plus_n.add_one();
return Some(plus_n)
}
Some(Equal) => {
self.start.replace_one();
self.end.replace_zero();
self.is_iterating = Some(false);
return Some(plus_n)
}
_ => {}
}
}

self.start.replace_one();
self.end.replace_zero();
self.is_iterating = Some(false);
None
}

Expand All @@ -394,68 +398,24 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
fn max(mut self) -> Option<A> {
self.next_back()
}

#[inline]
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
let mut accum = init;
if self.start <= self.end {
loop {
let (x, done) =
if self.start < self.end {
let n = self.start.add_one();
(mem::replace(&mut self.start, n), false)
} else {
self.end.replace_zero();
(self.start.replace_one(), true)
};
accum = f(accum, x)?;
if done { break }
}
}
Try::from_ok(accum)
}
}

#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
#[inline]
fn next_back(&mut self) -> Option<A> {
if self.start <= self.end {
if self.start < self.end {
let n = self.end.sub_one();
Some(mem::replace(&mut self.end, n))
} else {
let last = self.end.replace_zero();
self.start.replace_one();
Some(last)
}
} else {
None
if self.is_empty() {
self.is_iterating = Some(false);
return None;
}
}

#[inline]
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
let mut accum = init;
if self.start <= self.end {
loop {
let (x, done) =
if self.start < self.end {
let n = self.end.sub_one();
(mem::replace(&mut self.end, n), false)
} else {
self.start.replace_one();
(self.end.replace_zero(), true)
};
accum = f(accum, x)?;
if done { break }
}
if self.start < self.end {
let n = self.end.sub_one();
self.is_iterating = Some(true);
Some(mem::replace(&mut self.end, n))
} else {
self.is_iterating = Some(false);
Some(self.end.clone())
}
Try::from_ok(accum)
}
}

Expand Down
57 changes: 50 additions & 7 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use fmt;
use hash::{Hash, Hasher};

/// An unbounded range (`..`).
///
Expand Down Expand Up @@ -326,15 +327,56 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
/// ```
#[doc(alias = "..=")]
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[derive(Clone)] // not Copy -- see #27186
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub struct RangeInclusive<Idx> {
// FIXME: The current representation follows RFC 1980,
// but it is known that LLVM is not able to optimize loops following that RFC.
// Consider adding an extra `bool` field to indicate emptiness of the range.
// See #45222 for performance test cases.
pub(crate) start: Idx,
pub(crate) end: Idx,
pub(crate) is_iterating: Option<bool>,
// This field is:
// - `None` when next() or next_back() was never called
// - `Some(true)` when `start <= end` assuming no overflow
// - `Some(false)` otherwise
// The field cannot be a simple `bool` because the `..=` constructor can
// accept non-PartialOrd types, also we want the constructor to be const.
}

trait RangeInclusiveEquality: Sized {
fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool;
}
impl<T> RangeInclusiveEquality for T {
#[inline]
default fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool {
!range.is_iterating.unwrap_or(false)
}
}
impl<T: PartialOrd> RangeInclusiveEquality for T {
#[inline]
fn canonicalized_is_empty(range: &RangeInclusive<Self>) -> bool {
range.is_empty()
}
}

#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: PartialEq> PartialEq for RangeInclusive<Idx> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.start == other.start && self.end == other.end
&& RangeInclusiveEquality::canonicalized_is_empty(self)
== RangeInclusiveEquality::canonicalized_is_empty(other)
}
}

#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: Eq> Eq for RangeInclusive<Idx> {}

#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: Hash> Hash for RangeInclusive<Idx> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.start.hash(state);
self.end.hash(state);
RangeInclusiveEquality::canonicalized_is_empty(self).hash(state);
}
}

impl<Idx> RangeInclusive<Idx> {
Expand All @@ -350,7 +392,7 @@ impl<Idx> RangeInclusive<Idx> {
#[stable(feature = "inclusive_range_methods", since = "1.27.0")]
#[inline]
pub const fn new(start: Idx, end: Idx) -> Self {
Self { start, end }
Self { start, end, is_iterating: None }
}

/// Returns the lower bound of the range (inclusive).
Expand Down Expand Up @@ -492,8 +534,9 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// assert!(r.is_empty());
/// ```
#[unstable(feature = "range_is_empty", reason = "recently added", issue = "48111")]
#[inline]
pub fn is_empty(&self) -> bool {
!(self.start <= self.end)
!self.is_iterating.unwrap_or_else(|| self.start <= self.end)
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,33 @@ impl<T> Option<T> {
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None)
}

/// Replaces the actual value in the option by the value given in parameter,
/// returning the old value if present,
/// leaving a [`Some`] in its place without deinitializing either one.
///
/// [`Some`]: #variant.Some
///
/// # Examples
///
/// ```
/// #![feature(option_replace)]
///
/// let mut x = Some(2);
/// let old = x.replace(5);
/// assert_eq!(x, Some(5));
/// assert_eq!(old, Some(2));
///
/// let mut x = None;
/// let old = x.replace(3);
/// assert_eq!(x, Some(3));
/// assert_eq!(old, None);
/// ```
#[inline]
#[unstable(feature = "option_replace", issue = "51998")]
pub fn replace(&mut self, value: T) -> Option<T> {
mem::replace(self, Some(value))
}
}

impl<'a, T: Clone> Option<&'a T> {
Expand Down
Loading