Skip to content

Commit 20cf070

Browse files
committed
Auto merge of rust-lang#98632 - matthiaskrgr:rollup-peg868d, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#98548 (rustdoc-json: Allow Typedef to be different in sanity assert) - rust-lang#98560 (Add regression test for rust-lang#85907) - rust-lang#98564 (Remove references to `./tmp` in-tree) - rust-lang#98602 (Add regression test for rust-lang#80074) - rust-lang#98606 (:arrow_up: rust-analyzer) - rust-lang#98609 (Fix ICE for associated constant generics) - rust-lang#98611 (Fix glob import ICE in rustdoc JSON format) - rust-lang#98617 (Remove feature `const_option` from std) - rust-lang#98619 (Fix mir-opt wg name) - rust-lang#98621 (llvm-wrapper: adapt for removal of the ASanGlobalsMetadataAnalysis LLVM API) - rust-lang#98623 (fix typo in comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents aab4fec + 191ce07 commit 20cf070

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
#![feature(const_ip)]
336336
#![feature(const_ipv4)]
337337
#![feature(const_ipv6)]
338-
#![feature(const_option)]
339338
#![feature(const_socketaddr)]
340339
#![feature(thread_local_internals)]
341340
//

std/src/sys/windows/args.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ use crate::vec;
2121

2222
use core::iter;
2323

24+
/// This is the const equivalent to `NonZeroU16::new(n).unwrap()`
25+
///
26+
/// FIXME: This can be removed once `Option::unwrap` is stably const.
27+
/// See the `const_option` feature (#67441).
28+
const fn non_zero_u16(n: u16) -> NonZeroU16 {
29+
match NonZeroU16::new(n) {
30+
Some(n) => n,
31+
None => panic!("called `unwrap` on a `None` value"),
32+
}
33+
}
34+
2435
pub fn args() -> Args {
2536
// SAFETY: `GetCommandLineW` returns a pointer to a null terminated UTF-16
2637
// string so it's safe for `WStrUnits` to use.
@@ -58,10 +69,10 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
5869
lp_cmd_line: Option<WStrUnits<'a>>,
5970
exe_name: F,
6071
) -> Vec<OsString> {
61-
const BACKSLASH: NonZeroU16 = NonZeroU16::new(b'\\' as u16).unwrap();
62-
const QUOTE: NonZeroU16 = NonZeroU16::new(b'"' as u16).unwrap();
63-
const TAB: NonZeroU16 = NonZeroU16::new(b'\t' as u16).unwrap();
64-
const SPACE: NonZeroU16 = NonZeroU16::new(b' ' as u16).unwrap();
72+
const BACKSLASH: NonZeroU16 = non_zero_u16(b'\\' as u16);
73+
const QUOTE: NonZeroU16 = non_zero_u16(b'"' as u16);
74+
const TAB: NonZeroU16 = non_zero_u16(b'\t' as u16);
75+
const SPACE: NonZeroU16 = non_zero_u16(b' ' as u16);
6576

6677
let mut ret_val = Vec::new();
6778
// If the cmd line pointer is null or it points to an empty string then

0 commit comments

Comments
 (0)