Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a2dce77
Start documenting autodiff activities
ZuseZ4 Oct 28, 2025
f4efc37
feat: Add `bit_width` for unsigned `NonZero<T>`
sorairolake Nov 10, 2025
740b8ba
Make SIMD intrinsics available in `const`-contexts
sayantn Nov 3, 2025
47384f7
add check for when span is from macro expansion
Kivooeo Nov 12, 2025
f5892da
add autodiff examples
ZuseZ4 Nov 12, 2025
82ff614
Enable const-testing for the ported SIMD intrinsics
sayantn Nov 16, 2025
754a82d
recommend using a HashMap if a HashSet's second generic parameter doe…
Qelxiros Sep 30, 2025
1cfd0b7
Match <OsString as Debug>::fmt to that of str
tamird Aug 7, 2023
eb84efc
Remove <os::Vars as Debug> workaround
tamird Aug 13, 2023
a25950d
feat: Change return type of `NonZero::bit_width`
sorairolake Nov 18, 2025
0b2e02f
autodiff: update formating, improve examples for the unstable-book
ZuseZ4 Nov 19, 2025
847c422
Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead
matthiaskrgr Nov 19, 2025
2cc5bf7
Rollup merge of #147421 - Kivooeo:ice-fix51621, r=chenyukang
matthiaskrgr Nov 19, 2025
714f1ce
Rollup merge of #147521 - sayantn:simd-const-intrinsics, r=madsmtm
matthiaskrgr Nov 19, 2025
3732c3c
Rollup merge of #148201 - ZuseZ4:autodiff-activity-docs, r=oli-obk
matthiaskrgr Nov 19, 2025
8b74790
Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width…
matthiaskrgr Nov 19, 2025
48fa913
Rollup merge of #148798 - tamird:esc-single-quote, r=Amanieu
matthiaskrgr Nov 19, 2025
fd88e61
Rollup merge of #149082 - ZuseZ4:autodiff-unstable-book-fmt, r=chenyu…
matthiaskrgr Nov 19, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Match <OsString as Debug>::fmt to that of str
819247f changed <str as Debug>::fmt such that it does not escape single quotes, but neglected to apply the same choice to OsString. This commit does that.
  • Loading branch information
tamird committed Nov 17, 2025
commit 1cfd0b7c55257c65d8521707e7902e205571c7fd
7 changes: 6 additions & 1 deletion library/core/src/str/lossy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::char::EscapeDebugExtArgs;
use super::from_utf8_unchecked;
use super::validations::utf8_char_width;
use crate::fmt;
Expand Down Expand Up @@ -121,7 +122,11 @@ impl fmt::Debug for Debug<'_> {
let valid = chunk.valid();
let mut from = 0;
for (i, c) in valid.char_indices() {
let esc = c.escape_debug();
let esc = c.escape_debug_ext(EscapeDebugExtArgs {
escape_grapheme_extended: true,
escape_single_quote: false,
escape_double_quote: true,
});
// If char needs escaping, flush backlog so far and write, else skip
if esc.len() != 1 {
f.write_str(&valid[from..i])?;
Expand Down
16 changes: 11 additions & 5 deletions library/core/src/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// implementations, so, we'll have to add more doc(hidden)s anyway
#![doc(hidden)]

use crate::char::encode_utf16_raw;
use crate::char::{EscapeDebugExtArgs, encode_utf16_raw};
use crate::clone::CloneToUninit;
use crate::fmt::{self, Write};
use crate::hash::{Hash, Hasher};
Expand Down Expand Up @@ -144,14 +144,20 @@ impl AsRef<[u8]> for Wtf8 {
impl fmt::Debug for Wtf8 {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result {
use crate::fmt::Write;
for c in s.chars().flat_map(|c| c.escape_debug()) {
use crate::fmt::Write as _;
for c in s.chars().flat_map(|c| {
c.escape_debug_ext(EscapeDebugExtArgs {
escape_grapheme_extended: true,
escape_single_quote: false,
escape_double_quote: true,
})
}) {
f.write_char(c)?
}
Ok(())
}

formatter.write_str("\"")?;
formatter.write_char('"')?;
let mut pos = 0;
while let Some((surrogate_pos, surrogate)) = self.next_surrogate(pos) {
// SAFETY: next_surrogate provides an index for a range of valid UTF-8 bytes.
Expand All @@ -164,7 +170,7 @@ impl fmt::Debug for Wtf8 {

// SAFETY: after next_surrogate returns None, the remainder is valid UTF-8.
write_str_escaped(formatter, unsafe { str::from_utf8_unchecked(&self.bytes[pos..]) })?;
formatter.write_str("\"")
formatter.write_char('"')
}
}

Expand Down
1 change: 1 addition & 0 deletions library/coretests/tests/str_lossy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ fn debug() {
b"Hello\xC0\x80 There\xE6\x83 Goodbye\xf4\x8d\x93\xaa".utf8_chunks().debug(),
),
);
assert_eq!("\"'\"", &format!("{:?}", b"'".utf8_chunks().debug()));
}
6 changes: 6 additions & 0 deletions library/std/src/ffi/os_str/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,9 @@ fn clone_to_uninit() {
unsafe { a.clone_to_uninit(ptr::from_mut::<OsStr>(&mut b).cast()) };
assert_eq!(a, &*b);
}

#[test]
fn debug() {
let s = "'single quotes'";
assert_eq!(format!("{:?}", OsStr::new(s)), format!("{:?}", s));
}