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 11 pull requests #55433

Merged
merged 27 commits into from
Oct 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a0df420
Implement FromStr for PathBuf
SimonSapin Oct 17, 2018
ac18635
Add MaybeUninit::new
SimonSapin Oct 21, 2018
412ad9b
Allow extern statics with an extern type
mjbshaw Oct 22, 2018
5b84550
Keep an obligation for both sized and unsized types
mjbshaw Oct 22, 2018
37e1d29
Don't rerun Mir passes when inlining
nikomatsakis Oct 20, 2018
895a4b2
Remove the `suite_index` parameter of the `run_passes!()` macro
wesleywiser Oct 21, 2018
c535147
Replace the `run_passes!` macro with a regular function
wesleywiser Oct 23, 2018
4655866
Fix CR feedback
wesleywiser Oct 25, 2018
c674802
Remove unnecessary mut in iterator.find_map documentation example, Re…
meven Oct 23, 2018
b9bd2a6
Impl items have generics
oli-obk Oct 19, 2018
5a48f20
Update tests
oli-obk Oct 19, 2018
4cb611f
Update string.rs
rick68 Oct 27, 2018
c04893a
Fix an ICE in the min_const_fn analysis
oli-obk Oct 27, 2018
2fd378b
Fix sub-variant doc display
GuillaumeGomez Oct 18, 2018
0d06b8c
Add note linking to Rust 2018 path semantics docs.
davidtwco Oct 18, 2018
0757c0f
Add ManuallyDrop::take
CAD97 Oct 27, 2018
b9763de
Rollup merge of #55148 - SimonSapin:path-fromstr, r=oli-obk
kennytm Oct 28, 2018
883b819
Rollup merge of #55191 - GuillaumeGomez:fix-sub-variant, r=QuietMisdr…
kennytm Oct 28, 2018
409382e
Rollup merge of #55244 - wesleywiser:issue-50411, r=nikomatsakis
kennytm Oct 28, 2018
a79b912
Rollup merge of #55252 - SimonSapin:maybeuninit-new, r=bluss
kennytm Oct 28, 2018
316a443
Rollup merge of #55389 - meven:master, r=shepmaster
kennytm Oct 28, 2018
7a95c28
Rollup merge of #55406 - rick68:patch-16, r=varkor
kennytm Oct 28, 2018
b565e5d
Rollup merge of #55412 - oli-obk:min_const_fn_ice, r=estebank
kennytm Oct 28, 2018
360f32a
Rollup merge of #55421 - CAD97:patch-1, r=kennytm
kennytm Oct 28, 2018
aaa20c6
Rollup merge of #55185 - davidtwco:issue-55130, r=nikomatsakis
kennytm Oct 28, 2018
abf7243
Rollup merge of #55257 - mjbshaw:static, r=oli-obk
kennytm Oct 28, 2018
db4e77c
Rollup merge of #55199 - oli-obk:instance_printing, r=davidtwco
kennytm Oct 28, 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
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl String {
///
/// // These are all done without reallocating...
/// let cap = s.capacity();
/// for i in 0..10 {
/// for _ in 0..10 {
/// s.push('a');
/// }
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ pub trait Iterator {
/// ```
/// let a = ["lol", "NaN", "2", "5"];
///
/// let mut first_number = a.iter().find_map(|s| s.parse().ok());
/// let first_number = a.iter().find_map(|s| s.parse().ok());
///
/// assert_eq!(first_number, Some(2));
/// ```
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#![feature(const_fn)]
#![feature(const_int_ops)]
#![feature(const_fn_union)]
#![feature(const_manually_drop_new)]
#![feature(custom_attribute)]
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
Expand Down
29 changes: 29 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,26 @@ impl<T> ManuallyDrop<T> {
pub fn into_inner(slot: ManuallyDrop<T>) -> T {
slot.value
}

/// Takes the contained value out.
///
/// This method is primarily intended for moving out values in drop.
/// Instead of using [`ManuallyDrop::drop`] to manually drop the value,
/// you can use this method to take the value and use it however desired.
/// `Drop` will be invoked on the returned value following normal end-of-scope rules.
///
/// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead.
///
/// # Safety
///
/// This function semantically moves out the contained value without preventing further usage.
/// It is up to the user of this method to ensure that this container is not used again.
#[must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead"]
#[unstable(feature = "manually_drop_take", issue = "55422")]
#[inline]
pub unsafe fn take(slot: &mut ManuallyDrop<T>) -> T {
ManuallyDrop::into_inner(ptr::read(slot))
}
}

impl<T: ?Sized> ManuallyDrop<T> {
Expand Down Expand Up @@ -1021,6 +1041,15 @@ pub union MaybeUninit<T> {
}

impl<T> MaybeUninit<T> {
/// Create a new `MaybeUninit` initialized with the given value.
///
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
#[unstable(feature = "maybe_uninit", issue = "53491")]
pub const fn new(val: T) -> MaybeUninit<T> {
MaybeUninit { value: ManuallyDrop::new(val) }
}

/// Create a new `MaybeUninit` in an uninitialized state.
///
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
Expand Down
36 changes: 36 additions & 0 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,38 @@ impl<'tcx> HasLocalDecls<'tcx> for Mir<'tcx> {
}
}

/// The various "big phases" that MIR goes through.
///
/// Warning: ordering of variants is significant
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum MirPhase {
Build = 0,
Const = 1,
Validated = 2,
Optimized = 3,
}

impl MirPhase {
/// Gets the index of the current MirPhase within the set of all MirPhases.
pub fn phase_index(&self) -> usize {
*self as usize
}
}

/// Lowered representation of a single function.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mir<'tcx> {
/// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
/// that indexes into this vector.
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,

/// Records how far through the "desugaring and optimization" process this particular
/// MIR has traversed. This is particularly useful when inlining, since in that context
/// we instantiate the promoted constants and add them to our promoted vector -- but those
/// promoted items have already been optimized, whereas ours have not. This field allows
/// us to see the difference and forego optimization on the inlined promoted items.
pub phase: MirPhase,

/// List of source scopes; these are referenced by statements
/// and used for debuginfo. Indexed by a `SourceScope`.
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,
Expand Down Expand Up @@ -151,6 +176,7 @@ impl<'tcx> Mir<'tcx> {
);

Mir {
phase: MirPhase::Build,
basic_blocks,
source_scopes,
source_scope_local_data,
Expand Down Expand Up @@ -368,6 +394,7 @@ pub enum Safety {
}

impl_stable_hash_for!(struct Mir<'tcx> {
phase,
basic_blocks,
source_scopes,
source_scope_local_data,
Expand Down Expand Up @@ -616,6 +643,13 @@ impl_stable_hash_for!(enum self::ImplicitSelfKind {
None
});

impl_stable_hash_for!(enum self::MirPhase {
Build,
Const,
Validated,
Optimized,
});

mod binding_form_impl {
use ich::StableHashingContext;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
Expand Down Expand Up @@ -2905,6 +2939,7 @@ pub enum ClosureOutlivesSubject<'tcx> {

CloneTypeFoldableAndLiftImpls! {
BlockTailInfo,
MirPhase,
Mutability,
SourceInfo,
UpvarDecl,
Expand All @@ -2917,6 +2952,7 @@ CloneTypeFoldableAndLiftImpls! {

BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
phase,
basic_blocks,
source_scopes,
source_scope_local_data,
Expand Down
14 changes: 3 additions & 11 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,17 @@ impl PrintContext {
fn parameterized<F: fmt::Write>(&mut self,
f: &mut F,
substs: &subst::Substs<'_>,
mut did: DefId,
did: DefId,
projections: &[ty::ProjectionPredicate<'_>])
-> fmt::Result {
let key = ty::tls::with(|tcx| tcx.def_key(did));
let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() {
Some(name)
} else {
did.index = key.parent.unwrap_or_else(
|| bug!("finding type for {:?}, encountered def-id {:?} with no parent",
did, did));
self.parameterized(f, substs, did, projections)?;
return write!(f, "::{}", key.disambiguated_data.data.as_interned_str());
};

let verbose = self.is_verbose;
let mut num_supplied_defaults = 0;
let mut has_self = false;
let mut own_counts: GenericParamCount = Default::default();
let mut is_value_path = false;
let mut item_name = Some(key.disambiguated_data.data.as_interned_str());
let fn_trait_kind = ty::tls::with(|tcx| {
// Unfortunately, some kinds of items (e.g., closures) don't have
// generics. So walk back up the find the closest parent that DOES
Expand All @@ -282,6 +274,7 @@ impl PrintContext {
DefPathData::AssocTypeInImpl(_) |
DefPathData::AssocExistentialInImpl(_) |
DefPathData::Trait(_) |
DefPathData::Impl |
DefPathData::TypeNs(_) => {
break;
}
Expand All @@ -292,7 +285,6 @@ impl PrintContext {
}
DefPathData::CrateRoot |
DefPathData::Misc |
DefPathData::Impl |
DefPathData::Module(_) |
DefPathData::MacroDef(_) |
DefPathData::ClosureExpr |
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
other => return other,
}
}
// the first trace is for replicating an ice
// There's no tracking issue, but the next two lines concatenated link to the discussion on
// zulip. It's not really possible to test this, because it doesn't show up in diagnostics
// or MIR.
// https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
// subject/anon_const_instance_printing/near/135980032
trace!("const eval: {}", key.value.instance);
trace!("const eval: {:?}", key);

let cid = key.value;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
}

crate fn borrows(&self) -> &IndexVec<BorrowIndex, BorrowData<'tcx>> { &self.borrow_set.borrows }
pub fn scope_tree(&self) -> &Lrc<region::ScopeTree> { &self.scope_tree }

pub fn location(&self, idx: BorrowIndex) -> &Location {
&self.borrow_set.borrows[idx].reserve_location
Expand Down
14 changes: 0 additions & 14 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,20 +724,6 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
}
}
}

pub fn new_from_sets(mir: &'a Mir<'tcx>,
dead_unwinds: &'a BitSet<mir::BasicBlock>,
sets: AllSets<D::Idx>,
denotation: D) -> Self {
DataflowAnalysis {
mir,
dead_unwinds,
flow_state: DataflowState {
sets: sets,
operator: denotation,
}
}
}
}

impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
Expand Down
Loading