Skip to content

Commit be6260c

Browse files
committed
---
yaml --- r: 64597 b: refs/heads/snap-stage3 c: 9ed82fb h: refs/heads/master i: 64595: 1e6fe01 v: v3
1 parent 065ec48 commit be6260c

File tree

10 files changed

+58
-151
lines changed

10 files changed

+58
-151
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 73ab6c60f37263871a5e69f3eeaad72f0d804a02
4+
refs/heads/snap-stage3: 9ed82fbb43804ebc7e06daca5812079630ec8952
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
242242
let mut tests = ~[];
243243
let dirs = os::list_dir_path(&config.src_base);
244244
for dirs.iter().advance |file| {
245-
let file = (*file).clone();
245+
let file = file.clone();
246246
debug!("inspecting file %s", file.to_str());
247-
if is_test(config, file) {
248-
let t = do make_test(config, file) {
247+
if is_test(config, &file) {
248+
let t = do make_test(config, &file) {
249249
match config.mode {
250-
mode_codegen => make_metrics_test_closure(config, file),
251-
_ => make_test_closure(config, file)
250+
mode_codegen => make_metrics_test_closure(config, &file),
251+
_ => make_test_closure(config, &file)
252252
}
253253
};
254254
tests.push(t)

branches/snap-stage3/src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn search<T>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
9494
let r = os::list_dir_path(lib_search_path);
9595
for r.iter().advance |path| {
9696
debug!("testing %s", path.to_str());
97-
let maybe_picked = pick(*path);
97+
let maybe_picked = pick(path);
9898
if maybe_picked.is_some() {
9999
debug!("picked %s", path.to_str());
100100
rslt = maybe_picked;

branches/snap-stage3/src/librustpkg/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId) {
393393
}
394394
match maybe_p {
395395
Some(p) => {
396-
let w = io::file_writer(*p, &[io::Append]);
396+
let w = io::file_writer(p, &[io::Append]);
397397
match w {
398-
Err(s) => { let _ = cond.raise(((**p).clone(), fmt!("Bad path: %s", s))); }
398+
Err(s) => { let _ = cond.raise((p.clone(), fmt!("Bad path: %s", s))); }
399399
Ok(w) => w.write_line("")
400400
}
401401
}

branches/snap-stage3/src/libstd/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,8 @@ pub fn list_dir(p: &Path) -> ~[~str] {
788788
*
789789
* This version prepends each entry with the directory.
790790
*/
791-
pub fn list_dir_path(p: &Path) -> ~[~Path] {
792-
list_dir(p).map(|f| ~p.push(*f))
791+
pub fn list_dir_path(p: &Path) -> ~[Path] {
792+
list_dir(p).map(|f| p.push(*f))
793793
}
794794

795795
/// Removes a directory at the specified path, after removing

branches/snap-stage3/src/libstd/rt/io/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ pub use self::stdio::print;
252252
pub use self::stdio::println;
253253

254254
pub use self::file::FileStream;
255-
pub use self::timer::Timer;
256255
pub use self::net::ip::IpAddr;
257256
pub use self::net::tcp::TcpListener;
258257
pub use self::net::tcp::TcpStream;
@@ -297,9 +296,6 @@ mod extensions;
297296
/// Non-I/O things needed by the I/O module
298297
mod support;
299298

300-
/// Basic Timer
301-
pub mod timer;
302-
303299
/// Thread-blocking implementations
304300
pub mod native {
305301
/// Posix file I/O

branches/snap-stage3/src/libstd/rt/io/timer.rs

Lines changed: 0 additions & 64 deletions
This file was deleted.

branches/snap-stage3/src/libstd/rt/rtio.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub type IoFactoryObject = uvio::UvIoFactory;
2323
pub type RtioTcpStreamObject = uvio::UvTcpStream;
2424
pub type RtioTcpListenerObject = uvio::UvTcpListener;
2525
pub type RtioUdpSocketObject = uvio::UvUdpSocket;
26-
pub type RtioTimerObject = uvio::UvTimer;
2726

2827
pub trait EventLoop {
2928
fn run(&mut self);
@@ -47,7 +46,6 @@ pub trait IoFactory {
4746
fn tcp_connect(&mut self, addr: IpAddr) -> Result<~RtioTcpStreamObject, IoError>;
4847
fn tcp_bind(&mut self, addr: IpAddr) -> Result<~RtioTcpListenerObject, IoError>;
4948
fn udp_bind(&mut self, addr: IpAddr) -> Result<~RtioUdpSocketObject, IoError>;
50-
fn timer_init(&mut self) -> Result<~RtioTimerObject, IoError>;
5149
}
5250

5351
pub trait RtioTcpListener : RtioSocket {
@@ -86,7 +84,3 @@ pub trait RtioUdpSocket : RtioSocket {
8684
fn hear_broadcasts(&mut self);
8785
fn ignore_broadcasts(&mut self);
8886
}
89-
90-
pub trait RtioTimer {
91-
fn sleep(&self, msecs: u64);
92-
}

branches/snap-stage3/src/libstd/rt/uv/uvio.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ impl IoFactory for UvIoFactory {
280280
}
281281
}
282282
}
283-
284-
fn timer_init(&mut self) -> Result<~RtioTimerObject, IoError> {
285-
Ok(~UvTimer(TimerWatcher::new(self.uv_loop())))
286-
}
287283
}
288284

289285
// FIXME #6090: Prefer newtype structs but Drop doesn't work
@@ -566,48 +562,6 @@ impl RtioUdpSocket for UvUdpSocket {
566562
fn ignore_broadcasts(&mut self) { fail!(); }
567563
}
568564

569-
pub struct UvTimer(timer::TimerWatcher);
570-
571-
impl UvTimer {
572-
fn new(w: timer::TimerWatcher) -> UvTimer {
573-
UvTimer(w)
574-
}
575-
}
576-
577-
impl Drop for UvTimer {
578-
fn drop(&self) {
579-
rtdebug!("closing UvTimer");
580-
let scheduler = Local::take::<Scheduler>();
581-
do scheduler.deschedule_running_task_and_then |_, task| {
582-
let task_cell = Cell::new(task);
583-
do self.close {
584-
let scheduler = Local::take::<Scheduler>();
585-
scheduler.resume_task_immediately(task_cell.take());
586-
}
587-
}
588-
}
589-
}
590-
591-
impl RtioTimer for UvTimer {
592-
fn sleep(&self, msecs: u64) {
593-
let scheduler = Local::take::<Scheduler>();
594-
assert!(scheduler.in_task_context());
595-
do scheduler.deschedule_running_task_and_then |sched, task| {
596-
rtdebug!("sleep: entered scheduler context");
597-
assert!(!sched.in_task_context());
598-
let task_cell = Cell::new(task);
599-
let mut watcher = **self;
600-
do watcher.start(msecs, 0) |_, status| {
601-
assert!(status.is_none());
602-
let scheduler = Local::take::<Scheduler>();
603-
scheduler.resume_task_immediately(task_cell.take());
604-
}
605-
}
606-
let mut w = **self;
607-
w.stop();
608-
}
609-
}
610-
611565
#[test]
612566
fn test_simple_io_no_connect() {
613567
do run_in_newsched_task {
@@ -878,20 +832,3 @@ fn test_udp_many_read() {
878832
}
879833
}
880834
}
881-
882-
fn test_timer_sleep_simple_impl() {
883-
unsafe {
884-
let io = Local::unsafe_borrow::<IoFactoryObject>();
885-
let timer = (*io).timer_init();
886-
match timer {
887-
Ok(t) => t.sleep(1),
888-
Err(_) => assert!(false)
889-
}
890-
}
891-
}
892-
#[test]
893-
fn test_timer_sleep_simple() {
894-
do run_in_newsched_task {
895-
test_timer_sleep_simple_impl();
896-
}
897-
}

branches/snap-stage3/src/libstd/vec.rs

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ impl<'self,T:Clone> CopyableVector<T> for &'self [T] {
689689
#[allow(missing_doc)]
690690
pub trait ImmutableVector<'self, T> {
691691
fn slice(&self, start: uint, end: uint) -> &'self [T];
692+
fn slice_from(&self, start: uint) -> &'self [T];
693+
fn slice_to(&self, end: uint) -> &'self [T];
692694
fn iter(self) -> VecIterator<'self, T>;
693695
fn rev_iter(self) -> VecRevIterator<'self, T>;
694696
fn split_iter(self, pred: &'self fn(&T) -> bool) -> VecSplitIterator<'self, T>;
@@ -720,11 +722,17 @@ pub trait ImmutableVector<'self, T> {
720722

721723
/// Extension methods for vectors
722724
impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
723-
/// Return a slice that points into another slice.
725+
726+
/**
727+
* Returns a slice of self between `start` and `end`.
728+
*
729+
* Fails when `start` or `end` point outside the bounds of self,
730+
* or when `start` > `end`.
731+
*/
724732
#[inline]
725733
fn slice(&self, start: uint, end: uint) -> &'self [T] {
726-
assert!(start <= end);
727-
assert!(end <= self.len());
734+
assert!(start <= end);
735+
assert!(end <= self.len());
728736
do self.as_imm_buf |p, _len| {
729737
unsafe {
730738
transmute((ptr::offset(p, start),
@@ -733,6 +741,26 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
733741
}
734742
}
735743

744+
/**
745+
* Returns a slice of self from `start` to the end of the vec.
746+
*
747+
* Fails when `start` points outside the bounds of self.
748+
*/
749+
#[inline]
750+
fn slice_from(&self, start: uint) -> &'self [T] {
751+
self.slice(start, self.len())
752+
}
753+
754+
/**
755+
* Returns a slice of self from the start of the vec to `end`.
756+
*
757+
* Fails when `end` points outside the bounds of self.
758+
*/
759+
#[inline]
760+
fn slice_to(&self, end: uint) -> &'self [T] {
761+
self.slice(0, end)
762+
}
763+
736764
#[inline]
737765
fn iter(self) -> VecIterator<'self, T> {
738766
unsafe {
@@ -2453,6 +2481,22 @@ mod tests {
24532481
assert_eq!(v_d[4], 6);
24542482
}
24552483

2484+
#[test]
2485+
fn test_slice_from() {
2486+
let vec = &[1, 2, 3, 4];
2487+
assert_eq!(vec.slice_from(0), vec);
2488+
assert_eq!(vec.slice_from(2), &[3, 4]);
2489+
assert_eq!(vec.slice_from(4), &[]);
2490+
}
2491+
2492+
#[test]
2493+
fn test_slice_to() {
2494+
let vec = &[1, 2, 3, 4];
2495+
assert_eq!(vec.slice_to(4), vec);
2496+
assert_eq!(vec.slice_to(2), &[1, 2]);
2497+
assert_eq!(vec.slice_to(0), &[]);
2498+
}
2499+
24562500
#[test]
24572501
fn test_pop() {
24582502
// Test on-heap pop.

0 commit comments

Comments
 (0)