mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Delete tests/codegen/fmt_int_no_panic.rs
this test was included for demonstrative and discussion purposes but does not test what its name alleges - in fact it does not test much of value at all! as mentioned in this comment, https://github.com/rust-lang/rust/pull/122770#issuecomment-2474256965 , writing a correct test for this codegen outcome is difficult (partially because the public interface to std::fmt intentionally includes an #[inline(never)] function!), so to test this correctly will require more than i can offer in 122770.
This commit is contained in:
parent
cea973f857
commit
a54d6ad039
@ -1,24 +0,0 @@
|
||||
// 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(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user