Move std::util::ignore to std::prelude::drop
It's a more fitting name for the most common use case of this function.
This commit is contained in:
parent
693ec73b9b
commit
a243360401
13 changed files with 19 additions and 29 deletions
|
@ -77,8 +77,8 @@ impl RtioTimer for TimerWatcher {
|
||||||
let _missile = match util::replace(&mut self.action, None) {
|
let _missile = match util::replace(&mut self.action, None) {
|
||||||
None => missile, // no need to do a homing dance
|
None => missile, // no need to do a homing dance
|
||||||
Some(action) => {
|
Some(action) => {
|
||||||
util::ignore(missile); // un-home ourself
|
drop(missile); // un-home ourself
|
||||||
util::ignore(action); // destroy the previous action
|
drop(action); // destroy the previous action
|
||||||
self.fire_homing_missile() // re-home ourself
|
self.fire_homing_missile() // re-home ourself
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,6 @@ use std::libc::{O_CREAT, O_APPEND, O_TRUNC, O_RDWR, O_RDONLY, O_WRONLY,
|
||||||
use std::io::{FileMode, FileAccess, Open, Append, Truncate, Read, Write,
|
use std::io::{FileMode, FileAccess, Open, Append, Truncate, Read, Write,
|
||||||
ReadWrite, FileStat};
|
ReadWrite, FileStat};
|
||||||
use std::io::signal::Signum;
|
use std::io::signal::Signum;
|
||||||
use std::util;
|
|
||||||
use ai = std::io::net::addrinfo;
|
use ai = std::io::net::addrinfo;
|
||||||
|
|
||||||
#[cfg(test)] use std::unstable::run_in_bare_thread;
|
#[cfg(test)] use std::unstable::run_in_bare_thread;
|
||||||
|
@ -104,7 +103,7 @@ impl HomingMissile {
|
||||||
|
|
||||||
impl Drop for HomingMissile {
|
impl Drop for HomingMissile {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let f = ForbidUnwind::new("leaving home");
|
let _f = ForbidUnwind::new("leaving home");
|
||||||
|
|
||||||
// It would truly be a sad day if we had moved off the home I/O
|
// It would truly be a sad day if we had moved off the home I/O
|
||||||
// scheduler while we were doing I/O.
|
// scheduler while we were doing I/O.
|
||||||
|
@ -120,8 +119,6 @@ impl Drop for HomingMissile {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
util::ignore(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1179,7 +1179,7 @@ mod test {
|
||||||
file.write(bytes!("foo"));
|
file.write(bytes!("foo"));
|
||||||
file.fsync();
|
file.fsync();
|
||||||
file.datasync();
|
file.datasync();
|
||||||
util::ignore(file);
|
drop(file);
|
||||||
})
|
})
|
||||||
|
|
||||||
test!(fn truncate_works() {
|
test!(fn truncate_works() {
|
||||||
|
@ -1210,7 +1210,7 @@ mod test {
|
||||||
assert_eq!(stat(&path).size, 9);
|
assert_eq!(stat(&path).size, 9);
|
||||||
assert_eq!(File::open(&path).read_to_end(),
|
assert_eq!(File::open(&path).read_to_end(),
|
||||||
(bytes!("fo", 0, 0, 0, 0, "wut")).to_owned());
|
(bytes!("fo", 0, 0, 0, 0, "wut")).to_owned());
|
||||||
util::ignore(file);
|
drop(file);
|
||||||
})
|
})
|
||||||
|
|
||||||
test!(fn open_flavors() {
|
test!(fn open_flavors() {
|
||||||
|
|
|
@ -86,3 +86,7 @@ pub use vec::{Vector, VectorVector, CopyableVector, ImmutableVector};
|
||||||
// Reexported runtime types
|
// Reexported runtime types
|
||||||
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};
|
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};
|
||||||
pub use task::spawn;
|
pub use task::spawn;
|
||||||
|
|
||||||
|
/// Disposes of a value.
|
||||||
|
#[inline]
|
||||||
|
pub fn drop<T>(_x: T) { }
|
||||||
|
|
|
@ -1173,7 +1173,6 @@ mod test {
|
||||||
use rt::sleeper_list::SleeperList;
|
use rt::sleeper_list::SleeperList;
|
||||||
use rt::stack::StackPool;
|
use rt::stack::StackPool;
|
||||||
use rt::sched::{Shutdown, TaskFromFriend};
|
use rt::sched::{Shutdown, TaskFromFriend};
|
||||||
use util;
|
|
||||||
|
|
||||||
do run_in_bare_thread {
|
do run_in_bare_thread {
|
||||||
stress_factor().times(|| {
|
stress_factor().times(|| {
|
||||||
|
@ -1205,7 +1204,7 @@ mod test {
|
||||||
handle.send(TaskFromFriend(task));
|
handle.send(TaskFromFriend(task));
|
||||||
|
|
||||||
handle.send(Shutdown);
|
handle.send(Shutdown);
|
||||||
util::ignore(handle);
|
drop(handle);
|
||||||
|
|
||||||
thread.join();
|
thread.join();
|
||||||
})
|
})
|
||||||
|
|
|
@ -467,7 +467,6 @@ mod tests {
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use super::{Exclusive, UnsafeArc, atomically};
|
use super::{Exclusive, UnsafeArc, atomically};
|
||||||
use task;
|
use task;
|
||||||
use util;
|
|
||||||
use mem::size_of;
|
use mem::size_of;
|
||||||
|
|
||||||
//#[unsafe_no_drop_flag] FIXME: #9758
|
//#[unsafe_no_drop_flag] FIXME: #9758
|
||||||
|
@ -571,7 +570,7 @@ mod tests {
|
||||||
let x2 = x.clone();
|
let x2 = x.clone();
|
||||||
let left_x = x.try_unwrap();
|
let left_x = x.try_unwrap();
|
||||||
assert!(left_x.is_self());
|
assert!(left_x.is_self());
|
||||||
util::ignore(left_x);
|
drop(left_x);
|
||||||
assert!(x2.try_unwrap().expect_t("try_unwrap none") == ~~"hello");
|
assert!(x2.try_unwrap().expect_t("try_unwrap none") == ~~"hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +589,7 @@ mod tests {
|
||||||
task::deschedule(); // Try to make the unwrapper get blocked first.
|
task::deschedule(); // Try to make the unwrapper get blocked first.
|
||||||
let left_x = x.try_unwrap();
|
let left_x = x.try_unwrap();
|
||||||
assert!(left_x.is_self());
|
assert!(left_x.is_self());
|
||||||
util::ignore(left_x);
|
drop(left_x);
|
||||||
p.recv();
|
p.recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +619,7 @@ mod tests {
|
||||||
assert!(x2.unwrap() == ~~"hello");
|
assert!(x2.unwrap() == ~~"hello");
|
||||||
}
|
}
|
||||||
// Have to get rid of our reference before blocking.
|
// Have to get rid of our reference before blocking.
|
||||||
util::ignore(x);
|
drop(x);
|
||||||
res.recv();
|
res.recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,6 @@ use unstable::intrinsics;
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id<T>(x: T) -> T { x }
|
pub fn id<T>(x: T) -> T { x }
|
||||||
|
|
||||||
/// Ignores a value.
|
|
||||||
#[inline]
|
|
||||||
pub fn ignore<T>(_x: T) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap the values at two mutable locations of the same type, without
|
* Swap the values at two mutable locations of the same type, without
|
||||||
* deinitialising or copying either one.
|
* deinitialising or copying either one.
|
||||||
|
|
|
@ -63,7 +63,7 @@ mod bar {
|
||||||
fn main() {
|
fn main() {
|
||||||
cal(foo::Point{x:3, y:9});
|
cal(foo::Point{x:3, y:9});
|
||||||
let a = 3;
|
let a = 3;
|
||||||
ignore(a);
|
id(a);
|
||||||
test::C.b();
|
test::C.b();
|
||||||
let _a = from_elem(0, 0);
|
let _a = from_elem(0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#[feature(once_fns)];
|
#[feature(once_fns)];
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
use extra::arc;
|
use extra::arc;
|
||||||
use std::util;
|
|
||||||
|
|
||||||
fn foo(blk: proc()) {
|
fn foo(blk: proc()) {
|
||||||
blk();
|
blk();
|
||||||
|
@ -25,6 +24,6 @@ fn main() {
|
||||||
let x = arc::Arc::new(true);
|
let x = arc::Arc::new(true);
|
||||||
do foo {
|
do foo {
|
||||||
assert!(*x.get());
|
assert!(*x.get());
|
||||||
util::ignore(x);
|
drop(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#[feature(once_fns)];
|
#[feature(once_fns)];
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
use extra::arc;
|
use extra::arc;
|
||||||
use std::util;
|
|
||||||
|
|
||||||
fn foo(blk: once ||) {
|
fn foo(blk: once ||) {
|
||||||
blk();
|
blk();
|
||||||
|
@ -25,6 +24,6 @@ fn main() {
|
||||||
let x = arc::Arc::new(true);
|
let x = arc::Arc::new(true);
|
||||||
foo(|| {
|
foo(|| {
|
||||||
assert!(*x.get());
|
assert!(*x.get());
|
||||||
util::ignore(x);
|
drop(x);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
use extra::arc;
|
use extra::arc;
|
||||||
use std::util;
|
|
||||||
|
|
||||||
fn foo(blk: ||) {
|
fn foo(blk: ||) {
|
||||||
blk();
|
blk();
|
||||||
|
@ -24,6 +23,6 @@ fn main() {
|
||||||
let x = arc::Arc::new(true);
|
let x = arc::Arc::new(true);
|
||||||
foo(|| {
|
foo(|| {
|
||||||
assert!(*x.get());
|
assert!(*x.get());
|
||||||
util::ignore(x); //~ ERROR cannot move out of captured outer variable
|
drop(x); //~ ERROR cannot move out of captured outer variable
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#[feature(once_fns)];
|
#[feature(once_fns)];
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
use extra::arc;
|
use extra::arc;
|
||||||
use std::util;
|
|
||||||
|
|
||||||
fn foo(blk: proc()) {
|
fn foo(blk: proc()) {
|
||||||
blk();
|
blk();
|
||||||
|
@ -25,6 +24,6 @@ fn main() {
|
||||||
let x = arc::Arc::new(true);
|
let x = arc::Arc::new(true);
|
||||||
do foo {
|
do foo {
|
||||||
assert!(*x.get());
|
assert!(*x.get());
|
||||||
util::ignore(x);
|
drop(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#[feature(once_fns)];
|
#[feature(once_fns)];
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
use extra::arc;
|
use extra::arc;
|
||||||
use std::util;
|
|
||||||
|
|
||||||
fn foo(blk: once ||) {
|
fn foo(blk: once ||) {
|
||||||
blk();
|
blk();
|
||||||
|
@ -25,6 +24,6 @@ fn main() {
|
||||||
let x = arc::Arc::new(true);
|
let x = arc::Arc::new(true);
|
||||||
foo(|| {
|
foo(|| {
|
||||||
assert!(*x.get());
|
assert!(*x.get());
|
||||||
util::ignore(x);
|
drop(x);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue