Regression tests for issue 81211.

This commit is contained in:
Felix S. Klock II 2021-01-23 00:50:31 -05:00
parent 2307d08d2f
commit ff4665f45f
2 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,40 @@
// run-pass
#![allow(warnings)]
#[derive(Debug)]
pub struct Bar { pub t: () }
impl<T> Access for T {}
pub trait Access {
fn field(&self, _: impl Sized, _: impl Sized) {
panic!("got into Access::field");
}
fn finish(&self) -> Result<(), std::fmt::Error> {
panic!("got into Access::finish");
}
fn debug_struct(&self, _: impl Sized, _: impl Sized) {
panic!("got into Access::debug_struct");
}
}
impl<T> MutAccess for T {}
pub trait MutAccess {
fn field(&mut self, _: impl Sized, _: impl Sized) {
panic!("got into MutAccess::field");
}
fn finish(&mut self) -> Result<(), std::fmt::Error> {
panic!("got into MutAccess::finish");
}
fn debug_struct(&mut self, _: impl Sized, _: impl Sized) {
panic!("got into MutAccess::debug_struct");
}
}
fn main() {
let bar = Bar { t: () };
assert_eq!("Bar { t: () }", format!("{:?}", bar));
}

View file

@ -0,0 +1,32 @@
// run-pass
#![allow(warnings)]
#[derive(Debug)]
pub struct Foo<T>(pub T);
use std::fmt;
impl<T> Field for T {}
impl<T> Finish for T {}
impl Dt for &mut fmt::Formatter<'_> {}
pub trait Field {
fn field(&self, _: impl Sized) {
panic!("got into field");
}
}
pub trait Finish {
fn finish(&self) -> Result<(), std::fmt::Error> {
panic!("got into finish");
}
}
pub trait Dt {
fn debug_tuple(&self, _: &str) {
panic!("got into debug_tuple");
}
}
fn main() {
let foo = Foo(());
assert_eq!("Foo(())", format!("{:?}", foo));
}