Skip to content

Commit 99bd607

Browse files
committed
Merge remote-tracking branch 'origin/release-rs-v0.16.0' into feat/arrays
2 parents 0a01a2f + a1cd051 commit 99bd607

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2471
-1742
lines changed

hugr-core/src/builder/build_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub trait Container {
119119
}
120120

121121
/// Insert a copy of a HUGR as a child of the container.
122-
fn add_hugr_view(&mut self, child: &impl HugrView) -> InsertionResult {
122+
fn add_hugr_view<H: HugrView>(&mut self, child: &H) -> InsertionResult<H::Node, Node> {
123123
let parent = self.container_node();
124124
self.hugr_mut().insert_from_view(parent, child)
125125
}
@@ -153,7 +153,7 @@ pub trait Container {
153153
where
154154
ExtensionRegistry: Extend<Reg>,
155155
{
156-
self.hugr_mut().extensions_mut().extend(registry);
156+
self.hugr_mut().use_extensions(registry);
157157
}
158158
}
159159

hugr-core/src/extension.rs

+2-63
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ use derive_more::Display;
1919
use thiserror::Error;
2020

2121
use crate::hugr::IdentList;
22-
use crate::ops::constant::{ValueName, ValueNameRef};
2322
use crate::ops::custom::{ExtensionOp, OpaqueOp};
24-
use crate::ops::{self, OpName, OpNameRef};
23+
use crate::ops::{OpName, OpNameRef};
2524
use crate::types::type_param::{TypeArg, TypeArgError, TypeParam};
2625
use crate::types::RowVariable;
2726
use crate::types::{check_typevar_decl, CustomType, Substitution, TypeBound, TypeName};
@@ -378,6 +377,7 @@ pub static EMPTY_REG: ExtensionRegistry = ExtensionRegistry {
378377
/// TODO: decide on failure modes
379378
#[derive(Debug, Clone, Error, PartialEq, Eq)]
380379
#[allow(missing_docs)]
380+
#[non_exhaustive]
381381
pub enum SignatureError {
382382
/// Name mismatch
383383
#[error("Definition name ({0}) and instantiation name ({1}) do not match.")]
@@ -496,37 +496,6 @@ impl CustomConcrete for CustomType {
496496
}
497497
}
498498

499-
/// A constant value provided by a extension.
500-
/// Must be an instance of a type available to the extension.
501-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
502-
pub struct ExtensionValue {
503-
extension: ExtensionId,
504-
name: ValueName,
505-
typed_value: ops::Value,
506-
}
507-
508-
impl ExtensionValue {
509-
/// Returns a reference to the typed value of this [`ExtensionValue`].
510-
pub fn typed_value(&self) -> &ops::Value {
511-
&self.typed_value
512-
}
513-
514-
/// Returns a mutable reference to the typed value of this [`ExtensionValue`].
515-
pub(super) fn typed_value_mut(&mut self) -> &mut ops::Value {
516-
&mut self.typed_value
517-
}
518-
519-
/// Returns a reference to the name of this [`ExtensionValue`].
520-
pub fn name(&self) -> &str {
521-
self.name.as_str()
522-
}
523-
524-
/// Returns a reference to the extension this [`ExtensionValue`] belongs to.
525-
pub fn extension(&self) -> &ExtensionId {
526-
&self.extension
527-
}
528-
}
529-
530499
/// A unique identifier for a extension.
531500
///
532501
/// The actual [`Extension`] is stored externally.
@@ -582,8 +551,6 @@ pub struct Extension {
582551
pub runtime_reqs: ExtensionSet,
583552
/// Types defined by this extension.
584553
types: BTreeMap<TypeName, TypeDef>,
585-
/// Static values defined by this extension.
586-
values: BTreeMap<ValueName, ExtensionValue>,
587554
/// Operation declarations with serializable definitions.
588555
// Note: serde will serialize this because we configure with `features=["rc"]`.
589556
// That will clone anything that has multiple references, but each
@@ -607,7 +574,6 @@ impl Extension {
607574
version,
608575
runtime_reqs: Default::default(),
609576
types: Default::default(),
610-
values: Default::default(),
611577
operations: Default::default(),
612578
}
613579
}
@@ -679,11 +645,6 @@ impl Extension {
679645
self.types.get(type_name)
680646
}
681647

682-
/// Allows read-only access to the values in this Extension
683-
pub fn get_value(&self, value_name: &ValueNameRef) -> Option<&ExtensionValue> {
684-
self.values.get(value_name)
685-
}
686-
687648
/// Returns the name of the extension.
688649
pub fn name(&self) -> &ExtensionId {
689650
&self.name
@@ -704,25 +665,6 @@ impl Extension {
704665
self.types.iter()
705666
}
706667

707-
/// Add a named static value to the extension.
708-
pub fn add_value(
709-
&mut self,
710-
name: impl Into<ValueName>,
711-
typed_value: ops::Value,
712-
) -> Result<&mut ExtensionValue, ExtensionBuildError> {
713-
let extension_value = ExtensionValue {
714-
extension: self.name.clone(),
715-
name: name.into(),
716-
typed_value,
717-
};
718-
match self.values.entry(extension_value.name.clone()) {
719-
btree_map::Entry::Occupied(_) => {
720-
Err(ExtensionBuildError::ValueExists(extension_value.name))
721-
}
722-
btree_map::Entry::Vacant(ve) => Ok(ve.insert(extension_value)),
723-
}
724-
}
725-
726668
/// Instantiate an [`ExtensionOp`] which references an [`OpDef`] in this extension.
727669
pub fn instantiate_extension_op(
728670
&self,
@@ -783,9 +725,6 @@ pub enum ExtensionBuildError {
783725
/// Existing [`TypeDef`]
784726
#[error("Extension already has an type called {0}.")]
785727
TypeDefExists(TypeName),
786-
/// Existing [`ExtensionValue`]
787-
#[error("Extension already has an extension value called {0}.")]
788-
ValueExists(ValueName),
789728
}
790729

791730
/// A set of extensions identified by their unique [`ExtensionId`].

hugr-core/src/extension/resolution/extension.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::sync::Arc;
99

1010
use crate::extension::{Extension, ExtensionId, ExtensionRegistry, OpDef, SignatureFunc, TypeDef};
1111

12-
use super::types_mut::{resolve_signature_exts, resolve_value_exts};
12+
use super::types_mut::resolve_signature_exts;
1313
use super::{ExtensionResolutionError, WeakExtensionRegistry};
1414

1515
impl ExtensionRegistry {
@@ -59,14 +59,7 @@ impl Extension {
5959
for type_def in self.types.values_mut() {
6060
resolve_typedef_exts(&self.name, type_def, extensions, &mut used_extensions)?;
6161
}
62-
for val in self.values.values_mut() {
63-
resolve_value_exts(
64-
None,
65-
val.typed_value_mut(),
66-
extensions,
67-
&mut used_extensions,
68-
)?;
69-
}
62+
7063
let ops = mem::take(&mut self.operations);
7164
for (op_id, mut op_def) in ops {
7265
// TODO: We should be able to clone the definition if needed by using `make_mut`,

0 commit comments

Comments
 (0)