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
CARGO: fetch actual info about stdlb #6417
Conversation
95dead3
to
83cb266
Compare
6438: STUB: create stubs for lifetime parameters only if needed r=vlad20012 a=Undin Original issue was found in [gimli](https://github.com/gimli-rs/gimli/blob/d36fcf11c878c8ebfb4da4cad300773869b5b5e4/examples/simple.rs#L38-L41) project that now is part of stdlib sources (stdlib dependency). Also, print file url in `RsLazyBlockStubCreationTestBase` tests. It may help to find file with problem code and even open it in your IDE if it's located in local file system. Fix the corresponding test in #6374 and #6417 Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
src/main/kotlin/org/rust/cargo/project/workspace/StandardLibrary.kt
Outdated
Show resolved
Hide resolved
|
||
if (!stdlibDependenciesDir.exists()) { | ||
try { | ||
cargo.vendorDependencies(project, testPackageSrcDir, stdlibDependenciesDir) |
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.
Looks like testPackageSrcDir
is needed only in this branch. Let's move its calculations into the branch
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 add a short comment about why libtest
is used as a root for vendor
.
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'm not sure it's a good idea to mutate rust src directory (i.e. store "vendor" dir there if it doesn't exist). If rustup is not used, it can be any user-specified directory, maybe even located in a read-only filesystem. If rustup is used, well, latter versions may decide to delete it, for example.
I think it's ok for now, but we should rethink it before enabling this feature by default.
src/main/kotlin/org/rust/cargo/project/workspace/StandardLibrary.kt
Outdated
Show resolved
Hide resolved
7848de7
to
1fa62eb
Compare
We don't support old Cargo versions that cannot provide `workspace_members` field in `cargo metadata`
1fa62eb
to
df20d1d
Compare
Previously, we always used hardcoded info about stdlib: its packages and their relationships. But it prevented us from getting actual info about stdlib packages: dependencies, edition, features, etc. As a result, some code in stdlib that depends on third-party crates (like `cfg-if`) cannot be properly taken into account while name resolution and type inference. These changes introduce an option (as an experimental feature for now) to fetch actual info about stdlib packages. Due to the fact that stdlib sources contain `Cargo.toml`, it's possible just to run `cargo metadata` to get all necessary info. It allows us to get proper info about: - edition. When stdlib started to use `2018` edition, plugin name resolution was broken in some places because of it. See #3835. We solved this issue by hardcoded edition for root stdlib packages depending on `rustc` version. Actual info about edition allows avoiding similar issues for future editions like edition 2021. - dependencies. It fixes name resolution in cases when third-party libraries are used in stdlib packages. The most known case is the usage of `cfg-if` lib in `std::os` module that provides different API for different operating systems. Now name resolution and completion for child modules of `std::os` should work as expected. - features. They also are taken into account while name resolution
Otherwise, some name resolution doesn't work correctly
Previously, we used hardcoded options that prevented us from checking os specific things
df20d1d
to
2a8d603
Compare
bors r+ |
Build succeeded: |
Just a heads-up: rust-lang/rust#78790 is being (probably temporarily) removed (rust-lang/rust#80082). Not sure if it relates to this PR. |
@Kobzol thanks for the worry! |
6609: CARGO: download stdlib dependencies into system dir r=vlad20012 a=Undin Previously, the plugin downloaded stdlib dependencies (call `cargo vendor`) into src directory. But such approach didn't take into account read-only file systems and stdlib updates properly. Now, stdlib dependencies are downloaded into IDE system dir and its path depends on rustc version Continuation of #6417 Fixes #6603 changelog: TODO Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
6609: CARGO: download stdlib dependencies into system dir r=vlad20012 a=Undin Previously, the plugin downloaded stdlib dependencies (call `cargo vendor`) into src directory. But such approach didn't take into account read-only file systems and stdlib updates properly. Now, stdlib dependencies are downloaded into IDE system dir and its path depends on rustc version Continuation of #6417 Fixes #6603 changelog: TODO Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
Previously, we always used hardcoded info about stdlib: its packages and their relationships.
But it prevented us from getting actual info about stdlib packages: dependencies, edition, features, etc.
As a result, some code in stdlib that depends on third-party crates (like
cfg-if
) cannot be properly taken into account while name resolution and type inference.These changes introduce an option (as an experimental feature for now) to fetch actual info about stdlib packages.
Due to the fact that stdlib sources contain
Cargo.toml
, it's possible just to runcargo metadata
to get all necessary info.It allows us to get proper info about:
2018
edition, plugin name resolution was broken in some places because of it. See Cannot find declaration of BTreeMap and BTreeSet #3835. We solved this issue by hardcoded edition for root stdlib packages depending onrustc
version. Actual info about edition allows avoiding similar issues for future editions like edition 2021.cfg-if
lib instd::os
module that provides different API for different operating systems. Now name resolution and completion for child modules ofstd::os
should work as expected.Restrictions:
cargo vendor
to collect stdlib dependencies before rustc 1.49. Since Vendor libtest's dependencies in the rust-src component rust-lang/rust#78790rust-src
component already containsvendor
directory with the corresponding librariesKnown issues and future improvements:
org.rust.cargo.fetch.actual.stdlib.metadata
experimental featurestdlib
nodeSync
tool windowCloses #3864
Main step to fix the following issues: #3957 #4960 #5881 #6081
Part of #6104
changelog: provide a way to fetch actual info about stdlib packages like dependencies, edition, Cargo features. It should help the plugin better understand stdlib structure, for example, provide proper completion and navigation for items defined in
std::os
module. Note, the corresponding feature works since Rust 1.41 and disabled by default for now. You can enabled it viaorg.rust.cargo.fetch.actual.stdlib.metadata
option inExperimental Feature
dialog (Help | Find Action
and typeExperimental features
to open the dialog)