Skip to content

Commit 43ddc88

Browse files
committed
---
yaml --- r: 151093 b: refs/heads/try2 c: a08198b h: refs/heads/master i: 151091: 14afb59 v: v3
1 parent abf9163 commit 43ddc88

File tree

92 files changed

+707
-824
lines changed

Some content is hidden

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

92 files changed

+707
-824
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: 70647ccc6de1c319de647a2b8d75b667e88fbfd0
8+
refs/heads/try2: a08198ba6f58e33cd8dda6fec74f3ca2d28bbaf9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libfourcc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
9191

9292
let s = match expr.node {
9393
// expression is a literal
94-
ast::ExprLit(ref lit) => match lit.node {
94+
ast::ExprLit(lit) => match lit.node {
9595
// string literal
9696
ast::LitStr(ref s, _) => {
9797
if s.get().char_len() != 4 {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ extern "system" {
5050
pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long,
5151
argp: *mut libc::c_ulong) -> libc::c_int;
5252
pub fn select(nfds: libc::c_int,
53-
readfds: *fd_set,
54-
writefds: *fd_set,
55-
exceptfds: *fd_set,
53+
readfds: *mut fd_set,
54+
writefds: *mut fd_set,
55+
exceptfds: *mut fd_set,
5656
timeout: *libc::timeval) -> libc::c_int;
5757
pub fn getsockopt(sockfd: libc::SOCKET,
5858
level: libc::c_int,

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

Lines changed: 27 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::cast;
1313
use std::io::net::ip;
1414
use std::io;
1515
use std::mem;
16-
use std::os;
1716
use std::ptr;
1817
use std::rt::rtio;
1918
use std::sync::arc::UnsafeArc;
@@ -145,21 +144,6 @@ fn last_error() -> io::IoError {
145144
super::last_error()
146145
}
147146

148-
fn ms_to_timeval(ms: u64) -> libc::timeval {
149-
libc::timeval {
150-
tv_sec: (ms / 1000) as libc::time_t,
151-
tv_usec: ((ms % 1000) * 1000) as libc::suseconds_t,
152-
}
153-
}
154-
155-
fn timeout(desc: &'static str) -> io::IoError {
156-
io::IoError {
157-
kind: io::TimedOut,
158-
desc: desc,
159-
detail: None,
160-
}
161-
}
162-
163147
#[cfg(windows)] unsafe fn close(sock: sock_t) { let _ = libc::closesocket(sock); }
164148
#[cfg(unix)] unsafe fn close(sock: sock_t) { let _ = libc::close(sock); }
165149

@@ -287,7 +271,8 @@ impl TcpStream {
287271
fn connect_timeout(fd: sock_t,
288272
addrp: *libc::sockaddr,
289273
len: libc::socklen_t,
290-
timeout_ms: u64) -> IoResult<()> {
274+
timeout: u64) -> IoResult<()> {
275+
use std::os;
291276
#[cfg(unix)] use INPROGRESS = libc::EINPROGRESS;
292277
#[cfg(windows)] use INPROGRESS = libc::WSAEINPROGRESS;
293278
#[cfg(unix)] use WOULDBLOCK = libc::EWOULDBLOCK;
@@ -304,8 +289,12 @@ impl TcpStream {
304289
os::errno() as int == WOULDBLOCK as int => {
305290
let mut set: c::fd_set = unsafe { mem::init() };
306291
c::fd_set(&mut set, fd);
307-
match await(fd, &mut set, timeout_ms) {
308-
0 => Err(timeout("connection timed out")),
292+
match await(fd, &mut set, timeout) {
293+
0 => Err(io::IoError {
294+
kind: io::TimedOut,
295+
desc: "connection timed out",
296+
detail: None,
297+
}),
309298
-1 => Err(last_error()),
310299
_ => {
311300
let err: libc::c_int = try!(
@@ -349,14 +338,22 @@ impl TcpStream {
349338
// Recalculate the timeout each iteration (it is generally
350339
// undefined what the value of the 'tv' is after select
351340
// returns EINTR).
352-
let tv = ms_to_timeval(timeout - (::io::timer::now() - start));
353-
c::select(fd + 1, ptr::null(), &*set, ptr::null(), &tv)
341+
let timeout = timeout - (::io::timer::now() - start);
342+
let tv = libc::timeval {
343+
tv_sec: (timeout / 1000) as libc::time_t,
344+
tv_usec: ((timeout % 1000) * 1000) as libc::suseconds_t,
345+
};
346+
c::select(fd + 1, ptr::null(), set as *mut _ as *_,
347+
ptr::null(), &tv)
354348
})
355349
}
356350
#[cfg(windows)]
357351
fn await(_fd: sock_t, set: &mut c::fd_set, timeout: u64) -> libc::c_int {
358-
let tv = ms_to_timeval(timeout);
359-
unsafe { c::select(1, ptr::null(), &*set, ptr::null(), &tv) }
352+
let tv = libc::timeval {
353+
tv_sec: (timeout / 1000) as libc::time_t,
354+
tv_usec: ((timeout % 1000) * 1000) as libc::suseconds_t,
355+
};
356+
unsafe { c::select(1, ptr::mut_null(), set, ptr::mut_null(), &tv) }
360357
}
361358
}
362359

@@ -470,7 +467,7 @@ impl Drop for Inner {
470467
////////////////////////////////////////////////////////////////////////////////
471468

472469
pub struct TcpListener {
473-
inner: Inner,
470+
inner: UnsafeArc<Inner>,
474471
}
475472

476473
impl TcpListener {
@@ -480,7 +477,7 @@ impl TcpListener {
480477
let (addr, len) = addr_to_sockaddr(addr);
481478
let addrp = &addr as *libc::sockaddr_storage;
482479
let inner = Inner { fd: fd };
483-
let ret = TcpListener { inner: inner };
480+
let ret = TcpListener { inner: UnsafeArc::new(inner) };
484481
// On platforms with Berkeley-derived sockets, this allows
485482
// to quickly rebind a socket, without needing to wait for
486483
// the OS to clean up the previous one.
@@ -501,12 +498,15 @@ impl TcpListener {
501498
}
502499
}
503500

504-
pub fn fd(&self) -> sock_t { self.inner.fd }
501+
pub fn fd(&self) -> sock_t {
502+
// This is just a read-only arc so the unsafety is fine
503+
unsafe { (*self.inner.get()).fd }
504+
}
505505

506506
pub fn native_listen(self, backlog: int) -> IoResult<TcpAcceptor> {
507507
match unsafe { libc::listen(self.fd(), backlog as libc::c_int) } {
508508
-1 => Err(last_error()),
509-
_ => Ok(TcpAcceptor { listener: self, deadline: 0 })
509+
_ => Ok(TcpAcceptor { listener: self })
510510
}
511511
}
512512
}
@@ -525,16 +525,12 @@ impl rtio::RtioSocket for TcpListener {
525525

526526
pub struct TcpAcceptor {
527527
listener: TcpListener,
528-
deadline: u64,
529528
}
530529

531530
impl TcpAcceptor {
532531
pub fn fd(&self) -> sock_t { self.listener.fd() }
533532

534533
pub fn native_accept(&mut self) -> IoResult<TcpStream> {
535-
if self.deadline != 0 {
536-
try!(self.accept_deadline());
537-
}
538534
unsafe {
539535
let mut storage: libc::sockaddr_storage = mem::init();
540536
let storagep = &mut storage as *mut libc::sockaddr_storage;
@@ -550,25 +546,6 @@ impl TcpAcceptor {
550546
}
551547
}
552548
}
553-
554-
fn accept_deadline(&mut self) -> IoResult<()> {
555-
let mut set: c::fd_set = unsafe { mem::init() };
556-
c::fd_set(&mut set, self.fd());
557-
558-
match retry(|| {
559-
// If we're past the deadline, then pass a 0 timeout to select() so
560-
// we can poll the status of the socket.
561-
let now = ::io::timer::now();
562-
let ms = if self.deadline > now {0} else {self.deadline - now};
563-
let tv = ms_to_timeval(ms);
564-
let n = if cfg!(windows) {1} else {self.fd() as libc::c_int + 1};
565-
unsafe { c::select(n, &set, ptr::null(), ptr::null(), &tv) }
566-
}) {
567-
-1 => Err(last_error()),
568-
0 => Err(timeout("accept timed out")),
569-
_ => return Ok(()),
570-
}
571-
}
572549
}
573550

574551
impl rtio::RtioSocket for TcpAcceptor {
@@ -584,12 +561,6 @@ impl rtio::RtioTcpAcceptor for TcpAcceptor {
584561

585562
fn accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) }
586563
fn dont_accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) }
587-
fn set_timeout(&mut self, timeout: Option<u64>) {
588-
self.deadline = match timeout {
589-
None => 0,
590-
Some(t) => ::io::timer::now() + t,
591-
};
592-
}
593564
}
594565

595566
////////////////////////////////////////////////////////////////////////////////

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,6 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
8989
}
9090
}
9191

92-
// returns the current time (in milliseconds)
93-
pub fn now() -> u64 {
94-
let mut ticks_per_s = 0;
95-
assert_eq!(unsafe { libc::QueryPerformanceFrequency(&mut ticks_per_s) }, 1);
96-
let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s};
97-
let mut ticks = 0;
98-
assert_eq!(unsafe { libc::QueryPerformanceCounter(&mut ticks) }, 1);
99-
100-
return (ticks as u64 * 1000) / (ticks_per_s as u64);
101-
}
102-
10392
impl Timer {
10493
pub fn new() -> IoResult<Timer> {
10594
timer_helper::boot(helper);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn llvm_err(sess: &Session, msg: ~str) -> ! {
6060
if cstr == ptr::null() {
6161
sess.fatal(msg);
6262
} else {
63-
let err = CString::new(cstr, true);
63+
let err = CString::new(cstr, false);
6464
let err = str::from_utf8_lossy(err.as_bytes());
6565
sess.fatal(msg + ": " + err.as_slice());
6666
}
@@ -516,10 +516,7 @@ pub mod write {
516516

517517
pub fn find_crate_id(attrs: &[ast::Attribute], out_filestem: &str) -> CrateId {
518518
match attr::find_crateid(attrs) {
519-
None => from_str(out_filestem).unwrap_or_else(|| {
520-
let mut s = out_filestem.chars().filter(|c| c.is_XID_continue());
521-
from_str(s.collect::<~str>()).or(from_str("rust-out")).unwrap()
522-
}),
519+
None => from_str(out_filestem).unwrap(),
523520
Some(s) => s,
524521
}
525522
}

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ pub fn phase_3_run_analysis_passes(sess: Session,
346346
time(time_passes, "effect checking", (), |_|
347347
middle::effect::check_crate(&ty_cx, krate));
348348

349-
let middle::moves::MoveMaps {moves_map, capture_map} =
349+
let middle::moves::MoveMaps {moves_map, moved_variables_set,
350+
capture_map} =
350351
time(time_passes, "compute moves", (), |_|
351352
middle::moves::compute_moves(&ty_cx, krate));
352353

@@ -356,11 +357,14 @@ pub fn phase_3_run_analysis_passes(sess: Session,
356357
time(time_passes, "liveness checking", (), |_|
357358
middle::liveness::check_crate(&ty_cx, &capture_map, krate));
358359

359-
time(time_passes, "borrow checking", (), |_|
360-
middle::borrowck::check_crate(&ty_cx, &moves_map,
361-
&capture_map, krate));
360+
let root_map =
361+
time(time_passes, "borrow checking", (), |_|
362+
middle::borrowck::check_crate(&ty_cx, &moves_map,
363+
&moved_variables_set,
364+
&capture_map, krate));
362365

363366
drop(moves_map);
367+
drop(moved_variables_set);
364368

365369
time(time_passes, "kind checking", (), |_|
366370
kind::check_crate(&ty_cx, krate));
@@ -385,6 +389,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
385389
exported_items: exported_items,
386390
public_items: public_items,
387391
maps: astencode::Maps {
392+
root_map: root_map,
388393
capture_map: RefCell::new(capture_map)
389394
},
390395
reachable: reachable_map
@@ -488,7 +493,7 @@ pub fn stop_after_phase_5(sess: &Session) -> bool {
488493
fn write_out_deps(sess: &Session,
489494
input: &Input,
490495
outputs: &OutputFilenames,
491-
krate: &ast::Crate) {
496+
krate: &ast::Crate) -> io::IoResult<()> {
492497
let id = link::find_crate_id(krate.attrs.as_slice(), outputs.out_filestem);
493498

494499
let mut out_filenames = Vec::new();
@@ -517,34 +522,28 @@ fn write_out_deps(sess: &Session,
517522
StrInput(..) => {
518523
sess.warn("can not write --dep-info without a filename \
519524
when compiling stdin.");
520-
return
525+
return Ok(());
521526
},
522527
},
523-
_ => return,
528+
_ => return Ok(()),
524529
};
525530

526-
let result = (|| {
527-
// Build a list of files used to compile the output and
528-
// write Makefile-compatible dependency rules
529-
let files: Vec<~str> = sess.codemap().files.borrow()
530-
.iter().filter(|fmap| fmap.is_real_file())
531-
.map(|fmap| fmap.name.clone())
532-
.collect();
533-
let mut file = try!(io::File::create(&deps_filename));
534-
for path in out_filenames.iter() {
535-
try!(write!(&mut file as &mut Writer,
536-
"{}: {}\n\n", path.display(), files.connect(" ")));
537-
}
538-
Ok(())
539-
})();
540-
541-
match result {
542-
Ok(()) => {}
543-
Err(e) => {
544-
sess.fatal(format!("error writing dependencies to `{}`: {}",
545-
deps_filename.display(), e));
546-
}
531+
// Build a list of files used to compile the output and
532+
// write Makefile-compatible dependency rules
533+
let files: Vec<~str> = sess.codemap().files.borrow()
534+
.iter().filter_map(|fmap| {
535+
if fmap.is_real_file() {
536+
Some(fmap.name.clone())
537+
} else {
538+
None
539+
}
540+
}).collect();
541+
let mut file = try!(io::File::create(&deps_filename));
542+
for path in out_filenames.iter() {
543+
try!(write!(&mut file as &mut Writer,
544+
"{}: {}\n\n", path.display(), files.connect(" ")));
547545
}
546+
Ok(())
548547
}
549548

550549
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
@@ -568,7 +567,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
568567
krate, &id);
569568
(outputs, expanded_crate, ast_map)
570569
};
571-
write_out_deps(&sess, input, &outputs, &expanded_crate);
570+
write_out_deps(&sess, input, &outputs, &expanded_crate).unwrap();
572571

573572
if stop_after_phase_2(&sess) { return; }
574573

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -36,9 +36,6 @@ impl<'a> fold::Folder for Context<'a> {
3636
fn fold_item_underscore(&mut self, item: &ast::Item_) -> ast::Item_ {
3737
fold_item_underscore(self, item)
3838
}
39-
fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr {
40-
fold_expr(self, expr)
41-
}
4239
}
4340

4441
pub fn strip_items(krate: ast::Crate,
@@ -192,24 +189,6 @@ fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
192189
})
193190
}
194191

195-
fn fold_expr(cx: &mut Context, expr: @ast::Expr) -> @ast::Expr {
196-
let expr = match expr.node {
197-
ast::ExprMatch(ref m, ref arms) => {
198-
let arms = arms.iter()
199-
.filter(|a| (cx.in_cfg)(a.attrs.as_slice()))
200-
.map(|a| a.clone())
201-
.collect();
202-
@ast::Expr {
203-
id: expr.id,
204-
span: expr.span.clone(),
205-
node: ast::ExprMatch(m.clone(), arms),
206-
}
207-
}
208-
_ => expr.clone()
209-
};
210-
fold::noop_fold_expr(expr, cx)
211-
}
212-
213192
fn item_in_cfg(cx: &mut Context, item: &ast::Item) -> bool {
214193
return (cx.in_cfg)(item.attrs.as_slice());
215194
}

0 commit comments

Comments
 (0)