From 75a82c28ddfe1a611acfaff6d358a7406d444614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Tue, 3 Dec 2024 16:55:38 +0000 Subject: [PATCH] Remove unused `VaridationError::ExtensionResolution` variant --- hugr-core/src/hugr/validate.rs | 6 ------ hugr-core/src/package.rs | 19 +++++++++---------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/hugr-core/src/hugr/validate.rs b/hugr-core/src/hugr/validate.rs index 2d1544040..dd048bb3f 100644 --- a/hugr-core/src/hugr/validate.rs +++ b/hugr-core/src/hugr/validate.rs @@ -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; @@ -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. diff --git a/hugr-core/src/package.rs b/hugr-core/src/package.rs index 422cce4cd..7461203f4 100644 --- a/hugr-core/src/package.rs +++ b/hugr-core/src/package.rs @@ -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; @@ -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()); } @@ -149,11 +148,9 @@ impl Package { // As a fallback, try to load a hugr json. if let Ok(mut hugr) = serde_json::from_value::(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)?); } @@ -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.