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 9 pull requests #72203

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb27039
Use min_specialization in liballoc
matthewjasper Apr 19, 2020
e5a1be8
Use `LocalDefId` in `DumpVisitor::nest_tables`
marmeladema May 2, 2020
3471bc8
Fix unused_parens false positive when using binary operations
mibac138 May 4, 2020
717a7a8
Update src/test/ui/lint/issue-71290-unused-paren-binop.rs
mibac138 May 5, 2020
4b7a928
Fix unused_parens nested binary op false positive
mibac138 May 5, 2020
1fce203
expand "incomplete feature" message to include unsoundness and link t…
RalfJung May 9, 2020
6a8cf4a
adjust tests
RalfJung Apr 22, 2020
c400f75
Miri interning: replace ICEs by proper errors, make intern_shallow ty…
RalfJung Apr 29, 2020
8e48a30
remove some dead code, and assert we do not swallow allocating errors
RalfJung Apr 29, 2020
ff39457
avoid raising interpreter errors from interning
RalfJung Apr 29, 2020
d3b2e1f
fmt
RalfJung Apr 29, 2020
a06740c
Typo
RalfJung Apr 29, 2020
e73ee41
rebase fallout
RalfJung May 4, 2020
5e35493
cargo update -p serde_derive
Xanewok May 5, 2020
403a9d0
cargo update -p failure_derive
Xanewok May 5, 2020
8c6e568
cargo update -p pest_generator
Xanewok May 5, 2020
3bdaced
cargo update -p derive-new
Xanewok May 5, 2020
e26f35d
rustbook: Bump mdbook dependency
Xanewok May 5, 2020
9111d8b
Fix the new capacity measurement in arenas.
nnethercote May 4, 2020
40d4868
Be less aggressive with `DroplessArena`/`TypedArena` growth.
nnethercote May 4, 2020
31fbf33
Clean up E0589 explanation
GuillaumeGomez May 14, 2020
f6aa161
Don't ICE on missing `Unsize` impl
doctorn May 14, 2020
73c227c
Rollup merge of #71321 - matthewjasper:alloc-min-spec, r=sfackler
RalfJung May 14, 2020
47960fe
Rollup merge of #71665 - RalfJung:miri-intern-no-ice, r=oli-obk
RalfJung May 14, 2020
ef55dc0
Rollup merge of #71809 - marmeladema:fix-issue-71104, r=eddyb
RalfJung May 14, 2020
8bd2319
Rollup merge of #71872 - nnethercote:less-aggressive-arena-growth, r=…
RalfJung May 14, 2020
91cd222
Rollup merge of #71910 - mibac138:necessary-paren, r=cuviper
RalfJung May 14, 2020
30811cf
Rollup merge of #71919 - Xanewok:bump-syn-1, r=Mark-Simulacrum
RalfJung May 14, 2020
c038ea1
Rollup merge of #72045 - RalfJung:incomplete-unsound, r=petrochenkov
RalfJung May 14, 2020
8cc6147
Rollup merge of #72191 - GuillaumeGomez:cleanup-e0589, r=Dylan-DPC
RalfJung May 14, 2020
2b03aa2
Rollup merge of #72194 - doctorn:dispatch-from-dyn-ice, r=estebank
RalfJung May 14, 2020
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
86 changes: 31 additions & 55 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]

[[package]]
Expand Down Expand Up @@ -937,13 +937,13 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"

[[package]]
name = "derive-new"
version = "0.5.6"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c"
checksum = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]

[[package]]
Expand Down Expand Up @@ -1144,14 +1144,14 @@ dependencies = [

[[package]]
name = "failure_derive"
version = "0.1.5"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"synstructure 0.10.2",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure",
]

[[package]]
Expand Down Expand Up @@ -1404,30 +1404,18 @@ dependencies = [

[[package]]
name = "handlebars"
version = "2.0.1"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df044dd42cdb7e32f28557b661406fc0f2494be75199779998810dbc35030e0d"
checksum = "ba758d094d31274eb49d15da6f326b96bf3185239a6359bf684f3d5321148900"
dependencies = [
"hashbrown 0.5.0",
"lazy_static 1.4.0",
"log",
"pest",
"pest_derive",
"quick-error",
"regex",
"serde",
"serde_json",
]

[[package]]
name = "hashbrown"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353"
dependencies = [
"serde",
]

[[package]]
name = "hashbrown"
version = "0.6.2"
Expand Down Expand Up @@ -2054,9 +2042,9 @@ dependencies = [

[[package]]
name = "mdbook"
version = "0.3.5"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031bdd9d4893c983e2f69ebc4b59070feee8276a584c4aabdcb351235ea28016"
checksum = "e7ec525f7ebccc2dd935c263717250cd37f9a4b264a77c5dbc950ea2734d8159"
dependencies = [
"ammonia",
"chrono",
Expand Down Expand Up @@ -2556,15 +2544,15 @@ dependencies = [

[[package]]
name = "pest_generator"
version = "2.1.0"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
dependencies = [
"pest",
"pest_meta",
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]

[[package]]
Expand Down Expand Up @@ -2784,9 +2772,9 @@ checksum = "6ddd112cca70a4d30883b2d21568a1d376ff8be4758649f64f973c6845128ad3"

[[package]]
name = "quick-error"
version = "1.2.2"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"

[[package]]
name = "quine-mc_cluskey"
Expand Down Expand Up @@ -3448,7 +3436,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]

[[package]]
Expand Down Expand Up @@ -4058,7 +4046,7 @@ dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
"synstructure 0.12.1",
"synstructure",
]

[[package]]
Expand Down Expand Up @@ -4629,13 +4617,13 @@ dependencies = [

[[package]]
name = "serde_derive"
version = "1.0.81"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885"
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]

[[package]]
Expand Down Expand Up @@ -4799,7 +4787,7 @@ dependencies = [
"core",
"dlmalloc",
"fortanix-sgx-abi",
"hashbrown 0.6.2",
"hashbrown",
"hermit-abi",
"libc",
"panic_abort",
Expand Down Expand Up @@ -4931,18 +4919,6 @@ dependencies = [
"unicode-xid 0.2.0",
]

[[package]]
name = "synstructure"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"unicode-xid 0.1.0",
]

[[package]]
name = "synstructure"
version = "0.12.1"
Expand Down
53 changes: 0 additions & 53 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,59 +215,6 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
clone_subtree(self.root.as_ref().unwrap().as_ref())
}
}

fn clone_from(&mut self, other: &Self) {
BTreeClone::clone_from(self, other);
}
}

trait BTreeClone {
fn clone_from(&mut self, other: &Self);
}

impl<K: Clone, V: Clone> BTreeClone for BTreeMap<K, V> {
default fn clone_from(&mut self, other: &Self) {
*self = other.clone();
}
}

impl<K: Clone + Ord, V: Clone> BTreeClone for BTreeMap<K, V> {
fn clone_from(&mut self, other: &Self) {
// This truncates `self` to `other.len()` by calling `split_off` on
// the first key after `other.len()` elements if it exists.
let split_off_key = if self.len() > other.len() {
let diff = self.len() - other.len();
if diff <= other.len() {
self.iter().nth_back(diff - 1).map(|pair| (*pair.0).clone())
} else {
self.iter().nth(other.len()).map(|pair| (*pair.0).clone())
}
} else {
None
};
if let Some(key) = split_off_key {
self.split_off(&key);
}

let mut siter = self.range_mut(..);
let mut oiter = other.iter();
// After truncation, `self` is at most as long as `other` so this loop
// replaces every key-value pair in `self`. Since `oiter` is in sorted
// order and the structure of the `BTreeMap` stays the same,
// the BTree invariants are maintained at the end of the loop.
while !siter.is_empty() {
if let Some((ok, ov)) = oiter.next() {
// SAFETY: This is safe because `siter` is nonempty.
let (sk, sv) = unsafe { siter.next_unchecked() };
sk.clone_from(ok);
sv.clone_from(ov);
} else {
break;
}
}
// If `other` is longer than `self`, the remaining elements are inserted.
self.extend(oiter.map(|(k, v)| ((*k).clone(), (*v).clone())));
}
}

impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()>
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
#![feature(ptr_offset_from)]
#![feature(rustc_attrs)]
#![feature(receiver_trait)]
#![feature(specialization)]
#![feature(min_specialization)]
#![feature(staged_api)]
#![feature(std_internals)]
#![feature(str_internals)]
Expand Down
46 changes: 19 additions & 27 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ use core::mem::{self, align_of, align_of_val, forget, size_of_val};
use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
use core::pin::Pin;
use core::ptr::{self, NonNull};
use core::slice::{self, from_raw_parts_mut};
use core::slice::from_raw_parts_mut;

use crate::alloc::{box_free, handle_alloc_error, AllocInit, AllocRef, Global, Layout};
use crate::string::String;
Expand Down Expand Up @@ -1221,6 +1221,12 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
}
}

// Hack to allow specializing on `Eq` even though `Eq` has a method.
#[rustc_unsafe_specialization_marker]
pub(crate) trait MarkerEq: PartialEq<Self> {}

impl<T: Eq> MarkerEq for T {}

/// We're doing this specialization here, and not as a more general optimization on `&T`, because it
/// would otherwise add a cost to all equality checks on refs. We assume that `Rc`s are used to
/// store large values, that are slow to clone, but also heavy to check for equality, causing this
Expand All @@ -1229,7 +1235,7 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
///
/// We can only do this when `T: Eq` as a `PartialEq` might be deliberately irreflexive.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
impl<T: ?Sized + MarkerEq> RcEqIdent<T> for Rc<T> {
#[inline]
fn eq(&self, other: &Rc<T>) -> bool {
Rc::ptr_eq(self, other) || **self == **other
Expand Down Expand Up @@ -1548,25 +1554,25 @@ impl<T> iter::FromIterator<T> for Rc<[T]> {
/// # assert_eq!(&*evens, &*(0..10).collect::<Vec<_>>());
/// ```
fn from_iter<I: iter::IntoIterator<Item = T>>(iter: I) -> Self {
RcFromIter::from_iter(iter.into_iter())
ToRcSlice::to_rc_slice(iter.into_iter())
}
}

/// Specialization trait used for collecting into `Rc<[T]>`.
trait RcFromIter<T, I> {
fn from_iter(iter: I) -> Self;
trait ToRcSlice<T>: Iterator<Item = T> + Sized {
fn to_rc_slice(self) -> Rc<[T]>;
}

impl<T, I: Iterator<Item = T>> RcFromIter<T, I> for Rc<[T]> {
default fn from_iter(iter: I) -> Self {
iter.collect::<Vec<T>>().into()
impl<T, I: Iterator<Item = T>> ToRcSlice<T> for I {
default fn to_rc_slice(self) -> Rc<[T]> {
self.collect::<Vec<T>>().into()
}
}

impl<T, I: iter::TrustedLen<Item = T>> RcFromIter<T, I> for Rc<[T]> {
default fn from_iter(iter: I) -> Self {
impl<T, I: iter::TrustedLen<Item = T>> ToRcSlice<T> for I {
fn to_rc_slice(self) -> Rc<[T]> {
// This is the case for a `TrustedLen` iterator.
let (low, high) = iter.size_hint();
let (low, high) = self.size_hint();
if let Some(high) = high {
debug_assert_eq!(
low,
Expand All @@ -1577,29 +1583,15 @@ impl<T, I: iter::TrustedLen<Item = T>> RcFromIter<T, I> for Rc<[T]> {

unsafe {
// SAFETY: We need to ensure that the iterator has an exact length and we have.
Rc::from_iter_exact(iter, low)
Rc::from_iter_exact(self, low)
}
} else {
// Fall back to normal implementation.
iter.collect::<Vec<T>>().into()
self.collect::<Vec<T>>().into()
}
}
}

impl<'a, T: 'a + Clone> RcFromIter<&'a T, slice::Iter<'a, T>> for Rc<[T]> {
fn from_iter(iter: slice::Iter<'a, T>) -> Self {
// Delegate to `impl<T: Clone> From<&[T]> for Rc<[T]>`.
//
// In the case that `T: Copy`, we get to use `ptr::copy_nonoverlapping`
// which is even more performant.
//
// In the fall-back case we have `T: Clone`. This is still better
// than the `TrustedLen` implementation as slices have a known length
// and so we get to avoid calling `size_hint` and avoid the branching.
iter.as_slice().into()
}
}

/// `Weak` is a version of [`Rc`] that holds a non-owning reference to the
/// managed allocation. The allocation is accessed by calling [`upgrade`] on the `Weak`
/// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`.
Expand Down
Loading