-
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
How to activate unstable feature restricted_std in rust-analyzer? #16232
Comments
In what editor is this? It looks like rust-analyzer is trying to compile the standard library for you here which might be an issue with how the editor reports the workspaces. |
It's vscode. Any idea on how I can switch this?
…-------- Mensagem Original --------
Em 3 de jan. de 2024, 07:00, Lukas Wirth escreveu:
In what editor is this? It looks like rust-analyzer is trying to compile the standard library for you here which might be an issue with how the editor reports the workspaces.
—
Reply to this email directly, [view it on GitHub](#16232 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABSTHAKWGGULC2OHYVTO3YTYMUT4ZAVCNFSM6AAAAABBKZA6JCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVGEYTAMRUGU).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
|
You could try the equivalent |
Maybe this is rust-lang/wg-cargo-std-aware#87 so you forgot #![no_std] ? |
@mohe2015 it builds and runs with ˋcargo buildˋ and no ˋ#![no_std]ˋ so I guess no? I actually want to use the std lib. But yeah I added ˋ#![feature(restricted_std)] Also @lnicola your suggestion:
|
Is the rust analyzer config to enable build std correct? I'm not sure whether it accepts the build std at that location because I couldn't find any docs and can't test right now |
Ok, if I understood correctly, I'm trying to build, in rust-analyzer, with std, but I actually can only build with restricted_std, for my target. Is this correct? So rust-analyzer does not know what is my target and therefore tries to use std. |
Your target does not support std so I personally would add |
But it supports restricted_std because it works with cargo build, just not in rust-analyzer. Am I right?
…-------- Mensagem Original --------
Em 19 de jan. de 2024, 10:21, Moritz Hedtke escreveu:
> Ok, if I understood correctly, I'm trying to build, in rust-analyzer, with std, but I actually can only build with restricted_std, for my target. Is this correct? So rust-analyzer does not know what is my target and therefore tries to use std.
Your target does not support std so I personally would add #![no_std] and disable all std features of dependencies. [rust-lang/wg-cargo-std-aware#87](rust-lang/wg-cargo-std-aware#87) is the issue that wants to improve the error message.
See https://github.com/mohe2015/rust-analyzer-issue-16232/tree/main especially the .cargo/config.toml, .vscode/settings.json and src/main.rs.
—
Reply to this email directly, [view it on GitHub](#16232 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABSTHAKHEQFEFRV7VYSFPLTYPJXNFAVCNFSM6AAAAABBKZA6JCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBQGQYTOMZSGE).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Yeah with cargo it works just not in rust-analyzer. I think I found the issue. I think rust-analyzer sets the build-std "test" because the commit mohe2015/rust-analyzer-issue-16232@143d64a makes it work for cargo but not rust-analyzer and before it's broken for both. |
@mohe2015 are you going to merge this? |
It's not a commit in rust-analyzer but only in my test project (https://github.com/mohe2015/rust-analyzer-issue-16232/commits/restricted-std). It's also just an assumption what may happen. Somebody would need to find out whether that's actually the case and where in rust analyzer this is set for the project and fix it there. I currently don't have the time to do that. |
@mohe2015 yes. Unfortunately I'm on vscode.dev so it's a bit hard to compile my own. Any ideas on how to mitigate this with configurations? |
I am having a similar issue, while also targeting a variant of I noticed that setting I know that running
which seems to cause Regarding the errors that are reported, as of current prerelease of
It looks like the reported error is related to a different step within I suspect that there might be two separate bugs here
|
Yes for htese projects you should set Note that for the |
I don't think you expose
Yeah, noticed that in VSCode. |
Ah right, #16924 hasn't been merged yet. So we'll expose that soon |
I confirm that #16924 solves the issue for me. Just need to put {
"rust-analyzer.cargo.allTargets": false,
} in |
rust-analyzer version:
0.3.1791-standalone
rustc version: rustc 1.77.0-nightly (fb5ed726f 2023-12-28)
relevant settings: (eg. client settings, or environment variables like
CARGO
,RUSTC
,RUSTUP_HOME
orCARGO_HOME
)I'm trying to compile for esp32c6 (
riscv32imac-unknown-none-elf
). Actually,cargo build
runs, but when I save the file rust-analyzer checks it and complains:As you see, it's complaining about a feature in the std lib, which is strange. I added
#![feature(restricted_std)]
to main.rs but the error is in the standard library where I cannot add this feature.I also tried
and other variations without success. Also tried
in
rust-analyzer.toml
.Also
The text was updated successfully, but these errors were encountered: