Skip to content

Commit ff4665f

Browse files
committed
Regression tests for issue 81211.
1 parent 2307d08 commit ff4665f

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// run-pass
2+
#![allow(warnings)]
3+
4+
#[derive(Debug)]
5+
pub struct Bar { pub t: () }
6+
7+
impl<T> Access for T {}
8+
pub trait Access {
9+
fn field(&self, _: impl Sized, _: impl Sized) {
10+
panic!("got into Access::field");
11+
}
12+
13+
fn finish(&self) -> Result<(), std::fmt::Error> {
14+
panic!("got into Access::finish");
15+
}
16+
17+
fn debug_struct(&self, _: impl Sized, _: impl Sized) {
18+
panic!("got into Access::debug_struct");
19+
}
20+
}
21+
22+
impl<T> MutAccess for T {}
23+
pub trait MutAccess {
24+
fn field(&mut self, _: impl Sized, _: impl Sized) {
25+
panic!("got into MutAccess::field");
26+
}
27+
28+
fn finish(&mut self) -> Result<(), std::fmt::Error> {
29+
panic!("got into MutAccess::finish");
30+
}
31+
32+
fn debug_struct(&mut self, _: impl Sized, _: impl Sized) {
33+
panic!("got into MutAccess::debug_struct");
34+
}
35+
}
36+
37+
fn main() {
38+
let bar = Bar { t: () };
39+
assert_eq!("Bar { t: () }", format!("{:?}", bar));
40+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// run-pass
2+
#![allow(warnings)]
3+
4+
#[derive(Debug)]
5+
pub struct Foo<T>(pub T);
6+
7+
use std::fmt;
8+
9+
impl<T> Field for T {}
10+
impl<T> Finish for T {}
11+
impl Dt for &mut fmt::Formatter<'_> {}
12+
13+
pub trait Field {
14+
fn field(&self, _: impl Sized) {
15+
panic!("got into field");
16+
}
17+
}
18+
pub trait Finish {
19+
fn finish(&self) -> Result<(), std::fmt::Error> {
20+
panic!("got into finish");
21+
}
22+
}
23+
pub trait Dt {
24+
fn debug_tuple(&self, _: &str) {
25+
panic!("got into debug_tuple");
26+
}
27+
}
28+
29+
fn main() {
30+
let foo = Foo(());
31+
assert_eq!("Foo(())", format!("{:?}", foo));
32+
}

0 commit comments

Comments
 (0)