From fb76c7ec28b32def1a52aa35277a78326e43ecbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:14:08 +0100 Subject: [PATCH] chore: Fix some unstable lints (#971) Fix some lints that appear when compiling on nightly. These are mostly double-import warnings due to importing things already included by `use super::*`. --- hugr/src/algorithm/const_fold.rs | 4 ++-- hugr/src/algorithm/nest_cfgs.rs | 4 ++-- hugr/src/builder/cfg.rs | 1 - hugr/src/builder/circuit.rs | 2 +- hugr/src/builder/conditional.rs | 3 +-- hugr/src/builder/dataflow.rs | 6 +----- hugr/src/builder/tail_loop.rs | 2 +- hugr/src/extension/infer/test.rs | 4 ++-- hugr/src/extension/prelude.rs | 1 - hugr/src/hugr.rs | 1 + hugr/src/hugr/rewrite/consts.rs | 1 - hugr/src/hugr/rewrite/insert_identity.rs | 2 +- hugr/src/hugr/validate/test.rs | 8 ++++---- hugr/src/hugr/views/descendants.rs | 1 - hugr/src/hugr/views/sibling_subgraph.rs | 1 - hugr/src/ops/constant.rs | 3 +-- hugr/src/std_extensions/collections.rs | 7 +++---- hugr/src/types.rs | 4 +--- 18 files changed, 21 insertions(+), 34 deletions(-) diff --git a/hugr/src/algorithm/const_fold.rs b/hugr/src/algorithm/const_fold.rs index 00891f227..7aef60c88 100644 --- a/hugr/src/algorithm/const_fold.rs +++ b/hugr/src/algorithm/const_fold.rs @@ -212,8 +212,8 @@ mod test { use super::*; use crate::extension::prelude::{sum_with_error, BOOL_T}; - use crate::extension::{ExtensionRegistry, PRELUDE}; - use crate::ops::{OpType, UnpackTuple}; + use crate::extension::PRELUDE; + use crate::ops::UnpackTuple; use crate::std_extensions::arithmetic; use crate::std_extensions::arithmetic::conversions::ConvertOpDef; use crate::std_extensions::arithmetic::float_ops::FloatOps; diff --git a/hugr/src/algorithm/nest_cfgs.rs b/hugr/src/algorithm/nest_cfgs.rs index 55288b09b..eadd9e5ae 100644 --- a/hugr/src/algorithm/nest_cfgs.rs +++ b/hugr/src/algorithm/nest_cfgs.rs @@ -579,10 +579,10 @@ pub(crate) mod test { use crate::extension::{prelude::USIZE_T, ExtensionSet}; use crate::hugr::views::RootChecked; - use crate::ops::handle::{BasicBlockID, ConstID, NodeHandle}; + use crate::ops::handle::{ConstID, NodeHandle}; use crate::ops::Value; + use crate::type_row; use crate::types::{FunctionType, Type}; - use crate::{type_row, Hugr}; const NAT: Type = USIZE_T; pub fn group_by(h: HashMap) -> HashSet> { diff --git a/hugr/src/builder/cfg.rs b/hugr/src/builder/cfg.rs index 6fd783aca..2066f39f0 100644 --- a/hugr/src/builder/cfg.rs +++ b/hugr/src/builder/cfg.rs @@ -400,7 +400,6 @@ impl BlockBuilder { #[cfg(test)] pub(crate) mod test { - use crate::builder::build_traits::HugrBuilder; use crate::builder::{DataflowSubContainer, ModuleBuilder}; use crate::hugr::validate::InterGraphEdgeError; diff --git a/hugr/src/builder/circuit.rs b/hugr/src/builder/circuit.rs index eaaf75878..61fd3c61e 100644 --- a/hugr/src/builder/circuit.rs +++ b/hugr/src/builder/circuit.rs @@ -241,7 +241,7 @@ mod test { use crate::{ builder::{ test::{build_main, NAT, QB}, - Dataflow, DataflowSubContainer, Wire, + DataflowSubContainer, }, extension::prelude::BOOL_T, ops::{custom::OpaqueOp, CustomOp}, diff --git a/hugr/src/builder/conditional.rs b/hugr/src/builder/conditional.rs index f0e858af0..e39c88451 100644 --- a/hugr/src/builder/conditional.rs +++ b/hugr/src/builder/conditional.rs @@ -207,14 +207,13 @@ impl CaseBuilder { mod test { use cool_asserts::assert_matches; - use crate::builder::{DataflowSubContainer, HugrBuilder, ModuleBuilder}; + use crate::builder::{DataflowSubContainer, ModuleBuilder}; use crate::{ builder::{ test::{n_identity, NAT}, Dataflow, }, - extension::ExtensionSet, ops::Value, type_row, }; diff --git a/hugr/src/builder/dataflow.rs b/hugr/src/builder/dataflow.rs index 38bd4ec70..473e79877 100644 --- a/hugr/src/builder/dataflow.rs +++ b/hugr/src/builder/dataflow.rs @@ -217,11 +217,7 @@ pub(crate) mod test { use crate::types::Type; use crate::utils::test_quantum_extension::h_gate; use crate::{ - builder::{ - test::{n_identity, BIT, NAT, QB}, - BuildError, - }, - extension::ExtensionSet, + builder::test::{n_identity, BIT, NAT, QB}, type_row, Wire, }; diff --git a/hugr/src/builder/tail_loop.rs b/hugr/src/builder/tail_loop.rs index 9c0d681be..40baf8657 100644 --- a/hugr/src/builder/tail_loop.rs +++ b/hugr/src/builder/tail_loop.rs @@ -100,7 +100,7 @@ mod test { extension::ExtensionSet, hugr::ValidationError, ops::Value, - type_row, Hugr, + type_row, }; use super::*; diff --git a/hugr/src/extension/infer/test.rs b/hugr/src/extension/infer/test.rs index 5fc31eab3..74e0eb124 100644 --- a/hugr/src/extension/infer/test.rs +++ b/hugr/src/extension/infer/test.rs @@ -4,10 +4,10 @@ use super::*; use crate::builder::{ Container, DFGBuilder, Dataflow, DataflowHugr, DataflowSubContainer, HugrBuilder, ModuleBuilder, }; +use crate::extension::prelude::PRELUDE_REGISTRY; use crate::extension::prelude::QB_T; use crate::extension::ExtensionId; -use crate::extension::{prelude::PRELUDE_REGISTRY, ExtensionSet}; -use crate::hugr::{Hugr, HugrMut, HugrView, NodeType}; +use crate::hugr::{Hugr, HugrMut, NodeType}; use crate::macros::const_extension_ids; use crate::ops::custom::OpaqueOp; use crate::ops::{self, dataflow::IOTrait}; diff --git a/hugr/src/extension/prelude.rs b/hugr/src/extension/prelude.rs index 52329776f..9d0bee410 100644 --- a/hugr/src/extension/prelude.rs +++ b/hugr/src/extension/prelude.rs @@ -296,7 +296,6 @@ impl CustomConst for ConstError { mod test { use crate::{ builder::{DFGBuilder, Dataflow, DataflowHugr}, - types::FunctionType, Hugr, Wire, }; diff --git a/hugr/src/hugr.rs b/hugr/src/hugr.rs index 3687b9094..02b5a25b5 100644 --- a/hugr/src/hugr.rs +++ b/hugr/src/hugr.rs @@ -353,6 +353,7 @@ mod test { fn impls_send_and_sync() { // Send and Sync are automatically impl'd by the compiler, if possible. // This test will fail to compile if that wasn't possible. + #[allow(dead_code)] trait Test: Send + Sync {} impl Test for Hugr {} } diff --git a/hugr/src/hugr/rewrite/consts.rs b/hugr/src/hugr/rewrite/consts.rs index dd7e51bf9..746972817 100644 --- a/hugr/src/hugr/rewrite/consts.rs +++ b/hugr/src/hugr/rewrite/consts.rs @@ -119,7 +119,6 @@ mod test { prelude::{ConstUsize, USIZE_T}, PRELUDE_REGISTRY, }, - hugr::HugrMut, ops::{handle::NodeHandle, MakeTuple, Value}, type_row, types::FunctionType, diff --git a/hugr/src/hugr/rewrite/insert_identity.rs b/hugr/src/hugr/rewrite/insert_identity.rs index 318fed8c4..43cb35142 100644 --- a/hugr/src/hugr/rewrite/insert_identity.rs +++ b/hugr/src/hugr/rewrite/insert_identity.rs @@ -103,7 +103,7 @@ mod tests { algorithm::nest_cfgs::test::build_conditional_in_loop_cfg, extension::{prelude::QB_T, PRELUDE_REGISTRY}, ops::handle::NodeHandle, - Hugr, HugrView, + Hugr, }; #[rstest] diff --git a/hugr/src/hugr/validate/test.rs b/hugr/src/hugr/validate/test.rs index bd884a989..46fa21a47 100644 --- a/hugr/src/hugr/validate/test.rs +++ b/hugr/src/hugr/validate/test.rs @@ -9,14 +9,14 @@ use crate::builder::{ use crate::extension::prelude::{BOOL_T, PRELUDE, USIZE_T}; use crate::extension::{Extension, ExtensionId, TypeDefBound, EMPTY_REG, PRELUDE_REGISTRY}; use crate::hugr::hugrmut::sealed::HugrMutInternals; -use crate::hugr::{HugrMut, NodeType}; +use crate::hugr::HugrMut; use crate::ops::dataflow::IOTrait; -use crate::ops::{self, Noop, OpType, Value}; +use crate::ops::{self, Noop, Value}; use crate::std_extensions::logic::test::{and_op, or_op}; use crate::std_extensions::logic::{self, NotOp}; -use crate::types::type_param::{TypeArg, TypeArgError, TypeParam}; +use crate::types::type_param::{TypeArg, TypeArgError}; use crate::types::{CustomType, FunctionType, PolyFuncType, Type, TypeBound, TypeRow}; -use crate::{type_row, Direction, IncomingPort, Node}; +use crate::{type_row, IncomingPort}; const NAT: Type = crate::extension::prelude::USIZE_T; diff --git a/hugr/src/hugr/views/descendants.rs b/hugr/src/hugr/views/descendants.rs index 453503509..71df55524 100644 --- a/hugr/src/hugr/views/descendants.rs +++ b/hugr/src/hugr/views/descendants.rs @@ -201,7 +201,6 @@ where pub(super) mod test { use crate::{ builder::{Container, Dataflow, DataflowSubContainer, HugrBuilder, ModuleBuilder}, - ops::handle::NodeHandle, type_row, types::{FunctionType, Type}, utils::test_quantum_extension::h_gate, diff --git a/hugr/src/hugr/views/sibling_subgraph.rs b/hugr/src/hugr/views/sibling_subgraph.rs index 626607b17..ddc307509 100644 --- a/hugr/src/hugr/views/sibling_subgraph.rs +++ b/hugr/src/hugr/views/sibling_subgraph.rs @@ -698,7 +698,6 @@ mod tests { EMPTY_REG, }, hugr::views::{HierarchyView, SiblingGraph}, - hugr::HugrMut, ops::handle::{DfgID, FuncID, NodeHandle}, std_extensions::logic::{test::and_op, NotOp}, type_row, diff --git a/hugr/src/ops/constant.rs b/hugr/src/ops/constant.rs index 8a434ec7a..7050eba9a 100644 --- a/hugr/src/ops/constant.rs +++ b/hugr/src/ops/constant.rs @@ -346,11 +346,10 @@ mod test { prelude::{ConstUsize, USIZE_CUSTOM_T, USIZE_T}, ExtensionId, ExtensionRegistry, PRELUDE, }, - ops::constant::CustomSerialized, std_extensions::arithmetic::float_types::{self, ConstF64, FLOAT64_TYPE}, type_row, types::type_param::TypeArg, - types::{CustomType, FunctionType, Type, TypeBound, TypeRow}, + types::{Type, TypeBound, TypeRow}, }; use cool_asserts::assert_matches; use rstest::{fixture, rstest}; diff --git a/hugr/src/std_extensions/collections.rs b/hugr/src/std_extensions/collections.rs index eb06bfa7a..b69703445 100644 --- a/hugr/src/std_extensions/collections.rs +++ b/hugr/src/std_extensions/collections.rs @@ -290,15 +290,14 @@ impl ListOpInst { #[cfg(test)] mod test { + use crate::ops::OpTrait; use crate::{ extension::{ prelude::{ConstUsize, QB_T, USIZE_T}, - ExtensionRegistry, PRELUDE, + PRELUDE, }, - ops::OpTrait, std_extensions::arithmetic::float_types::{self, ConstF64, FLOAT64_TYPE}, - types::{type_param::TypeArg, TypeRow}, - Extension, + types::TypeRow, }; use super::*; diff --git a/hugr/src/types.rs b/hugr/src/types.rs index 8fc4776db..236d83d0f 100644 --- a/hugr/src/types.rs +++ b/hugr/src/types.rs @@ -447,9 +447,7 @@ pub(crate) fn check_typevar_decl( #[cfg(test)] pub(crate) mod test { use super::*; - use crate::{extension::prelude::USIZE_T, ops::AliasDecl}; - - use crate::types::TypeBound; + use crate::extension::prelude::USIZE_T; #[test] fn construct() {