fix: Fix target-data-layout fetching incorrectly passing 'rustc' to rustc

This commit is contained in:
Lukas Wirth 2023-01-19 19:21:44 +01:00
parent c9d33cddc9
commit 384fa4b84a
8 changed files with 144 additions and 63 deletions

View file

@ -12,6 +12,13 @@ pub fn target_data_layout_query(
krate: CrateId,
) -> Option<Arc<TargetDataLayout>> {
let crate_graph = db.crate_graph();
let target_layout = crate_graph[krate].target_layout.as_ref()?;
Some(Arc::new(TargetDataLayout::parse_from_llvm_datalayout_string(&target_layout).ok()?))
let target_layout = crate_graph[krate].target_layout.as_ref().ok()?;
let res = TargetDataLayout::parse_from_llvm_datalayout_string(&target_layout);
if let Err(_e) = &res {
// FIXME: Print the error here once it implements debug/display
// also logging here is somewhat wrong, but unfortunately this is the earliest place we can
// parse that doesn't impose a dependency to the rust-abi crate for project-model
tracing::error!("Failed to parse target data layout for {krate:?}");
}
res.ok().map(Arc::new)
}