Skip to content

Commit 8fc9ed5

Browse files
authored
Rollup merge of #107043 - Nilstrieb:true-and-false-is-false, r=wesleywiser
Support `true` and `false` as boolean flag params Implements [MCP 577](rust-lang/compiler-team#577).
2 parents a12d31d + 7605853 commit 8fc9ed5

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

compiler/rustc_session/src/options.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn build_options<O: Default>(
349349
#[allow(non_upper_case_globals)]
350350
mod desc {
351351
pub const parse_no_flag: &str = "no value";
352-
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
352+
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
353353
pub const parse_opt_bool: &str = parse_bool;
354354
pub const parse_string: &str = "a string";
355355
pub const parse_opt_string: &str = parse_string;
@@ -433,11 +433,11 @@ mod parse {
433433
/// Use this for any boolean option that has a static default.
434434
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
435435
match v {
436-
Some("y") | Some("yes") | Some("on") | None => {
436+
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
437437
*slot = true;
438438
true
439439
}
440-
Some("n") | Some("no") | Some("off") => {
440+
Some("n") | Some("no") | Some("off") | Some("false") => {
441441
*slot = false;
442442
true
443443
}
@@ -450,11 +450,11 @@ mod parse {
450450
/// other factors, such as other options, or target options.)
451451
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
452452
match v {
453-
Some("y") | Some("yes") | Some("on") | None => {
453+
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
454454
*slot = Some(true);
455455
true
456456
}
457-
Some("n") | Some("no") | Some("off") => {
457+
Some("n") | Some("no") | Some("off") | Some("false") => {
458458
*slot = Some(false);
459459
true
460460
}

src/doc/rustc/src/codegen-options/index.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ Guard](https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard)
4949
platform security feature. This flag is currently ignored for non-Windows targets.
5050
It takes one of the following values:
5151

52-
* `y`, `yes`, `on`, `checks`, or no value: enable Control Flow Guard.
52+
* `y`, `yes`, `on`, `true`, `checks`, or no value: enable Control Flow Guard.
5353
* `nochecks`: emit Control Flow Guard metadata without runtime enforcement checks (this
5454
should only be used for testing purposes as it does not provide security enforcement).
55-
* `n`, `no`, `off`: do not enable Control Flow Guard (the default).
55+
* `n`, `no`, `off`, `false`: do not enable Control Flow Guard (the default).
5656

5757
## debug-assertions
5858

5959
This flag lets you turn `cfg(debug_assertions)` [conditional
6060
compilation](../../reference/conditional-compilation.md#debug_assertions) on
6161
or off. It takes one of the following values:
6262

63-
* `y`, `yes`, `on`, or no value: enable debug-assertions.
64-
* `n`, `no`, or `off`: disable debug-assertions.
63+
* `y`, `yes`, `on`, `true`, or no value: enable debug-assertions.
64+
* `n`, `no`, `off` or `false`: disable debug-assertions.
6565

6666
If not specified, debug assertions are automatically enabled only if the
6767
[opt-level](#opt-level) is 0.
@@ -82,8 +82,8 @@ Note: The [`-g` flag][option-g-debug] is an alias for `-C debuginfo=2`.
8282
This flag controls whether or not the linker includes its default libraries.
8383
It takes one of the following values:
8484

85-
* `y`, `yes`, `on`, or no value: include default libraries (the default).
86-
* `n`, `no`, or `off`: exclude default libraries.
85+
* `y`, `yes`, `on`, `true` or no value: include default libraries (the default).
86+
* `n`, `no`, `off` or `false`: exclude default libraries.
8787

8888
For example, for gcc flavor linkers, this issues the `-nodefaultlibs` flag to
8989
the linker.
@@ -93,8 +93,8 @@ the linker.
9393
This flag controls whether or not the compiler embeds LLVM bitcode into object
9494
files. It takes one of the following values:
9595

96-
* `y`, `yes`, `on`, or no value: put bitcode in rlibs (the default).
97-
* `n`, `no`, or `off`: omit bitcode from rlibs.
96+
* `y`, `yes`, `on`, `true` or no value: put bitcode in rlibs (the default).
97+
* `n`, `no`, `off` or `false`: omit bitcode from rlibs.
9898

9999
LLVM bitcode is required when rustc is performing link-time optimization (LTO).
100100
It is also required on some targets like iOS ones where vendors look for LLVM
@@ -135,8 +135,8 @@ flag][option-emit] for more information.
135135
This flag forces the use of frame pointers. It takes one of the following
136136
values:
137137

138-
* `y`, `yes`, `on`, or no value: force-enable frame pointers.
139-
* `n`, `no`, or `off`: do not force-enable frame pointers. This does
138+
* `y`, `yes`, `on`, `true` or no value: force-enable frame pointers.
139+
* `n`, `no`, `off` or `false`: do not force-enable frame pointers. This does
140140
not necessarily mean frame pointers will be removed.
141141

142142
The default behaviour, if frame pointers are not force-enabled, depends on the
@@ -147,8 +147,8 @@ target.
147147
This flag forces the generation of unwind tables. It takes one of the following
148148
values:
149149

150-
* `y`, `yes`, `on`, or no value: Unwind tables are forced to be generated.
151-
* `n`, `no`, or `off`: Unwind tables are not forced to be generated. If unwind
150+
* `y`, `yes`, `on`, `true` or no value: Unwind tables are forced to be generated.
151+
* `n`, `no`, `off` or `false`: Unwind tables are not forced to be generated. If unwind
152152
tables are required by the target an error will be emitted.
153153

154154
The default if not specified depends on the target.
@@ -202,8 +202,8 @@ options should be separated by spaces.
202202
This flag controls whether the linker will keep dead code. It takes one of
203203
the following values:
204204

205-
* `y`, `yes`, `on`, or no value: keep dead code.
206-
* `n`, `no`, or `off`: remove dead code (the default).
205+
* `y`, `yes`, `on`, `true` or no value: keep dead code.
206+
* `n`, `no`, `off` or `false`: remove dead code (the default).
207207

208208
An example of when this flag might be useful is when trying to construct code coverage
209209
metrics.
@@ -215,8 +215,8 @@ linker will use libraries and objects shipped with Rust instead or those in the
215215
It takes one of the following values:
216216

217217
* no value: rustc will use heuristic to disable self-contained mode if system has necessary tools.
218-
* `y`, `yes`, `on`: use only libraries/objects shipped with Rust.
219-
* `n`, `no`, or `off`: rely on the user or the linker to provide non-Rust libraries/objects.
218+
* `y`, `yes`, `on`, `true`: use only libraries/objects shipped with Rust.
219+
* `n`, `no`, `off` or `false`: rely on the user or the linker to provide non-Rust libraries/objects.
220220

221221
This allows overriding cases when detection fails or user wants to use shipped libraries.
222222

@@ -261,8 +261,8 @@ This flag defers LTO optimizations to the linker. See
261261
[linker-plugin-LTO](../linker-plugin-lto.md) for more details. It takes one of
262262
the following values:
263263

264-
* `y`, `yes`, `on`, or no value: enable linker plugin LTO.
265-
* `n`, `no`, or `off`: disable linker plugin LTO (the default).
264+
* `y`, `yes`, `on`, `true` or no value: enable linker plugin LTO.
265+
* `n`, `no`, `off` or `false`: disable linker plugin LTO (the default).
266266
* A path to the linker plugin.
267267

268268
More specifically this flag will cause the compiler to replace its typical
@@ -292,9 +292,9 @@ optimizations](https://llvm.org/docs/LinkTimeOptimization.html) to produce
292292
better optimized code, using whole-program analysis, at the cost of longer
293293
linking time. It takes one of the following values:
294294

295-
* `y`, `yes`, `on`, `fat`, or no value: perform "fat" LTO which attempts to
295+
* `y`, `yes`, `on`, `true`, `fat`, or no value: perform "fat" LTO which attempts to
296296
perform optimizations across all crates within the dependency graph.
297-
* `n`, `no`, `off`: disables LTO.
297+
* `n`, `no`, `off`, `false`: disables LTO.
298298
* `thin`: perform ["thin"
299299
LTO](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html).
300300
This is similar to "fat", but takes substantially less time to run while
@@ -333,8 +333,8 @@ This flag allows you to disable [the
333333
red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). It takes one
334334
of the following values:
335335

336-
* `y`, `yes`, `on`, or no value: disable the red zone.
337-
* `n`, `no`, or `off`: enable the red zone.
336+
* `y`, `yes`, `on`, `true` or no value: disable the red zone.
337+
* `n`, `no`, `off` or `false`: enable the red zone.
338338

339339
The default behaviour, if the flag is not specified, depends on the target.
340340

@@ -376,8 +376,8 @@ overflow](../../reference/expressions/operator-expr.md#overflow). When
376376
overflow-checks are enabled, a panic will occur on overflow. This flag takes
377377
one of the following values:
378378

379-
* `y`, `yes`, `on`, or no value: enable overflow checks.
380-
* `n`, `no`, or `off`: disable overflow checks.
379+
* `y`, `yes`, `on`, `true` or no value: enable overflow checks.
380+
* `n`, `no`, `off` or `false`: disable overflow checks.
381381

382382
If not specified, overflow checks are enabled if
383383
[debug-assertions](#debug-assertions) are enabled, disabled otherwise.
@@ -409,8 +409,8 @@ for determining whether or not it is possible to statically or dynamically
409409
link with a dependency. For example, `cdylib` crate types may only use static
410410
linkage. This flag takes one of the following values:
411411

412-
* `y`, `yes`, `on`, or no value: use dynamic linking.
413-
* `n`, `no`, or `off`: use static linking (the default).
412+
* `y`, `yes`, `on`, `true` or no value: use dynamic linking.
413+
* `n`, `no`, `off` or `false`: use static linking (the default).
414414

415415
## profile-generate
416416

@@ -487,24 +487,24 @@ The list of passes should be separated by spaces.
487487
This flag controls whether [`rpath`](https://en.wikipedia.org/wiki/Rpath) is
488488
enabled. It takes one of the following values:
489489

490-
* `y`, `yes`, `on`, or no value: enable rpath.
491-
* `n`, `no`, or `off`: disable rpath (the default).
490+
* `y`, `yes`, `on`, `true` or no value: enable rpath.
491+
* `n`, `no`, `off` or `false`: disable rpath (the default).
492492

493493
## save-temps
494494

495495
This flag controls whether temporary files generated during compilation are
496496
deleted once compilation finishes. It takes one of the following values:
497497

498-
* `y`, `yes`, `on`, or no value: save temporary files.
499-
* `n`, `no`, or `off`: delete temporary files (the default).
498+
* `y`, `yes`, `on`, `true` or no value: save temporary files.
499+
* `n`, `no`, `off` or `false`: delete temporary files (the default).
500500

501501
## soft-float
502502

503503
This option controls whether `rustc` generates code that emulates floating
504504
point instructions in software. It takes one of the following values:
505505

506-
* `y`, `yes`, `on`, or no value: use soft floats.
507-
* `n`, `no`, or `off`: use hardware floats (the default).
506+
* `y`, `yes`, `on`, `true` or no value: use soft floats.
507+
* `n`, `no`, `off` or `false`: use hardware floats (the default).
508508

509509
## split-debuginfo
510510

tests/codegen/issue-75659.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test checks that the call to memchr/slice_contains is optimized away
22
// when searching in small slices.
33

4-
// compile-flags: -O -Zinline-mir=no
4+
// compile-flags: -O -Zinline-mir=false
55
// only-x86_64
66

77
#![crate_type = "lib"]

tests/ui/lint/reasons-forbidden.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99
// The test is much cleaner if we deduplicate, though.
1010

11-
// compile-flags: -Z deduplicate-diagnostics=yes
11+
// compile-flags: -Z deduplicate-diagnostics=true
1212

1313
#![forbid(
1414
unsafe_code,

tests/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-pass
2-
// compile-flags: -C debug_assertions=yes
2+
// compile-flags: -C debug_assertions=true
33
// needs-unwind
44
// ignore-emscripten dies with an LLVM error
55

tests/ui/rfc-2091-track-caller/call-chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
// revisions: default mir-opt
3-
//[default] compile-flags: -Zinline-mir=no
3+
//[default] compile-flags: -Zinline-mir=false
44
//[mir-opt] compile-flags: -Zmir-opt-level=4
55

66
use std::panic::Location;

0 commit comments

Comments
 (0)