Skip to content

Commit

Permalink
Fix feature name => crate (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Jan 12, 2024
1 parent 36b7a7a commit 02d1a88
Show file tree
Hide file tree
Showing 4 changed files with 760 additions and 306 deletions.
26 changes: 17 additions & 9 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,15 @@ impl Builder {
impl Node {
#[inline]
fn feature_index(&self, feat: &str) -> usize {
self.features
.binary_search_by(|f| f.as_str().cmp(feat))
.unwrap()
match self.features.binary_search_by(|f| f.as_str().cmp(feat)) {
Ok(i) => i,
Err(_i) => {
unreachable!(
"unable to locate {feat} for crate {} features({:?})",
self.id, self.features
);
}
}
}

#[inline]
Expand Down Expand Up @@ -1069,12 +1075,14 @@ impl Builder {
}
};

let Some(ndep) = rnode
.deps
.iter()
.find(|rdep| dep_names_match(krate_name, &rdep.name))
else {
unreachable!("unable to find dependency {krate_name} for {pid}");
let Some(ndep) = rnode.deps.iter().find(|rdep| {
dep_names_match(krate_name, &rdep.name)
|| crate_name_from_pid(&rdep.pkg) == krate_name
}) else {
unreachable!(
"unable to find dependency {krate_name} for {pid} {:#?}",
rnode.deps
);
};

let rdep_node = get_rnode(&ndep.pkg);
Expand Down
187 changes: 187 additions & 0 deletions tests/feature-bug/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/feature-bug/sub-crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition = "2021"
default = []
simple = ["dep:ndarray-linalg"]

[dependencies]
config = "0.13"

[target.'cfg(target_os = "windows")'.dependencies]
ndarray-linalg = { workspace = true, default-features = false, optional = true }

Expand Down

0 comments on commit 02d1a88

Please sign in to comment.