Skip to content

Commit

Permalink
Add compile_fail test for on purpose limited bounds (#393, #392)
Browse files Browse the repository at this point in the history
Resolves #392
Related to #371

## Synopsis

Before #371 this code would compile without any issues, but that would
actually
hide the problem that the resulting `Debug` implementation was never
applicable, because the bounds could not be satisfied.

## Solution

This problem was already solved by #371, but this adds a test case to
ensure
that we don't regress here again.
  • Loading branch information
JelteF authored Aug 5, 2024
1 parent f665d18 commit e8d60cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/compile_fail/debug/lifetime_no_debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct NoDebug<'a> {
a: &'a f64,
}

#[derive(derive_more::Debug)]
struct SomeType<'a> {
no_debug: NoDebug<'a>,
}

fn main() {}
16 changes: 16 additions & 0 deletions tests/compile_fail/debug/lifetime_no_debug.stderr
Original file line number Diff line number Diff line change
@@ -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> {
|

0 comments on commit e8d60cf

Please sign in to comment.