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
Hi, I am working on a project that requires me to somehow modify AST (or I think that's the best option I have). Specifically, I would like to wrap/replace some specific function calls with a call to a closure. I found that closures cannot be defined at MIR level as they require DefIds. My plan so far is, running the compiler the first time and find out which calls I want to modify and saving their NodeIds. Then, I run the compiler again, and during AST expansion, I try to replace the calls I'm interested in. The challenge is, this is breaking the compiler, either because I'm not doing it right, or I'm supposed to tackle it a different way. Any advice on how to proceed would be most appreciated.
This is what I have so far, but it fails to pass the typechecker, saying DefId{0:0} does not exist. For some reason I'm messing up the original crate.
Hi, I am working on a project that requires me to somehow modify AST (or I think that's the best option I have). Specifically, I would like to wrap/replace some specific function calls with a call to a closure. I found that closures cannot be defined at MIR level as they require DefIds. My plan so far is, running the compiler the first time and find out which calls I want to modify and saving their NodeIds. Then, I run the compiler again, and during AST expansion, I try to replace the calls I'm interested in. The challenge is, this is breaking the compiler, either because I'm not doing it right, or I'm supposed to tackle it a different way. Any advice on how to proceed would be most appreciated.
This is what I have so far, but it fails to pass the typechecker, saying DefId{0:0} does not exist. For some reason I'm messing up the original crate.
`pub fn wrap_extern_calls(
krate: &mut ast::Crate,
sess: &Session,
resolver: &mut dyn ResolverExpand,
crate_name: String,
features: &Features
) {
struct ExternCallVisitor<'a> {
extern_calls: FxHashSet,
ext_cx: ExtCtxt<'a>
}
}
Thanks in advance.
The text was updated successfully, but these errors were encountered: