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 12 pull requests #76951

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f8376b5
shim: monomorphic `FnPtrShim`s during construction
davidtwco Aug 9, 2020
8f27e3c
Make some methods of `Pin` unstable const
CDirkx Sep 12, 2020
176956c
Test and fix Sync & Send traits of BTreeMap artefacts
ssomers Sep 14, 2020
eede953
Only get ImplKind::Impl once
tesuji Sep 10, 2020
94dae60
simplfy condition in ItemLowerer::with_trait_impl_ref()
matthiaskrgr Sep 16, 2020
b7c8bea
Fix wording in mir doc
pickfire Sep 17, 2020
f4a7149
Don't compile regex at every function call.
hbina Sep 17, 2020
b479139
Remove intrinsics::arith_offset use from libarena
est31 Sep 17, 2020
4fe6ca3
Replace const_generics feature gate with min_const_generics
est31 Sep 17, 2020
ebdea01
Remove redundant #![feature(...)] 's from compiler/
est31 Sep 17, 2020
1dd3df6
black_box: silence unused_mut warning when building with cfg(miri)
RalfJung Sep 17, 2020
4382436
Make invalid integer operation messages consistent
varkor Sep 15, 2020
c9c5068
`char` not char
varkor Sep 15, 2020
5ec9e96
Bless mir-opt tests
varkor Sep 15, 2020
e2e000a
Bless mir-opt 32-bit tests
varkor Sep 16, 2020
e3c6e46
Make some methods of `Pin<&mut T>` unstable const
CDirkx Sep 18, 2020
78ff69b
Implement a destination propagation pass
jonas-schievink May 24, 2020
43ad8e4
simplify_try: print dest_prop diff and bless
jonas-schievink May 25, 2020
1649895
simplify_try: clean up test
jonas-schievink May 25, 2020
8a7b1c3
Make nrvo-simple set mir-opt-level=1
jonas-schievink May 25, 2020
8a3e2b7
Bless mir-opt tests
jonas-schievink Sep 12, 2020
812d4bb
Fix dataflow assert errors
jonas-schievink Sep 12, 2020
7dbc7f7
Add a few dest-prop MIR tests
jonas-schievink May 24, 2020
402f863
perf: walk liveness backwards in Conflicts::build
jonas-schievink Sep 12, 2020
665a98d
Fix dest-prop mir-opt tests
jonas-schievink Sep 12, 2020
ab26fb1
perf: only calculate conflicts for candidates
jonas-schievink May 26, 2020
ddd6930
perf: bail out when there's >500 candidate locals
jonas-schievink May 26, 2020
88538ad
Record intra-statement/terminator conflicts
jonas-schievink Sep 12, 2020
934634e
More logging
jonas-schievink Jun 22, 2020
484db5b
Properly inherit conflicts when merging locals
jonas-schievink Jun 24, 2020
5728834
Fix rebase fallout
jonas-schievink Jun 24, 2020
7af964f
Limit block count
jonas-schievink Jun 24, 2020
cd5d720
Fix rebase fallout
jonas-schievink Sep 12, 2020
682de94
Move inner items outside
jonas-schievink Sep 12, 2020
ffd9445
Return `Place` by value
jonas-schievink Sep 17, 2020
2f9271b
Clarify FIXME
jonas-schievink Sep 17, 2020
4d1ef03
cleanup promotion const_kind checks
RalfJung Sep 6, 2020
7febd5a
fix doc comment
RalfJung Sep 7, 2020
7b99c8e
never promote non-const operations; revert STATIC promotion change
RalfJung Sep 9, 2020
9216eb8
fix some comments
RalfJung Sep 9, 2020
3801bba
Rollup merge of #72632 - jonas-schievink:dest-prop, r=oli-obk
Dylan-DPC Sep 20, 2020
a6a5859
Rollup merge of #75346 - davidtwco:issue-69925-polymorphic-instancede…
Dylan-DPC Sep 20, 2020
57fb055
Rollup merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morse
Dylan-DPC Sep 20, 2020
42fbe59
Rollup merge of #76655 - CDirkx:const-pin, r=ecstatic-morse
Dylan-DPC Sep 20, 2020
63bc0c4
Rollup merge of #76722 - ssomers:btree_send_sync, r=Mark-Simulacrum
Dylan-DPC Sep 20, 2020
3dd5849
Rollup merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morse
Dylan-DPC Sep 20, 2020
7ad0db6
Rollup merge of #76783 - lzutao:rd_impl_kind, r=GuillaumeGomez
Dylan-DPC Sep 20, 2020
7c7e824
Rollup merge of #76809 - matthiaskrgr:simplify_cond, r=varkor
Dylan-DPC Sep 20, 2020
84f672f
Rollup merge of #76815 - pickfire:patch-6, r=jonas-schievink
Dylan-DPC Sep 20, 2020
c5f8123
Rollup merge of #76818 - hbina:dont_compile_regex_all_the_time, r=ecs…
Dylan-DPC Sep 20, 2020
0412fd6
Rollup merge of #76821 - est31:remove_redundant_nightly_features, r=o…
Dylan-DPC Sep 20, 2020
79af229
Rollup merge of #76823 - RalfJung:black-box-warn, r=joshtriplett
Dylan-DPC Sep 20, 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
4 changes: 1 addition & 3 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
test(no_crate_inject, attr(deny(warnings)))
)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(new_uninit)]
#![feature(maybe_uninit_slice)]
Expand All @@ -24,7 +23,6 @@ use smallvec::SmallVec;
use std::alloc::Layout;
use std::cell::{Cell, RefCell};
use std::cmp;
use std::intrinsics;
use std::marker::{PhantomData, Send};
use std::mem::{self, MaybeUninit};
use std::ptr;
Expand Down Expand Up @@ -122,7 +120,7 @@ impl<T> TypedArena<T> {

unsafe {
if mem::size_of::<T>() == 0 {
self.ptr.set(intrinsics::arith_offset(self.ptr.get() as *mut u8, 1) as *mut T);
self.ptr.set((self.ptr.get() as *mut u8).wrapping_offset(1) as *mut T);
let ptr = mem::align_of::<T>() as *mut T;
// Don't drop the object. This `write` is equivalent to `forget`.
ptr::write(ptr, object);
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(const_fn)] // For the `transmute` in `P::new`
#![feature(const_panic)]
#![feature(const_fn_transmute)]
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
#![feature(nll)]
#![feature(or_patterns)]
#![feature(try_trait)]
#![feature(unicode_internals)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
impl ItemLowerer<'_, '_, '_> {
fn with_trait_impl_ref(&mut self, impl_ref: &Option<TraitRef>, f: impl FnOnce(&mut Self)) {
let old = self.lctx.is_in_trait_impl;
self.lctx.is_in_trait_impl = if let &None = impl_ref { false } else { true };
self.lctx.is_in_trait_impl = impl_ref.is_some();
f(self);
self.lctx.is_in_trait_impl = old;
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#![feature(or_patterns)]
#![feature(trusted_len)]
#![feature(associated_type_bounds)]
#![feature(const_fn)] // for rustc_index::newtype_index
#![feature(const_panic)] // for rustc_index::newtype_index
#![recursion_limit = "256"]

//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![feature(control_flow_enum)]
#![feature(in_band_lifetimes)]
#![feature(unboxed_closures)]
#![feature(generators)]
#![feature(generator_trait)]
#![feature(fn_traits)]
#![feature(int_bits_const)]
Expand All @@ -27,7 +26,7 @@
#![feature(thread_id_value)]
#![feature(extend_one)]
#![feature(const_panic)]
#![feature(const_generics)]
#![feature(min_const_generics)]
#![feature(once_cell)]
#![allow(rustc::default_hash_types)]

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(bool_to_option)]
#![feature(cow_is_borrowed)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(or_patterns)]
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(bindings_after_at)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
Expand All @@ -23,7 +22,6 @@
#![feature(never_type)]
#![feature(or_patterns)]
#![feature(in_band_lifetimes)]
#![feature(crate_visibility_modifier)]
#![recursion_limit = "512"] // For rustdoc

#[macro_use]
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,21 @@
#![feature(cmp_min_max_by)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(const_fn_transmute)]
#![feature(core_intrinsics)]
#![feature(discriminant_kind)]
#![feature(drain_filter)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(extern_types)]
#![feature(nll)]
#![feature(once_cell)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(min_specialization)]
#![feature(trusted_len)]
#![feature(stmt_expr_attributes)]
#![feature(test)]
#![feature(in_band_lifetimes)]
#![feature(crate_visibility_modifier)]
#![feature(associated_type_bounds)]
#![feature(rustc_attrs)]
#![feature(hash_raw_entry)]
#![feature(int_error_matching)]
#![recursion_limit = "512"]

Expand Down
58 changes: 31 additions & 27 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,49 +1280,49 @@ impl<O> AssertKind<O> {
match self {
BoundsCheck { ref len, ref index } => write!(
f,
"\"index out of bounds: the len is {{}} but the index is {{}}\", {:?}, {:?}",
"\"index out of bounds: the length is {{}} but the index is {{}}\", {:?}, {:?}",
len, index
),

OverflowNeg(op) => {
write!(f, "\"attempt to negate {{}} which would overflow\", {:?}", op)
write!(f, "\"attempt to negate `{{}}`, which would overflow\", {:?}", op)
}
DivisionByZero(op) => write!(f, "\"attempt to divide {{}} by zero\", {:?}", op),
DivisionByZero(op) => write!(f, "\"attempt to divide `{{}}` by zero\", {:?}", op),
RemainderByZero(op) => write!(
f,
"\"attempt to calculate the remainder of {{}} with a divisor of zero\", {:?}",
"\"attempt to calculate the remainder of `{{}}` with a divisor of zero\", {:?}",
op
),
Overflow(BinOp::Add, l, r) => write!(
f,
"\"attempt to compute `{{}} + {{}}` which would overflow\", {:?}, {:?}",
"\"attempt to compute `{{}} + {{}}`, which would overflow\", {:?}, {:?}",
l, r
),
Overflow(BinOp::Sub, l, r) => write!(
f,
"\"attempt to compute `{{}} - {{}}` which would overflow\", {:?}, {:?}",
"\"attempt to compute `{{}} - {{}}`, which would overflow\", {:?}, {:?}",
l, r
),
Overflow(BinOp::Mul, l, r) => write!(
f,
"\"attempt to compute `{{}} * {{}}` which would overflow\", {:?}, {:?}",
"\"attempt to compute `{{}} * {{}}`, which would overflow\", {:?}, {:?}",
l, r
),
Overflow(BinOp::Div, l, r) => write!(
f,
"\"attempt to compute `{{}} / {{}}` which would overflow\", {:?}, {:?}",
"\"attempt to compute `{{}} / {{}}`, which would overflow\", {:?}, {:?}",
l, r
),
Overflow(BinOp::Rem, l, r) => write!(
f,
"\"attempt to compute the remainder of `{{}} % {{}}` which would overflow\", {:?}, {:?}",
"\"attempt to compute the remainder of `{{}} % {{}}`, which would overflow\", {:?}, {:?}",
l, r
),
Overflow(BinOp::Shr, _, r) => {
write!(f, "\"attempt to shift right by {{}} which would overflow\", {:?}", r)
write!(f, "\"attempt to shift right by `{{}}`, which would overflow\", {:?}", r)
}
Overflow(BinOp::Shl, _, r) => {
write!(f, "\"attempt to shift left by {{}} which would overflow\", {:?}", r)
write!(f, "\"attempt to shift left by `{{}}`, which would overflow\", {:?}", r)
}
_ => write!(f, "\"{}\"", self.description()),
}
Expand All @@ -1333,36 +1333,40 @@ impl<O: fmt::Debug> fmt::Debug for AssertKind<O> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use AssertKind::*;
match self {
BoundsCheck { ref len, ref index } => {
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index)
}
OverflowNeg(op) => write!(f, "attempt to negate {:#?} which would overflow", op),
DivisionByZero(op) => write!(f, "attempt to divide {:#?} by zero", op),
RemainderByZero(op) => {
write!(f, "attempt to calculate the remainder of {:#?} with a divisor of zero", op)
}
BoundsCheck { ref len, ref index } => write!(
f,
"index out of bounds: the length is {:?} but the index is {:?}",
len, index
),
OverflowNeg(op) => write!(f, "attempt to negate `{:#?}`, which would overflow", op),
DivisionByZero(op) => write!(f, "attempt to divide `{:#?}` by zero", op),
RemainderByZero(op) => write!(
f,
"attempt to calculate the remainder of `{:#?}` with a divisor of zero",
op
),
Overflow(BinOp::Add, l, r) => {
write!(f, "attempt to compute `{:#?} + {:#?}` which would overflow", l, r)
write!(f, "attempt to compute `{:#?} + {:#?}`, which would overflow", l, r)
}
Overflow(BinOp::Sub, l, r) => {
write!(f, "attempt to compute `{:#?} - {:#?}` which would overflow", l, r)
write!(f, "attempt to compute `{:#?} - {:#?}`, which would overflow", l, r)
}
Overflow(BinOp::Mul, l, r) => {
write!(f, "attempt to compute `{:#?} * {:#?}` which would overflow", l, r)
write!(f, "attempt to compute `{:#?} * {:#?}`, which would overflow", l, r)
}
Overflow(BinOp::Div, l, r) => {
write!(f, "attempt to compute `{:#?} / {:#?}` which would overflow", l, r)
write!(f, "attempt to compute `{:#?} / {:#?}`, which would overflow", l, r)
}
Overflow(BinOp::Rem, l, r) => write!(
f,
"attempt to compute the remainder of `{:#?} % {:#?}` which would overflow",
"attempt to compute the remainder of `{:#?} % {:#?}`, which would overflow",
l, r
),
Overflow(BinOp::Shr, _, r) => {
write!(f, "attempt to shift right by {:#?} which would overflow", r)
write!(f, "attempt to shift right by `{:#?}`, which would overflow", r)
}
Overflow(BinOp::Shl, _, r) => {
write!(f, "attempt to shift left by {:#?} which would overflow", r)
write!(f, "attempt to shift left by `{:#?}`, which would overflow", r)
}
_ => write!(f, "{}", self.description()),
}
Expand Down Expand Up @@ -2286,7 +2290,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
/// Constants
///
/// Two constants are equal if they are the same constant. Note that
/// this does not necessarily mean that they are `==` in Rust -- in
/// this does not necessarily mean that they are `==` in Rust. In
/// particular, one must be wary of `NaN`!

#[derive(Clone, Copy, PartialEq, TyEncodable, TyDecodable, HashStable)]
Expand Down
53 changes: 25 additions & 28 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ pub enum InstanceDef<'tcx> {
/// `<fn() as FnTrait>::call_*` (generated `FnTrait` implementation for `fn()` pointers).
///
/// `DefId` is `FnTrait::call_*`.
///
/// NB: the (`fn` pointer) type must currently be monomorphic to avoid double substitution
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
FnPtrShim(DefId, Ty<'tcx>),

/// Dynamic dispatch to `<dyn Trait as Trait>::fn`.
Expand All @@ -87,10 +83,6 @@ pub enum InstanceDef<'tcx> {
/// The `DefId` is for `core::ptr::drop_in_place`.
/// The `Option<Ty<'tcx>>` is either `Some(T)`, or `None` for empty drop
/// glue.
///
/// NB: the type must currently be monomorphic to avoid double substitution
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
DropGlue(DefId, Option<Ty<'tcx>>),

/// Compiler-generated `<T as Clone>::clone` implementation.
Expand All @@ -99,10 +91,6 @@ pub enum InstanceDef<'tcx> {
/// Additionally, arrays, tuples, and closures get a `Clone` shim even if they aren't `Copy`.
///
/// The `DefId` is for `Clone::clone`, the `Ty` is the type `T` with the builtin `Clone` impl.
///
/// NB: the type must currently be monomorphic to avoid double substitution
/// problems with the MIR shim bodies. `Instance::resolve` enforces this.
// FIXME(#69925) support polymorphic MIR shim bodies properly instead.
CloneShim(DefId, Ty<'tcx>),
}

Expand Down Expand Up @@ -243,6 +231,27 @@ impl<'tcx> InstanceDef<'tcx> {
_ => false,
}
}

/// Returns `true` when the MIR body associated with this instance should be monomorphized
/// by its users (e.g. codegen or miri) by substituting the `substs` from `Instance` (see
/// `Instance::substs_for_mir_body`).
///
/// Otherwise, returns `false` only for some kinds of shims where the construction of the MIR
/// body should perform necessary substitutions.
pub fn has_polymorphic_mir_body(&self) -> bool {
match *self {
InstanceDef::CloneShim(..)
| InstanceDef::FnPtrShim(..)
| InstanceDef::DropGlue(_, Some(_)) => false,
InstanceDef::ClosureOnceShim { .. }
| InstanceDef::DropGlue(..)
| InstanceDef::Item(_)
| InstanceDef::Intrinsic(..)
| InstanceDef::ReifyShim(..)
| InstanceDef::Virtual(..)
| InstanceDef::VtableShim(..) => true,
}
}
}

impl<'tcx> fmt::Display for Instance<'tcx> {
Expand Down Expand Up @@ -440,30 +449,18 @@ impl<'tcx> Instance<'tcx> {
Instance { def, substs }
}

/// FIXME(#69925) Depending on the kind of `InstanceDef`, the MIR body associated with an
/// Depending on the kind of `InstanceDef`, the MIR body associated with an
/// instance is expressed in terms of the generic parameters of `self.def_id()`, and in other
/// cases the MIR body is expressed in terms of the types found in the substitution array.
/// In the former case, we want to substitute those generic types and replace them with the
/// values from the substs when monomorphizing the function body. But in the latter case, we
/// don't want to do that substitution, since it has already been done effectively.
///
/// This function returns `Some(substs)` in the former case and None otherwise -- i.e., if
/// This function returns `Some(substs)` in the former case and `None` otherwise -- i.e., if
/// this function returns `None`, then the MIR body does not require substitution during
/// monomorphization.
/// codegen.
pub fn substs_for_mir_body(&self) -> Option<SubstsRef<'tcx>> {
match self.def {
InstanceDef::CloneShim(..)
| InstanceDef::DropGlue(_, Some(_)) => None,
InstanceDef::ClosureOnceShim { .. }
| InstanceDef::DropGlue(..)
// FIXME(#69925): `FnPtrShim` should be in the other branch.
| InstanceDef::FnPtrShim(..)
| InstanceDef::Item(_)
| InstanceDef::Intrinsic(..)
| InstanceDef::ReifyShim(..)
| InstanceDef::Virtual(..)
| InstanceDef::VtableShim(..) => Some(self.substs),
}
if self.def.has_polymorphic_mir_body() { Some(self.substs) } else { None }
}

/// Returns a new `Instance` where generic parameters in `instance.substs` are replaced by
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_mir/src/dataflow/framework/graphviz.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A helpful diagram for debugging dataflow problems.

use std::borrow::Cow;
use std::lazy::SyncOnceCell;
use std::{io, ops, str};

use regex::Regex;
Expand Down Expand Up @@ -570,6 +571,13 @@ where
}
}

macro_rules! regex {
($re:literal $(,)?) => {{
static RE: SyncOnceCell<regex::Regex> = SyncOnceCell::new();
RE.get_or_init(|| Regex::new($re).unwrap())
}};
}

fn diff_pretty<T, C>(new: T, old: T, ctxt: &C) -> String
where
T: DebugWithContext<C>,
Expand All @@ -578,7 +586,7 @@ where
return String::new();
}

let re = Regex::new("\t?\u{001f}([+-])").unwrap();
let re = regex!("\t?\u{001f}([+-])");

let raw_diff = format!("{:#?}", DebugDiffWithAdapter { new, old, ctxt });

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/dataflow/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {

/// `EverInitializedPlaces` tracks all places that might have ever been
/// initialized upon reaching a particular point in the control flow
/// for a function, without an intervening `Storage Dead`.
/// for a function, without an intervening `StorageDead`.
///
/// This dataflow is used to determine if an immutable local variable may
/// be assigned to.
Expand Down
Loading