Skip to content

feat: refactor Charon.toml to use Cargo.toml and add support for start_from, hide_marker_traits#1104

Open
oliver-butterley wants to merge 17 commits intoAeneasVerif:mainfrom
oliver-butterley:config-file-updates
Open

feat: refactor Charon.toml to use Cargo.toml and add support for start_from, hide_marker_traits#1104
oliver-butterley wants to merge 17 commits intoAeneasVerif:mainfrom
oliver-butterley:config-file-updates

Conversation

@oliver-butterley
Copy link
Copy Markdown
Contributor

@oliver-butterley oliver-butterley commented Apr 20, 2026

The Charon.toml config file previously supported only four fields (extract_opaque_bodies, include, opaque, exclude) and rustc flags.

This PR refactors the functionality to avoid the Charon.toml file and instead uses a [metadata] section in Cargo.toml. Moreover we extend functionality to cover other commonly-needed options:

  • start_from / start_from_if_exists / start_from_attribute / start_from_pub — control translation entry points
  • hide_marker_traits — suppress marker traits from output

The --help text for the cargo subcommand now mentions that the [package.metadata.charon] section in Cargo.toml is read when present.

Note: The charon option preset is not exposed in the config. The rationale being that this depends on which tool will consume Charon's output rather than on the crate itself, so it doesn't belong in the crate's Cargo.toml.

@oliver-butterley
Copy link
Copy Markdown
Contributor Author

oliver-butterley commented Apr 20, 2026

I noticed there is an existing integration test for the config file (tests/cargo/toml/). It could be extended to cover the new fields, in particular [cargo] flags and start_from.

Concrete possibilities:

  • A project with a feature-gated function and [cargo] flags = ["--features", "my_feature"] in Charon.toml: confirms the function appears in the output (analogous to the existing [rustc] flags test).
  • A project with two modules and start_from = ["crate::included"]: confirms the excluded module is absent from the output.
  • A bad preset name in Charon.toml should produce a clear error message: I could also do a test for this although there is likely a slight maintenance burden here since the panic output includes an internal file:line location that would make change with later updates.

Currently such tests are drafted in another branch (config-file-tests), let me know if they should be added to this PR.

@Nadrieril
Copy link
Copy Markdown
Member

I kinda want to rip out Charon.toml and replace it with a [metadata] section in Cargo.toml as is more standard

@Nadrieril
Copy link
Copy Markdown
Member

would you wanna do taht instead?

@oliver-butterley
Copy link
Copy Markdown
Contributor Author

I kinda want to rip out Charon.toml and replace it with a [metadata] section in Cargo.toml as is more standard

We are very flexible with our needs. Just needs to have something in order to have a convenient way to write the flags. E.g., our repos currently need to pass many flags like seen in this.

@oliver-butterley
Copy link
Copy Markdown
Contributor Author

would you wanna do taht instead?

OK! Will do.

@oliver-butterley oliver-butterley marked this pull request as ready for review April 20, 2026 14:03
Comment thread charon/src/bin/charon/toml_config.rs Outdated
Comment thread charon/src/bin/charon/toml_config.rs Outdated
Comment thread charon/src/bin/charon/toml_config.rs Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge these new tests into one, many cargo tests are not fun to have around.

Comment thread docs/usage.md Outdated
Comment thread docs/usage.md Outdated
Comment thread docs/usage.md Outdated
Comment thread docs/usage.md Outdated
Comment thread docs/usage.md Outdated
Comment thread charon/src/bin/charon/toml_config.rs Outdated
@oliver-butterley oliver-butterley marked this pull request as draft May 4, 2026 08:04
@oliver-butterley oliver-butterley changed the title feat: extend Charon.toml to support preset, start_from, hide_marker_traits, and cargo flags feat: refactor Charon.toml to use Cargo.toml instead, add support for start_from, hide_marker_traits May 4, 2026
@oliver-butterley oliver-butterley changed the title feat: refactor Charon.toml to use Cargo.toml instead, add support for start_from, hide_marker_traits feat: refactor Charon.toml to use Cargo.toml, add support for start_from, hide_marker_traits May 4, 2026
@oliver-butterley oliver-butterley changed the title feat: refactor Charon.toml to use Cargo.toml, add support for start_from, hide_marker_traits feat: refactor Charon.toml to use Cargo.toml and add support for start_from, hide_marker_traits May 4, 2026
@oliver-butterley oliver-butterley marked this pull request as ready for review May 4, 2026 09:24
@oliver-butterley
Copy link
Copy Markdown
Contributor Author

Thanks for your patience!

Summary of the latest updates following all the comments:

  • Dropped [package.metadata.charon.cargo] flags entirely
  • Dropped preset entirely. (it's tool-dependent rather than crate-dependent)
  • The additional tests added in the previous version of the PR have been removed. What remains is the single test from before, updated to the latest functionality.
  • docs/usage.md is now very concise info

Note: Updated read_toml reads ./Cargo.toml directly like was done before for Charon.toml. It's possible that for Cargo.toml there is a specific procedure which should be used but searching I didn't find a solution which was clearly better than the current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants