-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add a
hugr-core
crate (#1108)
Moves all the code from `hugr` into a `hugr-core` subcrate. This way, `hugr-passes` (and any other new subcrate) can depend on the core definitions and get reexported in `hugr`. This PR does not. Change any definition or visibility in the code, as the renamed files are noisy enough. In particular, having `hugr-core` will let us unseal `HugrInternals` and `HugrMutInternals` so they can be used in `tket2`, but that's work for another PR. As a bonus, #1100 is no longer a breaking change since we can re-export the library without a cyclic dependency. Closes #294
- Loading branch information
Showing
105 changed files
with
269 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
rust: | ||
- "hugr/**" | ||
- "hugr-passes/**" | ||
- "hugr-*/**" | ||
- "Cargo.toml" | ||
- "specification/schema/**" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[package] | ||
name = "hugr-core" | ||
version = "0.0.0" | ||
edition = { workspace = true } | ||
rust-version = { workspace = true } | ||
|
||
license = { workspace = true } | ||
readme = "README.md" | ||
documentation = "https://docs.rs/hugr/" | ||
homepage = { workspace = true } | ||
repository = { workspace = true } | ||
description = "Quantinuum's Hierarchical Unified Graph Representation" | ||
keywords = ["Quantum", "Quantinuum"] | ||
categories = ["compilers"] | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[features] | ||
extension_inference = [] | ||
cli = ["dep:clap", "dep:clap-stdin"] | ||
|
||
[dependencies] | ||
portgraph = { workspace = true, features = ["serde", "petgraph"] } | ||
thiserror = { workspace = true } | ||
regex = { workspace = true } | ||
cgmath = { workspace = true, features = ["serde"] } | ||
num-rational = { workspace = true, features = ["serde"] } | ||
downcast-rs = { workspace = true } | ||
# Rc used here for Extension, but unfortunately we must turn the feature on globally | ||
serde = { workspace = true, features = ["derive", "rc"] } | ||
serde_yaml = { workspace = true } | ||
typetag = { workspace = true } | ||
smol_str = { workspace = true, features = ["serde"] } | ||
derive_more = { workspace = true } | ||
itertools = { workspace = true } | ||
html-escape = { workspace = true } | ||
bitvec = { workspace = true, features = ["serde"] } | ||
enum_dispatch = { workspace = true } | ||
lazy_static = { workspace = true } | ||
petgraph = { workspace = true } | ||
context-iterators = { workspace = true } | ||
serde_json = { workspace = true } | ||
delegate = { workspace = true } | ||
paste = { workspace = true } | ||
strum = { workspace = true } | ||
strum_macros = { workspace = true } | ||
clap = { workspace = true, features = ["derive"], optional = true } | ||
clap-stdin = { workspace = true, optional = true } | ||
|
||
[dev-dependencies] | ||
rstest = { workspace = true } | ||
webbrowser = { workspace = true } | ||
urlencoding = { workspace = true } | ||
cool_asserts = { workspace = true } | ||
insta = { workspace = true, features = ["yaml"] } | ||
jsonschema = { workspace = true } | ||
proptest = { workspace = true } | ||
proptest-derive = { workspace = true } | ||
regex-syntax = { workspace = true } | ||
assert_cmd = { workspace = true } | ||
predicates = { workspace = true } | ||
assert_fs = { workspace = true } | ||
|
||
# Required for documentation examples | ||
hugr = { path = "../hugr" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
 | ||
|
||
hugr-core | ||
=============== | ||
|
||
[![build_status][]](https://github.com/CQCL/hugr/actions) | ||
[![crates][]](https://crates.io/crates/hugr-core) | ||
[![msrv][]](https://github.com/CQCL/hugr) | ||
[![codecov][]](https://codecov.io/gh/CQCL/hugr) | ||
|
||
Internal core definitions for the `hugr` package. | ||
Refer to the [main crate](http://crates.io/crates/hugr) for more information. | ||
|
||
Please read the [API documentation here][]. | ||
|
||
## Experimental Features | ||
|
||
- `extension_inference`: | ||
Experimental feature which allows automatic inference of extension usages and | ||
requirements in a HUGR and validation that extensions are correctly specified. | ||
Not enabled by default. | ||
|
||
## Recent Changes | ||
|
||
See [CHANGELOG][] for a list of changes. The minimum supported rust | ||
version will only change on major releases. | ||
|
||
## Development | ||
|
||
See [DEVELOPMENT.md](https://github.com/CQCL/hugr/blob/main/DEVELOPMENT.md) for instructions on setting up the development environment. | ||
|
||
## License | ||
|
||
This project is licensed under Apache License, Version 2.0 ([LICENSE][] or http://www.apache.org/licenses/LICENSE-2.0). | ||
|
||
[API documentation here]: https://docs.rs/hugr-core/ | ||
[build_status]: https://github.com/CQCL/hugr/actions/workflows/ci-rs.yml/badge.svg?branch=main | ||
[msrv]: https://img.shields.io/badge/rust-1.75.0%2B-blue.svg | ||
[crates]: https://img.shields.io/crates/v/hugr-core | ||
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/hugr?logo=codecov | ||
[LICENSE]: https://github.com/CQCL/hugr/blob/main/LICENCE | ||
[CHANGELOG]: https://github.com/CQCL/hugr/blob/main/hugr-core/CHANGELOG.md |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ts/hugr__hugr__views__tests__dot_cfg.snap → ...gr_core__hugr__views__tests__dot_cfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/hugr__hugr__views__tests__dot_dfg.snap → ...gr_core__hugr__views__tests__dot_dfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
source: hugr/views/tests.rs | ||
source: hugr-core/views/tests.rs | ||
expression: h.dot_string() | ||
--- | ||
digraph { | ||
|
2 changes: 1 addition & 1 deletion
2
...r__hugr__views__tests__dot_empty_dfg.snap → ...e__hugr__views__tests__dot_empty_dfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/hugr__hugr__views__tests__mmd_cfg.snap → ...gr_core__hugr__views__tests__mmd_cfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/hugr__hugr__views__tests__mmd_dfg.snap → ...gr_core__hugr__views__tests__mmd_dfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r__hugr__views__tests__mmd_empty_dfg.snap → ...e__hugr__views__tests__mmd_empty_dfg.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Extensible, graph-based program representation with first-class support for linear types. | ||
//! | ||
//! This crate contains the core definitions for the HUGR representation. | ||
//! See the [top-level crate documentation](https://docs.rs/hugr/latest/hugr/) for more information. | ||
// proptest-derive generates many of these warnings. | ||
// https://github.com/rust-lang/rust/issues/120363 | ||
// https://github.com/proptest-rs/proptest/issues/447 | ||
#![cfg_attr(test, allow(non_local_definitions))] | ||
|
||
pub mod builder; | ||
pub mod core; | ||
pub mod extension; | ||
pub mod hugr; | ||
pub mod macros; | ||
pub mod ops; | ||
pub mod std_extensions; | ||
pub mod types; | ||
pub mod utils; | ||
|
||
pub use crate::core::{ | ||
CircuitUnit, Direction, IncomingPort, Node, NodeIndex, OutgoingPort, Port, PortIndex, Wire, | ||
}; | ||
pub use crate::extension::Extension; | ||
pub use crate::hugr::{Hugr, HugrView, SimpleReplacement}; | ||
|
||
#[cfg(feature = "cli")] | ||
pub mod cli; | ||
|
||
#[cfg(test)] | ||
pub mod proptest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.