Add and use a From impl from CodegenError to ModuleError
This will also improve reporting of the chain of errors.
This commit is contained in:
committed by
Dan Gohman
parent
7e725cf880
commit
d6b3ca28b4
@@ -141,7 +141,7 @@ pub enum ModuleError {
|
|||||||
InvalidImportDefinition(String),
|
InvalidImportDefinition(String),
|
||||||
/// Wraps a `cranelift-codegen` error
|
/// Wraps a `cranelift-codegen` error
|
||||||
#[error("Compilation error: {0}")]
|
#[error("Compilation error: {0}")]
|
||||||
Compilation(CodegenError),
|
Compilation(#[from] CodegenError),
|
||||||
/// Wraps a generic error from a backend
|
/// Wraps a generic error from a backend
|
||||||
#[error("Backend error: {0}")]
|
#[error("Backend error: {0}")]
|
||||||
Backend(String),
|
Backend(String),
|
||||||
@@ -549,9 +549,7 @@ where
|
|||||||
func,
|
func,
|
||||||
ctx.func.display(self.backend.isa())
|
ctx.func.display(self.backend.isa())
|
||||||
);
|
);
|
||||||
let CodeInfo { total_size, .. } = ctx
|
let CodeInfo { total_size, .. } = ctx.compile(self.backend.isa())?;
|
||||||
.compile(self.backend.isa())
|
|
||||||
.map_err(ModuleError::Compilation)?;
|
|
||||||
let info = &self.contents.functions[func];
|
let info = &self.contents.functions[func];
|
||||||
if info.compiled.is_some() {
|
if info.compiled.is_some() {
|
||||||
return Err(ModuleError::DuplicateDefinition(info.decl.name.clone()));
|
return Err(ModuleError::DuplicateDefinition(info.decl.name.clone()));
|
||||||
|
|||||||
Reference in New Issue
Block a user