diff options
| author | dianqk <dianqk@dianqk.net> | 2025-06-30 19:23:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-30 19:23:17 +0800 |
| commit | 0952f86de31f90b0e9f2bc700243fcc711990aa9 (patch) | |
| tree | 3fd1ced5b745ab0c85c5b6a5d9fe26e69d7319d9 /tests/ui/fmt | |
| parent | a94f0a4af8a1c11c1934ee8ba44d59fb5da77d4b (diff) | |
| parent | 580bc128441236345a5f3d5022af5a60091451ac (diff) | |
| download | rust-0952f86de31f90b0e9f2bc700243fcc711990aa9.tar.gz rust-0952f86de31f90b0e9f2bc700243fcc711990aa9.zip | |
Rollup merge of #143118 - Kivooeo:tf15, r=tgross35
`tests/ui`: A New Order [15/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@jieyouxu`
Diffstat (limited to 'tests/ui/fmt')
| -rw-r--r-- | tests/ui/fmt/debug-single-call.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/fmt/debug-single-call.rs b/tests/ui/fmt/debug-single-call.rs new file mode 100644 index 00000000000..b59a766c71a --- /dev/null +++ b/tests/ui/fmt/debug-single-call.rs @@ -0,0 +1,32 @@ +//! Test that Debug::fmt is called exactly once during formatting. +//! +//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715 + +//@ run-pass +//@ needs-threads + +use std::cell::Cell; +use std::{fmt, thread}; + +struct Foo(Cell<isize>); + +impl fmt::Debug for Foo { + fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result { + let Foo(ref f) = *self; + assert_eq!(f.get(), 0); + f.set(1); + Ok(()) + } +} + +pub fn main() { + thread::spawn(move || { + let mut f = Foo(Cell::new(0)); + println!("{:?}", f); + let Foo(ref mut f) = f; + assert_eq!(f.get(), 1); + }) + .join() + .ok() + .unwrap(); +} |
