Stream: t-compiler/rust-analyzer

Topic: Semantics Database Questions

pksunkara (May 24 2020 at 15:47, on Zulip):

Hey all. I have CallExpr syntax node. How do I resolve the the function semantically? For MethodCallExpr I did semantics.resolve_method_call like @Laurențiu Nicola suggested. And I followed similarly for other stuff. But I am stumped for this. For example, I have a call expr Subcommand::from("help"). How can I find if call_expr.expr is resolved to Subcommand::from?

pksunkara (May 24 2020 at 15:50, on Zulip):

I want to catch cases for (Subcommand::from)("help") and (|| Subcommand::from)()("help") etc..

pksunkara (May 24 2020 at 15:51, on Zulip):

Or I guess, I could alternatively try to find whether from in a path expr end resolves to Subcommand::from

Florian Diebold (May 24 2020 at 20:02, on Zulip):

you get the type of the callee and inspect it, e.g. using as_callable

pksunkara (May 25 2020 at 07:16, on Zulip):

Thanks, that worked.

Last update: Jul 27 2021 at 22:45UTC