Skip to content

Commit fd3c2f6

Browse files
committed
Auto merge of #39652 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #38165, #39456, #39587, #39589, #39598, #39641 - Failed merges: #39586, #39595
2 parents 29dece1 + 7a48493 commit fd3c2f6

Some content is hidden

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

67 files changed

+1281
-992
lines changed

mk/cfg/aarch64-unknown-freebsd.mk

-1
This file was deleted.

mk/cfg/i686-unknown-netbsd.mk

-1
This file was deleted.

src/bootstrap/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct Build {
149149
python: Option<String>,
150150
full_bootstrap: Option<bool>,
151151
extended: Option<bool>,
152+
verbose: Option<usize>,
152153
}
153154

154155
/// TOML representation of various global install decisions.
@@ -294,6 +295,7 @@ impl Config {
294295
set(&mut config.vendor, build.vendor);
295296
set(&mut config.full_bootstrap, build.full_bootstrap);
296297
set(&mut config.extended, build.extended);
298+
set(&mut config.verbose, build.verbose);
297299

298300
if let Some(ref install) = toml.install {
299301
config.prefix = install.prefix.clone().map(PathBuf::from);

src/bootstrap/config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@
124124
# disabled by default.
125125
#extended = false
126126

127+
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
128+
#verbose = 0
129+
127130
# =============================================================================
128131
# General install configuration options
129132
# =============================================================================

src/bootstrap/dist.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,7 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {
515515

516516
let branch = match &build.config.channel[..] {
517517
"stable" |
518-
"beta" => {
519-
build.release.split(".").take(2).collect::<Vec<_>>().join(".")
520-
}
518+
"beta" => format!("rust-{}", build.release_num),
521519
_ => "master".to_string(),
522520
};
523521

src/doc/book/functions.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,19 @@ If you want more information, you can get a backtrace by setting the
230230
```text
231231
$ RUST_BACKTRACE=1 ./diverges
232232
thread 'main' panicked at 'This function never returns!', hello.rs:2
233+
Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
234+
stack backtrace:
235+
hello::diverges
236+
at ./hello.rs:2
237+
hello::main
238+
at ./hello.rs:6
239+
```
240+
241+
If you want the complete backtrace and filenames:
242+
243+
```text
244+
$ RUST_BACKTRACE=full ./diverges
245+
thread 'main' panicked at 'This function never returns!', hello.rs:2
233246
stack backtrace:
234247
1: 0x7f402773a829 - sys::backtrace::write::h0942de78b6c02817K8r
235248
2: 0x7f402773d7fc - panicking::on_panic::h3f23f9d0b5f4c91bu9w
@@ -262,7 +275,7 @@ note: Run with `RUST_BACKTRACE=1` for a backtrace.
262275
`RUST_BACKTRACE` also works with Cargo’s `run` command:
263276

264277
```text
265-
$ RUST_BACKTRACE=1 cargo run
278+
$ RUST_BACKTRACE=full cargo run
266279
Running `target/debug/diverges`
267280
thread 'main' panicked at 'This function never returns!', hello.rs:2
268281
stack backtrace:

src/librustc/middle/const_val.rs

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::rc::Rc;
1414
use hir::def_id::DefId;
1515
use rustc_const_math::*;
1616
use self::ConstVal::*;
17+
pub use rustc_const_math::ConstInt;
1718

1819
use std::collections::BTreeMap;
1920

@@ -48,4 +49,14 @@ impl ConstVal {
4849
Char(..) => "char",
4950
}
5051
}
52+
53+
pub fn to_const_int(&self) -> Option<ConstInt> {
54+
match *self {
55+
ConstVal::Integral(i) => Some(i),
56+
ConstVal::Bool(true) => Some(ConstInt::Infer(1)),
57+
ConstVal::Bool(false) => Some(ConstInt::Infer(0)),
58+
ConstVal::Char(ch) => Some(ConstInt::U32(ch as u32)),
59+
_ => None
60+
}
61+
}
5162
}

src/librustc/mir/mod.rs

+33-34
Original file line numberDiff line numberDiff line change
@@ -453,36 +453,30 @@ pub enum TerminatorKind<'tcx> {
453453
target: BasicBlock,
454454
},
455455

456-
/// jump to branch 0 if this lvalue evaluates to true
457-
If {
458-
cond: Operand<'tcx>,
459-
targets: (BasicBlock, BasicBlock),
460-
},
461-
462-
/// lvalue evaluates to some enum; jump depending on the branch
463-
Switch {
464-
discr: Lvalue<'tcx>,
465-
adt_def: &'tcx AdtDef,
466-
targets: Vec<BasicBlock>,
467-
},
468-
469456
/// operand evaluates to an integer; jump depending on its value
470457
/// to one of the targets, and otherwise fallback to `otherwise`
471458
SwitchInt {
472459
/// discriminant value being tested
473-
discr: Lvalue<'tcx>,
460+
discr: Operand<'tcx>,
474461

475462
/// type of value being tested
476463
switch_ty: Ty<'tcx>,
477464

478465
/// Possible values. The locations to branch to in each case
479466
/// are found in the corresponding indices from the `targets` vector.
480-
values: Vec<ConstVal>,
481-
482-
/// Possible branch sites. The length of this vector should be
483-
/// equal to the length of the `values` vector plus 1 -- the
484-
/// extra item is the block to branch to if none of the values
485-
/// fit.
467+
values: Cow<'tcx, [ConstInt]>,
468+
469+
/// Possible branch sites. The last element of this vector is used
470+
/// for the otherwise branch, so values.len() == targets.len() + 1
471+
/// should hold.
472+
// This invariant is quite non-obvious and also could be improved.
473+
// One way to make this invariant is to have something like this instead:
474+
//
475+
// branches: Vec<(ConstInt, BasicBlock)>,
476+
// otherwise: Option<BasicBlock> // exhaustive if None
477+
//
478+
// However we’ve decided to keep this as-is until we figure a case
479+
// where some other approach seems to be strictly better than other.
486480
targets: Vec<BasicBlock>,
487481
},
488482

@@ -546,12 +540,21 @@ impl<'tcx> Terminator<'tcx> {
546540
}
547541

548542
impl<'tcx> TerminatorKind<'tcx> {
543+
pub fn if_<'a, 'gcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>, cond: Operand<'tcx>,
544+
t: BasicBlock, f: BasicBlock) -> TerminatorKind<'tcx> {
545+
static BOOL_SWITCH_FALSE: &'static [ConstInt] = &[ConstInt::Infer(0)];
546+
TerminatorKind::SwitchInt {
547+
discr: cond,
548+
switch_ty: tcx.types.bool,
549+
values: From::from(BOOL_SWITCH_FALSE),
550+
targets: vec![f, t],
551+
}
552+
}
553+
549554
pub fn successors(&self) -> Cow<[BasicBlock]> {
550555
use self::TerminatorKind::*;
551556
match *self {
552557
Goto { target: ref b } => slice::ref_slice(b).into_cow(),
553-
If { targets: (b1, b2), .. } => vec![b1, b2].into_cow(),
554-
Switch { targets: ref b, .. } => b[..].into_cow(),
555558
SwitchInt { targets: ref b, .. } => b[..].into_cow(),
556559
Resume => (&[]).into_cow(),
557560
Return => (&[]).into_cow(),
@@ -580,8 +583,6 @@ impl<'tcx> TerminatorKind<'tcx> {
580583
use self::TerminatorKind::*;
581584
match *self {
582585
Goto { target: ref mut b } => vec![b],
583-
If { targets: (ref mut b1, ref mut b2), .. } => vec![b1, b2],
584-
Switch { targets: ref mut b, .. } => b.iter_mut().collect(),
585586
SwitchInt { targets: ref mut b, .. } => b.iter_mut().collect(),
586587
Resume => Vec::new(),
587588
Return => Vec::new(),
@@ -659,8 +660,6 @@ impl<'tcx> TerminatorKind<'tcx> {
659660
use self::TerminatorKind::*;
660661
match *self {
661662
Goto { .. } => write!(fmt, "goto"),
662-
If { cond: ref lv, .. } => write!(fmt, "if({:?})", lv),
663-
Switch { discr: ref lv, .. } => write!(fmt, "switch({:?})", lv),
664663
SwitchInt { discr: ref lv, .. } => write!(fmt, "switchInt({:?})", lv),
665664
Return => write!(fmt, "return"),
666665
Resume => write!(fmt, "resume"),
@@ -710,18 +709,11 @@ impl<'tcx> TerminatorKind<'tcx> {
710709
match *self {
711710
Return | Resume | Unreachable => vec![],
712711
Goto { .. } => vec!["".into()],
713-
If { .. } => vec!["true".into(), "false".into()],
714-
Switch { ref adt_def, .. } => {
715-
adt_def.variants
716-
.iter()
717-
.map(|variant| variant.name.to_string().into())
718-
.collect()
719-
}
720712
SwitchInt { ref values, .. } => {
721713
values.iter()
722714
.map(|const_val| {
723715
let mut buf = String::new();
724-
fmt_const_val(&mut buf, const_val).unwrap();
716+
fmt_const_val(&mut buf, &ConstVal::Integral(*const_val)).unwrap();
725717
buf.into()
726718
})
727719
.chain(iter::once(String::from("otherwise").into()))
@@ -997,6 +989,12 @@ pub enum Rvalue<'tcx> {
997989

998990
UnaryOp(UnOp, Operand<'tcx>),
999991

992+
/// Read the discriminant of an ADT.
993+
///
994+
/// Undefined (i.e. no effort is made to make it defined, but there’s no reason why it cannot
995+
/// be defined to return, say, a 0) if ADT is not an enum.
996+
Discriminant(Lvalue<'tcx>),
997+
1000998
/// Creates an *uninitialized* Box
1001999
Box(Ty<'tcx>),
10021000

@@ -1111,6 +1109,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
11111109
write!(fmt, "Checked{:?}({:?}, {:?})", op, a, b)
11121110
}
11131111
UnaryOp(ref op, ref a) => write!(fmt, "{:?}({:?})", op, a),
1112+
Discriminant(ref lval) => write!(fmt, "discriminant({:?})", lval),
11141113
Box(ref t) => write!(fmt, "Box({:?})", t),
11151114
InlineAsm { ref asm, ref outputs, ref inputs } => {
11161115
write!(fmt, "asm!({:?} : {:?} : {:?})", asm, outputs, inputs)

src/librustc/mir/tcx.rs

+23-12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use ty::subst::{Subst, Substs};
1818
use ty::{self, AdtDef, Ty, TyCtxt};
1919
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
2020
use hir;
21+
use ty::util::IntTypeExt;
2122

2223
#[derive(Copy, Clone, Debug)]
2324
pub enum LvalueTy<'tcx> {
@@ -135,15 +136,15 @@ impl<'tcx> Lvalue<'tcx> {
135136
impl<'tcx> Rvalue<'tcx> {
136137
pub fn ty<'a, 'gcx>(&self, mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Ty<'tcx>>
137138
{
138-
match self {
139-
&Rvalue::Use(ref operand) => Some(operand.ty(mir, tcx)),
140-
&Rvalue::Repeat(ref operand, ref count) => {
139+
match *self {
140+
Rvalue::Use(ref operand) => Some(operand.ty(mir, tcx)),
141+
Rvalue::Repeat(ref operand, ref count) => {
141142
let op_ty = operand.ty(mir, tcx);
142143
let count = count.value.as_u64(tcx.sess.target.uint_type);
143144
assert_eq!(count as usize as u64, count);
144145
Some(tcx.mk_array(op_ty, count as usize))
145146
}
146-
&Rvalue::Ref(reg, bk, ref lv) => {
147+
Rvalue::Ref(reg, bk, ref lv) => {
147148
let lv_ty = lv.ty(mir, tcx).to_ty(tcx);
148149
Some(tcx.mk_ref(reg,
149150
ty::TypeAndMut {
@@ -152,27 +153,37 @@ impl<'tcx> Rvalue<'tcx> {
152153
}
153154
))
154155
}
155-
&Rvalue::Len(..) => Some(tcx.types.usize),
156-
&Rvalue::Cast(.., ty) => Some(ty),
157-
&Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
156+
Rvalue::Len(..) => Some(tcx.types.usize),
157+
Rvalue::Cast(.., ty) => Some(ty),
158+
Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
158159
let lhs_ty = lhs.ty(mir, tcx);
159160
let rhs_ty = rhs.ty(mir, tcx);
160161
Some(op.ty(tcx, lhs_ty, rhs_ty))
161162
}
162-
&Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
163+
Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
163164
let lhs_ty = lhs.ty(mir, tcx);
164165
let rhs_ty = rhs.ty(mir, tcx);
165166
let ty = op.ty(tcx, lhs_ty, rhs_ty);
166167
let ty = tcx.intern_tup(&[ty, tcx.types.bool], false);
167168
Some(ty)
168169
}
169-
&Rvalue::UnaryOp(_, ref operand) => {
170+
Rvalue::UnaryOp(_, ref operand) => {
170171
Some(operand.ty(mir, tcx))
171172
}
172-
&Rvalue::Box(t) => {
173+
Rvalue::Discriminant(ref lval) => {
174+
let ty = lval.ty(mir, tcx).to_ty(tcx);
175+
if let ty::TyAdt(adt_def, _) = ty.sty {
176+
Some(adt_def.discr_ty.to_ty(tcx))
177+
} else {
178+
// Undefined behaviour, bug for now; may want to return something for
179+
// the `discriminant` intrinsic later.
180+
bug!("Rvalue::Discriminant on Lvalue of type {:?}", ty);
181+
}
182+
}
183+
Rvalue::Box(t) => {
173184
Some(tcx.mk_box(t))
174185
}
175-
&Rvalue::Aggregate(ref ak, ref ops) => {
186+
Rvalue::Aggregate(ref ak, ref ops) => {
176187
match *ak {
177188
AggregateKind::Array => {
178189
if let Some(operand) = ops.get(0) {
@@ -196,7 +207,7 @@ impl<'tcx> Rvalue<'tcx> {
196207
}
197208
}
198209
}
199-
&Rvalue::InlineAsm { .. } => None
210+
Rvalue::InlineAsm { .. } => None
200211
}
201212
}
202213
}

src/librustc/mir/visit.rs

+19-24
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use ty::subst::Substs;
1414
use ty::{ClosureSubsts, Region, Ty};
1515
use mir::*;
1616
use rustc_const_math::ConstUsize;
17-
use rustc_data_structures::tuple_slice::TupleSlice;
1817
use rustc_data_structures::indexed_vec::Idx;
1918
use syntax_pos::Span;
2019

@@ -224,6 +223,12 @@ macro_rules! make_mir_visitor {
224223
self.super_const_val(const_val);
225224
}
226225

226+
fn visit_const_int(&mut self,
227+
const_int: &ConstInt,
228+
_: Location) {
229+
self.super_const_int(const_int);
230+
}
231+
227232
fn visit_const_usize(&mut self,
228233
const_usize: & $($mutability)* ConstUsize,
229234
_: Location) {
@@ -363,31 +368,14 @@ macro_rules! make_mir_visitor {
363368
self.visit_branch(block, target);
364369
}
365370

366-
TerminatorKind::If { ref $($mutability)* cond,
367-
ref $($mutability)* targets } => {
368-
self.visit_operand(cond, source_location);
369-
for &target in targets.as_slice() {
370-
self.visit_branch(block, target);
371-
}
372-
}
373-
374-
TerminatorKind::Switch { ref $($mutability)* discr,
375-
adt_def: _,
376-
ref targets } => {
377-
self.visit_lvalue(discr, LvalueContext::Inspect, source_location);
378-
for &target in targets {
379-
self.visit_branch(block, target);
380-
}
381-
}
382-
383371
TerminatorKind::SwitchInt { ref $($mutability)* discr,
384372
ref $($mutability)* switch_ty,
385-
ref $($mutability)* values,
373+
ref values,
386374
ref targets } => {
387-
self.visit_lvalue(discr, LvalueContext::Inspect, source_location);
375+
self.visit_operand(discr, source_location);
388376
self.visit_ty(switch_ty);
389-
for value in values {
390-
self.visit_const_val(value, source_location);
377+
for value in &values[..] {
378+
self.visit_const_int(value, source_location);
391379
}
392380
for &target in targets {
393381
self.visit_branch(block, target);
@@ -506,6 +494,10 @@ macro_rules! make_mir_visitor {
506494
self.visit_operand(op, location);
507495
}
508496

497+
Rvalue::Discriminant(ref $($mutability)* lvalue) => {
498+
self.visit_lvalue(lvalue, LvalueContext::Inspect, location);
499+
}
500+
509501
Rvalue::Box(ref $($mutability)* ty) => {
510502
self.visit_ty(ty);
511503
}
@@ -712,10 +704,13 @@ macro_rules! make_mir_visitor {
712704
_substs: & $($mutability)* ClosureSubsts<'tcx>) {
713705
}
714706

715-
fn super_const_val(&mut self, _substs: & $($mutability)* ConstVal) {
707+
fn super_const_val(&mut self, _const_val: & $($mutability)* ConstVal) {
708+
}
709+
710+
fn super_const_int(&mut self, _const_int: &ConstInt) {
716711
}
717712

718-
fn super_const_usize(&mut self, _substs: & $($mutability)* ConstUsize) {
713+
fn super_const_usize(&mut self, _const_usize: & $($mutability)* ConstUsize) {
719714
}
720715

721716
// Convenience methods

0 commit comments

Comments
 (0)