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

Document rust-analyzer cargo workaround for 2021 edition #1217

Closed
aDotInTheVoid opened this issue Sep 23, 2021 · 7 comments
Closed

Document rust-analyzer cargo workaround for 2021 edition #1217

aDotInTheVoid opened this issue Sep 23, 2021 · 7 comments
Labels
E-medium Difficulty: might require some prior knowledge or code reading

Comments

@aDotInTheVoid
Copy link
Member

To get RA to work (currently) you need to run rustup override set beta, so the cargo RA invokes considers rust 2021 stable.

Otherwise you get this error:

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/nixon/upstreams/rust/rust/Cargo.toml, cargo 1.55.0 (32da73ab1 2021-08-23): Failed to run `cargo metadata --manifest-path /home/nixon/upstreams/rust/rust/Cargo.toml`: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `/home/nixon/upstreams/rust/rust/src/bootstrap` Caused by: failed to parse manifest at `/home/nixon/upstreams/rust/rust/src/bootstrap/Cargo.toml` Caused by: feature `edition2021` is required The package requires the Cargo feature called `edition2021`, but that feature is not stabilized in this version of Cargo (1.55.0 (32da73ab1 2021-08-23)). Consider trying a newer version of Cargo (this may require the nightly release). See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2021 for more information about the status of this feature.

Either this should be documented or .vscode/settings.json should point RA to the cargo downloaded by x.py.

I think the latter is more "elegant", but I dont know if its possible with RA.

Also, previously RA was fine with stable cargo, as AUIU it just needs it to run cargo metadata, as cargo check is already overridden, so once 1.56 is stable, this may no longer be needed.

@camelid
Copy link
Member

camelid commented Sep 23, 2021

Also, previously RA was fine with stable cargo, as AUIU it just needs it to run cargo metadata, as cargo check is already overridden, so once 1.56 is stable, this may no longer be needed.

Although in the future, there may be other changes to Cargo.toml that rust-lang/rust uses that are unstable, which I think would require using rustup override set nightly (or a cleaner solution).

@camelid camelid added the E-medium Difficulty: might require some prior knowledge or code reading label Sep 23, 2021
@camelid
Copy link
Member

camelid commented Sep 23, 2021

I marked this as Medium since we're not sure what the "best" solution is yet.

@jyn514
Copy link
Member

jyn514 commented Sep 23, 2021

which I think would require using rustup override set nightly (or a cleaner solution)

X.py has to be able to build with the beta compiler, so nightly should be never be required. I don't know if there's cases where you'd have to set RUSTC_BOOTSTRAP just to run cargo metadata or not.

@SkiFire13
Copy link

X.py has to be able to build with the beta compiler, so nightly should be never be required.

However to do that it uses a freshly compiled stdlib. This means that the compiler is able to use stdlib features that are not yet available on beta, not even as unstable. This happened for example with core::iter::zip when rust-lang/rust#82917 added the function to the stdlib and at the same time made the compiler use it. This meant that the beta toolchain wasn't enough for rust-analyzer to typecheck some parts of the compiler because that function was missing, and technically for the first day or less not even nightly was enough.

@jyn514
Copy link
Member

jyn514 commented Sep 23, 2021

@SkiFire13 right, well, there's not much we can do about that because rust-analyzer doesn't understand staged builds.

@JohnTitor
Copy link
Member

Triage: Does this situation still continue? If not, I think we could close this issue.

@jyn514
Copy link
Member

jyn514 commented Nov 20, 2022

No, 2021 is stable on beta now.

@jyn514 jyn514 closed this as completed Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-medium Difficulty: might require some prior knowledge or code reading
Projects
None yet
Development

No branches or pull requests

5 participants