|
36 | 36 | //! ``` |
37 | 37 | //! |
38 | 38 | //! # Using the `#[manyhow]` macro |
39 | | -//! To activate the error hadling, just add [`#[manyhow]`](manyhow) above any |
| 39 | +//! To activate the error handling, just add [`#[manyhow]`](manyhow) above any |
40 | 40 | //! proc-macro implementation, reducing the above example to: |
41 | 41 | //! |
42 | 42 | //! ``` |
|
70 | 70 | //! See [Without macros](#without-macros) to see what this expands to under the |
71 | 71 | //! hood. |
72 | 72 | //! |
73 | | -//! You can also use the `#[manyhow]` attrubutes on a use statement, useful when |
74 | | -//! moving your proc-macro implementations in seperate modules. |
| 73 | +//! You can also use the `#[manyhow]` attributes on a use statement, useful when |
| 74 | +//! moving your proc-macro implementations in separate modules. |
75 | 75 | //! |
76 | 76 | //! ``` |
77 | 77 | //! # use quote::quote; |
|
98 | 98 | //! |
99 | 99 | //! A proc macro function marked as `#[manyhow]` can take and return any |
100 | 100 | //! [`TokenStream`](AnyTokenStream), and can also return `Result<TokenStream, |
101 | | -//! E>` where `E` implments [`ToTokensError`]. As additional parameters a |
| 101 | +//! E>` where `E` implements [`ToTokensError`]. As additional parameters a |
102 | 102 | //! [dummy](#dummy-mut-tokenstream) and/or [emitter](#emitter-mut-emitter) can |
103 | 103 | //! be specified. |
104 | 104 | //! |
|
226 | 226 | //! macro. |
227 | 227 | //! - `syn`/`syn2` **default** Enables errors for [`syn` 2.x](https://docs.rs/syn/latest/syn/). |
228 | 228 | //! - `syn1` Enables errors for [`syn` 1.x](https://docs.rs/syn/1.0.109/syn/index.html). |
229 | | -//! - `darling` Enables erros for [`darling`](https://docs.rs/darling/latest/index.html). |
| 229 | +//! - `darling` Enables errors for [`darling`](https://docs.rs/darling/latest/index.html). |
230 | 230 |
|
231 | 231 | #[cfg(feature = "macros")] |
232 | 232 | pub use macros::manyhow; |
@@ -290,9 +290,13 @@ macro_rules! __macro_handler { |
290 | 290 | )+ $($dummy,)? implementation) |
291 | 291 | { |
292 | 292 | Err(tokens) => tokens.into(), |
293 | | - Ok((output, mut tokens)) => { |
| 293 | + Ok((output, mut tokens, mut dummy)) => { |
294 | 294 | match (&$crate::__private::WhatType::from(&output)).manyhow_try(output) { |
295 | | - Err(error) => (&$crate::__private::WhatType::from(&error)).manyhow_to_tokens(error, &mut tokens), |
| 295 | + Err(error) => { |
| 296 | + dummy.extend(tokens); |
| 297 | + tokens = dummy; |
| 298 | + (&$crate::__private::WhatType::from(&error)).manyhow_to_tokens(error, &mut tokens); |
| 299 | + }, |
296 | 300 | Ok(output) => (&$crate::__private::WhatType::from(&output)).manyhow_to_tokens(output, &mut tokens), |
297 | 301 | }; |
298 | 302 | tokens.into() |
@@ -762,7 +766,7 @@ macro_rules! macro_input { |
762 | 766 | /// |
763 | 767 | /// Trait is implemented for any [`function`](FnOnce), taking in |
764 | 768 | #[doc = concat!($token_streams, ".")] |
765 | | - /// Additionally they can take optionally in any order a [`&mut |
| 769 | + /// Additionally, they can take optionally in any order a [`&mut |
766 | 770 | /// Emitter`](Emitter) which allows emitting errors without returning early. And |
767 | 771 | /// a `&mut TokenStream` to return a dummy `TokenStream` on failure. |
768 | 772 | /// |
|
0 commit comments