Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 4b655df

Browse files
authored
Merge pull request #601 from Xanewok/simplify-build-result
Simplify BuildResult enum
2 parents 3cdfef2 + 752f6ca commit 4b655df

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

src/actions/post_build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ impl<O: Output> PostBuildHandler<O> {
4949
));
5050

5151
match result {
52-
BuildResult::Success(messages, new_analysis)
53-
| BuildResult::Failure(messages, new_analysis) => {
52+
BuildResult::Success(messages, new_analysis) => {
5453
thread::spawn(move || {
5554
trace!("build - Success");
5655

src/build/cargo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,7 @@ impl Executor for RlsExecutor {
476476
self.config.clone(),
477477
env_lock,
478478
) {
479-
BuildResult::Success(mut messages, mut analysis)
480-
| BuildResult::Failure(mut messages, mut analysis) => {
479+
BuildResult::Success(mut messages, mut analysis) => {
481480
self.compiler_messages.lock().unwrap().append(&mut messages);
482481
self.analysis.lock().unwrap().append(&mut analysis);
483482
}

src/build/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ struct Internals {
9292
/// The result of a build request.
9393
#[derive(Debug)]
9494
pub enum BuildResult {
95-
/// Build was successful, argument is warnings.
95+
/// Build was performed without any internal errors. The payload
96+
/// contains emitted raw diagnostics and Analysis data.
9697
Success(Vec<String>, Vec<Analysis>),
97-
/// Build finished with errors, argument is errors and warnings.
98-
Failure(Vec<String>, Vec<Analysis>),
9998
/// Build was coalesced with another build.
10099
Squashed,
101100
/// There was an error attempting to build.
@@ -421,7 +420,7 @@ impl Internals {
421420
// now. It's possible that a build was scheduled with given files, but
422421
// user later changed them. These should still be left as dirty (not built).
423422
match *&result {
424-
BuildResult::Success(_, _) | BuildResult::Failure(_, _) => {
423+
BuildResult::Success(_, _) => {
425424
let mut dirty_files = self.dirty_files.lock().unwrap();
426425
dirty_files.retain(|file, dirty_version| {
427426
built_files

src/build/plan.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,16 @@ impl JobQueue {
361361
internals.config.clone(),
362362
internals.env_lock.as_facade(),
363363
) {
364-
BuildResult::Success(mut messages, mut analysis)
365-
| BuildResult::Failure(mut messages, mut analysis) => {
364+
BuildResult::Success(mut messages, mut analysis) => {
366365
compiler_messages.append(&mut messages);
367366
analyses.append(&mut analysis);
368367
}
369368
BuildResult::Err => return BuildResult::Err,
370369
_ => {}
371370
}
372371
}
373-
// TODO: Should we combine with ::Failure? What's the difference between those two?
374-
return BuildResult::Success(compiler_messages, analyses);
372+
373+
BuildResult::Success(compiler_messages, analyses)
375374
}
376375
}
377376

src/build/rustc.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ pub fn rustc(
7474

7575
let mut controller = RlsRustcCalls::new(analysis.clone());
7676

77-
let exit_code = ::std::panic::catch_unwind(|| {
77+
// rustc explicitly panics in run_compiler() on compile failure, regardless
78+
// if it encounters an ICE (internal compiler error) or not.
79+
// TODO: Change librustc_driver behaviour to distinguish between ICEs and
80+
// regular compilation failure with errors?
81+
let _ = ::std::panic::catch_unwind(|| {
7882
run(move || {
7983
// Replace stderr so we catch most errors.
8084
run_compiler(
@@ -94,10 +98,8 @@ pub fn rustc(
9498

9599
let analysis = analysis.lock().unwrap().clone();
96100
let analysis = analysis.map(|analysis| vec![analysis]).unwrap_or(vec![]);
97-
match exit_code {
98-
Ok(0) => BuildResult::Success(stderr_json_msgs, analysis),
99-
_ => BuildResult::Failure(stderr_json_msgs, analysis),
100-
}
101+
102+
BuildResult::Success(stderr_json_msgs, analysis)
101103
}
102104

103105
// Our compiler controller. We mostly delegate to the default rustc

0 commit comments

Comments
 (0)