1
0
Fork 0
forked from mirror/grapevine

Add type annotation to fix weird inference error

error[E0275]: overflow evaluating the requirement `Box<[_]>: Deserialize<'_>`
    --> src/api/server_server.rs:1801:32
     |
1801 |       let invited_user: Box<_> = serde_json::from_value(
     |  ________________________________^
1802 | |         signed_event
1803 | |             .get("state_key")
1804 | |             .ok_or(Error::BadRequest(
...    |
1809 | |             .into(),
1810 | |     )
     | |_____^
     |
     = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`grapevine`)
     = note: required for `Box<zerovec::varzerovec::slice::VarZeroSlice<[_], _>>` to implement `Deserialize<'_>`
     = note: 126 redundant requirements hidden
     = note: required for `Box<VarZeroSlice<VarZeroSlice<VarZeroSlice<VarZeroSlice<..., ...>, ...>, ...>, ...>>` to implement `for<'de> Deserialize<'de>`
     = note: required for `Box<VarZeroSlice<VarZeroSlice<VarZeroSlice<VarZeroSlice<..., ...>, ...>, ...>, ...>>` to implement `DeserializeOwned`
note: required by a bound in `serde_json::from_value`
    --> /home/xiretza/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.117/src/value/mod.rs:1006:8
     |
1004 | pub fn from_value<T>(value: Value) -> Result<T, Error>
     |        ---------- required by a bound in this function
1005 | where
1006 |     T: DeserializeOwned,
     |        ^^^^^^^^^^^^^^^^ required by this bound in `from_value`
     = note: the full name for the type has been written to '/home/xiretza/dev/rust/grapevine-fork/target/debug/deps/grapevine-212231bd4a0b94d3.long-type-685143825526684512.txt'
     = note: consider using `--verbose` to print the full type name to the console
     = note: the full name for the type has been written to '/home/xiretza/dev/rust/grapevine-fork/target/debug/deps/grapevine-212231bd4a0b94d3.long-type-685143825526684512.txt'
     = note: consider using `--verbose` to print the full type name to the console
This commit is contained in:
Lambda 2024-09-05 21:52:25 +00:00
parent d6fe411443
commit cd658d038a

View file

@ -63,7 +63,7 @@ use ruma::{
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName,
ServerName, UserId,
};
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
use tokio::sync::RwLock;
@ -1797,7 +1797,7 @@ pub(crate) async fn create_invite_route(
Error::BadRequest(ErrorKind::InvalidParam, "sender is not a user id.")
})?;
let invited_user: Box<_> = serde_json::from_value(
let invited_user: Box<UserId> = serde_json::from_value(
signed_event
.get("state_key")
.ok_or(Error::BadRequest(