diff options
| author | bors <bors@rust-lang.org> | 2016-07-28 11:20:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-28 11:20:33 -0700 |
| commit | d1df3fecdf8dc959fbd8901603a16e5bc0bfa21d (patch) | |
| tree | 52351065a422a440701808df99b4f476058eb2fb /src/test | |
| parent | 748ecb1235d1cfa1aeaa0e5424c454837089f6cc (diff) | |
| parent | 3d09b4a0d58200da84fe19cd3b0003d61e5b1791 (diff) | |
| download | rust-d1df3fecdf8dc959fbd8901603a16e5bc0bfa21d.tar.gz rust-d1df3fecdf8dc959fbd8901603a16e5bc0bfa21d.zip | |
Auto merge of #34485 - tbu-:pr_unicode_debug_str, r=alexcrichton
Escape fewer Unicode codepoints in `Debug` impl of `str`
Use the same procedure as Python to determine whether a character is
printable, described in [PEP 3138]. In particular, this means that the
following character classes are escaped:
- Cc (Other, Control)
- Cf (Other, Format)
- Cs (Other, Surrogate), even though they can't appear in Rust strings
- Co (Other, Private Use)
- Cn (Other, Not Assigned)
- Zl (Separator, Line)
- Zp (Separator, Paragraph)
- Zs (Separator, Space), except for the ASCII space `' '` `0x20`
This allows for user-friendly inspection of strings that are not
English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`).
Fixes #34318.
CC #34422.
[PEP 3138]: https://www.python.org/dev/peps/pep-3138/
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/ifmt.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass/sync-send-iterators-in-libcore.rs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index ed56519d236..8b5536de12e 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -70,15 +70,15 @@ pub fn main() { t!(format!("{}", '☃'), "☃"); t!(format!("{}", 10), "10"); t!(format!("{}", 10_usize), "10"); - t!(format!("{:?}", '☃'), "'\\u{2603}'"); + t!(format!("{:?}", '☃'), "'☃'"); t!(format!("{:?}", 10), "10"); t!(format!("{:?}", 10_usize), "10"); t!(format!("{:?}", "true"), "\"true\""); t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\""); t!(format!("{:?}", "foo\n\"bar\"\r\n\'baz\'\t\\qux\\"), r#""foo\n\"bar\"\r\n\'baz\'\t\\qux\\""#); - t!(format!("{:?}", "foo\0bar\x01baz\u{3b1}q\u{75}x"), - r#""foo\u{0}bar\u{1}baz\u{3b1}qux""#); + t!(format!("{:?}", "foo\0bar\x01baz\u{7f}q\u{75}x"), + r#""foo\u{0}bar\u{1}baz\u{7f}qux""#); t!(format!("{:o}", 10_usize), "12"); t!(format!("{:x}", 10_usize), "a"); t!(format!("{:X}", 10_usize), "A"); diff --git a/src/test/run-pass/sync-send-iterators-in-libcore.rs b/src/test/run-pass/sync-send-iterators-in-libcore.rs index 93178994815..d12bdf182fa 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcore.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcore.rs @@ -67,7 +67,7 @@ macro_rules! is_sync_send { fn main() { // for char.rs - all_sync_send!("Я", escape_default, escape_unicode); + all_sync_send!("Я", escape_debug, escape_default, escape_unicode); // for iter.rs all_sync_send_mutable_ref!([1], iter); |
