Skip to content

Commit b88349d

Browse files
committed
fix: begin to handle comments in super random places
1 parent 5c1b331 commit b88349d

19 files changed

Lines changed: 3925 additions & 125 deletions

File tree

crates/macros/src/lib.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use syn::{parse_macro_input, visit_mut::VisitMut, ImplItem};
55

66
struct ReplaceQuestions {
77
name: syn::Type,
8-
count: usize,
98
}
109

1110
impl VisitMut for ReplaceQuestions {
@@ -16,23 +15,22 @@ impl VisitMut for ReplaceQuestions {
1615

1716
// let name = syn::LitStr::new(&self.name, self.span);
1817
let e = &try_expr.expr;
19-
// *i = syn::parse_quote! {
20-
// match #e {
21-
// ::core::result::Result::Ok(v) => v,
22-
// ::core::result::Result::Err(e) => {
23-
// panic!(#name);
24-
// // return Err(e.context("oh no"));
25-
// }
26-
// }
27-
// };
28-
29-
self.count += 1;
3018
let name = &self.name;
31-
// let count = &self.count;
32-
3319
*i = syn::parse_quote! {
34-
#e.expect(&format!("{}.{}", stringify!(#name), stringify!(#e)))
35-
}
20+
match #e {
21+
::core::result::Result::Ok(v) => v,
22+
::core::result::Result::Err(e) => {
23+
// panic!(#name);
24+
return Err(::anyhow::anyhow!(
25+
format!("{}\n- {}::{}", e, stringify!(#name), stringify!(#e))
26+
));
27+
}
28+
}
29+
};
30+
31+
// *i = syn::parse_quote! {
32+
// #e.expect(&format!("{}.{}", stringify!(#name), stringify!(#e)))
33+
// }
3634
}
3735
_ => syn::visit_mut::visit_expr_mut(self, i),
3836
}
@@ -48,7 +46,6 @@ pub fn parse_context(_attr: TokenStream, tokens: TokenStream) -> TokenStream {
4846
ImplItem::Method(_) => {
4947
let mut replacer = ReplaceQuestions {
5048
name: *input.self_ty.clone(),
51-
count: 0,
5249
};
5350

5451
replacer.visit_impl_item_mut(&mut item);

0 commit comments

Comments
 (0)