This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new b94b787b [Rust] Remove WalkResult::interrupt_with (#927)
b94b787b is described below
commit b94b787b3da8def992e210e88702c80cdb86af61
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Nov 4 20:04:25 2026 -0500
[Rust] Remove WalkResult::interrupt_with (#927)
This PR removes `WalkResult::interrupt_with`. `WalkResult` is a plain
enum, so a handler builds the payload variant directly, as with std's
`ControlFlow::Break(value)`:
```rust
return WalkResult::InterruptWith(value.into());
```
The helper only added `.into()` and gave the variant a second spelling.
The Rust guide and the tests now use the variant.
---
docs/guides/rust_lang_guide.rst | 4 ++--
rust/tvm-ffi/src/extra/structural_walk.rs | 8 --------
rust/tvm-ffi/tests/test_structural_visit.rs | 6 +++---
3 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/docs/guides/rust_lang_guide.rst b/docs/guides/rust_lang_guide.rst
index 3414cb7d..e780bf06 100644
--- a/docs/guides/rust_lang_guide.rst
+++ b/docs/guides/rust_lang_guide.rst
@@ -717,7 +717,7 @@ take a trailing ``DefRegionKind`` argument:
Both entry points return ``Result<Option<VisitInterrupt>>``: ``Ok(None)`` means
the whole graph was visited, and a handler stops the walk early by returning
-``WalkResult::interrupt_with(payload)``, which comes back to the caller as
+``WalkResult::InterruptWith(payload)``, which comes back to the caller as
``Ok(Some(interrupt))``. Handlers may also return ``Result<WalkResult>`` and
propagate errors with ``?``:
@@ -730,7 +730,7 @@ propagate errors with ``?``:
&values,
|value: i64| {
if value == 2 {
- return WalkResult::interrupt_with(value);
+ return WalkResult::InterruptWith(value.into());
}
WalkResult::Advance
},
diff --git a/rust/tvm-ffi/src/extra/structural_walk.rs
b/rust/tvm-ffi/src/extra/structural_walk.rs
index a12a50a0..432bd70b 100644
--- a/rust/tvm-ffi/src/extra/structural_walk.rs
+++ b/rust/tvm-ffi/src/extra/structural_walk.rs
@@ -45,14 +45,6 @@ pub enum WalkResult {
InterruptWith(Any),
}
-impl WalkResult {
- /// Halt traversal with an FFI-compatible payload.
- #[inline(always)]
- pub fn interrupt_with<T: Into<Any>>(payload: T) -> Self {
- Self::InterruptWith(payload.into())
- }
-}
-
/// Convert either an infallible or fallible typed handler result.
///
/// This keeps simple handlers terse while allowing a handler to return
diff --git a/rust/tvm-ffi/tests/test_structural_visit.rs
b/rust/tvm-ffi/tests/test_structural_visit.rs
index f7833062..5052c2bb 100644
--- a/rust/tvm-ffi/tests/test_structural_visit.rs
+++ b/rust/tvm-ffi/tests/test_structural_visit.rs
@@ -521,7 +521,7 @@ fn primitive_fast_path_preserves_none_interrupt_and_error()
{
let interrupt = structural_walk(
&1i64,
- |_value: i64| WalkResult::interrupt_with(9i64),
+ |_value: i64| WalkResult::InterruptWith(9i64.into()),
WalkOrder::PostOrder,
)
.unwrap()
@@ -574,7 +574,7 @@ fn interrupt_payload_crosses_map_traversal() {
&root,
|value: AnyView<'_>| {
if value.try_as::<i64>().is_some() {
- return WalkResult::interrupt_with(99i64);
+ return WalkResult::InterruptWith(99i64.into());
}
WalkResult::Advance
},
@@ -1009,7 +1009,7 @@ fn interrupt_payload_is_returned_to_the_caller() {
&root,
|value: AnyView<'_>| {
if value.try_as::<i64>() == Some(1) {
- return WalkResult::interrupt_with(42i64);
+ return WalkResult::InterruptWith(42i64.into());
}
WalkResult::Advance
},