You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a piece of code rudely extracted from my playing-around:
syn::ItemKind::Fn(_, _, _, _, _, block) => {for stmt in block.stmts{match stmt {
syn::Stmt::Expr(i) => {// i.node; // `node` is privateprintln!("e {:?}", i);// but I can see the interesting block under here}
_ => unimplemented!(),}}// Descend}
I am trying to parse this code:
pubfnunsafe_block_inside(){unsafe{}}
My goal is to be able to answer a "simple" true/false question: does a crate use unsafe code? If you have pointers for a better way I should be doing that, I'd much appreciate it!
Thanks for making such a useful library! ❤️
The text was updated successfully, but these errors were encountered:
One thing that would be helpful here is #44, some syn equivalent to libsyntax's visit module. Then implementing something like "does a crate use unsafe code" is a matter of writing a single Visitor with just a few methods implemented (visit_expr to check for an unsafe block, visit_item to check for an unsafe fn, maybe a couple more). Sounds like you'll be doing most of that work anyway to recursively walk through the entire tree of expressions. I would be delighted if you have the extra time to factor that into a syn visitor crate, even if it isn't fully complete and I can follow up from there to add the rest of the syntax when I have time.
Thanks for the quick fix! I'll skim over visit and see how close I am. One thing is that I don't care at all about visitation order, so I can be very slapdash about which nodes I visit.
Here's a piece of code rudely extracted from my playing-around:
I am trying to parse this code:
My goal is to be able to answer a "simple" true/false question: does a crate use
unsafe
code? If you have pointers for a better way I should be doing that, I'd much appreciate it!Thanks for making such a useful library! ❤️
The text was updated successfully, but these errors were encountered: