-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Improve handling of rustc_private #7891
Conversation
This is a hack to work around miri being included in our analysis of rustc-dev Really, we should probably use an include set of the actual root libraries I'm not sure how those are determined however
Never mind, we have the |
This gives the advantage that A future extension would be to check for `feature(rustc_private)` instead
Also add some more detailed comments Extract into function deleted the previous comments
Packages which probably currently use rustc_private and rust-analyzer:
|
It's worse than I thought...
In rustc_codegen_cranelift I don't use |
This PR should also significantly reduce memory usage from using (This is because we now only index the crates brought in by rustc-dev, instead of all crates in |
I just tried it out. The memory usage is indeed lower. However it tried to run |
@bjorn3 I've added a setting which could help - |
crates/rust-analyzer/src/config.rs
Outdated
/// Disable running build scripts (`build.rs`) for the `rustc_private` crates in `rustcSource`. | ||
cargo_disableRustcBuildScripts: bool = "false", |
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.
Let's move this and rustcSource
into rustc_private
section, so that we have
"rustcPrivate.src": ...,
"rustcPrivate.runBuildScripts": ...,
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.
Would cargo.rustcPrivate.runBuildScripts
and cargo.rustcPrivate.src
make sense? Since we only have special behaviour for the rustcSource for cargo, afaik.
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.
I'd rathe keep it top level. The fact that it is rustcPrivate
is more important than that it is cargo
.
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.
but no strong opinion here!
This looks good to me! I am a bit hesitant about putting Hm, now that I've spelled this out, I wonder if we can do somthing worse :D Can we just read |
I think we can just bypass VFS here and use just EDIT: seems to fancy, and without a clear place to report an error, lets keep this as a key in metadata. |
This will break if only one crate in the workspace uses rustc_private (unless you mean to do this for each crate?) |
A setting seems kind of weird, |
bors r+ |
7891: Improve handling of rustc_private r=matklad a=DJMcNab This PR changes how `rust-analyzer` handles `rustc_private`. In particular, packages now must opt-in to using `rustc_private` in `Cargo.toml`, by adding: ```toml [package.metadata.rust-analyzer] rustc_private=true ``` This means that depending on crates which also use `rustc_private` will be significantly improved, since their dependencies on the `rustc_private` crates will be resolved properly. A similar approach could be used in #6714 to allow annotating that your package uses the `test` crate, although I have not yet handled that in this PR. Additionally, we now only index the crates which are transitive dependencies of `rustc_driver` in the `rustcSource` directory. This should not cause any change in behaviour when using `rustcSource: "discover"`, as the source used then will only be a partial clone. However, if `rustcSource` pointing at a local checkout of rustc, this should significantly improve the memory usage and lower indexing time. This is because we avoids indexing all crates in `src/tools/`, which includes `rust-analyzer` itself. Furthermore, we also prefer named dependencies over dependencies from `rustcSource`. This ensures that feature resolution for crates which are depended on by both `rustc` and your crate uses the correct set for analysing your crate. See also [introductory zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229086673) I have tested this in [priroda](https://github.com/oli-obk/priroda/), and it provides a significant improvement to the development experience (once I give `miri` the required data in `Cargo.toml`) Todo: - [ ] Documentation This is ready to review, and I will add documentation if this would be accepted (or if I get time to do so anyway) Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Canceled. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔒 Permission denied Existing reviewers: click here to make DJMcNab a reviewer |
bors r+ |
This is suggested to make the dependency on rustc internals explicit in the crate manifest; see rust-lang/rust-analyzer#7891 for some more details. This change adds this hint to all crates that use `#![feature(rustc_private)]`.
Opt-in to rustc_private for `rust-analyzer` rust-lang/rust-analyzer#7891 changelog: none This will also help priroda and any other package which depends on the `miri` library crate.
This is suggested to make the dependency on rustc internals explicit in the crate manifest; see rust-lang/rust-analyzer#7891 for some more details. This change adds this hint to all crates that use `#![feature(rustc_private)]`.
Opt-in to rustc_private for `rust-analyzer` rust-lang/rust-analyzer#7891
Opt-in to rustc_private for `rust-analyzer` rust-lang/rust-analyzer#7891
This PR changes how
rust-analyzer
handlesrustc_private
. In particular, packages now must opt-in to usingrustc_private
inCargo.toml
, by adding:This means that depending on crates which also use
rustc_private
will be significantly improved, since their dependencies on therustc_private
crates will be resolved properly.A similar approach could be used in #6714 to allow annotating that your package uses the
test
crate, although I have not yet handled that in this PR.Additionally, we now only index the crates which are transitive dependencies of
rustc_driver
in therustcSource
directory. This should not cause any change in behaviour when usingrustcSource: "discover"
, as the source used then will only be a partial clone. However, ifrustcSource
pointing at a local checkout of rustc, this should significantly improve the memory usage and lower indexing time. This is because we avoids indexing all crates insrc/tools/
, which includesrust-analyzer
itself.Furthermore, we also prefer named dependencies over dependencies from
rustcSource
. This ensures that feature resolution for crates which are depended on by bothrustc
and your crate uses the correct set for analysing your crate.See also introductory zulip stream
I have tested this in priroda, and it provides a significant improvement to the development experience (once I give
miri
the required data inCargo.toml
)Todo:
This is ready to review, and I will add documentation if this would be accepted (or if I get time to do so anyway)