Skip to content

Commit fa8e71a

Browse files
committed
Allow fail messages to be caught, and introduce the Any trait
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
1 parent cb5b21e commit fa8e71a

24 files changed

+912
-214
lines changed

src/libextra/sync.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ mod tests {
918918
let m = Mutex::new();
919919
let m2 = m.clone();
920920

921-
let result: result::Result<(),()> = do task::try {
921+
let result: result::Result<(), ~Any> = do task::try {
922922
do m2.lock {
923923
fail!();
924924
}
@@ -935,7 +935,7 @@ mod tests {
935935
let m = Mutex::new();
936936
let m2 = m.clone();
937937

938-
let result: result::Result<(),()> = do task::try {
938+
let result: result::Result<(), ~Any> = do task::try {
939939
let (p, c) = comm::stream();
940940
do task::spawn || { // linked
941941
let _ = p.recv(); // wait for sibling to get in the mutex
@@ -963,7 +963,7 @@ mod tests {
963963
let m2 = m.clone();
964964
let (p, c) = comm::stream();
965965

966-
let result: result::Result<(),()> = do task::try {
966+
let result: result::Result<(), ~Any> = do task::try {
967967
let mut sibling_convos = ~[];
968968
do 2.times {
969969
let (p, c) = comm::stream();
@@ -1272,7 +1272,7 @@ mod tests {
12721272
let x = RWLock::new();
12731273
let x2 = x.clone();
12741274

1275-
let result: result::Result<(),()> = do task::try || {
1275+
let result: result::Result<(), ~Any> = do task::try || {
12761276
do lock_rwlock_in_mode(&x2, mode1) {
12771277
fail!();
12781278
}

src/libextra/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,7 @@ pub fn run_test(force_ignore: bool,
873873
task.spawn(testfn_cell.take());
874874

875875
let task_result = result_future.recv();
876-
let test_result = calc_result(&desc,
877-
task_result == task::Success);
876+
let test_result = calc_result(&desc, task_result.is_ok());
878877
monitor_ch.send((desc.clone(), test_result));
879878
}
880879
}

src/librustpkg/tests.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,8 @@ fn test_install_invalid() {
640640
pkgid.clone());
641641
ctxt.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything));
642642
};
643-
// Not the best test -- doesn't test that we failed in the right way.
644-
// Best we can do for now.
645-
assert!(result == Err(()));
643+
assert!(result.unwrap_err()
644+
.to_str().contains("supplied path for package dir does not exist"));
646645
}
647646

648647
#[test]

0 commit comments

Comments
 (0)