Skip to content

Commit 64760cc

Browse files
committed
---
yaml --- r: 149383 b: refs/heads/try2 c: 33923f4 h: refs/heads/master i: 149381: 5bd7cff 149379: ba304d3 149375: 2679e90 v: v3
1 parent ae43476 commit 64760cc

31 files changed

+249
-233
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: 801f8f67f81c06891964dec0d0930029fb203b89
8+
refs/heads/try2: 33923f47e3f90442ae3c604d8ea80992b71611f7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/test.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,15 @@ pub fn opt_shard(maybestr: Option<~str>) -> Option<(uint,uint)> {
315315
match maybestr {
316316
None => None,
317317
Some(s) => {
318-
match s.split('.').to_owned_vec() {
319-
[a, b] => match (from_str::<uint>(a), from_str::<uint>(b)) {
320-
(Some(a), Some(b)) => Some((a,b)),
318+
let vector = s.split('.').to_owned_vec();
319+
if vector.len() == 2 {
320+
match (from_str::<uint>(vector[0]),
321+
from_str::<uint>(vector[1])) {
322+
(Some(a), Some(b)) => Some((a, b)),
321323
_ => None
322-
},
323-
_ => None
324+
}
325+
} else {
326+
None
324327
}
325328
}
326329
}

branches/try2/src/libnative/io/timer_other.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,25 @@ fn helper(input: libc::c_int, messages: Port<Req>) {
130130
}
131131

132132
'outer: loop {
133-
let timeout = match active {
133+
let timeout = if active.len() == 0 {
134134
// Empty array? no timeout (wait forever for the next request)
135-
[] => ptr::null(),
136-
137-
[~Inner { target, .. }, ..] => {
138-
let now = now();
139-
// If this request has already expired, then signal it and go
140-
// through another iteration
141-
if target <= now {
142-
signal(&mut active, &mut dead);
143-
continue;
144-
}
145-
146-
// The actual timeout listed in the requests array is an
147-
// absolute date, so here we translate the absolute time to a
148-
// relative time.
149-
let tm = target - now;
150-
timeout.tv_sec = (tm / 1000) as libc::time_t;
151-
timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t;
152-
&timeout as *libc::timeval
135+
ptr::null()
136+
} else {
137+
let now = now();
138+
// If this request has already expired, then signal it and go
139+
// through another iteration
140+
if active[0].target <= now {
141+
signal(&mut active, &mut dead);
142+
continue;
153143
}
144+
145+
// The actual timeout listed in the requests array is an
146+
// absolute date, so here we translate the absolute time to a
147+
// relative time.
148+
let tm = active[0].target - now;
149+
timeout.tv_sec = (tm / 1000) as libc::time_t;
150+
timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t;
151+
&timeout as *libc::timeval
154152
};
155153

156154
imp::fd_set(&mut set, input);

branches/try2/src/libnum/bigint.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -495,24 +495,23 @@ impl ToPrimitive for BigUint {
495495
#[cfg(target_word_size = "32")]
496496
#[inline]
497497
fn to_u64(&self) -> Option<u64> {
498-
match self.data {
499-
[] => {
500-
Some(0)
498+
match self.data.len() {
499+
0 => Some(0),
500+
1 => Some(self.data[0] as u64),
501+
2 => {
502+
Some(BigDigit::to_uint(self.data[1], self.data[0]) as u64)
501503
}
502-
[n0] => {
503-
Some(n0 as u64)
504-
}
505-
[n0, n1] => {
506-
Some(BigDigit::to_uint(n1, n0) as u64)
507-
}
508-
[n0, n1, n2] => {
509-
let n_lo = BigDigit::to_uint(n1, n0) as u64;
510-
let n_hi = n2 as u64;
504+
3 => {
505+
let n_lo = BigDigit::to_uint(self.data[1], self.data[0]) as
506+
u64;
507+
let n_hi = self.data[2] as u64;
511508
Some((n_hi << 32) + n_lo)
512509
}
513-
[n0, n1, n2, n3] => {
514-
let n_lo = BigDigit::to_uint(n1, n0) as u64;
515-
let n_hi = BigDigit::to_uint(n3, n2) as u64;
510+
4 => {
511+
let n_lo = BigDigit::to_uint(self.data[1], self.data[0])
512+
as u64;
513+
let n_hi = BigDigit::to_uint(self.data[3], self.data[2])
514+
as u64;
516515
Some((n_hi << 32) + n_lo)
517516
}
518517
_ => None
@@ -522,16 +521,10 @@ impl ToPrimitive for BigUint {
522521
#[cfg(target_word_size = "64")]
523522
#[inline]
524523
fn to_u64(&self) -> Option<u64> {
525-
match self.data {
526-
[] => {
527-
Some(0)
528-
}
529-
[n0] => {
530-
Some(n0 as u64)
531-
}
532-
[n0, n1] => {
533-
Some(BigDigit::to_uint(n1, n0) as u64)
534-
}
524+
match self.data.len() {
525+
0 => Some(0),
526+
1 => Some(self.data[0] as u64),
527+
2 => Some(BigDigit::to_uint(self.data[1], self.data[0]) as u64),
535528
_ => None
536529
}
537530
}

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

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ use middle;
2727
use util::common::time;
2828
use util::ppaux;
2929

30-
use extra::json;
31-
use serialize::Encodable;
32-
3330
use std::cell::{Cell, RefCell};
3431
use std::hashmap::{HashMap,HashSet};
3532
use std::io;
@@ -157,7 +154,7 @@ pub enum Input {
157154

158155
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
159156
-> ast::Crate {
160-
let krate = time(sess.time_passes(), "parsing", (), |_| {
157+
time(sess.time_passes(), "parsing", (), |_| {
161158
match *input {
162159
FileInput(ref file) => {
163160
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
@@ -169,15 +166,7 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
169166
sess.parse_sess)
170167
}
171168
}
172-
});
173-
174-
if sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0 {
175-
let mut stdout = io::stdout();
176-
let mut json = json::PrettyEncoder::new(&mut stdout);
177-
krate.encode(&mut json);
178-
}
179-
180-
krate
169+
})
181170
}
182171

183172
// For continuing compilation after a parsed crate has been
@@ -231,16 +220,8 @@ pub fn phase_2_configure_and_expand(sess: Session,
231220
krate = time(time_passes, "prelude injection", krate, |krate|
232221
front::std_inject::maybe_inject_prelude(sess, krate));
233222

234-
let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
235-
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
236-
237-
if sess.opts.debugging_opts & session::AST_JSON != 0 {
238-
let mut stdout = io::stdout();
239-
let mut json = json::PrettyEncoder::new(&mut stdout);
240-
krate.encode(&mut json);
241-
}
242-
243-
(krate, map)
223+
time(time_passes, "assinging node ids and indexing ast", krate, |krate|
224+
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate))
244225
}
245226

246227
pub struct CrateAnalysis {
@@ -447,15 +428,15 @@ pub fn stop_after_phase_1(sess: Session) -> bool {
447428
debug!("invoked with --parse-only, returning early from compile_input");
448429
return true;
449430
}
450-
return sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0;
431+
return false;
451432
}
452433

453434
pub fn stop_after_phase_2(sess: Session) -> bool {
454435
if sess.opts.no_analysis {
455436
debug!("invoked with --no-analysis, returning early from compile_input");
456437
return true;
457438
}
458-
return sess.opts.debugging_opts & session::AST_JSON != 0;
439+
return false;
459440
}
460441

461442
pub fn stop_after_phase_5(sess: Session) -> bool {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ debugging_opts!(
6565
GC,
6666
PRINT_LINK_ARGS,
6767
PRINT_LLVM_PASSES,
68-
LTO,
69-
AST_JSON,
70-
AST_JSON_NOEXPAND
68+
LTO
7169
]
7270
0
7371
)
@@ -99,8 +97,6 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
9997
"Prints the llvm optimization passes being run",
10098
PRINT_LLVM_PASSES),
10199
("lto", "Perform LLVM link-time optimizations", LTO),
102-
("ast-json", "Print the AST as JSON and halt", AST_JSON),
103-
("ast-json-noexpand", "Print the pre-expansion AST as JSON and halt", AST_JSON_NOEXPAND),
104100
]
105101
}
106102

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,15 +1213,13 @@ fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
12131213
ast::PatIdent(ast::BindByValue(ast::MutMutable),
12141214
ref path, _) if pat_util::pat_is_binding(cx.tcx.def_map, p)=> {
12151215
// `let mut _a = 1;` doesn't need a warning.
1216-
let initial_underscore = match path.segments {
1217-
[ast::PathSegment { identifier: id, .. }] => {
1218-
token::get_ident(id).get().starts_with("_")
1219-
}
1220-
_ => {
1221-
cx.tcx.sess.span_bug(p.span,
1222-
"mutable binding that doesn't \
1223-
consist of exactly one segment");
1224-
}
1216+
let initial_underscore = if path.segments.len() == 1 {
1217+
token::get_ident(path.segments[0].identifier).get()
1218+
.starts_with("_")
1219+
} else {
1220+
cx.tcx.sess.span_bug(p.span,
1221+
"mutable binding that doesn't consist \
1222+
of exactly one segment")
12251223
};
12261224

12271225
let used_mut_nodes = cx.tcx.used_mut_nodes.borrow();

branches/try2/src/librustc/middle/trans/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use syntax::codemap::Span;
2020
use middle::trans::builder::Builder;
2121
use middle::trans::type_::Type;
2222

23+
use std::cast;
2324
use std::libc::{c_uint, c_ulonglong, c_char};
2425

2526
pub fn terminate(cx: &Block, _: &str) {
@@ -622,7 +623,9 @@ pub fn Phi(cx: &Block, Ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> Va
622623
pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
623624
unsafe {
624625
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
625-
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
626+
let valptr = cast::transmute(&val);
627+
let bbptr = cast::transmute(&bb);
628+
llvm::LLVMAddIncoming(phi, valptr, bbptr, 1 as c_uint);
626629
}
627630
}
628631

branches/try2/src/librustc/middle/trans/builder.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use middle::trans::base;
1717
use middle::trans::common::*;
1818
use middle::trans::machine::llalign_of_pref;
1919
use middle::trans::type_::Type;
20+
use std::cast;
2021
use std::hashmap::HashMap;
2122
use std::libc::{c_uint, c_ulonglong, c_char};
2223
use syntax::codemap::Span;
@@ -29,8 +30,10 @@ pub struct Builder<'a> {
2930
// This is a really awful way to get a zero-length c-string, but better (and a
3031
// lot more efficient) than doing str::as_c_str("", ...) every time.
3132
pub fn noname() -> *c_char {
32-
static cnull: c_char = 0;
33-
&cnull as *c_char
33+
unsafe {
34+
static cnull: uint = 0u;
35+
cast::transmute(&cnull)
36+
}
3437
}
3538

3639
impl<'a> Builder<'a> {

branches/try2/src/librustc/middle/trans/common.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use util::ppaux::Repr;
3030

3131
use arena::TypedArena;
3232
use std::c_str::ToCStr;
33+
use std::cast::transmute;
34+
use std::cast;
3335
use std::cell::{Cell, RefCell};
3436
use std::hashmap::HashMap;
3537
use std::libc::{c_uint, c_longlong, c_ulonglong, c_char};
@@ -666,7 +668,7 @@ pub fn C_array(ty: Type, elts: &[ValueRef]) -> ValueRef {
666668

667669
pub fn C_bytes(bytes: &[u8]) -> ValueRef {
668670
unsafe {
669-
let ptr = bytes.as_ptr() as *c_char;
671+
let ptr = cast::transmute(bytes.as_ptr());
670672
return llvm::LLVMConstStringInContext(base::task_llcx(), ptr, bytes.len() as c_uint, True);
671673
}
672674
}

branches/try2/src/librustc/middle/typeck/check/_match.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,17 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
603603
ty::ty_vec(mt, vstore) => {
604604
let region_var = match vstore {
605605
ty::vstore_slice(r) => r,
606-
ty::vstore_uniq | ty::vstore_fixed(_) => {
606+
ty::vstore_uniq => {
607+
fcx.type_error_message(pat.span,
608+
|_| {
609+
~"unique vector patterns are no \
610+
longer supported"
611+
},
612+
expected,
613+
None);
614+
default_region_var
615+
}
616+
ty::vstore_fixed(_) => {
607617
default_region_var
608618
}
609619
};

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,8 +3894,11 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
38943894
ast::ExprVstoreUniq => ty::vstore_uniq,
38953895
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
38963896
match e.node {
3897-
ast::ExprLit(..) |
3898-
ast::ExprVec([], _) => {
3897+
ast::ExprLit(..) => {
3898+
// string literals and *empty slices* live in static memory
3899+
ty::vstore_slice(ty::ReStatic)
3900+
}
3901+
ast::ExprVec(ref elements, _) if elements.len() == 0 => {
38993902
// string literals and *empty slices* live in static memory
39003903
ty::vstore_slice(ty::ReStatic)
39013904
}

branches/try2/src/librustdoc/passes.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,20 +311,19 @@ pub fn unindent(s: &str) -> ~str {
311311
}
312312
});
313313

314-
match lines {
315-
[head, .. tail] => {
316-
let mut unindented = ~[ head.trim() ];
317-
unindented.push_all(tail.map(|&line| {
318-
if line.is_whitespace() {
319-
line
320-
} else {
321-
assert!(line.len() >= min_indent);
322-
line.slice_from(min_indent)
323-
}
324-
}));
325-
unindented.connect("\n")
326-
}
327-
[] => s.to_owned()
314+
if lines.len() >= 1 {
315+
let mut unindented = ~[ lines[0].trim() ];
316+
unindented.push_all(lines.tail().map(|&line| {
317+
if line.is_whitespace() {
318+
line
319+
} else {
320+
assert!(line.len() >= min_indent);
321+
line.slice_from(min_indent)
322+
}
323+
}));
324+
unindented.connect("\n")
325+
} else {
326+
s.to_owned()
328327
}
329328
}
330329

0 commit comments

Comments
 (0)