Skip to content
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

Merge CompilerError::CompilationFailed and CompilerError::ICE. #121205

Merged
merged 1 commit into from
Feb 20, 2024
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
10 changes: 8 additions & 2 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,14 @@ macro_rules! run_driver {
Err(CompilerError::Interrupted(value))
}
(Ok(Ok(_)), None) => Err(CompilerError::Skipped),
(Ok(Err(_)), _) => Err(CompilerError::CompilationFailed),
(Err(_), _) => Err(CompilerError::ICE),
// Two cases here:
// - `run` finished normally and returned `Err`
// - `run` panicked with `FatalErr`
// You might think that normal compile errors cause the former, and
// ICEs cause the latter. But some normal compiler errors also cause
// the latter. So we can't meaningfully distinguish them, and group
// them together.
(Ok(Err(_)), _) | (Err(_), _) => Err(CompilerError::Failed),
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions compiler/stable_mir/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ macro_rules! error {
/// An error type used to represent an error that has already been reported by the compiler.
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum CompilerError<T> {
/// Internal compiler error (I.e.: Compiler crashed).
ICE,
/// Compilation failed.
CompilationFailed,
/// Compilation failed, either due to normal errors or ICE.
Failed,
/// Compilation was interrupted.
Interrupted(T),
/// Compilation skipped. This happens when users invoke rustc to retrieve information such as
Expand Down Expand Up @@ -54,8 +52,7 @@ where
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
CompilerError::ICE => write!(f, "Internal Compiler Error"),
CompilerError::CompilationFailed => write!(f, "Compilation Failed"),
CompilerError::Failed => write!(f, "Compilation Failed"),
CompilerError::Interrupted(reason) => write!(f, "Compilation Interrupted: {reason}"),
CompilerError::Skipped => write!(f, "Compilation Skipped"),
}
Expand All @@ -68,8 +65,7 @@ where
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
CompilerError::ICE => write!(f, "Internal Compiler Error"),
CompilerError::CompilationFailed => write!(f, "Compilation Failed"),
CompilerError::Failed => write!(f, "Compilation Failed"),
CompilerError::Interrupted(reason) => write!(f, "Compilation Interrupted: {reason:?}"),
CompilerError::Skipped => write!(f, "Compilation Skipped"),
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-fulldeps/stable-mir/compilation-result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn test_skipped(mut args: Vec<String>) {
fn test_failed(mut args: Vec<String>) {
args.push("--cfg=broken".to_string());
let result = run!(args, || unreachable!() as ControlFlow<()>);
assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed));
assert_eq!(result, Err(stable_mir::CompilerError::Failed));
}

/// Test that we are able to pass a closure and set the return according to the captured value.
Expand Down
Loading