Skip to content

Commit 6b5e262

Browse files
committed
---
yaml --- r: 136669 b: refs/heads/dist-snap c: 9a01da9 h: refs/heads/master i: 136667: c0ee820 v: v3
1 parent 8959352 commit 6b5e262

Some content is hidden

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

51 files changed

+787
-578
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 189b7332968972f34cdbbbd9b62d97ababf53059
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 5e13d3aa00e8cfdf1a64f58f6c649460400231c0
9+
refs/heads/dist-snap: 9a01da9460a9e7a8be88896e9da0306fd47823a1
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/doc/guide-unsafe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32,
573573
return ret;
574574
}
575575
576-
#[lang = "begin_unwind"]
577-
extern fn begin_unwind(args: &core::fmt::Arguments,
576+
#[lang = "fail_fmt"]
577+
extern fn fail_fmt(args: &core::fmt::Arguments,
578578
file: &str,
579579
line: uint) -> ! {
580580
loop {}
@@ -587,8 +587,8 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
587587
```
588588

589589
Note that there is one extra lang item here which differs from the examples
590-
above, `begin_unwind`. This must be defined by consumers of libcore because the
591-
core library declares failure, but it does not define it. The `begin_unwind`
590+
above, `fail_fmt`. This must be defined by consumers of libcore because the
591+
core library declares failure, but it does not define it. The `fail_fmt`
592592
lang item is this crate's definition of failure, and it must be guaranteed to
593593
never return.
594594

branches/dist-snap/src/libcore/failure.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ pub fn begin_unwind_string(msg: &str, file: &(&'static str, uint)) -> ! {
6464
pub fn begin_unwind(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
6565
#[allow(ctypes)]
6666
extern {
67+
68+
#[cfg(stage0)]
6769
#[lang = "begin_unwind"]
6870
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
6971
line: uint) -> !;
72+
73+
#[cfg(not(stage0))]
74+
#[lang = "fail_fmt"]
75+
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
76+
line: uint) -> !;
77+
7078
}
7179
let (file, line) = *file_line;
7280
unsafe { begin_unwind(fmt, file, line) }

branches/dist-snap/src/libcore/fmt/float.rs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ 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
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,
3235
}
3336

3437
/// The number of digits used for emitting the fractional part of a number, if
3538
/// any.
3639
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+
3746
/// At most the given number of digits will be printed, truncating any
3847
/// trailing zeroes.
3948
DigMax(uint),
@@ -44,11 +53,17 @@ pub enum SignificantDigits {
4453

4554
/// How to emit the sign of a number.
4655
pub enum SignFormat {
56+
/// No sign will be printed. The exponent sign will also be emitted.
57+
SignNone,
4758
/// `-` will be printed for negative values, but no sign will be emitted
4859
/// for positive numbers.
49-
SignNeg
60+
SignNeg,
61+
/// `+` will be printed for positive values, and `-` will be printed for
62+
/// negative values.
63+
SignAll,
5064
}
5165

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

5469
/**
@@ -96,6 +111,9 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
96111
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
97112
=> fail!("float_to_str_bytes_common: radix {} incompatible with \
98113
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),
99117
_ => ()
100118
}
101119

@@ -105,10 +123,16 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
105123
match num.classify() {
106124
FPNaN => return f("NaN".as_bytes()),
107125
FPInfinite if num > _0 => {
108-
return f("inf".as_bytes());
126+
return match sign {
127+
SignAll => return f("+inf".as_bytes()),
128+
_ => return f("inf".as_bytes()),
129+
};
109130
}
110131
FPInfinite if num < _0 => {
111-
return f("-inf".as_bytes());
132+
return match sign {
133+
SignNone => return f("inf".as_bytes()),
134+
_ => return f("-inf".as_bytes()),
135+
};
112136
}
113137
_ => {}
114138
}
@@ -123,10 +147,11 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
123147

124148
let (num, exp) = match exp_format {
125149
ExpNone => (num, 0i32),
126-
ExpDec if num == _0 => (num, 0i32),
127-
ExpDec => {
150+
ExpDec | ExpBin if num == _0 => (num, 0i32),
151+
ExpDec | ExpBin => {
128152
let (exp, exp_base) = match exp_format {
129153
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),
154+
ExpBin => (num.abs().log2().floor(), cast::<f64, T>(2.0f64).unwrap()),
130155
ExpNone => fail!("unreachable"),
131156
};
132157

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

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

167193
// Decide what sign to put in front
168194
match sign {
169-
SignNeg if neg => {
195+
SignNeg | SignAll if neg => {
170196
buf[end] = b'-';
171197
end += 1;
172198
}
199+
SignAll => {
200+
buf[end] = b'+';
201+
end += 1;
202+
}
173203
_ => ()
174204
}
175205

@@ -299,6 +329,8 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
299329
buf[end] = match exp_format {
300330
ExpDec if exp_upper => 'E',
301331
ExpDec if !exp_upper => 'e',
332+
ExpBin if exp_upper => 'P',
333+
ExpBin if !exp_upper => 'p',
302334
_ => fail!("unreachable"),
303335
} as u8;
304336
end += 1;
@@ -324,6 +356,11 @@ pub fn float_to_str_bytes_common<T: Primitive + Float, U>(
324356
fmt::write(&mut filler, args)
325357
}, "{:-}", exp);
326358
}
359+
SignNone | SignAll => {
360+
let _ = format_args!(|args| {
361+
fmt::write(&mut filler, args)
362+
}, "{}", exp);
363+
}
327364
}
328365
}
329366
}

branches/dist-snap/src/librustc/back/link.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,13 @@ 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+
400407
pub fn remove(sess: &Session, path: &Path) {
401408
match fs::unlink(path) {
402409
Ok(..) => {}

branches/dist-snap/src/librustc/diagnostics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ register_diagnostics!(
114114
E0102,
115115
E0103,
116116
E0104,
117+
E0105,
117118
E0106,
118119
E0107,
119120
E0108,
@@ -151,6 +152,7 @@ register_diagnostics!(
151152
E0144,
152153
E0145,
153154
E0146,
155+
E0147,
154156
E0148,
155157
E0151,
156158
E0152,

branches/dist-snap/src/librustc/driver/config.rs

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

3333
use std::collections::HashMap;
34-
use std::collections::hashmap::{Occupied, Vacant};
3534
use getopts::{optopt, optmulti, optflag, optflagopt};
3635
use getopts;
3736
use std::cell::{RefCell};
@@ -805,11 +804,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
805804
Some(s) => s,
806805
None => early_error("--extern value must be of the format `foo=bar`"),
807806
};
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-
}
807+
let locs = externs.find_or_insert(name.to_string(), Vec::new());
808+
locs.push(location.to_string());
813809
}
814810

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

branches/dist-snap/src/librustc/lint/builtin.rs

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

3737
use std::cmp;
3838
use std::collections::HashMap;
39-
use std::collections::hashmap::{Occupied, Vacant};
4039
use std::slice;
4140
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4241
use syntax::abi;
@@ -1204,18 +1203,15 @@ impl UnusedMut {
12041203
fn check_unused_mut_pat(&self, cx: &Context, pats: &[P<ast::Pat>]) {
12051204
// collect all mutable pattern and group their NodeIDs by their Identifier to
12061205
// avoid false warnings in match arms with multiple patterns
1207-
12081206
let mut mutables = HashMap::new();
12091207
for p in pats.iter() {
12101208
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
12111209
let ident = path1.node;
12121210
match mode {
12131211
ast::BindByValue(ast::MutMutable) => {
12141212
if !token::get_ident(ident).get().starts_with("_") {
1215-
match mutables.entry(ident.name.uint()) {
1216-
Vacant(entry) => { entry.set(vec![id]); },
1217-
Occupied(mut entry) => { entry.get_mut().push(id); },
1218-
}
1213+
mutables.insert_or_update_with(ident.name.uint(),
1214+
vec!(id), |_, old| { old.push(id); });
12191215
}
12201216
}
12211217
_ => {
@@ -1273,6 +1269,11 @@ impl LintPass for UnusedMut {
12731269
}
12741270
}
12751271

1272+
enum Allocation {
1273+
VectorAllocation,
1274+
BoxAllocation
1275+
}
1276+
12761277
declare_lint!(UNNECESSARY_ALLOCATION, Warn,
12771278
"detects unnecessary allocations that can be eliminated")
12781279

@@ -1284,21 +1285,30 @@ impl LintPass for UnnecessaryAllocation {
12841285
}
12851286

12861287
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1287-
match e.node {
1288-
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (),
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+
12891293
_ => return
1290-
}
1294+
};
12911295

12921296
match cx.tcx.adjustments.borrow().find(&e.id) {
12931297
Some(adjustment) => {
12941298
match *adjustment {
12951299
ty::AdjustDerefRef(ty::AutoDerefRef { ref autoref, .. }) => {
1296-
match autoref {
1297-
&Some(ty::AutoPtr(_, ast::MutImmutable, None)) => {
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))) => {
12981307
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
12991308
"unnecessary allocation, use & instead");
13001309
}
1301-
&Some(ty::AutoPtr(_, ast::MutMutable, None)) => {
1310+
(BoxAllocation,
1311+
&Some(ty::AutoPtr(_, ast::MutMutable, None))) => {
13021312
cx.span_lint(UNNECESSARY_ALLOCATION, e.span,
13031313
"unnecessary allocation, use &mut instead");
13041314
}

branches/dist-snap/src/librustc/metadata/creader.rs

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

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

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

branches/dist-snap/src/librustc/metadata/loader.rs

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

239239
use std::collections::{HashMap, HashSet};
240-
use std::collections::hashmap::{Occupied, Vacant};
241240
use flate;
242241
use time;
243242

@@ -429,18 +428,15 @@ impl<'a> Context<'a> {
429428
return FileDoesntMatch
430429
};
431430
info!("lib candidate: {}", path.display());
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-
};
431+
let slot = candidates.find_or_insert_with(hash.to_string(), |_| {
432+
(HashSet::new(), HashSet::new())
433+
});
437434
let (ref mut rlibs, ref mut dylibs) = *slot;
438435
if rlib {
439436
rlibs.insert(fs::realpath(path).unwrap());
440437
} else {
441438
dylibs.insert(fs::realpath(path).unwrap());
442439
}
443-
444440
FileMatches
445441
});
446442

0 commit comments

Comments
 (0)