Skip to content

Custom target not being detected (or the --target flag is not being passed?) if a custom toolchain is set using rust-toolchain.toml #10615

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

Closed
Tracked by #11387
PizzaFlavoured opened this issue Oct 22, 2021 · 6 comments
Labels
Broken Window Bugs / technical debt to be addressed immediately

Comments

@PizzaFlavoured
Copy link

I have no idea what's going on but that title is the only conclusion I have been able to draw so far.

cargo build works fine and builds an AVR file, respecting .cargo/config.toml and rust-toolchain.toml. Deleting rust-toolchain.toml makes the error disappear, however, the project now fails to compile as, apparently, the old version is necessary, but that's outside of the scope of this issue.

I'm using vim with youcompleteme, but I doubt this matters that much. All rust-analyzer options are the default.

@PizzaFlavoured PizzaFlavoured changed the title rust-analyzer doesn't detect the set target when a custom toolchain is set using rust-toolchain.toml Custom target not being detected (or the --target flag is not being passed?) if a custom toolchain is set using rust-toolchain.toml Oct 22, 2021
@matze
Copy link

matze commented Oct 27, 2021

I am running into the same issue. What exactly did you do that made you close this issue?

@fenjalien
Copy link

Hi, I've just run into the same issue idk why it happens but you can fix it by setting the config option rust-analyzer.cargo.target to what the build target is set to in .cargo/config.toml.
I'm using vscode and an atmega328p so .vscode/settings.json is

{
    "rust-analyzer.cargo.target": "avr-specs/avr-atmega328p.json",
}

@matze
Copy link

matze commented Nov 2, 2021

I use LSPs in neovim but that info is a good hint, thanks!

@PizzaFlavoured
Copy link
Author

I am running into the same issue. What exactly did you do that made you close this issue?

I honestly thought this was me doing something wrong and not an actual issue. I'll reopen the issue since other people ran into the same problem. My bad.

Hi, I've just run into the same issue idk why it happens but you can fix it by setting the config option rust-analyzer.cargo.target to what the build target is set to in .cargo/config.toml. I'm using vscode and an atmega328p so .vscode/settings.json is

{
    "rust-analyzer.cargo.target": "avr-specs/avr-atmega328p.json",
}

I had tried doing but it did not help, unfortunately. I ended up disabling the feature (setting rust-analyzer.procMacro.enable to false) as a workaround.

@PizzaFlavoured PizzaFlavoured reopened this Nov 3, 2021
@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Nov 3, 2021
@lnicola lnicola mentioned this issue Jan 31, 2022
15 tasks
@Veykril
Copy link
Member

Veykril commented Feb 1, 2022

From the looks of it it seems like we are failing to use cargo to fetch the cfgs here, therefor we fall back to querying rustc directly which means we skip the cargo/.config.toml. For some reason calling cargo -Zunstable-options rustc --print cfg fails with

error: Found argument '--print' which wasn't expected, or isn't valid in this context

USAGE:
    cargo.exe rustc [OPTIONS] [--] [args]...

For more information try --help

on the toolchain nightly-2021-01-07 that is specified by that toolchain file. This works on newer toolchains though so I assume the way we call this has been fixed after that toolchain release. Running cargo -Zunstable-options rustc -- --print cfg makes it work, but will cause the command to fail for virtual workspaces(like rust-analyzer itself for example).

Given we don't tend to go out of our way to support older versions currently I propose to mark this as a wont-fix?

@Veykril
Copy link
Member

Veykril commented Feb 22, 2022

Given we don't tend to go out of our way to support older versions currently I propose to mark this as a wont-fix?

Closing as stated previously.

@Veykril Veykril closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately
Projects
None yet
Development

No branches or pull requests

4 participants