Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tonic build output to src/xxx #253

Closed
hzxuzhonghu opened this issue Dec 7, 2022 · 9 comments
Closed

make tonic build output to src/xxx #253

hzxuzhonghu opened this issue Dec 7, 2022 · 9 comments

Comments

@hzxuzhonghu
Copy link
Member

so that we could use that mod directly and vscode can jump to the definition of the generated code

@howardjohn
Copy link
Member

goland can jump to it fwiw, are you sure vscode cannot?

storing generated code in tree doesn't seem common in rust

@hzxuzhonghu
Copy link
Member Author

Yes, my vscode could not. I am using windows and developing via vscode ssh.

I tried to change to goland ssh, but the goland cost is very huge.

@howardjohn
Copy link
Member

This is explicitly not recommended: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script. Tools like https://github.com/dtolnay/cargo-expand can help, also looks like maybe some vscode settings: rust-lang/rust-analyzer#5799

@hzxuzhonghu
Copy link
Member Author

rust-lang/rust-analyzer#5799 This does not help

@stevenctl
Copy link
Contributor

macro expansion is part of rust-analyzer. It's a little less ergonomic to first jump to the macro, then trigger this but it works well enough to skim the generated code as needed. My setup (vim) doesn't give me any proper code navigation within the expanded macro though. Not sure if CLion does.

I don't think you need any settings, just trigger this action: rust-analyzer: Expand macro recursively

source: https://rust-analyzer.github.io/manual.html#expand-macro-recursively

@hzxuzhonghu
Copy link
Member Author

Let me have a try

@hzxuzhonghu
Copy link
Member Author

After config as https://github.com/hyperium/tonic#getting-started

If you're using [rust-analyzer](https://rust-analyzer.github.io/) we recommend you set "rust-analyzer.cargo.buildScripts.enable": true to correctly load the generated code.

it can jump to macro here https://github.com/istio/ztunnel/blob/master/src/xds/types.rs#L31-L36

And then trigger this action: rust-analyzer: Expand macro recursively, it can show the generated file

@daixiang0
Copy link
Member

After config as https://github.com/hyperium/tonic#getting-started

If you're using [rust-analyzer](https://rust-analyzer.github.io/) we recommend you set "rust-analyzer.cargo.buildScripts.enable": true to correctly load the generated code.

it can jump to macro here https://github.com/istio/ztunnel/blob/master/src/xds/types.rs#L31-L36

And then trigger this action: rust-analyzer: Expand macro recursively, it can show the generated file

Does it support autojump? I test at local, it can show but can not jump.

@hzxuzhonghu
Copy link
Member Author

No it does not support autojump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants