Skip to content

Commit

Permalink
fix: add missing default feature at first position
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Jun 30, 2024
1 parent 4b34c96 commit 5eb5df5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lua/crates/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ function M.parse_crate(index_json_str, meta_json_str)
-- sort features
table.sort(version.features.list, sort_features)

-- add missing default feature
if not version.features.map["default"] then
local feature = {
name = "default",
members = {},
}
table.insert(version.features.list, feature)
version.features.map["default"] = feature
end

-- add optional dependencies as features
for _, d in ipairs(version.deps) do
if d.opt then
Expand All @@ -388,14 +398,6 @@ function M.parse_crate(index_json_str, meta_json_str)
end
end

-- add missing default feature
if not version.features.list[1] or not (version.features.list[1].name == "default") then
version.features:insert({
name = "default",
members = {},
})
end

versions[version.num] = version
end

Expand Down

0 comments on commit 5eb5df5

Please sign in to comment.