diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2021-01-23 00:50:31 -0500 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2021-02-01 17:08:37 -0500 |
| commit | ff4665f45f846f82fd8046c50a0fe501b7f31665 (patch) | |
| tree | fde32d1a267f03cdf3bb38b929e44d25647a4392 | |
| parent | 2307d08d2f34ef782a1cc7af7bde57d766acd344 (diff) | |
| download | rust-ff4665f45f846f82fd8046c50a0fe501b7f31665.tar.gz rust-ff4665f45f846f82fd8046c50a0fe501b7f31665.zip | |
Regression tests for issue 81211.
| -rw-r--r-- | src/test/ui/derives/derive-Debug-use-ufcs-struct.rs | 40 | ||||
| -rw-r--r-- | src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs | 32 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs b/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs new file mode 100644 index 00000000000..cb9dda84159 --- /dev/null +++ b/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs @@ -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)); +} diff --git a/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs b/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs new file mode 100644 index 00000000000..5f786769fe7 --- /dev/null +++ b/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs @@ -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)); +} |
