Skip to content
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

cmm: Fix handling of top-level arrays of tables #51

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hacking/cargo-manifest-management/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ none:

.PHONY: clean
clean:
rm -rf $(target_dir) $(blueprint)
rm -rf tool/target $(blueprint)

.PHONY: $(blueprint)
$(blueprint):
Expand Down
10 changes: 4 additions & 6 deletions hacking/cargo-manifest-management/manual-manifests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ let

relativeToWorkspaceRoot = relativePath: "${toString ../..}/${relativePath}";

relativeToTmpSrc = relativePath: relativeToWorkspaceRoot "tmp/src/${relativePath}";

in {
# "virtio-drivers" = relativeToWorkspaceRoot "tmp/virtio-drivers";
# "mbedtls" = relativeToWorkspaceRoot "tmp/rust-mbedtls/mbedtls";
# "mbedtls-sys-auto" = relativeToWorkspaceRoot "tmp/rust-mbedtls/mbedtls-sys";
# "mbedtls-platform-support" = relativeToWorkspaceRoot "tmp/rust-mbedtls/mbedtls-platform-support";
# "embedded-fat" = relativeToWorkspaceRoot "tmp/rust-embedded-fat";
# "volatile" = relativeToWorkspaceRoot "tmp/volatile";
# ring = relativeToTmpSrc "ring";
# rustls = relativeToTmpSrc "rustls/rustls";
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct Blueprint {
pub entries: Vec<Entry>,
}

// TODO these rename attributes cause a mix of caml and snake case
#[derive(Debug, Deserialize)]
pub struct Entry {
#[serde(rename = "absolutePath")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,17 @@ impl<'a, P: AbstractPolicy> FormatterState<'a, P> {
.map(Option::unwrap)
.enumerate()
{
let inline_table =
self.with_index(i, |this| this.format_table_to_inline_table(x))?;
if self.is_inline_table_too_wide_for_array(&inline_table) {
inline_tables = None;
break;
} else {
inline_tables.as_mut().unwrap().push(inline_table);
match self.with_index(i, |this| this.format_table_to_inline_table(x)) {
Err(Error::CannotInlineTable(_)) => {}
Ok(inline_table) => {
if !self.is_inline_table_too_wide_for_array(&inline_table) {
inline_tables.as_mut().unwrap().push(inline_table);
continue;
}
}
}
inline_tables = None;
break;
}
inline_tables.map(|inline_tables| {
let mut array = Array::new();
Expand Down Expand Up @@ -236,6 +239,7 @@ impl<'a, P: AbstractPolicy> FormatterState<'a, P> {
fn current_key(&self) -> Option<&str> {
self.current_path().last()?.as_key()
}

fn push(&mut self, seg: PathSegment) {
self.current_path.push(seg);
}
Expand Down