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

rust_analyzer: generate more reqired sources #3031

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sam-mccall
Copy link
Contributor

The existing support for this has limitations:

  • only works for sources that are specially tagged (rust_generated_srcs).
    I've removed this mechanism as it's no longer needed.
  • only provides sources of the directly selected library, but
    rust-analyzer needs to parse its dependencies too.
  • is missing the target.json file, which rust-analyzer requires to
    parse the library (it invokes rustc --print cfg --target=...)

The dependency depth to generate sources for is a tradeoff. More layers
of deps will give more accurate analysis but be slower to generate.

My guess is that in the end we'll want full transitive sources, but
direct deps should be a non-controversial starting point. (Without these
sources, rust-analyzer can't understand the direct API usage at all).
We can change this later and probably need to reconcile with #3028.

The existing support for this has limitations:

- only works for sources that are specially tagged (rust_generated_srcs).
  I've removed this mechanism as it's no longer needed.
- only provides sources of the directly selected library, but
  rust-analyzer needs to parse its dependencies too.
- is missing the target.json file, which rust-analyzer requires to
  parse the library (it invokes rustc --print cfg --target=...)

The dependency depth to generate sources for is a tradeoff. More layers
of deps will give more accurate analysis but be slower to generate.

My guess is that in the end we'll want full transitive sources, but
direct deps should be a non-controversial starting point. (Without these
sources, rust-analyzer can't understand the direct API usage at all).
We can change this later and probably need to reconcile with bazelbuild#3028.
@krasimirgg krasimirgg self-requested a review December 5, 2024 12:10
@krasimirgg
Copy link
Collaborator

The changes to rust_analyzer look good. I'm not sure if the rust_generated_srcs output group is used for anything else though?

It would be nice to add some tests to make sure that the expected sources are made available to the expected actions.

Copy link
Collaborator

@krasimirgg krasimirgg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry I left a comment in the wrong review state) The changes to rust_analyzer look good. I'm not sure if the rust_generated_srcs output group is used for anything else though?

It would be nice to add some tests to make sure that the expected sources are made available to the expected actions.

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

Successfully merging this pull request may close these issues.

2 participants