Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Use registries of Weak<Extension>s when doing resolution #1781

Merged
merged 5 commits into from
Dec 13, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Dec 12, 2024

We'll need this to resolve extension references inside an extension that's being created.

drive-by: Make "node" optional in resolution errors.

BREAKING CHANGE: ::extension::resolve operations now use WeakExtensionRegistryes.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 70.31250% with 38 lines in your changes missing coverage. Please review.

Project coverage is 86.58%. Comparing base (8722c10) to head (b4c8af6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ugr-core/src/extension/resolution/weak_registry.rs 51.02% 23 Missing and 1 partial ⚠️
hugr-core/src/extension/resolution.rs 70.58% 5 Missing ⚠️
hugr-core/src/extension/resolution/ops.rs 0.00% 4 Missing ⚠️
hugr-core/src/extension/resolution/types_mut.rs 89.65% 3 Missing ⚠️
hugr-core/src/extension/prelude.rs 0.00% 1 Missing ⚠️
hugr-core/src/ops/constant/custom.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1781      +/-   ##
==========================================
- Coverage   86.64%   86.58%   -0.07%     
==========================================
  Files         186      187       +1     
  Lines       34145    34208      +63     
  Branches    31020    31083      +63     
==========================================
+ Hits        29586    29619      +33     
- Misses       2883     2912      +29     
- Partials     1676     1677       +1     
Flag Coverage Δ
python 92.35% <ø> (ø)
rust 86.00% <70.31%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aborgna-q aborgna-q marked this pull request as ready for review December 13, 2024 08:57
@aborgna-q aborgna-q requested a review from a team as a code owner December 13, 2024 08:57
@aborgna-q aborgna-q requested review from acl-cqc and ss2165 and removed request for acl-cqc December 13, 2024 08:57
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much use remains for a normal registry now?


/// The equivalent to an [`ExtensionRegistry`] that only contains weak references.
///
/// This is used to resolve extensions pointers while
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while what?

hugr-core/src/extension/resolution/weak_registry.rs Outdated Show resolved Hide resolved
@@ -111,13 +103,14 @@ pub enum ExtensionResolutionError {
available_extensions: Vec<ExtensionId>,
},
#[display(
"Type {ty} in {node} requires extension {missing_extension}, but it could not be found in the extension list used during resolution. The available extensions are: {}",
"Type {ty}{} requires extension {missing_extension}, but it could not be found in the extension list used during resolution. The available extensions are: {}",
node.map(|n| format!(" in {}", n)).unwrap_or_default(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the default behaviour?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a node: "Type Unit in Node(4) requires..."
If there's no node: "Type Unit requires ..."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah sorry misread, thanks

@@ -20,13 +20,16 @@ use crate::Node;
/// When a pointer is replaced, the extension is added to the
/// `used_extensions` registry.
///
/// Returns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns what?

@aborgna-q
Copy link
Collaborator Author

aborgna-q commented Dec 13, 2024

How much use remains for a normal registry now?

That's for the last PR in the chain! #1784
ExtensionRegistry is still needed when we need as someone has to have a strong pointer to the Arcs, but we'll remove most uses of them.

@aborgna-q aborgna-q requested a review from ss2165 December 13, 2024 15:38
@@ -21,6 +21,15 @@ pub struct WeakExtensionRegistry {
}

impl WeakExtensionRegistry {
/// Create a new empty extension registry.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look empty....

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the hundred typos 🤦

@aborgna-q aborgna-q added this pull request to the merge queue Dec 13, 2024
Merged via the queue into main with commit 2d08fc1 Dec 13, 2024
23 of 24 checks passed
@aborgna-q aborgna-q deleted the ab/weak-registries branch December 13, 2024 16:13
@hugrbot hugrbot mentioned this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants