github link for full code
pub enum Resp {
SimpleString(SimpleString),
BulkString(BulkString),
Array(Array),
}
impl Resp {
// This calls Array::parse_body
pub fn parse(
mut read: impl AsyncBufRead + Unpin + Send,
) -> impl Future<Output = Result<Self>> + Send { Box::pin(async move {...}) }
}
pub struct Array(Vec<Resp>);
impl RespParsable for Array {
// This calls Resp::parse
async fn parse_body(mut read: impl AsyncBufRead + Unpin + Send) -> Result<Self>
where
Self: Sized, { ... }
}
I tried to build a simple Redis Resp enum by defining async Resp::parse() -> Result<Self>
and async Array::parse_body() -> Result<Self>
, but I've had E0275 so I boxed Resp::parse
in order to break the cycle. (You can see the code with E2705 error here)
After that cargo clippy
has no error but cargo build
has following error:
error: reached the recursion limit while instantiating `std::ptr::drop_in_place::<{async block@src/resp/mod.rs:34:18: 55:10}> - shim(Some({async block@src/resp/mod.rs:34:18: 55:10}))`
--> /(userpath)/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:514:1
|
514 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `std::ptr::drop_in_place` defined here
--> /Users/jcshin/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:514:1
|
514 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What is this error message and how can I fix it?