Account for RPITIT in E0310 explicit lifetime constraint suggestion
When given ```rust trait Original { fn f() -> impl Fn(); } trait Erased { fn f(&self) -> Box<dyn Fn()>; } impl<T: Original> Erased for T { fn f(&self) -> Box<dyn Fn()> { Box::new(<T as Original>::f()) } } ``` avoid suggestion to restrict the `Trait::{opaque}` type in a `where` clause: ``` error[E0310]: the associated type `<T as Original>::{opaque#0}` may not live long enough --> $DIR/missing-static-bound-from-impl.rs:11:9 | LL | Box::new(<T as Original>::f()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the associated type `<T as Original>::{opaque#0}` must be valid for the static lifetime... | ...so that the type `impl Fn()` will meet its required lifetime bounds ``` CC #119773.
This commit is contained in:
parent
933a05bd0b
commit
5e6da720f6
4 changed files with 36 additions and 2 deletions
|
@ -0,0 +1,12 @@
|
|||
error[E0310]: the associated type `<T as Original>::{opaque#0}` may not live long enough
|
||||
--> $DIR/missing-static-bound-from-impl.rs:11:9
|
||||
|
|
||||
LL | Box::new(<T as Original>::f())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| the associated type `<T as Original>::{opaque#0}` must be valid for the static lifetime...
|
||||
| ...so that the type `impl Fn()` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
Loading…
Add table
Add a link
Reference in a new issue