Skip to content

Rollup of 12 pull requests #77132

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

Closed
wants to merge 42 commits into from
Closed
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c100e72
Stabilize intra-doc links
Manishearth Jul 17, 2020
63d5bee
Move intra-doc-links documentation out of unstable section
Manishearth Jul 17, 2020
bc06674
Mention super/crate/self in docs
Manishearth Jul 17, 2020
f072e4a
Mention URL fragments
Manishearth Jul 17, 2020
2a98409
Fill out docs on intra-doc resolution failure lint
Manishearth Jul 29, 2020
4e0eb0b
Update src/doc/rustdoc/src/linking-to-items-by-name.md
Manishearth Aug 9, 2020
175e305
Update src/doc/rustdoc/src/linking-to-items-by-name.md
Manishearth Aug 9, 2020
51c1351
Resolve some conflicts
Manishearth Sep 14, 2020
6f1fa2b
Fix lint name in docs
Manishearth Sep 14, 2020
792b2ea
Update src/doc/rustdoc/src/lints.md
Manishearth Sep 15, 2020
ff1a9e4
Fix underflow when calculating the number of no-op jumps folded
tmiasko Sep 16, 2020
6928041
Update src/doc/rustdoc/src/linking-to-items-by-name.md
Manishearth Sep 18, 2020
5fd6301
ICEs should print the top of the query stack
hosseind75 Sep 19, 2020
132c9ef
run full query stack print just when RUST_BACKTRACE is set
hosseind75 Sep 19, 2020
767e84a
change approach and run ui tests
hosseind75 Sep 19, 2020
339181a
show a message when we are showing limited slice of query stack
hosseind75 Sep 19, 2020
51c32f4
fix invalid-punct-ident-1 test
hosseind75 Sep 19, 2020
d8af4b3
add filter regexes to load-panic-backtraces test
hosseind75 Sep 20, 2020
3f0f409
Documented From impls in std/sync/mpsc/mod.rs
duckymirror Sep 20, 2020
16eee2a
Applied review comments
duckymirror Sep 21, 2020
4a6bc77
Liballoc bench vec use mem take not replace
pickfire Sep 22, 2020
0082d20
Typo fix: "satsify" -> "satisfy"
follower Sep 22, 2020
4b6a482
Fix dest prop miscompilation around references
jonas-schievink Sep 22, 2020
928a29f
Bless mir-opt tests
jonas-schievink Sep 22, 2020
9f27f37
Include libunwind in the rust-src component.
ehuss Sep 23, 2020
6586c37
Move MiniSet to data_structures
andjo403 Sep 23, 2020
631c688
Make [].as_[mut_]ptr_range() (unstably) const.
m-ou-se Sep 23, 2020
b5d47bf
clarify that `changelog-seen = 1` goes to the beginning of config.toml
matthiaskrgr Sep 23, 2020
cdd3126
fix show we're just showing... message instead of the end of query st…
hosseind75 Sep 23, 2020
947536f
Make delegation methods of `std::net::IpAddr` unstable const
CDirkx Sep 7, 2020
c7d68ed
Rollup merge of #74430 - Manishearth:stabilize-intra-doc, r=Manishearth
Dylan-DPC Sep 24, 2020
4893b4f
Rollup merge of #76304 - CDirkx:const-ip, r=ecstatic-morse
Dylan-DPC Sep 24, 2020
8836966
Rollup merge of #76748 - tmiasko:no-op-jumps, r=matthewjasper
Dylan-DPC Sep 24, 2020
0e4149d
Rollup merge of #76920 - hosseind75:ICEs_should_always_print_the_top_…
Dylan-DPC Sep 24, 2020
bd7f3f1
Rollup merge of #76978 - duckymirror:mpsc-from-doc, r=jyn514
Dylan-DPC Sep 24, 2020
63ea0cf
Rollup merge of #77028 - andjo403:mini, r=matthewjasper
Dylan-DPC Sep 24, 2020
af24b83
Rollup merge of #77044 - pickfire:patch-4, r=jyn514
Dylan-DPC Sep 24, 2020
7075433
Rollup merge of #77050 - follower:patch-1, r=oli-obk
Dylan-DPC Sep 24, 2020
1a66e27
Rollup merge of #77066 - jonas-schievink:dest-prop-borrow, r=oli-obk
Dylan-DPC Sep 24, 2020
9a85615
Rollup merge of #77086 - ehuss:src-libunwind, r=Mark-Simulacrum
Dylan-DPC Sep 24, 2020
5572820
Rollup merge of #77097 - fusion-engineering-forks:slice-ptr-range-con…
Dylan-DPC Sep 24, 2020
feb6392
Rollup merge of #77106 - matthiaskrgr:changelog_seen, r=Mark-Simulacrum
Dylan-DPC Sep 24, 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
2 changes: 0 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -3638,7 +3638,6 @@ dependencies = [
name = "rustc_infer"
version = "0.0.0"
dependencies = [
"arrayvec",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
@@ -3778,7 +3777,6 @@ dependencies = [
name = "rustc_middle"
version = "0.0.0"
dependencies = [
"arrayvec",
"bitflags",
"chalk-ir",
"measureme",
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ pub mod work_queue;
pub use atomic_ref::AtomicRef;
pub mod frozen;
pub mod mini_map;
pub mod mini_set;
pub mod tagged_ptr;
pub mod temp_dir;
pub mod unhash;
41 changes: 41 additions & 0 deletions compiler/rustc_data_structures/src/mini_set.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::fx::FxHashSet;
use arrayvec::ArrayVec;
use std::hash::Hash;
/// Small-storage-optimized implementation of a set.
///
/// Stores elements in a small array up to a certain length
/// and switches to `HashSet` when that length is exceeded.
pub enum MiniSet<T> {
Array(ArrayVec<[T; 8]>),
Set(FxHashSet<T>),
}

impl<T: Eq + Hash> MiniSet<T> {
/// Creates an empty `MiniSet`.
pub fn new() -> Self {
MiniSet::Array(ArrayVec::new())
}

/// Adds a value to the set.
///
/// If the set did not have this value present, true is returned.
///
/// If the set did have this value present, false is returned.
pub fn insert(&mut self, elem: T) -> bool {
match self {
MiniSet::Array(array) => {
if array.iter().any(|e| *e == elem) {
false
} else {
if let Err(error) = array.try_push(elem) {
let mut set: FxHashSet<T> = array.drain(..).collect();
set.insert(error.element());
*self = MiniSet::Set(set);
}
true
}
}
MiniSet::Set(set) => set.insert(elem),
}
}
}
6 changes: 3 additions & 3 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1205,9 +1205,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
// If backtraces are enabled, also print the query stack
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);

if backtrace {
TyCtxt::try_print_query_stack(&handler);
}
let num_frames = if backtrace { None } else { Some(2) };

TyCtxt::try_print_query_stack(&handler, num_frames);

#[cfg(windows)]
unsafe {
1 change: 0 additions & 1 deletion compiler/rustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -21,5 +21,4 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
arrayvec = { version = "0.5.1", default-features = false }
rustc_ast = { path = "../rustc_ast" }
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::{GenericKind, VerifyBound};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::mini_set::MiniSet;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::walk::MiniSet;
use rustc_middle::ty::{self, Ty, TyCtxt};

/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
1 change: 0 additions & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -28,6 +28,5 @@ rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
chalk-ir = "0.21.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
arrayvec = { version = "0.5.1", default-features = false }
measureme = "0.7.1"
rustc_session = { path = "../rustc_session" }
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/outlives.rs
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
// RFC for reference.

use crate::ty::subst::{GenericArg, GenericArgKind};
use crate::ty::walk::MiniSet;
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::mini_set::MiniSet;
use smallvec::SmallVec;

#[derive(Debug)]
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/print/mod.rs
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ use crate::ty::subst::{GenericArg, Subst};
use crate::ty::{self, DefIdTree, Ty, TyCtxt};

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::mini_set::MiniSet;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
use rustc_middle::ty::walk::MiniSet;

// `pretty` is a separate module only for organization.
mod pretty;
11 changes: 9 additions & 2 deletions compiler/rustc_middle/src/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

pub fn try_print_query_stack(handler: &Handler) {
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
eprintln!("query stack during panic:");

// Be careful reyling on global state here: this code is called from
@@ -138,6 +138,9 @@ impl<'tcx> TyCtxt<'tcx> {
let mut i = 0;

while let Some(query) = current_query {
if num_frames == Some(i) {
break;
}
let query_info =
if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) {
info
@@ -163,7 +166,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
});

eprintln!("end of query stack");
if num_frames != None {
eprintln!("we're just showing a limited slice of the query stack");
} else {
eprintln!("end of query stack");
}
}
}

44 changes: 1 addition & 43 deletions compiler/rustc_middle/src/ty/walk.rs
Original file line number Diff line number Diff line change
@@ -3,50 +3,8 @@

use crate::ty;
use crate::ty::subst::{GenericArg, GenericArgKind};
use arrayvec::ArrayVec;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::mini_set::MiniSet;
use smallvec::{self, SmallVec};
use std::hash::Hash;

/// Small-storage-optimized implementation of a set
/// made specifically for walking type tree.
///
/// Stores elements in a small array up to a certain length
/// and switches to `HashSet` when that length is exceeded.
pub enum MiniSet<T> {
Array(ArrayVec<[T; 8]>),
Set(FxHashSet<T>),
}

impl<T: Eq + Hash + Copy> MiniSet<T> {
/// Creates an empty `MiniSet`.
pub fn new() -> Self {
MiniSet::Array(ArrayVec::new())
}

/// Adds a value to the set.
///
/// If the set did not have this value present, true is returned.
///
/// If the set did have this value present, false is returned.
pub fn insert(&mut self, elem: T) -> bool {
match self {
MiniSet::Array(array) => {
if array.iter().any(|e| *e == elem) {
false
} else {
if array.try_push(elem).is_err() {
let mut set: FxHashSet<T> = array.iter().copied().collect();
set.insert(elem);
*self = MiniSet::Set(set);
}
true
}
}
MiniSet::Set(set) => set.insert(elem),
}
}
}

// The TypeWalker's stack is hot enough that it's worth going to some effort to
// avoid heap allocations.
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/dest_prop.rs
Original file line number Diff line number Diff line change
@@ -905,7 +905,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindAssignments<'a, 'tcx> {
// FIXME: This can be smarter and take `StorageDead` into account (which
// invalidates borrows).
if self.ever_borrowed_locals.contains(dest.local)
&& self.ever_borrowed_locals.contains(src.local)
|| self.ever_borrowed_locals.contains(src.local)
{
return;
}
19 changes: 10 additions & 9 deletions compiler/rustc_mir/src/transform/remove_noop_landing_pads.rs
Original file line number Diff line number Diff line change
@@ -102,6 +102,16 @@ impl RemoveNoopLandingPads {
let postorder: Vec<_> = traversal::postorder(body).map(|(bb, _)| bb).collect();
for bb in postorder {
debug!(" processing {:?}", bb);
if let Some(unwind) = body[bb].terminator_mut().unwind_mut() {
if let Some(unwind_bb) = *unwind {
if nop_landing_pads.contains(unwind_bb) {
debug!(" removing noop landing pad");
landing_pads_removed += 1;
*unwind = None;
}
}
}

for target in body[bb].terminator_mut().successors_mut() {
if *target != resume_block && nop_landing_pads.contains(*target) {
debug!(" folding noop jump to {:?} to resume block", target);
@@ -110,15 +120,6 @@ impl RemoveNoopLandingPads {
}
}

if let Some(unwind) = body[bb].terminator_mut().unwind_mut() {
if *unwind == Some(resume_block) {
debug!(" removing noop landing pad");
jumps_folded -= 1;
landing_pads_removed += 1;
*unwind = None;
}
}

let is_nop_landing_pad = self.is_nop_landing_pad(bb, body, &nop_landing_pads);
if is_nop_landing_pad {
nop_landing_pads.insert(bb);
6 changes: 3 additions & 3 deletions library/alloc/benches/vec.rs
Original file line number Diff line number Diff line change
@@ -241,7 +241,7 @@ fn bench_extend_recycle(b: &mut Bencher) {
let mut data = vec![0; 1000];

b.iter(|| {
let tmp = std::mem::replace(&mut data, Vec::new());
let tmp = std::mem::take(&mut data);
let mut to_extend = black_box(Vec::new());
to_extend.extend(tmp.into_iter());
data = black_box(to_extend);
@@ -500,7 +500,7 @@ fn bench_in_place_recycle(b: &mut Bencher) {
let mut data = vec![0; 1000];

b.iter(|| {
let tmp = std::mem::replace(&mut data, Vec::new());
let tmp = std::mem::take(&mut data);
data = black_box(
tmp.into_iter()
.enumerate()
@@ -520,7 +520,7 @@ fn bench_in_place_zip_recycle(b: &mut Bencher) {
rng.fill_bytes(&mut subst[..]);

b.iter(|| {
let tmp = std::mem::replace(&mut data, Vec::new());
let tmp = std::mem::take(&mut data);
let mangled = tmp
.into_iter()
.zip(subst.iter().copied())
2 changes: 1 addition & 1 deletion library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
@@ -412,7 +412,7 @@ impl<T> Vec<T> {
/// (at least, it's highly likely to be incorrect if it wasn't).
/// * `T` needs to have the same size and alignment as what `ptr` was allocated with.
/// (`T` having a less strict alignment is not sufficient, the alignment really
/// needs to be equal to satsify the [`dealloc`] requirement that memory must be
/// needs to be equal to satisfy the [`dealloc`] requirement that memory must be
/// allocated and deallocated with the same layout.)
/// * `length` needs to be less than or equal to `capacity`.
/// * `capacity` needs to be the capacity that the pointer was allocated with.
9 changes: 6 additions & 3 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
@@ -433,8 +433,9 @@ impl<T> [T] {
/// assert_eq!(x, &[3, 4, 6]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
#[inline]
pub fn as_mut_ptr(&mut self) -> *mut T {
pub const fn as_mut_ptr(&mut self) -> *mut T {
self as *mut [T] as *mut T
}

@@ -469,8 +470,9 @@ impl<T> [T] {
///
/// [`as_ptr`]: #method.as_ptr
#[unstable(feature = "slice_ptr_range", issue = "65807")]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
#[inline]
pub fn as_ptr_range(&self) -> Range<*const T> {
pub const fn as_ptr_range(&self) -> Range<*const T> {
let start = self.as_ptr();
// SAFETY: The `add` here is safe, because:
//
@@ -510,8 +512,9 @@ impl<T> [T] {
///
/// [`as_mut_ptr`]: #method.as_mut_ptr
#[unstable(feature = "slice_ptr_range", issue = "65807")]
#[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
#[inline]
pub fn as_mut_ptr_range(&mut self) -> Range<*mut T> {
pub const fn as_mut_ptr_range(&mut self) -> Range<*mut T> {
let start = self.as_mut_ptr();
// SAFETY: See as_ptr_range() above for why `add` here is safe.
let end = unsafe { start.add(self.len()) };
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -238,6 +238,7 @@
#![feature(const_cstr_unchecked)]
#![feature(const_fn_transmute)]
#![feature(const_fn)]
#![feature(const_ip)]
#![feature(const_ipv6)]
#![feature(const_raw_ptr_deref)]
#![feature(const_ipv4)]
15 changes: 10 additions & 5 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
@@ -148,8 +148,9 @@ impl IpAddr {
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)).is_unspecified(), true);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)).is_unspecified(), true);
/// ```
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[stable(feature = "ip_shared", since = "1.12.0")]
pub fn is_unspecified(&self) -> bool {
pub const fn is_unspecified(&self) -> bool {
match self {
IpAddr::V4(ip) => ip.is_unspecified(),
IpAddr::V6(ip) => ip.is_unspecified(),
@@ -169,8 +170,9 @@ impl IpAddr {
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).is_loopback(), true);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1)).is_loopback(), true);
/// ```
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[stable(feature = "ip_shared", since = "1.12.0")]
pub fn is_loopback(&self) -> bool {
pub const fn is_loopback(&self) -> bool {
match self {
IpAddr::V4(ip) => ip.is_loopback(),
IpAddr::V6(ip) => ip.is_loopback(),
@@ -192,7 +194,8 @@ impl IpAddr {
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(80, 9, 12, 3)).is_global(), true);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true);
/// ```
pub fn is_global(&self) -> bool {
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
pub const fn is_global(&self) -> bool {
match self {
IpAddr::V4(ip) => ip.is_global(),
IpAddr::V6(ip) => ip.is_global(),
@@ -212,8 +215,9 @@ impl IpAddr {
/// assert_eq!(IpAddr::V4(Ipv4Addr::new(224, 254, 0, 0)).is_multicast(), true);
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0)).is_multicast(), true);
/// ```
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
#[stable(feature = "ip_shared", since = "1.12.0")]
pub fn is_multicast(&self) -> bool {
pub const fn is_multicast(&self) -> bool {
match self {
IpAddr::V4(ip) => ip.is_multicast(),
IpAddr::V6(ip) => ip.is_multicast(),
@@ -238,7 +242,8 @@ impl IpAddr {
/// true
/// );
/// ```
pub fn is_documentation(&self) -> bool {
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
pub const fn is_documentation(&self) -> bool {
match self {
IpAddr::V4(ip) => ip.is_documentation(),
IpAddr::V6(ip) => ip.is_documentation(),
Loading