-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
JSON-based workspaces don't detect or read target data layout? #14673
Comments
We definitely want target data layout for rust-project.json based projects, and your possible solution sections looks like it is to the point. It would be great if you come with a PR.
I think you can provide the custom target with |
Thanks for your reply!
Sure. Let me try.
Yeah I agree. It is also reflected in the snippet (the But my point was, the snippet seemingly wants to extract certain information from
and if this first run of -- I am just confused about this design, and "why this function is currently only used for Cargo-based workspaces". Anyway, let me try it for JSON-based workspaces too. |
I guess in case of cargo, the caller of this function won't provide the target (unless it is explicitly provided as a config) and it finds the target by running rustc in the directory of the crate. So for the |
That's a bug, the first one should be invoking Though for rust-project.json I'm not sure if we wanna attempt using cargo at all? Usually rust-project.json indicates a different workflow than standard cargo. |
At least in my employer's case, it's possible to invoke |
Yes, rustc is fine to do. The question is whether attempting to invoke cargo first makes sense, which I would argue it does not. AS usual, for non cargo based projects we should probably offer a way to set this in a different way/discover it differently. |
I guess so according to the context :) Then one follow-up question is: what extra infomation can |
Running the command through cargo allows honoring target settings set through |
Ahh I see. Thanks! |
Sorry about that! I misread what you were saying. |
Question
Looks like JSON-based workspace doesn't have an equivalent of
target_layout
filed as in Cargo-based ones?rust-analyzer/crates/project-model/src/workspace.rs
Lines 70 to 93 in 237ffa3
So when creating the crate graph here, we pass in an
Err
:rust-analyzer/crates/project-model/src/workspace.rs
Line 622 in 237ffa3
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.
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?rust-analyzer/crates/project-model/src/target_data_layout.rs
Lines 15 to 37 in 237ffa3
By the way, in this function there are two attempts of issuing
rustc
command. It looks to me the only difference between them is tocd <project root>
or not. Idk, will the existence ofCargo.toml
in the current directory affect the result ofrustc +nightly -Z unstable-options --print target-spec-json
?derive the data layout information from this provided triple?
rust-analyzer/crates/project-model/src/project_json.rs
Line 83 in 62c81d6
Thanks for your effort!
The text was updated successfully, but these errors were encountered: