Skip to content

Rename std::util::ignore to std::util::drop #10783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustuv/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ impl RtioTimer for TimerWatcher {
let _missile = match util::replace(&mut self.action, None) {
None => missile, // no need to do a homing dance
Some(action) => {
util::ignore(missile); // un-home ourself
util::ignore(action); // destroy the previous action
drop(missile); // un-home ourself
drop(action); // destroy the previous action
self.fire_homing_missile() // re-home ourself
}
};
Expand Down
5 changes: 1 addition & 4 deletions src/librustuv/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
ReadWrite, FileStat};
use std::io::signal::Signum;
use std::util;
use ai = std::io::net::addrinfo;

#[cfg(test)] use std::unstable::run_in_bare_thread;
Expand Down Expand Up @@ -104,7 +103,7 @@ impl HomingMissile {

impl Drop for HomingMissile {
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
// scheduler while we were doing I/O.
Expand All @@ -120,8 +119,6 @@ impl Drop for HomingMissile {
});
})
}

util::ignore(f);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ mod test {
file.write(bytes!("foo"));
file.fsync();
file.datasync();
util::ignore(file);
drop(file);
})

test!(fn truncate_works() {
Expand Down Expand Up @@ -1210,7 +1210,7 @@ mod test {
assert_eq!(stat(&path).size, 9);
assert_eq!(File::open(&path).read_to_end(),
(bytes!("fo", 0, 0, 0, 0, "wut")).to_owned());
util::ignore(file);
drop(file);
})

test!(fn open_flavors() {
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ pub use vec::{Vector, VectorVector, CopyableVector, ImmutableVector};
// Reexported runtime types
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};
pub use task::spawn;

/// Disposes of a value.
#[inline]
pub fn drop<T>(_x: T) { }
3 changes: 1 addition & 2 deletions src/libstd/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,6 @@ mod test {
use rt::sleeper_list::SleeperList;
use rt::stack::StackPool;
use rt::sched::{Shutdown, TaskFromFriend};
use util;

do run_in_bare_thread {
stress_factor().times(|| {
Expand Down Expand Up @@ -1205,7 +1204,7 @@ mod test {
handle.send(TaskFromFriend(task));

handle.send(Shutdown);
util::ignore(handle);
drop(handle);

thread.join();
})
Expand Down
7 changes: 3 additions & 4 deletions src/libstd/unstable/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ mod tests {
use prelude::*;
use super::{Exclusive, UnsafeArc, atomically};
use task;
use util;
use mem::size_of;

//#[unsafe_no_drop_flag] FIXME: #9758
Expand Down Expand Up @@ -571,7 +570,7 @@ mod tests {
let x2 = x.clone();
let left_x = x.try_unwrap();
assert!(left_x.is_self());
util::ignore(left_x);
drop(left_x);
assert!(x2.try_unwrap().expect_t("try_unwrap none") == ~~"hello");
}

Expand All @@ -590,7 +589,7 @@ mod tests {
task::deschedule(); // Try to make the unwrapper get blocked first.
let left_x = x.try_unwrap();
assert!(left_x.is_self());
util::ignore(left_x);
drop(left_x);
p.recv();
}

Expand Down Expand Up @@ -620,7 +619,7 @@ mod tests {
assert!(x2.unwrap() == ~~"hello");
}
// Have to get rid of our reference before blocking.
util::ignore(x);
drop(x);
res.recv();
}

Expand Down
4 changes: 0 additions & 4 deletions src/libstd/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ use unstable::intrinsics;
#[inline]
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
* deinitialising or copying either one.
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/lint-unused-imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod bar {
fn main() {
cal(foo::Point{x:3, y:9});
let a = 3;
ignore(a);
id(a);
test::C.b();
let _a = from_elem(0, 0);
}
3 changes: 1 addition & 2 deletions src/test/compile-fail/once-cant-call-twice-on-heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#[feature(once_fns)];
extern mod extra;
use extra::arc;
use std::util;

fn foo(blk: proc()) {
blk();
Expand All @@ -25,6 +24,6 @@ fn main() {
let x = arc::Arc::new(true);
do foo {
assert!(*x.get());
util::ignore(x);
drop(x);
}
}
3 changes: 1 addition & 2 deletions src/test/compile-fail/once-cant-call-twice-on-stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#[feature(once_fns)];
extern mod extra;
use extra::arc;
use std::util;

fn foo(blk: once ||) {
blk();
Expand All @@ -25,6 +24,6 @@ fn main() {
let x = arc::Arc::new(true);
foo(|| {
assert!(*x.get());
util::ignore(x);
drop(x);
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

extern mod extra;
use extra::arc;
use std::util;

fn foo(blk: ||) {
blk();
Expand All @@ -24,6 +23,6 @@ fn main() {
let x = arc::Arc::new(true);
foo(|| {
assert!(*x.get());
util::ignore(x); //~ ERROR cannot move out of captured outer variable
drop(x); //~ ERROR cannot move out of captured outer variable
})
}
3 changes: 1 addition & 2 deletions src/test/run-pass/once-move-out-on-heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#[feature(once_fns)];
extern mod extra;
use extra::arc;
use std::util;

fn foo(blk: proc()) {
blk();
Expand All @@ -25,6 +24,6 @@ fn main() {
let x = arc::Arc::new(true);
do foo {
assert!(*x.get());
util::ignore(x);
drop(x);
}
}
3 changes: 1 addition & 2 deletions src/test/run-pass/once-move-out-on-stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#[feature(once_fns)];
extern mod extra;
use extra::arc;
use std::util;

fn foo(blk: once ||) {
blk();
Expand All @@ -25,6 +24,6 @@ fn main() {
let x = arc::Arc::new(true);
foo(|| {
assert!(*x.get());
util::ignore(x);
drop(x);
})
}