-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try adding a test that LowerHex and friends don't panic, but it doesn…
…'t work
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Trying to check that formatting u8/u32/u64/etc do not panic. | ||
// | ||
// This test does not correctly do so yet. | ||
|
||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
// expected to need to write some kind of `impl core::fmt::Write` on a struct like this to avoid | ||
// unrelated panics if `String::write_str` can't make space.. | ||
// struct CanAlwaysBeWrittenTo; | ||
|
||
use std::fmt::Write; | ||
|
||
// CHECK-LABEL: @format_int_doesnt_panic | ||
#[no_mangle] | ||
pub fn format_int_doesnt_panic(s: &mut String) -> std::fmt::Result { | ||
// CHECK-NOT: panic | ||
// ... but wait! this will definitely panic if `s.vec.reserve_for_push()` cannot alloc! this | ||
// shouldn't pass! | ||
write!(s, "{:x}", 0u8)?; | ||
write!(s, "{:x}", u8::MAX)?; | ||
Ok(()) | ||
} |