Unhelpful error message "ambiguous lifetime bound, explicit lifetime bound required" #130952
Open
Description
opened on Sep 27, 2024
Code
trait MyTrait<'a, 'b> where Self: 'a + 'b {}
pub struct Foo<'a, 'b> {
expr: Box<dyn MyTrait<'a, 'b>>,
}
// Fix:
pub struct Bar<'all, 'a, 'b> where 'all: 'a, 'all: 'b {
expr: Box<dyn MyTrait<'a, 'b> + 'all>,
}
Current output
error[E0227]: ambiguous lifetime bound, explicit lifetime bound required
--> src/lib.rs:4:15
|
4 | expr: Box<dyn MyTrait<'a, 'b>>,
| ^^^^^^^^^^^^^^^^^^^
For more information about this error, try rustc --explain E0227
.
Desired output
No response
Rationale and extra context
No response
Other cases
No response
Rust Version
$ rustc -Vv
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Anything else?
No response
Activity