From f021a10c5447f04ca7a324cb3247ba27f208187c Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Sun, 4 Aug 2024 11:00:54 +0200 Subject: [PATCH] Add compile_fail test for on purpose limited bounds --- tests/compile_fail/debug/lifetime_no_debug.rs | 10 ++++++++++ .../compile_fail/debug/lifetime_no_debug.stderr | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/compile_fail/debug/lifetime_no_debug.rs create mode 100644 tests/compile_fail/debug/lifetime_no_debug.stderr diff --git a/tests/compile_fail/debug/lifetime_no_debug.rs b/tests/compile_fail/debug/lifetime_no_debug.rs new file mode 100644 index 00000000..46e7382d --- /dev/null +++ b/tests/compile_fail/debug/lifetime_no_debug.rs @@ -0,0 +1,10 @@ +struct NoDebug<'a> { + a: &'a f64, +} + +#[derive(derive_more::Debug)] +struct SomeType<'a> { + no_debug: NoDebug<'a>, +} + +fn main() {} diff --git a/tests/compile_fail/debug/lifetime_no_debug.stderr b/tests/compile_fail/debug/lifetime_no_debug.stderr new file mode 100644 index 00000000..66d02bba --- /dev/null +++ b/tests/compile_fail/debug/lifetime_no_debug.stderr @@ -0,0 +1,16 @@ +error[E0277]: `NoDebug<'_>` doesn't implement `Debug` + --> tests/compile_fail/debug/lifetime_no_debug.rs:5:10 + | +5 | #[derive(derive_more::Debug)] + | ^^^^^^^^^^^^^^^^^^ `NoDebug<'_>` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `NoDebug<'_>`, which is required by `&NoDebug<'_>: Debug` + = note: add `#[derive(Debug)]` to `NoDebug<'_>` or manually `impl Debug for NoDebug<'_>` + = note: required for `&NoDebug<'_>` to implement `Debug` + = note: required for the cast from `&&NoDebug<'_>` to `&dyn Debug` + = note: this error originates in the derive macro `derive_more::Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NoDebug<'_>` with `#[derive(Debug)]` + | +1 + #[derive(Debug)] +2 | struct NoDebug<'a> { + |