-
Notifications
You must be signed in to change notification settings - Fork 1.9k
proc-macro-srv: support file and local_file via bidirectional callbacks #21377
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
proc-macro-srv: support file and local_file via bidirectional callbacks #21377
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do local file name and file name differ for us here? I'd expect both of the functions to return the same results for us, reading the corresponding function docs https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.file and https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.local_file
Ahh, right, fetch the local filename first, and if that doesn’t exist, fall back to manually constructing it. I was too focused on the display-side logic for the filename and totally missed the obvious. Thanks for pointing it out! |
|
No my point was more that for rust-analyzer, both functions will effectively return the same info. rustc has some extra stuff like path remapping and what not that are only handled in one of the two functions, we don't though. Also ntoably, both functions are supposed to return full paths, not just file names. |
|
After some more thought, the suggestion clicked. I’ve aligned filename and localfilename so they now emit the same info. Thanks for the suggestion, it helped me understand this part better. |
|
There is still some slight confusion here I think, your implementation returns the file name only, but it should really return the entire file path. That is, these are also misnamed as they are about the full path, not just the file name. |
20bf54f to
1684686
Compare
1684686 to
26b3c82
Compare
Shoot, thanks for mentioning that. Ah!!! my bad... so sorry, I completely mixed it with filename for some reason. Updated. |
This PR extends the proc-macro bidirectional protocol to support Span::file() and Span::local_file().