Skip to content

Commit 232ff41

Browse files
fw-immunantkkysen
authored andcommitted
transpile: enable --reorganize-definitions by default
Unfortunately, we have to bend over backwards to make this work without changing CLI behavior. This adds a new `--no-reorganize-definitions` flag to disable reorganizing definitions, because it would not be backwards-compatible to add an optional argument for the flag (it would eat a following argument that would previously be unassociated with the flag).
1 parent c4f6060 commit 232ff41

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

c2rust/src/bin/c2rust-transpile.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,17 @@ struct Args {
124124
#[clap(long)]
125125
reduce_type_annotations: bool,
126126

127-
/// Output file in such a way that the refactoring tool can deduplicate code
128-
#[clap(short = 'r', long)]
129-
reorganize_definitions: bool,
127+
/// Disable `--reorganize-definitions`
128+
#[clap(long = "no-reorganize-definitions", hidden = true, action = clap::ArgAction::SetFalse)]
129+
reorganize_definitions: bool, // NB, this *is* the right field; this flag sets it to *false*.
130+
131+
/// Output file in such a way that the refactoring tool can deduplicate code (enabled by default; disable with `--no-reorganize-definitions`)
132+
#[clap(
133+
short = 'r',
134+
long = "reorganize-definitions",
135+
conflicts_with = "reorganize-definitions"
136+
)]
137+
_no_reorganize_definitions: bool, // Field is unused, but flag mutually excludes the negative sense above.
130138

131139
/// Extra arguments to pass to clang frontend during parsing the input C file
132140
#[clap(multiple = true, last(true))]

0 commit comments

Comments
 (0)