Skip to content

Rust analyzer config #202

Closed
Closed

Description

@adamrk

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

Activity

  1. wedsonaf commented on Apr 16, 2021

    @wedsonaf
  2. bjorn3 commented on Apr 16, 2021

    @bjorn3
    Member

    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.

  3. adamrk commented on Apr 16, 2021

    @adamrk
    Author

    Thanks!

  4. wedsonaf commented on Apr 19, 2021

    @wedsonaf

    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"
    				}
    			]
    		}
    	]
    }
  5. ojeda commented on May 8, 2021

    @ojeda
    Member

    Closed via #227.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    • miscRelated to other topics (e.g. CI).

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions