Skip to content

Commit

Permalink
remove feature "proptest"
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed May 16, 2024
1 parent 2f8a0d3 commit ec79951
Showing 18 changed files with 52 additions and 64 deletions.
8 changes: 3 additions & 5 deletions hugr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -22,9 +22,7 @@ bench = false
path = "src/lib.rs"

[features]
default = ["proptest"]
extension_inference = []
proptest = ["dep:proptest","dep:proptest-derive","dep:regex-syntax"]

[dependencies]
portgraph = { workspace = true, features = ["serde", "petgraph"] }
@@ -54,9 +52,9 @@ delegate = "0.12.0"
paste = "1.0"
strum = "0.26.1"
strum_macros = "0.26.1"
proptest = { version = "1.4.0", optional = true }
proptest-derive = { version = "0.4.0", optional = true}
regex-syntax = { version = "0.8.3", optional = true}
proptest = { version = "1.4.0" }
proptest-derive = { version = "0.4.0"}
regex-syntax = { version = "0.8.3"}

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
1 change: 0 additions & 1 deletion hugr/src/extension.rs
Original file line number Diff line number Diff line change
@@ -537,7 +537,6 @@ impl FromIterator<ExtensionId> for ExtensionSet {
#[cfg(test)]
mod test {

#[cfg(feature = "proptest")]
mod proptest {

use ::proptest::{collection::hash_set, prelude::*};
1 change: 0 additions & 1 deletion hugr/src/hugr/ident.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,6 @@ pub struct InvalidIdentifier(SmolStr);
#[cfg(test)]
mod test {

#[cfg(feature = "proptest")]
mod proptest {
use crate::hugr::ident::IdentList;
use ::proptest::prelude::*;
2 changes: 0 additions & 2 deletions hugr/src/hugr/serialize/test.rs
Original file line number Diff line number Diff line change
@@ -179,7 +179,6 @@ pub fn check_hugr_roundtrip(hugr: &Hugr, check_schema: bool) -> Hugr {

// for now this is only used in property testing, so otherwise configured out to
// avoid unused warnings.
#[cfg(feature = "proptest")]
fn check_testing_roundtrip(t: impl Into<TestingModel>) {
let before = Versioned::new(t.into());
let after_strict = ser_roundtrip_validate(&before, Some(&TESTING_SCHEMA_STRICT));
@@ -377,7 +376,6 @@ fn serialize_types_roundtrip() {
assert_eq!(ser_roundtrip(&t), t);
}

#[cfg(feature = "proptest")]
mod proptest {
use super::super::NodeSer;
use super::check_testing_roundtrip;
4 changes: 2 additions & 2 deletions hugr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@
// 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(all(test, feature = "proptest"), allow(non_local_definitions))]
#![cfg_attr(test, allow(non_local_definitions))]

pub mod algorithm;
pub mod builder;
@@ -157,5 +157,5 @@ pub use crate::core::{
pub use crate::extension::Extension;
pub use crate::hugr::{Hugr, HugrView, SimpleReplacement};

#[cfg(all(feature = "proptest", test))]
#[cfg(test)]
pub mod proptest;
2 changes: 1 addition & 1 deletion hugr/src/ops.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ pub use tag::OpTag;

#[enum_dispatch(OpTrait, NamedOp, ValidateOp, OpParent)]
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
/// The concrete operation types for a node in the HUGR.
// TODO: Link the NodeHandles to the OpType.
#[non_exhaustive]
3 changes: 1 addition & 2 deletions hugr/src/ops/constant.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ pub use custom::{
///
/// Represents core types and extension types.
#[non_exhaustive]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Const {
#[serde(rename = "v")]
value: Value,
@@ -631,7 +631,6 @@ mod test {
assert_ne!(yaml_const.get_type(), t);
}

#[cfg(feature = "proptest")]
mod proptest {
use super::super::OpaqueValue;
use crate::{
12 changes: 6 additions & 6 deletions hugr/src/ops/controlflow.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ use super::{OpName, OpTag};

/// Tail-controlled loop.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct TailLoop {
/// Types that are only input
pub just_inputs: TypeRow,
@@ -53,7 +53,7 @@ impl TailLoop {

/// Conditional operation, defined by child `Case` nodes for each branch.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Conditional {
/// The possible rows of the Sum input
pub sum_rows: Vec<TypeRow>,
@@ -93,7 +93,7 @@ impl Conditional {
/// A dataflow node which is defined by a child CFG.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[allow(missing_docs)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct CFG {
pub signature: FunctionType,
}
@@ -113,7 +113,7 @@ impl DataflowOpTrait for CFG {
}

#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
/// A CFG basic block node. The signature is that of the internal Dataflow graph.
#[allow(missing_docs)]
pub struct DataflowBlock {
@@ -124,7 +124,7 @@ pub struct DataflowBlock {
}

#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
/// The single exit node of the CFG. Has no children,
/// stores the types of the CFG node output.
pub struct ExitBlock {
@@ -246,7 +246,7 @@ impl BasicBlock for ExitBlock {
}

#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
/// Case ops - nodes valid inside Conditional nodes.
pub struct Case {
/// The signature of the contained dataflow graph.
7 changes: 3 additions & 4 deletions hugr/src/ops/custom.rs
Original file line number Diff line number Diff line change
@@ -268,16 +268,16 @@ impl DataflowOpTrait for ExtensionOp {

/// An opaquely-serialized op that refers to an as-yet-unresolved [`OpDef`]
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct OpaqueOp {
extension: ExtensionId,
#[cfg_attr(
all(test, feature = "proptest"),
test,
proptest(strategy = "crate::proptest::any_nonempty_smolstr()")
)]
op_name: SmolStr,
#[cfg_attr(
all(test, feature = "proptest"),
test,
proptest(strategy = "crate::proptest::any_nonempty_string()")
)]
description: String, // cache in advance so description() can return &str
@@ -449,7 +449,6 @@ mod test {
assert!(!op.is_extension_op());
}

#[cfg(feature = "proptest")]
mod proptest {
use ::proptest::prelude::*;

14 changes: 7 additions & 7 deletions hugr/src/ops/dataflow.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ pub trait IOTrait {
/// An input node.
/// The outputs of this node are the inputs to the function.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Input {
/// Input value types
pub types: TypeRow,
@@ -69,7 +69,7 @@ impl IOTrait for Input {

/// An output node. The inputs are the outputs of the function.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Output {
/// Output value types
pub types: TypeRow,
@@ -153,7 +153,7 @@ impl<T: DataflowOpTrait> StaticTag for T {
/// The port immediately following those those is connected to the def/declare
/// block with a [`EdgeKind::Function`] edge.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Call {
/// Signature of function being called
func_sig: PolyFuncType,
@@ -247,7 +247,7 @@ impl Call {
/// Call a function indirectly. Like call, but the function input is a value
/// (runtime, not static) dataflow edge, and thus does not need any type-args.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct CallIndirect {
/// Signature of function being called
pub signature: FunctionType,
@@ -272,7 +272,7 @@ impl DataflowOpTrait for CallIndirect {

/// Load a static constant in to the local dataflow graph.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct LoadConstant {
/// Constant type
pub datatype: Type,
@@ -323,7 +323,7 @@ impl LoadConstant {

/// Load a static function in to the local dataflow graph.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct LoadFunction {
/// Signature of the function
func_sig: PolyFuncType,
@@ -410,7 +410,7 @@ pub trait DataflowParent {

/// A simply nested dataflow graph.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct DFG {
/// Signature of DFG node
pub signature: FunctionType,
10 changes: 5 additions & 5 deletions hugr/src/ops/leaf.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ use crate::{
/// A no-op operation.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Noop {
/// The type of edges connecting the Noop.
pub ty: Type,
@@ -34,7 +34,7 @@ impl Default for Noop {

/// An operation that packs all its inputs into a tuple.
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[non_exhaustive]
pub struct MakeTuple {
///Tuple element types.
@@ -50,7 +50,7 @@ impl MakeTuple {

/// An operation that unpacks a tuple into its components.
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[non_exhaustive]
pub struct UnpackTuple {
///Tuple element types.
@@ -67,7 +67,7 @@ impl UnpackTuple {
/// An operation that creates a tagged sum value from one of its variants.
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Tag {
/// The variant to create.
pub tag: usize,
@@ -85,7 +85,7 @@ impl Tag {
/// A node which adds a extension req to the types of the wires it is passed
/// It has no effect on the values passed along the edge
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(test, feature = "proptest"), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[non_exhaustive]
pub struct Lift {
/// The types of the edges
18 changes: 9 additions & 9 deletions hugr/src/ops/module.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use super::{impl_op_name, OpTag, OpTrait};

/// The root of a module, parent of all other `OpType`s.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct Module;

impl_op_name!(Module);
@@ -34,11 +34,11 @@ impl OpTrait for Module {
///
/// Children nodes are the body of the definition.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct FuncDefn {
/// Name of function
#[cfg_attr(
all(feature = "proptest", test),
test,
proptest(strategy = "crate::proptest::any_nonempty_string()")
)]
pub name: String,
@@ -73,11 +73,11 @@ impl OpTrait for FuncDefn {

/// External function declaration, linked at runtime.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct FuncDecl {
/// Name of function
#[cfg_attr(
all(feature = "proptest", test),
test,
proptest(strategy = "crate::proptest::any_nonempty_string()")
)]
pub name: String,
@@ -106,11 +106,11 @@ impl OpTrait for FuncDecl {

/// A type alias definition, used only for debug/metadata.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct AliasDefn {
/// Alias name
#[cfg_attr(
all(feature = "proptest", test),
test,
proptest(strategy = "crate::proptest::any_nonempty_smolstr()")
)]
pub name: SmolStr,
@@ -133,11 +133,11 @@ impl OpTrait for AliasDefn {

/// A type alias declaration. Resolved at link time.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(all(feature = "proptest", test), derive(proptest_derive::Arbitrary))]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub struct AliasDecl {
/// Alias name
#[cfg_attr(
all(feature = "proptest", test),
test,
proptest(strategy = "crate::proptest::any_nonempty_smolstr()")
)]
pub name: SmolStr,
Loading

0 comments on commit ec79951

Please sign in to comment.