aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-20 04:22:43 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-20 04:22:43 +0800
commitf6113a33f782d1eabd350e3b34ce8de2cec2f8d3 (patch)
treeeef1ce51194d467a50901ade540a60c3374527fb /mingling_macros/src/lib.rs
parent12d8b602415f1c0688f47c8f002e48a4de1c683c (diff)
feat(routeify): map `?` span to `route!` for tooling support
Use the span of the `?` token when generating the macro invocation in the `#[routeify]` transformation, so that rust-analyzer resolves hover and go-to-definition on `?` to the `route!` macro's documentation
Diffstat (limited to 'mingling_macros/src/lib.rs')
-rw-r--r--mingling_macros/src/lib.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index a85648f..be355cd 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -511,6 +511,28 @@ pub fn pack_err_structural(input: TokenStream) -> TokenStream {
/// directly, while the `Err` value is converted via `Routable::to_chain()` and
/// returned early.
///
+/// ## Interaction with `#[routeify]`
+///
+/// The [`#[routeify]`](attr.routeify.html) attribute macro automatically replaces
+/// every `expr?` inside a function with `route!(expr)`. This means you can use the
+/// familiar `?` syntax in chain functions instead of writing `route!(...)`
+/// explicitly:
+///
+/// ```rust,ignore
+/// use mingling::macros::chain;
+///
+/// #[chain(routeify)]
+/// fn process(prev: SomeEntry) -> Next {
+/// // `?` here expands to `route!(...)` → this macro → the match block
+/// let value = some_fallible_call()?;
+/// value.to_chain()
+/// }
+/// ```
+///
+/// Because `#[routeify]` maps the span of `?` to this macro, hovering over `?` in
+/// a `#[routeify]` function will display this documentation — explaining what
+/// the `?` actually expands to.
+///
/// # Example
///
/// ```rust,ignore