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

Add a request for setting response prefix #16032

Closed
wants to merge 1 commit into from

Conversation

vlad20012
Copy link
Member

@vlad20012 vlad20012 commented Dec 5, 2023

Currently, if a proc macro prints something to the stdout (println!("stuff {{}}")) the output mixes with the proc-macro-srv protocol messages (proc-macro-srv uses stdout to communicate with rust-analyzer) and rust-analyzer then can't distinguish proc-macro-srv JSON messages from the output from the proc macro.

My idea is to prepend proc-macro-srv protocol messages with some long string, and then skip the proc-macro-srv process output in rust-analyzer until that known string (a bit similar to how Ethernet framing works). I.e. the proc-macro-srv message should look like "OsdgHOghs895whrhg598{response_fields: {...}}"

I don't want to hardcode some specific string because it could be exploited by some macro, or that string could become a problem if we decide to place that string inside a macro in rust-analyzer itself. So I think we should generate a random string.

I added a new requst type msg::Request::SetExpanderSettings with response_prefix field in order to delegate random string generation to rust-analyzer (and keep the proc-macro-srv implementation as simple as possible).

In this PR I just change the proc-macro-srv part

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 5, 2023
@vlad20012 vlad20012 changed the title Add RA_EXPAND_MACRO_RESPONSE_PREFIX Add a request for setting response prefix Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants