diff options
| author | bors <bors@rust-lang.org> | 2024-10-15 05:02:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-15 05:02:38 +0000 |
| commit | 88f311479dd19288e5ad85e22cd80368489ce1e9 (patch) | |
| tree | a3111d2bfbd3be9cc54af57ee3c366d7b68316fd /library/std/src | |
| parent | 785c83015cb39b832cd54263823f78a1bc43c4a0 (diff) | |
| parent | 83252bd780bbce636e8dce64003985b31515e295 (diff) | |
| download | rust-88f311479dd19288e5ad85e22cd80368489ce1e9.tar.gz rust-88f311479dd19288e5ad85e22cd80368489ce1e9.zip | |
Auto merge of #131724 - matthiaskrgr:rollup-ntgkkk8, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #130608 (Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`) - #130635 (Add `&pin (mut|const) T` type position sugar) - #130747 (improve error messages for `C-cmse-nonsecure-entry` functions) - #131137 (Add 1.82 release notes) - #131328 (Remove unnecessary sorts in `rustc_hir_analysis`) - #131496 (Stabilise `const_make_ascii`.) - #131706 (Fix two const-hacks) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/pal/windows/args.rs | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/library/std/src/sys/pal/windows/args.rs b/library/std/src/sys/pal/windows/args.rs index 848632ec2a7..e9fc19bcb99 100644 --- a/library/std/src/sys/pal/windows/args.rs +++ b/library/std/src/sys/pal/windows/args.rs @@ -18,17 +18,6 @@ use crate::sys_common::AsInner; use crate::sys_common::wstr::WStrUnits; use crate::{fmt, io, iter, vec}; -/// This is the const equivalent to `NonZero::new(n).unwrap()` -/// -/// FIXME(const-hack): This can be removed once `Option::unwrap` is stably const. -/// See the `const_option` feature (#67441). -const fn non_zero_u16(n: u16) -> NonZero<u16> { - match NonZero::new(n) { - Some(n) => n, - None => panic!("called `unwrap` on a `None` value"), - } -} - pub fn args() -> Args { // SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16 // string so it's safe for `WStrUnits` to use. @@ -66,10 +55,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>( lp_cmd_line: Option<WStrUnits<'a>>, exe_name: F, ) -> Vec<OsString> { - const BACKSLASH: NonZero<u16> = non_zero_u16(b'\\' as u16); - const QUOTE: NonZero<u16> = non_zero_u16(b'"' as u16); - const TAB: NonZero<u16> = non_zero_u16(b'\t' as u16); - const SPACE: NonZero<u16> = non_zero_u16(b' ' as u16); + const BACKSLASH: NonZero<u16> = NonZero::new(b'\\' as u16).unwrap(); + const QUOTE: NonZero<u16> = NonZero::new(b'"' as u16).unwrap(); + const TAB: NonZero<u16> = NonZero::new(b'\t' as u16).unwrap(); + const SPACE: NonZero<u16> = NonZero::new(b' ' as u16).unwrap(); let mut ret_val = Vec::new(); // If the cmd line pointer is null or it points to an empty string then |
