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

Rust analyzer config #202

Closed
adamrk opened this issue Apr 16, 2021 · 5 comments
Closed

Rust analyzer config #202

adamrk opened this issue Apr 16, 2021 · 5 comments
Labels
• misc Related to other topics (e.g. CI).

Comments

@adamrk
Copy link

adamrk commented Apr 16, 2021

Has anyone gotten rust-analyzer configuration that works for rust-for-linux? Could be useful to add to the documentation.

@wedsonaf
Copy link

wedsonaf commented Apr 16, 2021 via email

@bjorn3
Copy link
Member

bjorn3 commented Apr 16, 2021

Rust-for-linux doesn't use cargo and as such rust-analyzer can't automatically detect the crate roots and dependencies. Instead it is necessary to manually specify it in a rust-project.json file. rust-project.json needs to be either in the project root or be linked to using rust-analyzer.linkedProjects in the vscode configuration. See https://rust-analyzer.github.io/manual.html#non-cargo-based-projects for more documentation.

@adamrk
Copy link
Author

adamrk commented Apr 16, 2021

Thanks!

@ojeda ojeda added prio: normal • misc Related to other topics (e.g. CI). labels Apr 16, 2021
@wedsonaf
Copy link

Here's my rust-project.json, it lives in the top directory of tree. You'll need to update sysroot_src to point to the appropriate one on your system.

{
	"sysroot_src": "/usr/local/google/home/wedsonaf/.rustup/toolchains/nightly-2021-02-20-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/",
	"crates": [
		{
			"root_module": "rust/module.rs",
			"edition": "2018",
			"deps": [ ]
		},
		{
			"root_module": "rust/kernel/lib.rs",
			"edition": "2018",
			"deps": [
				{
					"crate": 0,
					"name": "module"
				}
			]
		},
		{
			"root_module": "drivers/android/rust_binder.rs",
			"edition": "2018",
			"deps": [
				{
					"crate": 0,
					"name": "module"
				},
				{
					"crate": 1,
					"name": "kernel"
				}
			]
		}
	]
}

@ojeda
Copy link
Member

ojeda commented May 8, 2021

Closed via #227.

@ojeda ojeda closed this as completed May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• misc Related to other topics (e.g. CI).
Development

No branches or pull requests

4 participants