Open
Description
I tried this code:
trait Service<Req> {}
impl<'a, Req: 'a> Service<&'a Req> for u8 {}
fn main() {
fn impl_check() where u8: for<'a, 'b> Service<&'a &'b u8> {}
impl_check()
}
I expected to see this happen: code compiles fine
Instead, this happened: Implementation is not general enough
Error
Removing the explicit lifetime bound on the impl fixes the problem:
- impl<'a, Req: 'a> Service<&'a Req> for u8 {}
+ impl<'a, Req> Service<&'a Req> for u8 {}
Meta
Reproduced on both the current stable and nightly branches.
rustc --version --verbose
:
1.62.0-nightly (2022-04-09 8bf93e9b6791acee3a59)
Error Output
error: implementation of `Service` is not general enough
[--> src/lib.rs:7:5
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021#) |
7 | impl_check()
| ^^^^^^^^^^ implementation of `Service` is not general enough
|
= note: `u8` must implement `Service<&'0 &'1 u8>`, for any two lifetimes `'0` and `'1`...
= note: ...but it actually implements `Service<&'2 &'b u8>`, for some specific lifetime `'2`
Metadata
Metadata
Assignees
Labels
Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lifetimes / regionsArea: Trait systemArea: Type systemCategory: This is a bug.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.