Skip to content

Commit

Permalink
rust-project: Strip version from lang crates
Browse files Browse the repository at this point in the history
Summary: rust-analyzer identifies lang crates by name, so we need to normalize these. In the future, we should properly mark the crates somehow rather than using the name.

Reviewed By: davidbarsky

Differential Revision: D70200075

fbshipit-source-id: bf52de7ed5f43f46b92114e3a35a60394d383853
  • Loading branch information
darichey authored and facebook-github-bot committed Feb 26, 2025
1 parent c094977 commit fef0709
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion integrations/rust-project/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(crate) fn resolve_buckconfig_sysroot(
// so that rust-analyzer will be able to find standard library sources.
let sysroot_src = project_root.join(sysroot_src).join("library");

let sysroot_project = develop_with_sysroot(
let mut sysroot_project = develop_with_sysroot(
buck,
vec![sysroot_targets],
Sysroot {
Expand All @@ -85,6 +85,14 @@ pub(crate) fn resolve_buckconfig_sysroot(
false,
false,
)?;
for krate in &mut sysroot_project.crates {
if let Some(display_name) = &mut krate.display_name {
*display_name = display_name
.strip_suffix("-0.0.0") // rust-analyzer identifies lang crates by name, so we need `core-0.0.0` to be `core`
.unwrap_or(display_name)
.to_owned();
}
}

Ok(Sysroot {
sysroot,
Expand Down

0 comments on commit fef0709

Please sign in to comment.