Skip to content

Commit a5404dd

Browse files
committed
---
yaml --- r: 155399 b: refs/heads/try2 c: 9ff3081 h: refs/heads/master i: 155397: ed25871 155395: e863aed 155391: 462693d v: v3
1 parent d2a5d0b commit a5404dd

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

+571
-761
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c8b767dd3d06fcabc2df753cbb9fd694ebc0eec6
8+
refs/heads/try2: 9ff308137afcacb4bc0d47e00d1dbb730229d932
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/fmt/float.rs

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,12 @@ pub enum ExponentFormat {
2828
/// Use exponential notation with the exponent having a base of 10 and the
2929
/// exponent sign being `e` or `E`. For example, 1000 would be printed
3030
/// 1e3.
31-
ExpDec,
32-
/// Use exponential notation with the exponent having a base of 2 and the
33-
/// exponent sign being `p` or `P`. For example, 8 would be printed 1p3.
34-
ExpBin,
31+
ExpDec
3532
}
3633

3734
/// The number of digits used for emitting the fractional part of a number, if
3835
/// any.
3936
pub enum SignificantDigits {
40-
/// All calculable digits will be printed.
41-
///
42-
/// Note that bignums or fractions may cause a surprisingly large number
43-
/// of digits to be printed.
44-
DigAll,
45-
4637
/// At most the given number of digits will be printed, truncating any
4738
/// trailing zeroes.
4839
DigMax(uint),
@@ -53,17 +44,11 @@ pub enum SignificantDigits {
5344

5445
/// How to emit the sign of a number.
5546
pub enum SignFormat {
56-
/// No sign will be printed. The exponent sign will also be emitted.
57-
SignNone,
5847
/// `-` will be printed for negative values, but no sign will be emitted
5948
/// for positive numbers.
60-
SignNeg,
61-
/// `+` will be printed for positive values, and `-` will be printed for
62-
/// negative values.
63-
SignAll,
49+
SignNeg
6450
}
6551

66-
static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
6752
static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
6853

6954
/**
@@ -111,9 +96,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
11196
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
11297
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
11398
use of 'e' as decimal exponent", radix),
114-
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
115-
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
116-
use of 'p' as binary exponent", radix),
11799
_ => ()
118100
}
119101

@@ -123,16 +105,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
123105
match num.classify() {
124106
FPNaN => return f("NaN".as_bytes()),
125107
FPInfinite if num > _0 => {
126-
return match sign {
127-
SignAll => return f("+inf".as_bytes()),
128-
_ => return f("inf".as_bytes()),
129-
};
108+
return f("inf".as_bytes());
130109
}
131110
FPInfinite if num < _0 => {
132-
return match sign {
133-
SignNone => return f("inf".as_bytes()),
134-
_ => return f("-inf".as_bytes()),
135-
};
111+
return f("-inf".as_bytes());
136112
}
137113
_ => {}
138114
}
@@ -147,11 +123,10 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
147123

148124
let (num, exp) = match exp_format {
149125
ExpNone => (num, 0i32),
150-
ExpDec | ExpBin if num == _0 => (num, 0i32),
151-
ExpDec | ExpBin => {
126+
ExpDec if num == _0 => (num, 0i32),
127+
ExpDec => {
152128
let (exp, exp_base) = match exp_format {
153129
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),
154-
ExpBin => (num.abs().log2().floor(), cast::<f64, T>(2.0f64).unwrap()),
155130
ExpNone => fail!("unreachable"),
156131
};
157132

@@ -185,21 +160,16 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
185160

186161
// If limited digits, calculate one digit more for rounding.
187162
let (limit_digits, digit_count, exact) = match digits {
188-
DigAll => (false, 0u, false),
189-
DigMax(count) => (true, count+1, false),
190-
DigExact(count) => (true, count+1, true)
163+
DigMax(count) => (true, count + 1, false),
164+
DigExact(count) => (true, count + 1, true)
191165
};
192166

193167
// Decide what sign to put in front
194168
match sign {
195-
SignNeg | SignAll if neg => {
169+
SignNeg if neg => {
196170
buf[end] = b'-';
197171
end += 1;
198172
}
199-
SignAll => {
200-
buf[end] = b'+';
201-
end += 1;
202-
}
203173
_ => ()
204174
}
205175

@@ -329,8 +299,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
329299
buf[end] = match exp_format {
330300
ExpDec if exp_upper => 'E',
331301
ExpDec if !exp_upper => 'e',
332-
ExpBin if exp_upper => 'P',
333-
ExpBin if !exp_upper => 'p',
334302
_ => fail!("unreachable"),
335303
} as u8;
336304
end += 1;
@@ -356,11 +324,6 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
356324
fmt::write(&mut filler, args)
357325
}, "{:-}", exp);
358326
}
359-
SignNone | SignAll => {
360-
let _ = format_args!(|args| {
361-
fmt::write(&mut filler, args)
362-
}, "{}", exp);
363-
}
364327
}
365328
}
366329
}

branches/try2/src/librustc/back/link.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,6 @@ pub fn get_cc_prog(sess: &Session) -> String {
397397
}.to_string()
398398
}
399399

400-
pub fn get_ar_prog(sess: &Session) -> String {
401-
match sess.opts.cg.ar {
402-
Some(ref ar) => (*ar).clone(),
403-
None => "ar".to_string()
404-
}
405-
}
406-
407400
pub fn remove(sess: &Session, path: &Path) {
408401
match fs::unlink(path) {
409402
Ok(..) => {}

branches/try2/src/librustc/diagnostics.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ register_diagnostics!(
114114
E0102,
115115
E0103,
116116
E0104,
117-
E0105,
118117
E0106,
119118
E0107,
120119
E0108,
@@ -152,7 +151,6 @@ register_diagnostics!(
152151
E0144,
153152
E0145,
154153
E0146,
155-
E0147,
156154
E0148,
157155
E0151,
158156
E0152,

branches/try2/src/librustc/driver/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use syntax::parse;
3131
use syntax::parse::token::InternedString;
3232

3333
use std::collections::HashMap;
34+
use std::collections::hashmap::{Occupied, Vacant};
3435
use getopts::{optopt, optmulti, optflag, optflagopt};
3536
use getopts;
3637
use std::cell::{RefCell};
@@ -804,8 +805,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
804805
Some(s) => s,
805806
None => early_error("--extern value must be of the format `foo=bar`"),
806807
};
807-
let locs = externs.find_or_insert(name.to_string(), Vec::new());
808-
locs.push(location.to_string());
808+
809+
match externs.entry(name.to_string()) {
810+
Vacant(entry) => { entry.set(vec![location.to_string()]); },
811+
Occupied(mut entry) => { entry.get_mut().push(location.to_string()); },
812+
}
809813
}
810814

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

branches/try2/src/librustc/lint/builtin.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use lint::{Context, LintPass, LintArray};
3636

3737
use std::cmp;
3838
use std::collections::HashMap;
39+
use std::collections::hashmap::{Occupied, Vacant};
3940
use std::slice;
4041
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4142
use syntax::abi;
@@ -1203,15 +1204,18 @@ impl UnusedMut {
12031204
fn check_unused_mut_pat(&self, cx: &Context, pats: &[P<ast::Pat>]) {
12041205
// collect all mutable pattern and group their NodeIDs by their Identifier to
12051206
// avoid false warnings in match arms with multiple patterns
1207+
12061208
let mut mutables = HashMap::new();
12071209
for p in pats.iter() {
12081210
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
12091211
let ident = path1.node;
12101212
match mode {
12111213
ast::BindByValue(ast::MutMutable) => {
12121214
if !token::get_ident(ident).get().starts_with("_") {
1213-
mutables.insert_or_update_with(ident.name.uint(),
1214-
vec!(id), |_, old| { old.push(id); });
1215+
match mutables.entry(ident.name.uint()) {
1216+
Vacant(entry) => { entry.set(vec![id]); },
1217+
Occupied(mut entry) => { entry.get_mut().push(id); },
1218+
}
12151219
}
12161220
}
12171221
_ => {
@@ -1269,11 +1273,6 @@ impl LintPass for UnusedMut {
12691273
}
12701274
}
12711275

1272-
enum Allocation {
1273-
VectorAllocation,
1274-
BoxAllocation
1275-
}
1276-
12771276
declare_lint!(UNNECESSARY_ALLOCATION, Warn,
12781277
"detects unnecessary allocations that can be eliminated")
12791278

@@ -1285,30 +1284,21 @@ impl LintPass for UnnecessaryAllocation {
12851284
}
12861285

12871286
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1288-
// Warn if boxing expressions are immediately borrowed.
1289-
let allocation = match e.node {
1290-
ast::ExprUnary(ast::UnUniq, _) |
1291-
ast::ExprUnary(ast::UnBox, _) => BoxAllocation,
1292-
1287+
match e.node {
1288+
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (),
12931289
_ => return
1294-
};
1290+
}
12951291

12961292
match cx.tcx.adjustments.borrow().find(&e.id) {
12971293
Some(adjustment) => {
12981294
match *adjustment {
12991295
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
1300-
match (allocation, autoref) {
1301-
(VectorAllocation, &Some(ty::AutoPtr(_, _, None))) => {
1302-
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
1303-
"unnecessary allocation, the sigil can be removed");
1304-
}
1305-
(BoxAllocation,
1306-
&Some(ty::AutoPtr(_, ast::MutImmutable, None))) => {
1296+
match autoref {
1297+
&Some(ty::AutoPtr(_, ast::MutImmutable, None)) => {
13071298
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
13081299
"unnecessary allocation, use & instead");
13091300
}
1310-
(BoxAllocation,
1311-
&Some(ty::AutoPtr(_, ast::MutMutable, None))) => {
1301+
&Some(ty::AutoPtr(_, ast::MutMutable, None)) => {
13121302
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
13131303
"unnecessary allocation, use &mut instead");
13141304
}

branches/try2/src/librustc/metadata/creader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use plugin::load::PluginMetadata;
2424

2525
use std::rc::Rc;
2626
use std::collections::HashMap;
27+
use std::collections::hashmap::{Occupied, Vacant};
2728
use syntax::ast;
2829
use syntax::abi;
2930
use syntax::attr;
@@ -82,7 +83,10 @@ fn dump_crates(cstore: &CStore) {
8283
fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
8384
let mut map = HashMap::new();
8485
cstore.iter_crate_data(|cnum, data| {
85-
map.find_or_insert_with(data.name(), |_| Vec::new()).push(cnum);
86+
match map.entry(data.name()) {
87+
Vacant(entry) => { entry.set(vec![cnum]); },
88+
Occupied(mut entry) => { entry.get_mut().push(cnum); },
89+
}
8690
});
8791

8892
for (name, dupes) in map.into_iter() {

branches/try2/src/librustc/metadata/loader.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ use std::slice;
237237
use std::string;
238238

239239
use std::collections::{HashMap, HashSet};
240+
use std::collections::hashmap::{Occupied, Vacant};
240241
use flate;
241242
use time;
242243

@@ -428,15 +429,18 @@ impl<'a> Context<'a> {
428429
return FileDoesntMatch
429430
};
430431
info!("lib candidate: {}", path.display());
431-
let slot = candidates.find_or_insert_with(hash.to_string(), |_| {
432-
(HashSet::new(), HashSet::new())
433-
});
432+
433+
let slot = match candidates.entry(hash.to_string()) {
434+
Occupied(entry) => entry.into_mut(),
435+
Vacant(entry) => entry.set((HashSet::new(), HashSet::new())),
436+
};
434437
let (ref mut rlibs, ref mut dylibs) = *slot;
435438
if rlib {
436439
rlibs.insert(fs::realpath(path).unwrap());
437440
} else {
438441
dylibs.insert(fs::realpath(path).unwrap());
439442
}
443+
440444
FileMatches
441445
});
442446

0 commit comments

Comments
 (0)