rust-lang / rust-lang/rust-analyzer

JSON-based workspaces don't detect or read target data layout?

Open
#14,673 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Question

Looks like JSON-based workspace doesn't have an equivalent of target_layout filed as in Cargo-based ones?

https://github.com/rust-lang/rust-analyzer/blob/237ffa3997250b8569ced477a5072310eb48c847/crates/project-model/src/workspace.rs#L70-L93

So when creating the crate graph here, we pass in an Err:

https://github.com/rust-lang/rust-analyzer/blob/237ffa3997250b8569ced477a5072310eb48c847/crates/project-model/src/workspace.rs#L622

May I know whether this is intentional, or perhaps at least a FIXME should be tagged at this line?


Observed effects

#8813 won't work in JSON-based workspaces, e.g.

let _x = [true; 100];
  //^^ [bool; _] 

the length part is still Unknown thus displayed as an underscore.


Possible solutions? (if we are to fix it)

Thanks for your effort!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/project-model/src/workspace.rs, especially the workspace data definitions and crate-graph construction around the referenced lines. Read target_data_layout.rs and project_json.rs to compare Cargo-based and JSON-based handling, then reproduce the provided [true; 100] example. Done means JSON-based workspaces provide the needed layout information so the array length is no longer displayed as Unknown.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.