Skip to content

Commit e8d60cf

Browse files
authored
Add compile_fail test for on purpose limited bounds (#393, #392)
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.
1 parent f665d18 commit e8d60cf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct NoDebug<'a> {
2+
a: &'a f64,
3+
}
4+
5+
#[derive(derive_more::Debug)]
6+
struct SomeType<'a> {
7+
no_debug: NoDebug<'a>,
8+
}
9+
10+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0277]: `NoDebug<'_>` doesn't implement `Debug`
2+
--> tests/compile_fail/debug/lifetime_no_debug.rs:5:10
3+
|
4+
5 | #[derive(derive_more::Debug)]
5+
| ^^^^^^^^^^^^^^^^^^ `NoDebug<'_>` cannot be formatted using `{:?}`
6+
|
7+
= help: the trait `Debug` is not implemented for `NoDebug<'_>`, which is required by `&NoDebug<'_>: Debug`
8+
= note: add `#[derive(Debug)]` to `NoDebug<'_>` or manually `impl Debug for NoDebug<'_>`
9+
= note: required for `&NoDebug<'_>` to implement `Debug`
10+
= note: required for the cast from `&&NoDebug<'_>` to `&dyn Debug`
11+
= note: this error originates in the derive macro `derive_more::Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
help: consider annotating `NoDebug<'_>` with `#[derive(Debug)]`
13+
|
14+
1 + #[derive(Debug)]
15+
2 | struct NoDebug<'a> {
16+
|

0 commit comments

Comments
 (0)