Skip to content

Commit d015f01

Browse files
committed
fix should_panic and add docs
1 parent 8d6f9d5 commit d015f01

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

library/core/src/ascii/ascii_char.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ impl Add<u8> for AsciiChar {
633633
/// #![feature(ascii_char, ascii_char_variants)]
634634
/// use core::ascii::Char;
635635
///
636+
/// // This produces value which is not a valid ASCII character and thus
637+
/// // panics in debug builds.
636638
/// let _ = Char::Digit0 + 100;
637639
/// ```
638640
#[inline]

library/core/tests/ascii_char.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,24 @@ fn test_arithmetic_ok() {
1515

1616
/// Tests addition wraps values when built in release mode.
1717
#[test]
18-
#[cfg_attr(debug_assertions, ignore)]
18+
#[cfg_attr(debug_assertions, ignore = "works in release builds only")]
1919
fn test_arithmetic_wrapping() {
2020
assert_eq!(Char::Digit0, Char::Digit8 + 120);
2121
assert_eq!(Char::Digit0, Char::Digit8 + 248);
2222
}
2323

2424
/// Tests addition panics in debug build when it produces an invalid ASCII char.
25-
///
26-
/// Note: Rust tests (at least when run via `./x.py test library/core`) are
27-
/// built in release mode so this test is normally ignored. However, we have
28-
/// a doctest which checks the behaviour.
2925
#[test]
30-
#[cfg_attr(not(debug_assertions), ignore)]
26+
#[cfg_attr(not(debug_assertions), ignore = "works in debug builds only")]
27+
#[should_panic]
3128
fn test_arithmetic_non_ascii() {
3229
let _ = Char::Digit0 + 120;
3330
}
3431

3532
/// Tests addition panics in debug build when it overflowing u8.
36-
///
37-
/// Note: Rust tests (at least when run via `./x.py test library/core`) are
38-
/// built in release mode so this test is normally ignored. However, we have
39-
/// a doctest which checks the behaviour.
4033
#[test]
41-
#[cfg_attr(not(debug_assertions), ignore)]
34+
#[cfg_attr(not(debug_assertions), ignore = "works in debug builds only")]
35+
#[should_panic]
4236
fn test_arithmetic_overflow() {
4337
let _ = Char::Digit0 + 250;
4438
}

0 commit comments

Comments
 (0)