Skip to content

Commit 1004860

Browse files
committed
Auto merge of #30028 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #29397, #29933, #30004, #30019, #30020, #30023 - Failed merges:
2 parents ebb560a + 204fe21 commit 1004860

File tree

12 files changed

+54
-124
lines changed

12 files changed

+54
-124
lines changed

mk/clean.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ clean-generic-$(2)-$(1):
6565
-name '*.def' -o \
6666
-name '*.py' -o \
6767
-name '*.pyc' -o \
68-
-name '*.bc' \
68+
-name '*.bc' -o \
69+
-name '*.rs' \
6970
\) \
7071
| xargs rm -f
7172
$(Q)find $(1) \

src/doc/book/error-handling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ fn main() {
16431643
16441644
let matches = match opts.parse(&args[1..]) {
16451645
Ok(m) => { m }
1646-
Err(e) => { panic!(e.to_string()) }
1646+
Err(e) => { panic!(e.to_string()) }
16471647
};
16481648
16491649
if matches.opt_present("h") {

src/doc/reference.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ apply to the crate as a whole.
677677
```
678678

679679
A crate that contains a `main` function can be compiled to an executable. If a
680-
`main` function is present, its return type must be [`unit`](#tuple-types)
681-
and it must take no arguments.
680+
`main` function is present, its return type must be `()`
681+
("[unit](#tuple-types)") and it must take no arguments.
682682

683683
# Items and attributes
684684

src/librustc/middle/dataflow.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
//! and thus uses bitvectors. Your job is simply to specify the so-called
1515
//! GEN and KILL bits for each expression.
1616
17-
pub use self::EntryOrExit::*;
18-
1917
use middle::cfg;
2018
use middle::cfg::CFGIndex;
2119
use middle::ty;
@@ -340,7 +338,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
340338
}
341339
let indices = get_cfg_indices(id, &self.nodeid_to_index);
342340
for &cfgidx in indices {
343-
if !self.each_bit_for_node(Entry, cfgidx, |i| f(i)) {
341+
if !self.each_bit_for_node(EntryOrExit::Entry, cfgidx, |i| f(i)) {
344342
return false;
345343
}
346344
}
@@ -363,8 +361,8 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
363361
let on_entry = &self.on_entry[start.. end];
364362
let temp_bits;
365363
let slice = match e {
366-
Entry => on_entry,
367-
Exit => {
364+
EntryOrExit::Entry => on_entry,
365+
EntryOrExit::Exit => {
368366
let mut t = on_entry.to_vec();
369367
self.apply_gen_kill(cfgidx, &mut t);
370368
temp_bits = t;

src/librustc/util/ppaux.rs

+4-46
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags};
2424
use middle::ty::fold::TypeFoldable;
2525

2626
use std::fmt;
27-
use syntax::abi;
28-
use syntax::ast;
27+
use syntax::{abi, ast_util};
2928
use syntax::parse::token;
3029
use syntax::ast::CRATE_NODE_ID;
3130
use rustc_front::hir;
@@ -774,55 +773,14 @@ impl<'tcx> fmt::Display for ty::TraitRef<'tcx> {
774773
}
775774
}
776775

777-
pub fn int_ty_to_string(t: ast::IntTy, val: Option<i64>) -> String {
778-
let s = match t {
779-
ast::TyIs => "isize",
780-
ast::TyI8 => "i8",
781-
ast::TyI16 => "i16",
782-
ast::TyI32 => "i32",
783-
ast::TyI64 => "i64"
784-
};
785-
786-
match val {
787-
// cast to a u64 so we can correctly print INT64_MIN. All integral types
788-
// are parsed as u64, so we wouldn't want to print an extra negative
789-
// sign.
790-
Some(n) => format!("{}{}", n as u64, s),
791-
None => s.to_string()
792-
}
793-
}
794-
795-
pub fn uint_ty_to_string(t: ast::UintTy, val: Option<u64>) -> String {
796-
let s = match t {
797-
ast::TyUs => "usize",
798-
ast::TyU8 => "u8",
799-
ast::TyU16 => "u16",
800-
ast::TyU32 => "u32",
801-
ast::TyU64 => "u64"
802-
};
803-
804-
match val {
805-
Some(n) => format!("{}{}", n, s),
806-
None => s.to_string()
807-
}
808-
}
809-
810-
811-
pub fn float_ty_to_string(t: ast::FloatTy) -> String {
812-
match t {
813-
ast::TyF32 => "f32".to_string(),
814-
ast::TyF64 => "f64".to_string(),
815-
}
816-
}
817-
818776
impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
819777
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
820778
match *self {
821779
TyBool => write!(f, "bool"),
822780
TyChar => write!(f, "char"),
823-
TyInt(t) => write!(f, "{}", int_ty_to_string(t, None)),
824-
TyUint(t) => write!(f, "{}", uint_ty_to_string(t, None)),
825-
TyFloat(t) => write!(f, "{}", float_ty_to_string(t)),
781+
TyInt(t) => write!(f, "{}", ast_util::int_ty_to_string(t)),
782+
TyUint(t) => write!(f, "{}", ast_util::uint_ty_to_string(t)),
783+
TyFloat(t) => write!(f, "{}", ast_util::float_ty_to_string(t)),
826784
TyBox(typ) => write!(f, "Box<{}>", typ),
827785
TyRawPtr(ref tm) => {
828786
write!(f, "*{} {}", match tm.mutbl {

src/librustc_borrowck/graphviz.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use borrowck::{BorrowckCtxt, LoanPath};
2222
use dot;
2323
use rustc::middle::cfg::CFGIndex;
2424
use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
25-
use rustc::middle::dataflow;
2625
use std::rc::Rc;
2726
use std::borrow::IntoCow;
2827

@@ -134,8 +133,8 @@ impl<'a, 'tcx> dot::Labeller<'a, Node<'a>, Edge<'a>> for DataflowLabeller<'a, 't
134133
fn graph_id(&'a self) -> dot::Id<'a> { self.inner.graph_id() }
135134
fn node_id(&'a self, n: &Node<'a>) -> dot::Id<'a> { self.inner.node_id(n) }
136135
fn node_label(&'a self, n: &Node<'a>) -> dot::LabelText<'a> {
137-
let prefix = self.dataflow_for(dataflow::Entry, n);
138-
let suffix = self.dataflow_for(dataflow::Exit, n);
136+
let prefix = self.dataflow_for(EntryOrExit::Entry, n);
137+
let suffix = self.dataflow_for(EntryOrExit::Exit, n);
139138
let inner_label = self.inner.node_label(n);
140139
inner_label
141140
.prefix_line(dot::LabelText::LabelStr(prefix.into_cow()))

src/librustc_llvm/diagnostic.rs

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl OptimizationDiagnosticKind {
3737
}
3838
}
3939

40-
#[derive(Copy, Clone)]
4140
pub struct OptimizationDiagnostic {
4241
pub kind: OptimizationDiagnosticKind,
4342
pub pass_name: *const c_char,
@@ -94,7 +93,6 @@ impl InlineAsmDiagnostic {
9493
}
9594
}
9695

97-
#[derive(Copy, Clone)]
9896
pub enum Diagnostic {
9997
Optimization(OptimizationDiagnostic),
10098
InlineAsm(InlineAsmDiagnostic),

src/librustc_trans/trans/debuginfo/metadata.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use std::rc::Rc;
4646
use syntax;
4747
use syntax::util::interner::Interner;
4848
use syntax::codemap::Span;
49-
use syntax::{ast, codemap};
49+
use syntax::{ast, ast_util, codemap};
5050
use syntax::parse::token;
5151

5252

@@ -932,26 +932,17 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
932932

933933
let (name, encoding) = match t.sty {
934934
ty::TyTuple(ref elements) if elements.is_empty() =>
935-
("()".to_string(), DW_ATE_unsigned),
936-
ty::TyBool => ("bool".to_string(), DW_ATE_boolean),
937-
ty::TyChar => ("char".to_string(), DW_ATE_unsigned_char),
938-
ty::TyInt(int_ty) => match int_ty {
939-
ast::TyIs => ("isize".to_string(), DW_ATE_signed),
940-
ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
941-
ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
942-
ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
943-
ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
935+
("()", DW_ATE_unsigned),
936+
ty::TyBool => ("bool", DW_ATE_boolean),
937+
ty::TyChar => ("char", DW_ATE_unsigned_char),
938+
ty::TyInt(int_ty) => {
939+
(ast_util::int_ty_to_string(int_ty), DW_ATE_signed)
944940
},
945-
ty::TyUint(uint_ty) => match uint_ty {
946-
ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
947-
ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
948-
ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
949-
ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
950-
ast::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
941+
ty::TyUint(uint_ty) => {
942+
(ast_util::uint_ty_to_string(uint_ty), DW_ATE_unsigned)
951943
},
952-
ty::TyFloat(float_ty) => match float_ty {
953-
ast::TyF32 => ("f32".to_string(), DW_ATE_float),
954-
ast::TyF64 => ("f64".to_string(), DW_ATE_float),
944+
ty::TyFloat(float_ty) => {
945+
(ast_util::float_ty_to_string(float_ty), DW_ATE_float)
955946
},
956947
_ => cx.sess().bug("debuginfo::basic_type_metadata - t is invalid type")
957948
};

src/librustc_trans/trans/debuginfo/type_names.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::subst::{self, Substs};
1919
use middle::ty::{self, Ty};
2020

2121
use rustc_front::hir;
22-
use syntax::ast;
22+
use syntax::ast_util;
2323

2424
// Compute the name of the type as it should be stored in debuginfo. Does not do
2525
// any caching, i.e. calling the function twice with the same type will also do
@@ -41,21 +41,12 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
4141
qualified: bool,
4242
output: &mut String) {
4343
match t.sty {
44-
ty::TyBool => output.push_str("bool"),
45-
ty::TyChar => output.push_str("char"),
46-
ty::TyStr => output.push_str("str"),
47-
ty::TyInt(ast::TyIs) => output.push_str("isize"),
48-
ty::TyInt(ast::TyI8) => output.push_str("i8"),
49-
ty::TyInt(ast::TyI16) => output.push_str("i16"),
50-
ty::TyInt(ast::TyI32) => output.push_str("i32"),
51-
ty::TyInt(ast::TyI64) => output.push_str("i64"),
52-
ty::TyUint(ast::TyUs) => output.push_str("usize"),
53-
ty::TyUint(ast::TyU8) => output.push_str("u8"),
54-
ty::TyUint(ast::TyU16) => output.push_str("u16"),
55-
ty::TyUint(ast::TyU32) => output.push_str("u32"),
56-
ty::TyUint(ast::TyU64) => output.push_str("u64"),
57-
ty::TyFloat(ast::TyF32) => output.push_str("f32"),
58-
ty::TyFloat(ast::TyF64) => output.push_str("f64"),
44+
ty::TyBool => output.push_str("bool"),
45+
ty::TyChar => output.push_str("char"),
46+
ty::TyStr => output.push_str("str"),
47+
ty::TyInt(int_ty) => output.push_str(ast_util::int_ty_to_string(int_ty)),
48+
ty::TyUint(uint_ty) => output.push_str(ast_util::uint_ty_to_string(uint_ty)),
49+
ty::TyFloat(float_ty) => output.push_str(ast_util::float_ty_to_string(float_ty)),
5950
ty::TyStruct(def, substs) |
6051
ty::TyEnum(def, substs) => {
6152
push_item_name(cx, def.did, qualified, output);

src/libsyntax/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ impl fmt::Debug for IntTy {
12581258

12591259
impl fmt::Display for IntTy {
12601260
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1261-
write!(f, "{}", ast_util::int_ty_to_string(*self, None))
1261+
write!(f, "{}", ast_util::int_ty_to_string(*self))
12621262
}
12631263
}
12641264

@@ -1303,7 +1303,7 @@ impl fmt::Debug for UintTy {
13031303

13041304
impl fmt::Display for UintTy {
13051305
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1306-
write!(f, "{}", ast_util::uint_ty_to_string(*self, None))
1306+
write!(f, "{}", ast_util::uint_ty_to_string(*self))
13071307
}
13081308
}
13091309

src/libsyntax/ast_util.rs

+18-24
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,23 @@ pub fn is_path(e: P<Expr>) -> bool {
111111
match e.node { ExprPath(..) => true, _ => false }
112112
}
113113

114-
/// Get a string representation of a signed int type, with its value.
115-
/// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
116-
pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
117-
let s = match t {
114+
pub fn int_ty_to_string(t: IntTy) -> &'static str {
115+
match t {
118116
TyIs => "isize",
119117
TyI8 => "i8",
120118
TyI16 => "i16",
121119
TyI32 => "i32",
122120
TyI64 => "i64"
123-
};
124-
125-
match val {
126-
// cast to a u64 so we can correctly print INT64_MIN. All integral types
127-
// are parsed as u64, so we wouldn't want to print an extra negative
128-
// sign.
129-
Some(n) => format!("{}{}", n as u64, s),
130-
None => s.to_string()
131121
}
132122
}
133123

124+
pub fn int_val_to_string(t: IntTy, val: i64) -> String {
125+
// cast to a u64 so we can correctly print INT64_MIN. All integral types
126+
// are parsed as u64, so we wouldn't want to print an extra negative
127+
// sign.
128+
format!("{}{}", val as u64, int_ty_to_string(t))
129+
}
130+
134131
pub fn int_ty_max(t: IntTy) -> u64 {
135132
match t {
136133
TyI8 => 0x80,
@@ -140,23 +137,20 @@ pub fn int_ty_max(t: IntTy) -> u64 {
140137
}
141138
}
142139

143-
/// Get a string representation of an unsigned int type, with its value.
144-
/// We want to avoid "42u" in favor of "42us". "42uint" is right out.
145-
pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
146-
let s = match t {
140+
pub fn uint_ty_to_string(t: UintTy) -> &'static str {
141+
match t {
147142
TyUs => "usize",
148143
TyU8 => "u8",
149144
TyU16 => "u16",
150145
TyU32 => "u32",
151146
TyU64 => "u64"
152-
};
153-
154-
match val {
155-
Some(n) => format!("{}{}", n, s),
156-
None => s.to_string()
157147
}
158148
}
159149

150+
pub fn uint_val_to_string(t: UintTy, val: u64) -> String {
151+
format!("{}{}", val, uint_ty_to_string(t))
152+
}
153+
160154
pub fn uint_ty_max(t: UintTy) -> u64 {
161155
match t {
162156
TyU8 => 0xff,
@@ -166,10 +160,10 @@ pub fn uint_ty_max(t: UintTy) -> u64 {
166160
}
167161
}
168162

169-
pub fn float_ty_to_string(t: FloatTy) -> String {
163+
pub fn float_ty_to_string(t: FloatTy) -> &'static str {
170164
match t {
171-
TyF32 => "f32".to_string(),
172-
TyF64 => "f64".to_string(),
165+
TyF32 => "f32",
166+
TyF64 => "f64",
173167
}
174168
}
175169

src/libsyntax/print/pprust.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -651,15 +651,15 @@ pub trait PrintState<'a> {
651651
match t {
652652
ast::SignedIntLit(st, ast::Plus) => {
653653
word(self.writer(),
654-
&ast_util::int_ty_to_string(st, Some(i as i64)))
654+
&ast_util::int_val_to_string(st, i as i64))
655655
}
656656
ast::SignedIntLit(st, ast::Minus) => {
657-
let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
657+
let istr = ast_util::int_val_to_string(st, -(i as i64));
658658
word(self.writer(),
659659
&format!("-{}", istr))
660660
}
661661
ast::UnsignedIntLit(ut) => {
662-
word(self.writer(), &ast_util::uint_ty_to_string(ut, Some(i)))
662+
word(self.writer(), &ast_util::uint_val_to_string(ut, i))
663663
}
664664
ast::UnsuffixedIntLit(ast::Plus) => {
665665
word(self.writer(), &format!("{}", i))

0 commit comments

Comments
 (0)