Skip to content

Commit 8b03dc9

Browse files
committed
fix PrepareError and OverrideResult not being found in error chain
1 parent 9b2abe2 commit 8b03dc9

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

src/runner/test.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,18 @@ pub(super) fn detect_broken<T>(res: Result<T, Error>) -> Result<T, Error> {
7070
Ok(ok) => Ok(ok),
7171
Err(err) => {
7272
let mut reason = None;
73-
for cause in err.chain() {
74-
if let Some(error) = cause.downcast_ref() {
75-
reason = match *error {
76-
PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml),
77-
PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml),
78-
PrepareError::YankedDependencies(_) => Some(BrokenReason::Yanked),
79-
PrepareError::MissingDependencies(_) => {
80-
Some(BrokenReason::MissingDependencies)
81-
}
82-
PrepareError::PrivateGitRepository => {
83-
Some(BrokenReason::MissingGitRepository)
84-
}
85-
_ => None,
86-
}
87-
}
88-
if reason.is_some() {
89-
break;
73+
74+
if let Some(error) = err.downcast_ref() {
75+
reason = match *error {
76+
PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml),
77+
PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml),
78+
PrepareError::YankedDependencies(_) => Some(BrokenReason::Yanked),
79+
PrepareError::MissingDependencies(_) => Some(BrokenReason::MissingDependencies),
80+
PrepareError::PrivateGitRepository => Some(BrokenReason::MissingGitRepository),
81+
_ => None,
9082
}
9183
}
84+
9285
if let Some(reason) = reason {
9386
Err(err.context(OverrideResult(TestResult::BrokenCrate(reason))))
9487
} else {

src/runner/worker.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,8 @@ impl<'a> Worker<'a> {
149149
TestResult::Error
150150
};
151151

152-
for err in e.chain() {
153-
if let Some(OverrideResult(res)) = err.downcast_ref() {
154-
result = res.clone();
155-
break;
156-
}
152+
if let Some(OverrideResult(res)) = e.downcast_ref() {
153+
result = res.clone();
157154
}
158155

159156
Err((e, result))
@@ -249,11 +246,9 @@ impl<'a> Worker<'a> {
249246
} else {
250247
TestResult::Error
251248
};
252-
for err in err.chain() {
253-
if let Some(OverrideResult(res)) = err.downcast_ref() {
254-
result = res.clone();
255-
break;
256-
}
249+
250+
if let Some(OverrideResult(res)) = err.downcast_ref() {
251+
result = res.clone();
257252
}
258253

259254
for tc in &self.ex.toolchains {

0 commit comments

Comments
 (0)