You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strongly type differing compiler args for clarity (#4220)
### Context
When working on #4211 & #4213, I was initially very confused by all the
machinery in
[`call_cargo.rs`](https://github.com/model-checking/kani/blob/main/kani-driver/src/call_cargo.rs)
and
[`call_single_file.rs`](https://github.com/model-checking/kani/blob/main/kani-driver/src/call_single_file.rs)
that we used to pass arguments to the different layers of the compiler.
The main source of my confusion was that there were many arguments all
destined for different places (e.g. cargo, rustc, or kani-compiler) that
all had to be encoded in differing ways (e.g. through the `--llvm-args`
flag or the `CARGO_ENCODED_RUSTFLAGS` environment variable) but were
mixed together sharing the same `String` type and similar-sounding
variable names.
Although misconfiguration would often be caught at runtime with a
section of the compiler complaining about unexpected arguments, this
confusion silently bit me a few times where argument names were shared.
### Fix
This PR represents an attempt to encode the way arguments target
different portions of the compiler into the type system using specific
wrapper types for each kind of argument we use. You can convert
transparently into these wrapper types, but then can only convert
between them or pass them to a cargo command using the proper encoding
methods.
Although not perfect (you could still convert into the wrong kind of
argument wrapper initially), this does seem to add some slight
guardrails on the way we call cargo, especially against smaller changes
to the existing patterns like the ones I was making in my PRs. It also
may make the code easier to parse.
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
0 commit comments