Skip to content

Commit

Permalink
Remove unused VaridationError::ExtensionResolution variant
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Dec 3, 2024
1 parent 56106aa commit 75a82c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
6 changes: 0 additions & 6 deletions hugr-core/src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use petgraph::visit::{Topo, Walker};
use portgraph::{LinkView, PortView};
use thiserror::Error;

use crate::extension::resolution::ExtensionResolutionError;
use crate::extension::{SignatureError, TO_BE_INFERRED};

use crate::ops::constant::ConstTypeError;
Expand Down Expand Up @@ -769,11 +768,6 @@ pub enum ValidationError {
/// [Type]: crate::types::Type
#[error(transparent)]
ConstTypeError(#[from] ConstTypeError),
/// Some operations or types in the HUGR reference invalid extensions.
//
// TODO: Remove once `hugr::update_validate` is removed.
#[error(transparent)]
ExtensionResolutionError(#[from] ExtensionResolutionError),
}

/// Errors related to the inter-graph edge validations.
Expand Down
19 changes: 9 additions & 10 deletions hugr-core/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use std::path::Path;
use std::{fs, io, mem};

use crate::builder::{Container, Dataflow, DataflowSubContainer, ModuleBuilder};
use crate::extension::resolution::ExtensionResolutionError;
use crate::extension::{ExtensionId, ExtensionRegistry};
use crate::hugr::internal::HugrMutInternals;
use crate::hugr::{HugrView, ValidationError};
use crate::hugr::{ExtensionError, HugrView, ValidationError};
use crate::ops::{FuncDefn, Module, NamedOp, OpTag, OpTrait, OpType};
use crate::Hugr;

Expand Down Expand Up @@ -137,9 +138,7 @@ impl Package {
combined_registry.extend(&pkg.extensions);

for module in &mut pkg.modules {
module
.resolve_extension_defs(&combined_registry)
.map_err(|e| PackageEncodingError::ExtensionResolution(e.into()))?;
module.resolve_extension_defs(&combined_registry)?;
pkg.extensions.extend(module.extensions());
}

Expand All @@ -149,11 +148,9 @@ impl Package {

// As a fallback, try to load a hugr json.
if let Ok(mut hugr) = serde_json::from_value::<Hugr>(val) {
hugr.resolve_extension_defs(extension_registry)
.map_err(|e| PackageEncodingError::ExtensionResolution(e.into()))?;
hugr.resolve_extension_defs(extension_registry)?;
if cfg!(feature = "extension_inference") {
hugr.infer_extensions(false)
.map_err(|e| PackageEncodingError::ExtensionResolution(e.into()))?;
hugr.infer_extensions(false)?;
}
return Ok(Package::from_hugr(hugr)?);
}
Expand Down Expand Up @@ -305,8 +302,10 @@ pub enum PackageEncodingError {
IOError(io::Error),
/// Improper package definition.
Package(PackageError),
/// Could not resolve extension ops in the encoded hugr.
ExtensionResolution(ValidationError),
/// Could not resolve the extension needed to encode the hugr.
ExtensionResolution(ExtensionResolutionError),
/// Could not resolve the runtime extensions for the hugr.
RuntimeExtensionResolution(ExtensionError),
}

/// Error raised while validating a package.
Expand Down

0 comments on commit 75a82c2

Please sign in to comment.