Support true
and false
as boolean flag params
Implements MCP 577.
This commit is contained in:
parent
1f72129ffe
commit
a6fda3ee7f
5 changed files with 9 additions and 9 deletions
|
@ -349,7 +349,7 @@ fn build_options<O: Default>(
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
mod desc {
|
mod desc {
|
||||||
pub const parse_no_flag: &str = "no value";
|
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_opt_bool: &str = parse_bool;
|
||||||
pub const parse_string: &str = "a string";
|
pub const parse_string: &str = "a string";
|
||||||
pub const parse_opt_string: &str = parse_string;
|
pub const parse_opt_string: &str = parse_string;
|
||||||
|
@ -432,11 +432,11 @@ mod parse {
|
||||||
/// Use this for any boolean option that has a static default.
|
/// Use this for any boolean option that has a static default.
|
||||||
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
pub(crate) fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("y") | Some("yes") | Some("on") | None => {
|
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
|
||||||
*slot = true;
|
*slot = true;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Some("n") | Some("no") | Some("off") => {
|
Some("n") | Some("no") | Some("off") | Some("false") => {
|
||||||
*slot = false;
|
*slot = false;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -449,11 +449,11 @@ mod parse {
|
||||||
/// other factors, such as other options, or target options.)
|
/// other factors, such as other options, or target options.)
|
||||||
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
pub(crate) fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("y") | Some("yes") | Some("on") | None => {
|
Some("y") | Some("yes") | Some("on") | Some("true") | None => {
|
||||||
*slot = Some(true);
|
*slot = Some(true);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Some("n") | Some("no") | Some("off") => {
|
Some("n") | Some("no") | Some("off") | Some("false") => {
|
||||||
*slot = Some(false);
|
*slot = Some(false);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// This test checks that the call to memchr/slice_contains is optimized away
|
// This test checks that the call to memchr/slice_contains is optimized away
|
||||||
// when searching in small slices.
|
// when searching in small slices.
|
||||||
|
|
||||||
// compile-flags: -O -Zinline-mir=no
|
// compile-flags: -O -Zinline-mir=false
|
||||||
// only-x86_64
|
// only-x86_64
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//
|
//
|
||||||
// The test is much cleaner if we deduplicate, though.
|
// The test is much cleaner if we deduplicate, though.
|
||||||
|
|
||||||
// compile-flags: -Z deduplicate-diagnostics=yes
|
// compile-flags: -Z deduplicate-diagnostics=true
|
||||||
|
|
||||||
#![forbid(
|
#![forbid(
|
||||||
unsafe_code,
|
unsafe_code,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// compile-flags: -C debug_assertions=yes
|
// compile-flags: -C debug_assertions=true
|
||||||
// needs-unwind
|
// needs-unwind
|
||||||
// ignore-emscripten dies with an LLVM error
|
// ignore-emscripten dies with an LLVM error
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// revisions: default mir-opt
|
// revisions: default mir-opt
|
||||||
//[default] compile-flags: -Zinline-mir=no
|
//[default] compile-flags: -Zinline-mir=false
|
||||||
//[mir-opt] compile-flags: -Zmir-opt-level=4
|
//[mir-opt] compile-flags: -Zmir-opt-level=4
|
||||||
|
|
||||||
use std::panic::Location;
|
use std::panic::Location;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue