rust-lang / rust-lang/rust-analyzer
JSON-based workspaces don't detect or read target data layout?
Nobody has claimed this yet.
- 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?
So when creating the crate graph here, we pass in an Err:
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)
-
reuse this
target_data_layout::get()function for JSON-based workspaces?By the way, in this function there are two attempts of issuing
rustccommand. It looks to me the only difference between them is tocd <project root>or not. Idk, will the existence ofCargo.tomlin the current directory affect the result ofrustc +nightly -Z unstable-options --print target-spec-json? -
derive the data layout information from this provided triple?
Thanks for your effort!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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