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

Use rust-project.json instead of patching Cargo.toml #5803

Closed
ragne opened this issue Jul 15, 2020 · 7 comments
Closed

Use rust-project.json instead of patching Cargo.toml #5803

ragne opened this issue Jul 15, 2020 · 7 comments
Labels
A-infra Area: CI issues and issues that require full access for GitHub/CI C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.

Comments

@ragne
Copy link

ragne commented Jul 15, 2020

Preface

I've noticed that to use rust-analyzer with clippy you need to run cargo dev ra-setup, which'll patch existing Cargo.toml for workspace and clippy-lints.
After that it was cumbersome (maybe just for me) to run compile/test because now cargo basically tries to compile parts of the rust.
And of course you need to get rid of those bits before submitting a PR.

Proposal

Nowadays rust-analyzer has a different way to define a project, mostly intended for projects that don't use Cargo. One can write a rust-project.json and point rust-analyzer to that file instead.
Could it be used instead and put into .gitignore for example? I think it should be more convenient than current solution.

I probably can take the ticket on the next week and try to come with PR.
Main questions (assuming approach works):

  • Should it replace existing ra-setup or add a feature flag?
  • Should it try to locate .vscode settings and specify rust-analyzer.linkedProjects for user?
  • Support for any other editors if previous is true?
@flip1995 flip1995 added C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. A-infra Area: CI issues and issues that require full access for GitHub/CI labels Jul 15, 2020
@dima74
Copy link
Contributor

dima74 commented Aug 9, 2020

After that it was cumbersome to run compile/test because now cargo basically tries to compile parts of the rust.

I also faced this problem and fixed it by putting rustc crates under [target.'cfg(NOT_A_PLATFORM)'.dependencies] section

@phansch
Copy link
Member

phansch commented Sep 18, 2020

Using the rust-project.json will not be necessary once/if rust-lang/rust#76856 lands and the rustc internals are included in the rustc-dev component.

@flip1995
Copy link
Member

rust-lang/rust#76856 landed. Does this mean we can remove the ra_setup command from cargo dev? cc @matthiaskrgr

@matthiaskrgr
Copy link
Member

Mhh, it seems that 76856 did not help, RA does not automatically find rustc sources in clippy, at least when I tried.
cc rust-lang/rust-analyzer#3517
I found compiler sources at ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/rustc-src/rust/compiler.

We could perhaps use that (and use master toolchain sources) instead of some kind of path to a local repo at least...

@matthiaskrgr
Copy link
Member

@flip1995
Copy link
Member

rust-analyzer works for me. But it doesn't find the rustc source because this isn't implmented in rust-analyzer yet :D Probably needs the same as this:

https://github.com/rust-analyzer/rust-analyzer/blob/96e988fcc3be11acc89dc2c1957bc14e8f39c911/crates/project_model/src/sysroot.rs#L108

@blyxyas
Copy link
Member

blyxyas commented May 14, 2023

I think this issue can be closed. cargo dev ra-setup doesn't even exist anymore, #6869 and the solution to Rust Analyzer not finding crates is documented.

{
	"rust-analyzer.rustc.source": "discover",
	"rust-analyzer.linkedProjects": [
        "./Cargo.toml",
        "clippy_dev/Cargo.toml",
        "lintcheck/Cargo.toml",
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infra Area: CI issues and issues that require full access for GitHub/CI C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise.
Projects
None yet
Development

No branches or pull requests

6 participants