Skip to content

Commit cfa161c

Browse files
authored
chore!: Remove deprecated definitions (#2175)
Closes #2117. Some remaining deprecations will be removed by the other open PRs. BREAKING CHANGE: Removed `EnvelopeError::MultipleHugrs` BREAKING CHANGE: Removed `add_int_extension` alias in `hugr_llvm::extension` BREAKING CHANGE: Removed re-export of `ArrayOpBuilder` in `hugr_llvm` BREAKING CHANGE: Removed unused `ConstLoader::value_from_function` in `hugr_passes` BREAKING CHANGE: `Monomorphize` pass in `hugr_passes` no longer removes the poly functions.
1 parent 719723b commit cfa161c

File tree

8 files changed

+10
-109
lines changed

8 files changed

+10
-109
lines changed

hugr-core/src/envelope.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,6 @@ pub enum EnvelopeError {
164164
#[display("Zstd compression is not supported. This requires the 'zstd' feature for `hugr`.")]
165165
#[from(ignore)]
166166
ZstdUnsupported,
167-
/// Tried to encode a package with multiple HUGRs, when only 1 was expected.
168-
#[display(
169-
"Packages with multiple HUGRs are currently unsupported. Tried to encode {count} HUGRs, when 1 was expected."
170-
)]
171-
#[from(ignore)]
172-
/// Deprecated: Packages with multiple HUGRs is a legacy feature that is no longer supported.
173-
#[deprecated(since = "0.15.2", note = "Multiple HUGRs are supported via packages.")]
174-
MultipleHugrs {
175-
/// The number of HUGRs in the package.
176-
count: usize,
177-
},
178167
/// JSON serialization error.
179168
SerdeError {
180169
/// The source error.

hugr-llvm/src/extension/collections/array.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,9 @@ mod test {
892892
use hugr_core::extension::prelude::either_type;
893893
use hugr_core::ops::Tag;
894894
use hugr_core::std_extensions::collections::array::op_builder::build_all_array_ops;
895-
use hugr_core::std_extensions::collections::array::{self, array_type, ArrayRepeat, ArrayScan};
895+
use hugr_core::std_extensions::collections::array::{
896+
self, array_type, ArrayOpBuilder, ArrayRepeat, ArrayScan,
897+
};
896898
use hugr_core::std_extensions::STD_REG;
897899
use hugr_core::types::Type;
898900
use hugr_core::{
@@ -919,7 +921,7 @@ mod test {
919921
check_emission,
920922
emit::test::SimpleHugrConfig,
921923
test::{exec_ctx, llvm_ctx, TestContext},
922-
utils::{ArrayOpBuilder, IntOpBuilder, LogicOpBuilder},
924+
utils::{IntOpBuilder, LogicOpBuilder},
923925
};
924926

925927
#[rstest]

hugr-llvm/src/extension/int.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,31 +1114,7 @@ fn emit_const_int<'c, H: HugrView<Node = Node>>(
11141114
Ok(ty.const_int(k.value_u(), false).as_basic_value_enum())
11151115
}
11161116

1117-
/// Populates a [CodegenExtsBuilder] with all extensions needed to lower int
1118-
/// ops, types, and constants.
1119-
///
1120-
/// Any ops that panic will do so using [DefaultPreludeCodegen].
1121-
#[deprecated]
1122-
pub fn add_int_extensions<'a, H: HugrView<Node = Node> + 'a>(
1123-
cem: CodegenExtsBuilder<'a, H>,
1124-
) -> CodegenExtsBuilder<'a, H> {
1125-
cem.add_extension(IntCodegenExtension(DefaultPreludeCodegen))
1126-
}
1127-
11281117
impl<'a, H: HugrView<Node = Node> + 'a> CodegenExtsBuilder<'a, H> {
1129-
/// Populates a [CodegenExtsBuilder] with all extensions needed to lower int
1130-
/// ops, types, and constants.
1131-
///
1132-
/// Any ops that panic will do so using [DefaultPreludeCodegen].
1133-
///
1134-
/// # Deprecated
1135-
///
1136-
/// This method is deprecated in favor of [Self::add_default_int_extensions].
1137-
#[deprecated]
1138-
pub fn add_int_extensions(self) -> Self {
1139-
self.add_default_int_extensions()
1140-
}
1141-
11421118
/// Populates a [CodegenExtsBuilder] with all extensions needed to lower int
11431119
/// ops, types, and constants.
11441120
///

hugr-llvm/src/utils.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
//! Module for utilities that do not depend on LLVM. These are candidates for
22
//! upstreaming.
3-
#[deprecated(note = "This module is deprecated and will be removed in a future release.")]
4-
pub mod array_op_builder;
53
pub mod fat;
64
pub mod inline_constant_functions;
75
pub mod int_op_builder;
86
pub mod logic_op_builder;
97
pub mod type_map;
108

11-
#[deprecated(note = "Import from hugr_core::std_extensions::collections::array.")]
12-
pub use hugr_core::std_extensions::collections::array::ArrayOpBuilder;
139
pub use inline_constant_functions::inline_constant_functions;
1410
pub use int_op_builder::IntOpBuilder;
1511
pub use logic_op_builder::LogicOpBuilder;

hugr-llvm/src/utils/array_op_builder.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

hugr-passes/src/dataflow.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub use partial_value::{AbstractValue, AsConcrete, LoadedFunction, PartialSum, P
1313

1414
use hugr_core::ops::constant::OpaqueValue;
1515
use hugr_core::ops::{ExtensionOp, Value};
16-
use hugr_core::types::TypeArg;
1716
use hugr_core::Hugr;
1817

1918
/// Clients of the dataflow framework (particular analyses, such as constant folding)
@@ -73,18 +72,6 @@ pub trait ConstLoader<V> {
7372
fn value_from_const_hugr(&self, _loc: ConstLocation<Self::Node>, _h: &Hugr) -> Option<V> {
7473
None
7574
}
76-
77-
/// Produces an abstract value from a [FuncDefn] or [FuncDecl] node
78-
/// (that has been loaded via a [LoadFunction]), if possible.
79-
/// The default just returns `None`, which will be interpreted as [PartialValue::Top].
80-
///
81-
/// [FuncDefn]: hugr_core::ops::FuncDefn
82-
/// [FuncDecl]: hugr_core::ops::FuncDecl
83-
/// [LoadFunction]: hugr_core::ops::LoadFunction
84-
#[deprecated(note = "Automatically handled by Datalog, implementation will be ignored")]
85-
fn value_from_function(&self, _node: Self::Node, _type_args: &[TypeArg]) -> Option<V> {
86-
None
87-
}
8875
}
8976

9077
/// Produces a [PartialValue] from a constant. Traverses [Sum](Value::Sum) constants

hugr-passes/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ pub mod merge_bbs;
1818
mod monomorphize;
1919
pub mod untuple;
2020

21-
// TODO: Deprecated re-export. Remove on a breaking release.
22-
#[deprecated(
23-
since = "0.14.1",
24-
note = "Use `hugr_passes::RemoveDeadFuncsPass` instead."
25-
)]
26-
#[allow(deprecated)]
27-
pub use monomorphize::remove_polyfuncs;
2821
pub use monomorphize::{mangle_name, monomorphize, MonomorphizePass};
2922
pub mod replace_types;
3023
pub use replace_types::ReplaceTypes;

hugr-passes/src/monomorphize.rs

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use hugr_core::{
1010
Node,
1111
};
1212

13-
use hugr_core::hugr::{hugrmut::HugrMut, Hugr, HugrView, OpType};
13+
use hugr_core::hugr::{hugrmut::HugrMut, HugrView, OpType};
1414
use itertools::Itertools as _;
1515

1616
use crate::composable::{validate_if_test, ValidatePassError};
@@ -38,40 +38,6 @@ pub fn monomorphize(
3838
validate_if_test(MonomorphizePass, hugr)
3939
}
4040

41-
/// Removes any polymorphic [FuncDefn]s from the Hugr. Note that if these have
42-
/// calls from *monomorphic* code, this will make the Hugr invalid (call [monomorphize]
43-
/// first).
44-
///
45-
/// Deprecated: use [crate::remove_dead_funcs] instead.
46-
#[deprecated(
47-
since = "0.14.1",
48-
note = "Use hugr_passes::RemoveDeadFuncsPass instead"
49-
)]
50-
pub fn remove_polyfuncs(mut h: Hugr) -> Hugr {
51-
#[allow(deprecated)] // we are in a deprecated function, so remove both at same time
52-
remove_polyfuncs_ref(&mut h);
53-
h
54-
}
55-
56-
#[deprecated(
57-
since = "0.14.1",
58-
note = "Use hugr_passes::RemoveDeadFuncsPass instead"
59-
)]
60-
fn remove_polyfuncs_ref(h: &mut impl HugrMut<Node = Node>) {
61-
let mut pfs_to_delete = Vec::new();
62-
let mut to_scan = Vec::from_iter(h.children(h.entrypoint()));
63-
while let Some(n) = to_scan.pop() {
64-
if is_polymorphic_funcdefn(h.get_optype(n)) {
65-
pfs_to_delete.push(n)
66-
} else {
67-
to_scan.extend(h.children(n));
68-
}
69-
}
70-
for n in pfs_to_delete {
71-
h.remove_subtree(n);
72-
}
73-
}
74-
7541
fn is_polymorphic(fd: &FuncDefn) -> bool {
7642
!fd.signature.params().is_empty()
7743
}
@@ -243,10 +209,8 @@ fn instantiate(
243209
/// Replaces calls to polymorphic functions with calls to new monomorphic
244210
/// instantiations of the polymorphic ones.
245211
///
246-
/// If the Hugr is [Module](OpType::Module)-rooted,
247-
/// * then the original polymorphic [FuncDefn]s are left untouched (including Calls inside them)
248-
/// - call [remove_polyfuncs] when no other Hugr will be linked in that might instantiate these
249-
/// * else, the originals are removed (they are invisible from outside the Hugr).
212+
/// The original polymorphic [FuncDefn]s are left untouched (including Calls inside them).
213+
/// Call [crate::remove_dead_funcs] to remove them.
250214
///
251215
/// If the Hugr is [FuncDefn](OpType::FuncDefn)-rooted with polymorphic
252216
/// signature then the HUGR will not be modified.
@@ -268,10 +232,6 @@ impl ComposablePass for MonomorphizePass {
268232
// If the root is a polymorphic function, then there are no external calls, so nothing to do
269233
if !is_polymorphic_funcdefn(h.get_optype(root)) {
270234
mono_scan(h, root, None, &mut HashMap::new());
271-
if !h.get_optype(root).is_module() {
272-
#[allow(deprecated)] // TODO remove in next breaking release and update docs
273-
remove_polyfuncs_ref(h);
274-
}
275235
}
276236
Ok(())
277237
}
@@ -578,14 +538,15 @@ mod test {
578538
&mangle_name(&pf2_name, &[TypeArg::BoundedNat { n: 4 }, arr2u().into()]), // from pf1<4>
579539
&mangle_name(&pf2_name, &[TypeArg::BoundedNat { n: 2 }, usize_t().into()]), // from both pf1<4> and <5>
580540
&mangle_inner_func(&pf2_name, "get_usz"),
581-
"mainish"
541+
&pf2_name,
542+
"mainish",
543+
"pf1"
582544
]
583545
.into_iter()
584546
.sorted()
585547
.collect_vec()
586548
);
587549
for (n, fd) in funcs.into_values() {
588-
assert!(!is_polymorphic(fd));
589550
if n == mono_hugr.entrypoint() {
590551
assert_eq!(fd.name, "mainish");
591552
} else {
@@ -633,7 +594,6 @@ mod test {
633594
let mono_hugr = hugr;
634595

635596
let mut funcs = list_funcs(&mono_hugr);
636-
assert!(funcs.values().all(|(_, fd)| !is_polymorphic(fd)));
637597
#[allow(clippy::unnecessary_to_owned)] // It is necessary
638598
let (m, _) = funcs.remove(&"id2".to_string()).unwrap();
639599
assert_eq!(m, mono.handle().node());

0 commit comments

Comments
 (0)