From 8b5b13d3783f35205cf3cdf99160099c14433737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Fri, 13 Dec 2024 15:41:16 +0000 Subject: [PATCH] Review comments --- hugr-core/src/extension.rs | 11 ++++++----- hugr-core/src/extension/resolution/test.rs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hugr-core/src/extension.rs b/hugr-core/src/extension.rs index 9d88015c7..7fe83d303 100644 --- a/hugr-core/src/extension.rs +++ b/hugr-core/src/extension.rs @@ -257,15 +257,16 @@ impl ExtensionRegistry { { let extensions = extensions.into_iter().collect_vec(); - // Unsafe internally-mutable wrapper around an extension. - // Important: The layout is identical to A + // Unsafe internally-mutable wrapper around an extension. Important: + // `repr(transparent)` ensures the layout is identical to `Extension`, + // so it can be safely transmuted. #[repr(transparent)] struct ExtensionCell { ext: UnsafeCell, } // Create the arcs with internal mutability, and collect weak references - // over non-mutable references. + // over immutable references. // // This is safe as long as the cell mutation happens when we can guarantee // that the weak references are not used. @@ -778,10 +779,10 @@ pub enum ExtensionRegistryError { #[derive(Debug, Error)] #[non_exhaustive] pub enum ExtensionRegistryLoadError { - /// Extension already defined. + /// Deserialization error. #[error(transparent)] SerdeError(#[from] serde_json::Error), - /// A registered extension has invalid signatures. + /// Error when resolving internal extension references. #[error(transparent)] ExtensionResolutionError(#[from] ExtensionResolutionError), } diff --git a/hugr-core/src/extension/resolution/test.rs b/hugr-core/src/extension/resolution/test.rs index a52cddac5..65bcb2aad 100644 --- a/hugr-core/src/extension/resolution/test.rs +++ b/hugr-core/src/extension/resolution/test.rs @@ -90,7 +90,7 @@ fn make_extension(name: &str, op_name: &str) -> (Arc, OpType) { /// Create a new test extension with a type and an op using that type /// -/// Returns an instance of the defined op. +/// Returns the defined extension. fn make_extension_self_referencing(name: &str, op_name: &str, type_name: &str) -> Arc { let ext = Extension::new_test_arc(ExtensionId::new_unchecked(name), |ext, extension_ref| { let type_def = ext