Skip to content

Commit 81622c6

Browse files
committed
Auto merge of #46874 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests - Successful merges: #46359, #46517, #46671, #46751, #46760, #46787, #46794, #46828, #46831, #46835, #46851, #46852, #46856, #46870 - Failed merges:
2 parents df8dfde + 66e5c79 commit 81622c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+255
-143
lines changed

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ impl Step for DebuggerScripts {
504504
install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"),
505505
0o755);
506506

507+
cp_debugger_script("natvis/intrinsic.natvis");
507508
cp_debugger_script("natvis/liballoc.natvis");
508509
cp_debugger_script("natvis/libcore.natvis");
509510
} else {

src/etc/rust-windbg.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ for /f "delims=" %%i in ('rustc --print=sysroot') do set rustc_sysroot=%%i
1515

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

18-
windbg -c ".nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*
18+
windbg -c ".nvload %rust_etc%\intrinsic.natvis; .nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %*

src/libcore/cell.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,14 @@ impl<T> RefCell<T> {
584584
/// # Examples
585585
///
586586
/// ```
587-
/// #![feature(refcell_replace_swap)]
588587
/// use std::cell::RefCell;
589588
/// let cell = RefCell::new(5);
590589
/// let old_value = cell.replace(6);
591590
/// assert_eq!(old_value, 5);
592591
/// assert_eq!(cell, RefCell::new(6));
593592
/// ```
594593
#[inline]
595-
#[unstable(feature = "refcell_replace_swap", issue="43570")]
594+
#[stable(feature = "refcell_replace", since="1.24.0")]
596595
pub fn replace(&self, t: T) -> T {
597596
mem::replace(&mut *self.borrow_mut(), t)
598597
}
@@ -636,7 +635,6 @@ impl<T> RefCell<T> {
636635
/// # Examples
637636
///
638637
/// ```
639-
/// #![feature(refcell_replace_swap)]
640638
/// use std::cell::RefCell;
641639
/// let c = RefCell::new(5);
642640
/// let d = RefCell::new(6);
@@ -645,7 +643,7 @@ impl<T> RefCell<T> {
645643
/// assert_eq!(d, RefCell::new(5));
646644
/// ```
647645
#[inline]
648-
#[unstable(feature = "refcell_replace_swap", issue="43570")]
646+
#[stable(feature = "refcell_swap", since="1.24.0")]
649647
pub fn swap(&self, other: &Self) {
650648
mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut())
651649
}

src/libcore/fmt/float.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
3232
// Don't inline this so callers that call both this and the above won't wind
3333
// up using the combined stack space of both functions in some cases.
3434
#[inline(never)]
35-
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter,
36-
num: &T, sign: flt2dec::Sign) -> Result
35+
fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter, num: &T,
36+
sign: flt2dec::Sign, precision: usize) -> Result
3737
where T: flt2dec::DecodableFloat
3838
{
3939
unsafe {
4040
// enough for f32 and f64
4141
let mut buf: [u8; flt2dec::MAX_SIG_DIGITS] = mem::uninitialized();
4242
let mut parts: [flt2dec::Part; 4] = mem::uninitialized();
43-
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest,
44-
*num, sign, 0, false, &mut buf, &mut parts);
43+
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num,
44+
sign, precision, false, &mut buf, &mut parts);
4545
fmt.pad_formatted_parts(&formatted)
4646
}
4747
}
4848

4949
// Common code of floating point Debug and Display.
50-
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result
50+
fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T,
51+
negative_zero: bool, min_precision: usize) -> Result
5152
where T: flt2dec::DecodableFloat
5253
{
5354
let force_sign = fmt.sign_plus();
@@ -61,7 +62,7 @@ fn float_to_decimal_common<T>(fmt: &mut Formatter, num: &T, negative_zero: bool)
6162
if let Some(precision) = fmt.precision {
6263
float_to_decimal_common_exact(fmt, num, sign, precision)
6364
} else {
64-
float_to_decimal_common_shortest(fmt, num, sign)
65+
float_to_decimal_common_shortest(fmt, num, sign, min_precision)
6566
}
6667
}
6768

@@ -125,14 +126,14 @@ macro_rules! floating {
125126
#[stable(feature = "rust1", since = "1.0.0")]
126127
impl Debug for $ty {
127128
fn fmt(&self, fmt: &mut Formatter) -> Result {
128-
float_to_decimal_common(fmt, self, true)
129+
float_to_decimal_common(fmt, self, true, 1)
129130
}
130131
}
131132

132133
#[stable(feature = "rust1", since = "1.0.0")]
133134
impl Display for $ty {
134135
fn fmt(&self, fmt: &mut Formatter) -> Result {
135-
float_to_decimal_common(fmt, self, false)
136+
float_to_decimal_common(fmt, self, false, 0)
136137
}
137138
}
138139

src/libcore/slice/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<T> SliceExt for [T] {
400400
while size > 1 {
401401
let half = size / 2;
402402
let mid = base + half;
403-
// mid is always in [0, size).
403+
// mid is always in [0, size), that means mid is >= 0 and < size.
404404
// mid >= 0: by definition
405405
// mid < size: mid = size / 2 + size / 4 + size / 8 ...
406406
let cmp = f(unsafe { s.get_unchecked(mid) });

src/libcore/tests/fmt/float.rs

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ fn test_format_f64() {
2020
assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64));
2121
assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64));
2222
assert_eq!("1.23456789E3", format!("{:E}", 1234.56789f64));
23+
assert_eq!("0.0", format!("{:?}", 0.0f64));
24+
assert_eq!("1.01", format!("{:?}", 1.01f64));
2325
}
2426

2527
#[test]
@@ -34,4 +36,6 @@ fn test_format_f32() {
3436
assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32));
3537
assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32));
3638
assert_eq!("1.2345679E3", format!("{:E}", 1234.56789f32));
39+
assert_eq!("0.0", format!("{:?}", 0.0f32));
40+
assert_eq!("1.01", format!("{:?}", 1.01f32));
3741
}

src/librustc/hir/print.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,16 @@ impl<'a> State<'a> {
408408
hir::TyTraitObject(ref bounds, ref lifetime) => {
409409
let mut first = true;
410410
for bound in bounds {
411-
self.nbsp()?;
412411
if first {
413412
first = false;
414413
} else {
414+
self.nbsp()?;
415415
self.word_space("+")?;
416416
}
417417
self.print_poly_trait_ref(bound)?;
418418
}
419419
if !lifetime.is_elided() {
420+
self.nbsp()?;
420421
self.word_space("+")?;
421422
self.print_lifetime(lifetime)?;
422423
}
@@ -764,7 +765,8 @@ impl<'a> State<'a> {
764765
real_bounds.push(b.clone());
765766
}
766767
}
767-
self.print_bounds(" = ", &real_bounds[..])?;
768+
self.nbsp()?;
769+
self.print_bounds("=", &real_bounds[..])?;
768770
self.print_where_clause(&generics.where_clause)?;
769771
self.s.word(";")?;
770772
}
@@ -788,6 +790,7 @@ impl<'a> State<'a> {
788790
comma = true;
789791
}
790792
self.s.word(">")?;
793+
self.nbsp()?;
791794
}
792795
Ok(())
793796
}
@@ -2016,30 +2019,29 @@ impl<'a> State<'a> {
20162019
self.s.word(prefix)?;
20172020
let mut first = true;
20182021
for bound in bounds {
2019-
self.nbsp()?;
2022+
if !(first && prefix.is_empty()) {
2023+
self.nbsp()?;
2024+
}
20202025
if first {
20212026
first = false;
20222027
} else {
20232028
self.word_space("+")?;
20242029
}
20252030

2026-
match *bound {
2027-
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
2028-
self.print_poly_trait_ref(tref)
2029-
}
2030-
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
2031-
self.s.word("?")?;
2032-
self.print_poly_trait_ref(tref)
2031+
match bound {
2032+
TraitTyParamBound(tref, modifier) => {
2033+
if modifier == &TraitBoundModifier::Maybe {
2034+
self.s.word("?")?;
2035+
}
2036+
self.print_poly_trait_ref(tref)?;
20332037
}
2034-
RegionTyParamBound(ref lt) => {
2035-
self.print_lifetime(lt)
2038+
RegionTyParamBound(lt) => {
2039+
self.print_lifetime(lt)?;
20362040
}
2037-
}?
2041+
}
20382042
}
2039-
Ok(())
2040-
} else {
2041-
Ok(())
20422043
}
2044+
Ok(())
20432045
}
20442046

20452047
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {

src/librustc/mir/visit.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ macro_rules! make_mir_visitor {
376376
ref $($mutability)* inputs,
377377
asm: _ } => {
378378
for output in & $($mutability)* outputs[..] {
379-
self.visit_place(output, PlaceContext::Store, location);
379+
self.visit_place(output, PlaceContext::AsmOutput, location);
380380
}
381381
for input in & $($mutability)* inputs[..] {
382382
self.visit_operand(input, location);
@@ -835,6 +835,11 @@ pub enum PlaceContext<'tcx> {
835835
// Appears as LHS of an assignment
836836
Store,
837837

838+
// Can often be treated as a Store, but needs to be separate because
839+
// ASM is allowed to read outputs as well, so a Store-AsmOutput sequence
840+
// cannot be simplified the way a Store-Store can be.
841+
AsmOutput,
842+
838843
// Dest of a call
839844
Call,
840845

@@ -910,7 +915,7 @@ impl<'tcx> PlaceContext<'tcx> {
910915
/// Returns true if this place context represents a use that potentially changes the value.
911916
pub fn is_mutating_use(&self) -> bool {
912917
match *self {
913-
PlaceContext::Store | PlaceContext::Call |
918+
PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call |
914919
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } |
915920
PlaceContext::Projection(Mutability::Mut) |
916921
PlaceContext::Drop => true,
@@ -932,6 +937,7 @@ impl<'tcx> PlaceContext<'tcx> {
932937
PlaceContext::Projection(Mutability::Not) |
933938
PlaceContext::Copy | PlaceContext::Move => true,
934939
PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store |
940+
PlaceContext::AsmOutput |
935941
PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) |
936942
PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead |
937943
PlaceContext::Validate => false,

src/librustc/session/config.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10131013
"set the threshold for inlining a function (default: 225)"),
10141014
panic: Option<PanicStrategy> = (None, parse_panic_strategy,
10151015
[TRACKED], "panic strategy to compile crate with"),
1016+
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
1017+
"enable incremental compilation"),
10161018
}
10171019

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

1666-
if cg.lto && debugging_opts.incremental.is_some() {
1668+
let incremental = match (&debugging_opts.incremental, &cg.incremental) {
1669+
(&Some(ref path1), &Some(ref path2)) => {
1670+
if path1 != path2 {
1671+
early_error(error_format,
1672+
&format!("conflicting paths for `-Z incremental` and \
1673+
`-C incremental` specified: {} versus {}",
1674+
path1,
1675+
path2));
1676+
} else {
1677+
Some(path1)
1678+
}
1679+
}
1680+
(&Some(ref path), &None) => Some(path),
1681+
(&None, &Some(ref path)) => Some(path),
1682+
(&None, &None) => None,
1683+
}.map(|m| PathBuf::from(m));
1684+
1685+
if cg.lto && incremental.is_some() {
16671686
early_error(error_format, "can't perform LTO when compiling incrementally");
16681687
}
16691688

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

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

1840-
let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
1841-
18421859
(Options {
18431860
crate_types,
18441861
optimize: opt_level,
@@ -2581,6 +2598,9 @@ mod tests {
25812598
opts.cg.save_temps = true;
25822599
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
25832600

2601+
opts.cg.incremental = Some(String::from("abc"));
2602+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2603+
25842604

25852605
// Make sure changing a [TRACKED] option changes the hash
25862606
opts = reference.clone();

src/librustc_mir/dataflow/impls/borrows.rs

+4
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> {
540540
// "deep" does validation go?
541541
PlaceContext::Validate => false,
542542

543+
// FIXME: This is here to not change behaviour from before
544+
// AsmOutput existed, but it's not necessarily a pure overwrite.
545+
// so it's possible this should activate the place.
546+
PlaceContext::AsmOutput |
543547
// pure overwrites of an place do not activate it. (note
544548
// PlaceContext::Call is solely about dest place)
545549
PlaceContext::Store | PlaceContext::Call => false,

src/librustc_mir/transform/check_unsafety.rs

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
173173
ty::TyAdt(adt, _) => {
174174
if adt.is_union() {
175175
if context == PlaceContext::Store ||
176+
context == PlaceContext::AsmOutput ||
176177
context == PlaceContext::Drop
177178
{
178179
let elem_ty = match elem {

src/librustc_mir/transform/promote_consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
103103
if *temp == TempState::Undefined {
104104
match context {
105105
PlaceContext::Store |
106+
PlaceContext::AsmOutput |
106107
PlaceContext::Call => {
107108
*temp = TempState::Defined {
108109
location,

src/librustc_mir/util/liveness.rs

+3
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor {
273273

274274
PlaceContext::Store |
275275

276+
// This is potentially both a def and a use...
277+
PlaceContext::AsmOutput |
278+
276279
// We let Call define the result in both the success and
277280
// unwind cases. This is not really correct, however it
278281
// does not seem to be observable due to the way that we

src/librustc_trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
10241024

10251025
assert_symbols_are_distinct(tcx, items.iter());
10261026

1027-
let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() {
1027+
let strategy = if tcx.sess.opts.incremental.is_some() {
10281028
PartitioningStrategy::PerModule
10291029
} else {
10301030
PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units())

src/librustc_trans/mir/analyze.rs

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> {
193193

194194
PlaceContext::Inspect |
195195
PlaceContext::Store |
196+
PlaceContext::AsmOutput |
196197
PlaceContext::Borrow { .. } |
197198
PlaceContext::Projection(..) => {
198199
self.mark_as_memory(index);

src/librustc_typeck/check/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12741274
impl_id: DefId,
12751275
impl_trait_ref: ty::TraitRef<'tcx>,
12761276
impl_item_refs: &[hir::ImplItemRef]) {
1277+
let impl_span = tcx.sess.codemap().def_span(impl_span);
1278+
12771279
// If the trait reference itself is erroneous (so the compilation is going
12781280
// to fail), skip checking the items here -- the `impl_item` table in `tcx`
12791281
// isn't populated for such impls.

0 commit comments

Comments
 (0)