From 661c355172f34b08c68afea1cef99b5ee91c68ad Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Mon, 1 Feb 2021 22:43:13 +0000 Subject: [PATCH] fix: Address issues with Rust nightly caused by rust-lang/rust#79819 --- src/api/collections/get_collection.rs | 4 ++-- src/api/collections/get_collections.rs | 2 +- src/api/collections/new_collection.rs | 2 +- src/api/collections/remove_collection.rs | 4 ++-- src/api/collections/store_collection.rs | 4 ++-- src/api/ideas/get_idea.rs | 18 +++++++++--------- src/api/ideas/get_ideas.rs | 10 +++++----- src/api/ideas/get_random_idea.rs | 10 +++++----- src/api/ideas/new_idea.rs | 10 +++++----- src/api/ideas/remove_idea.rs | 18 +++++++++--------- src/api/ideas/store_idea.rs | 18 +++++++++--------- src/api/macros.rs | 4 ++-- .../role_assignments/get_role_assignment.rs | 6 +++--- .../role_assignments/get_role_assignments.rs | 4 ++-- .../role_assignments/remove_role_assignment.rs | 6 +++--- .../role_assignments/store_role_assignment.rs | 6 +++--- src/api/users/get_user.rs | 2 +- 17 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/api/collections/get_collection.rs b/src/api/collections/get_collection.rs index 455a6277..cc02030f 100644 --- a/src/api/collections/get_collection.rs +++ b/src/api/collections/get_collection.rs @@ -12,8 +12,8 @@ async fn get_collection_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Collections.Read"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetCollection { id: cid, principal_id: uid }.trace()).await?.map(|collection| collection.clone().into()) } diff --git a/src/api/collections/get_collections.rs b/src/api/collections/get_collections.rs index 0ff8c9c9..b7a1a9c4 100644 --- a/src/api/collections/get_collections.rs +++ b/src/api/collections/get_collections.rs @@ -11,7 +11,7 @@ async fn get_collections_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Collections.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; diff --git a/src/api/collections/new_collection.rs b/src/api/collections/new_collection.rs index e9cda642..b476e160 100644 --- a/src/api/collections/new_collection.rs +++ b/src/api/collections/new_collection.rs @@ -13,7 +13,7 @@ async fn new_collection_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Collections.Write"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); let collection = state.store.send(StoreCollection { principal_id: uid, diff --git a/src/api/collections/remove_collection.rs b/src/api/collections/remove_collection.rs index 42757e22..ed139cd9 100644 --- a/src/api/collections/remove_collection.rs +++ b/src/api/collections/remove_collection.rs @@ -12,8 +12,8 @@ async fn remove_collection_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Collections.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(RemoveCollection { id: cid, principal_id: uid }.trace()).await??; diff --git a/src/api/collections/store_collection.rs b/src/api/collections/store_collection.rs index 2892a0e6..597a53b9 100644 --- a/src/api/collections/store_collection.rs +++ b/src/api/collections/store_collection.rs @@ -14,8 +14,8 @@ async fn store_collection_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Collections.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(StoreCollection { principal_id: uid, diff --git a/src/api/ideas/get_idea.rs b/src/api/ideas/get_idea.rs index eaec35db..5b208509 100644 --- a/src/api/ideas/get_idea.rs +++ b/src/api/ideas/get_idea.rs @@ -12,8 +12,8 @@ async fn get_idea_v1( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetIdea { collection: uid, id: id }.trace()).await?.map(|idea| idea.clone().into()) } @@ -26,8 +26,8 @@ async fn get_idea_v2( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetIdea { collection: uid, id: id }.trace()).await?.map(|idea| idea.clone().into()) } @@ -40,8 +40,8 @@ async fn get_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -56,9 +56,9 @@ async fn get_collection_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let id = parse_uuid!(info.id, idea ID); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; diff --git a/src/api/ideas/get_ideas.rs b/src/api/ideas/get_ideas.rs index 6d4c998c..d8edaf47 100644 --- a/src/api/ideas/get_ideas.rs +++ b/src/api/ideas/get_ideas.rs @@ -12,7 +12,7 @@ async fn get_ideas_v1( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetIdeas { collection: uid, is_completed: None, tag: None }.trace()).await?.map(|ideas| web::Json(ideas.iter().map(|i| i.clone().into()).collect())) } @@ -25,7 +25,7 @@ async fn get_ideas_v2( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetIdeas { collection: uid, @@ -42,7 +42,7 @@ async fn get_ideas_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; state.store.send(GetRoleAssignment { principal_id: uid, collection_id: uid }).await??; @@ -62,8 +62,8 @@ async fn get_collection_ideas_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; state.store.send(GetRoleAssignment { principal_id: uid, collection_id: cid }.trace()).await??; diff --git a/src/api/ideas/get_random_idea.rs b/src/api/ideas/get_random_idea.rs index 8db6437e..b7bcb4e2 100644 --- a/src/api/ideas/get_random_idea.rs +++ b/src/api/ideas/get_random_idea.rs @@ -9,7 +9,7 @@ async fn get_random_idea_v1(state: web::Data, token: AuthToken) -> require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetRandomIdea { collection: uid, is_completed: None, tag: None }.trace()).await?.map(|idea| idea.clone().into()) } @@ -22,7 +22,7 @@ async fn get_random_idea_v2( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetRandomIdea { collection: uid, is_completed: query.complete, tag: query.tag.clone() }.trace()).await?.map(|idea| idea.clone().into()) } @@ -35,7 +35,7 @@ async fn get_random_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; state.store.send(GetRoleAssignment { principal_id: uid, collection_id: uid }.trace()).await??; @@ -51,8 +51,8 @@ async fn get_random_collection_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Read"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(GetRoleAssignment { principal_id: uid, collection_id: cid }.trace()).await??; diff --git a/src/api/ideas/new_idea.rs b/src/api/ideas/new_idea.rs index 16693e3b..6e840e2a 100644 --- a/src/api/ideas/new_idea.rs +++ b/src/api/ideas/new_idea.rs @@ -13,7 +13,7 @@ async fn new_idea_v1( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -36,7 +36,7 @@ async fn new_idea_v2( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -59,7 +59,7 @@ async fn new_idea_v3( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let uid = parse_uuid!(token.oid(), auth token oid); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -82,8 +82,8 @@ async fn new_collection_idea_v3( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); if cid == uid { ensure_user_collection(&state, &token).await?; diff --git a/src/api/ideas/remove_idea.rs b/src/api/ideas/remove_idea.rs index b8ed2218..894cc53d 100644 --- a/src/api/ideas/remove_idea.rs +++ b/src/api/ideas/remove_idea.rs @@ -12,8 +12,8 @@ async fn remove_idea_v1( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Write"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(RemoveIdea { collection: uid, id: id }.trace()).await??; @@ -28,8 +28,8 @@ async fn remove_idea_v2( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Write"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(RemoveIdea { collection: uid, id: id }.trace()).await??; @@ -44,8 +44,8 @@ async fn remove_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Write"); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); state.store.send(RemoveIdea { collection: uid, id: id }.trace()).await??; @@ -60,9 +60,9 @@ async fn remove_collection_idea_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "Ideas.Write"); - let id = parse_uuid!(info.id, idea ID); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; diff --git a/src/api/ideas/store_idea.rs b/src/api/ideas/store_idea.rs index 794ff60b..f64b39dc 100644 --- a/src/api/ideas/store_idea.rs +++ b/src/api/ideas/store_idea.rs @@ -18,8 +18,8 @@ async fn store_idea_v1( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -47,8 +47,8 @@ async fn store_idea_v2( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -76,8 +76,8 @@ async fn store_idea_v3( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let id = parse_uuid!(info.id, idea ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; @@ -105,9 +105,9 @@ async fn store_collection_idea_v3( require_scope!(token, "Ideas.Write"); let idea: Idea = new_idea.into_inner().into(); - let id = parse_uuid!(info.id, idea ID); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let id = parse_uuid!(info.id, "idea ID"); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); ensure_user_collection(&state, &token).await?; diff --git a/src/api/macros.rs b/src/api/macros.rs index 20beff1c..a6c5e851 100644 --- a/src/api/macros.rs +++ b/src/api/macros.rs @@ -1,8 +1,8 @@ #[macro_export] macro_rules! parse_uuid { - ($from:expr, $($desc:tt)+) => { + ($from:expr, $desc:expr) => { u128::from_str_radix($from.replace("-", "").as_str(), 16) - .or(Err(APIError::new(400, "Bad Request", "The $($desc)+ you provided could not be parsed. Please check it and try again.")))?; + .or(Err(APIError::new(400, "Bad Request", &format!("The {} you provided could not be parsed. Please check it and try again.", $desc))))? }; } diff --git a/src/api/role_assignments/get_role_assignment.rs b/src/api/role_assignments/get_role_assignment.rs index ce80d939..0ac6cbac 100644 --- a/src/api/role_assignments/get_role_assignment.rs +++ b/src/api/role_assignments/get_role_assignment.rs @@ -12,9 +12,9 @@ async fn get_role_assignment_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "RoleAssignments.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); - let tuid = parse_uuid!(info.user, user ID); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); + let tuid = parse_uuid!(info.user, "user ID"); if uid != tuid { let role = state.store.send(GetRoleAssignment { collection_id: cid, principal_id: uid }.trace()).await??; diff --git a/src/api/role_assignments/get_role_assignments.rs b/src/api/role_assignments/get_role_assignments.rs index 33b7b515..6fdf0e95 100644 --- a/src/api/role_assignments/get_role_assignments.rs +++ b/src/api/role_assignments/get_role_assignments.rs @@ -12,8 +12,8 @@ async fn get_role_assignments_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "RoleAssignments.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); let role = state.store.send(GetRoleAssignment { collection_id: cid, principal_id: uid }.trace()).await??; match role.role { diff --git a/src/api/role_assignments/remove_role_assignment.rs b/src/api/role_assignments/remove_role_assignment.rs index 7611c73d..c364d07c 100644 --- a/src/api/role_assignments/remove_role_assignment.rs +++ b/src/api/role_assignments/remove_role_assignment.rs @@ -12,9 +12,9 @@ async fn remove_role_assignment_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "RoleAssignments.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); - let tuid = parse_uuid!(info.user, user ID); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); + let tuid = parse_uuid!(info.user, "user ID"); if tuid == uid { return Err(APIError::new(400, "Bad Request", "You cannot remove yourself from a collection. Please request that another collection owner performs this for you.")) diff --git a/src/api/role_assignments/store_role_assignment.rs b/src/api/role_assignments/store_role_assignment.rs index 4a25cacc..f8a11c1a 100644 --- a/src/api/role_assignments/store_role_assignment.rs +++ b/src/api/role_assignments/store_role_assignment.rs @@ -14,9 +14,9 @@ async fn store_role_assignment_v3( require_role!(token, "Administrator", "User"); require_scope!(token, "RoleAssignments.Write"); - let cid = parse_uuid!(info.collection, collection ID); - let uid = parse_uuid!(token.oid(), auth token oid); - let tuid = parse_uuid!(info.user, user ID); + let cid = parse_uuid!(info.collection, "collection ID"); + let uid = parse_uuid!(token.oid(), "auth token oid"); + let tuid = parse_uuid!(info.user, "user ID"); let original_collection = state.store.send(GetCollection { id: cid, diff --git a/src/api/users/get_user.rs b/src/api/users/get_user.rs index 36ef5555..be78b206 100644 --- a/src/api/users/get_user.rs +++ b/src/api/users/get_user.rs @@ -11,7 +11,7 @@ async fn get_user_v3( ) -> Result { require_role!(token, "Administrator", "User"); - let tuid = parse_uuid!(info.user, user ID); + let tuid = parse_uuid!(info.user, "user ID"); state.store.send(GetUser { email_hash: tuid }.trace()).await?.map(|user| user.clone().into()) }