Skip to content

Commit

Permalink
Auto merge of #46874 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

- Successful merges: #46359, #46517, #46671, #46751, #46760, #46787, #46794, #46828, #46831, #46835, #46851, #46852, #46856, #46870
- Failed merges:
  • Loading branch information
bors committed Dec 20, 2017
2 parents df8dfde + 66e5c79 commit 81622c6
Show file tree
Hide file tree
Showing 45 changed files with 255 additions and 143 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ impl Step for DebuggerScripts {
install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"),
0o755);

cp_debugger_script("natvis/intrinsic.natvis");
cp_debugger_script("natvis/liballoc.natvis");
cp_debugger_script("natvis/libcore.natvis");
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/etc/rust-windbg.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ for /f "delims=" %%i in ('rustc --print=sysroot') do set rustc_sysroot=%%i

set rust_etc=%rustc_sysroot%\lib\rustlib\etc

windbg -c ".nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*
windbg -c ".nvload %rust_etc%\intrinsic.natvis; .nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*
6 changes: 2 additions & 4 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,14 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let cell = RefCell::new(5);
/// let old_value = cell.replace(6);
/// assert_eq!(old_value, 5);
/// assert_eq!(cell, RefCell::new(6));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_replace", since="1.24.0")]
pub fn replace(&self, t: T) -> T {
mem::replace(&mut *self.borrow_mut(), t)
}
Expand Down Expand Up @@ -636,7 +635,6 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let c = RefCell::new(5);
/// let d = RefCell::new(6);
Expand All @@ -645,7 +643,7 @@ impl<T> RefCell<T> {
/// assert_eq!(d, RefCell::new(5));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_swap", since="1.24.0")]
pub fn swap(&self, other: &Self) {
mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut())
}
Expand Down
17 changes: 9 additions & 8 deletions src/libcore/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,23 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
// Don't inline this so callers that call both this and the above won't wind
// up using the combined stack space of both functions in some cases.
#[inline(never)]
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter,
num: &T, sign: flt2dec::Sign) -> Result
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter, num: &T,
sign: flt2dec::Sign, precision: usize) -> Result
where T: flt2dec::DecodableFloat
{
unsafe {
// enough for f32 and f64
let mut buf: [u8; flt2dec::MAX_SIG_DIGITS] = mem::uninitialized();
let mut parts: [flt2dec::Part; 4] = mem::uninitialized();
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest,
*num, sign, 0, false, &mut buf, &mut parts);
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num,
sign, precision, false, &mut buf, &mut parts);
fmt.pad_formatted_parts(&formatted)
}
}

// Common code of floating point Debug and Display.
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T,
negative_zero: bool, min_precision: usize) -> Result
where T: flt2dec::DecodableFloat
{
let force_sign = fmt.sign_plus();
Expand All @@ -61,7 +62,7 @@ fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool)
if let Some(precision) = fmt.precision {
float_to_decimal_common_exact(fmt, num, sign, precision)
} else {
float_to_decimal_common_shortest(fmt, num, sign)
float_to_decimal_common_shortest(fmt, num, sign, min_precision)
}
}

Expand Down Expand Up @@ -125,14 +126,14 @@ macro_rules! floating {
#[stable(feature = "rust1", since = "1.0.0")]
impl Debug for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
float_to_decimal_common(fmt, self, true)
float_to_decimal_common(fmt, self, true, 1)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Display for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
float_to_decimal_common(fmt, self, false)
float_to_decimal_common(fmt, self, false, 0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl<T> SliceExt for [T] {
while size > 1 {
let half = size / 2;
let mid = base + half;
// mid is always in [0, size).
// mid is always in [0, size), that means mid is >= 0 and < size.
// mid >= 0: by definition
// mid < size: mid = size / 2 + size / 4 + size / 8 ...
let cmp = f(unsafe { s.get_unchecked(mid) });
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/tests/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ fn test_format_f64() {
assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64));
assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64));
assert_eq!("1.23456789E3", format!("{:E}", 1234.56789f64));
assert_eq!("0.0", format!("{:?}", 0.0f64));
assert_eq!("1.01", format!("{:?}", 1.01f64));
}

#[test]
Expand All @@ -34,4 +36,6 @@ fn test_format_f32() {
assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32));
assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32));
assert_eq!("1.2345679E3", format!("{:E}", 1234.56789f32));
assert_eq!("0.0", format!("{:?}", 0.0f32));
assert_eq!("1.01", format!("{:?}", 1.01f32));
}
34 changes: 18 additions & 16 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,16 @@ impl<'a> State<'a> {
hir::TyTraitObject(ref bounds, ref lifetime) => {
let mut first = true;
for bound in bounds {
self.nbsp()?;
if first {
first = false;
} else {
self.nbsp()?;
self.word_space("+")?;
}
self.print_poly_trait_ref(bound)?;
}
if !lifetime.is_elided() {
self.nbsp()?;
self.word_space("+")?;
self.print_lifetime(lifetime)?;
}
Expand Down Expand Up @@ -764,7 +765,8 @@ impl<'a> State<'a> {
real_bounds.push(b.clone());
}
}
self.print_bounds(" = ", &real_bounds[..])?;
self.nbsp()?;
self.print_bounds("=", &real_bounds[..])?;
self.print_where_clause(&generics.where_clause)?;
self.s.word(";")?;
}
Expand All @@ -788,6 +790,7 @@ impl<'a> State<'a> {
comma = true;
}
self.s.word(">")?;
self.nbsp()?;
}
Ok(())
}
Expand Down Expand Up @@ -2016,30 +2019,29 @@ impl<'a> State<'a> {
self.s.word(prefix)?;
let mut first = true;
for bound in bounds {
self.nbsp()?;
if !(first && prefix.is_empty()) {
self.nbsp()?;
}
if first {
first = false;
} else {
self.word_space("+")?;
}

match *bound {
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
self.print_poly_trait_ref(tref)
}
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
self.s.word("?")?;
self.print_poly_trait_ref(tref)
match bound {
TraitTyParamBound(tref, modifier) => {
if modifier == &TraitBoundModifier::Maybe {
self.s.word("?")?;
}
self.print_poly_trait_ref(tref)?;
}
RegionTyParamBound(ref lt) => {
self.print_lifetime(lt)
RegionTyParamBound(lt) => {
self.print_lifetime(lt)?;
}
}?
}
}
Ok(())
} else {
Ok(())
}
Ok(())
}

pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ macro_rules! make_mir_visitor {
ref $($mutability)* inputs,
asm: _ } => {
for output in & $($mutability)* outputs[..] {
self.visit_place(output, PlaceContext::Store, location);
self.visit_place(output, PlaceContext::AsmOutput, location);
}
for input in & $($mutability)* inputs[..] {
self.visit_operand(input, location);
Expand Down Expand Up @@ -835,6 +835,11 @@ pub enum PlaceContext<'tcx> {
// Appears as LHS of an assignment
Store,

// Can often be treated as a Store, but needs to be separate because
// ASM is allowed to read outputs as well, so a Store-AsmOutput sequence
// cannot be simplified the way a Store-Store can be.
AsmOutput,

// Dest of a call
Call,

Expand Down Expand Up @@ -910,7 +915,7 @@ impl<'tcx> PlaceContext<'tcx> {
/// Returns true if this place context represents a use that potentially changes the value.
pub fn is_mutating_use(&self) -> bool {
match *self {
PlaceContext::Store | PlaceContext::Call |
PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call |
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } |
PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop => true,
Expand All @@ -932,6 +937,7 @@ impl<'tcx> PlaceContext<'tcx> {
PlaceContext::Projection(Mutability::Not) |
PlaceContext::Copy | PlaceContext::Move => true,
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead |
PlaceContext::Validate => false,
Expand Down
26 changes: 23 additions & 3 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"set the threshold for inlining a function (default: 225)"),
panic: Option<PanicStrategy> = (None, parse_panic_strategy,
[TRACKED], "panic strategy to compile crate with"),
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
"enable incremental compilation"),
}

options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
Expand Down Expand Up @@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
}

if cg.lto && debugging_opts.incremental.is_some() {
let incremental = match (&debugging_opts.incremental, &cg.incremental) {
(&Some(ref path1), &Some(ref path2)) => {
if path1 != path2 {
early_error(error_format,
&format!("conflicting paths for `-Z incremental` and \
`-C incremental` specified: {} versus {}",
path1,
path2));
} else {
Some(path1)
}
}
(&Some(ref path), &None) => Some(path),
(&None, &Some(ref path)) => Some(path),
(&None, &None) => None,
}.map(|m| PathBuf::from(m));

if cg.lto && incremental.is_some() {
early_error(error_format, "can't perform LTO when compiling incrementally");
}

Expand Down Expand Up @@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)

let crate_name = matches.opt_str("crate-name");

let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));

(Options {
crate_types,
optimize: opt_level,
Expand Down Expand Up @@ -2581,6 +2598,9 @@ mod tests {
opts.cg.save_temps = true;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());

opts.cg.incremental = Some(String::from("abc"));
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());


// Make sure changing a [TRACKED] option changes the hash
opts = reference.clone();
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
// "deep" does validation go?
PlaceContext::Validate => false,

// FIXME: This is here to not change behaviour from before
// AsmOutput existed, but it's not necessarily a pure overwrite.
// so it's possible this should activate the place.
PlaceContext::AsmOutput |
// pure overwrites of an place do not activate it. (note
// PlaceContext::Call is solely about dest place)
PlaceContext::Store | PlaceContext::Call => false,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/transform/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
ty::TyAdt(adt, _) => {
if adt.is_union() {
if context == PlaceContext::Store ||
context == PlaceContext::AsmOutput ||
context == PlaceContext::Drop
{
let elem_ty = match elem {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
if *temp == TempState::Undefined {
match context {
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call => {
*temp = TempState::Defined {
location,
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_mir/util/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor {

PlaceContext::Store |

// This is potentially both a def and a use...
PlaceContext::AsmOutput |

// We let Call define the result in both the success and
// unwind cases. This is not really correct, however it
// does not seem to be observable due to the way that we
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(

assert_symbols_are_distinct(tcx, items.iter());

let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() {
let strategy = if tcx.sess.opts.incremental.is_some() {
PartitioningStrategy::PerModule
} else {
PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units())
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {

PlaceContext::Inspect |
PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Borrow { .. } |
PlaceContext::Projection(..) => {
self.mark_as_memory(index);
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_id: DefId,
impl_trait_ref: ty::TraitRef<'tcx>,
impl_item_refs: &[hir::ImplItemRef]) {
let impl_span = tcx.sess.codemap().def_span(impl_span);

// If the trait reference itself is erroneous (so the compilation is going
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
// isn't populated for such impls.
Expand Down
Loading

0 comments on commit 81622c6

Please sign in to comment.