1
Fork 0

Rollup merge of #107043 - Nilstrieb:true-and-false-is-false, r=wesleywiser

Support `true` and `false` as boolean flag params

Implements [MCP 577](https://github.com/rust-lang/compiler-team/issues/577).
This commit is contained in:
Matthias Krüger 2023-02-10 06:09:56 +01:00 committed by GitHub
commit 8fc9ed51f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 41 deletions

View file

@ -349,7 +349,7 @@ fn build_options<O: Default>(
#[allow(non_upper_case_globals)]
mod desc {
pub const parse_no_flag: &str = "no value";
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
pub const parse_opt_bool: &str = parse_bool;
pub const parse_string: &str = "a string";
pub const parse_opt_string: &str = parse_string;
@ -433,11 +433,11 @@ mod parse {
/// Use this for any boolean option that has a static default.
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
match v {
Some("y") | Some("yes") | Some("on") | None => {
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
*slot = true;
true
}
Some("n") | Some("no") | Some("off") => {
Some("n") | Some("no") | Some("off") | Some("false") => {
*slot = false;
true
}
@ -450,11 +450,11 @@ mod parse {
/// other factors, such as other options, or target options.)
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
match v {
Some("y") | Some("yes") | Some("on") | None => {
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
*slot = Some(true);
true
}
Some("n") | Some("no") | Some("off") => {
Some("n") | Some("no") | Some("off") | Some("false") => {
*slot = Some(false);
true
}