Open asensio-project opened 1 year ago
This is due to the unfortunate interaction of two different lints:
The line
let user = web::block(move || query(user_data, pool)).await??;
triggers let_unit_value
, as user
will be of type ()
. The lint recommends removing the (useless) binding of ()
to users
.
The line
Ok(HttpResponse::Ok().json(&user))
triggers the needless_borrow
lint, as it should read .json(user)
instead of .json(&user)
. But the binding to user
has already been removed by the other lint, triggering this error. You'll have to manually fix this, as the lints can't coordinate their actions with respect to one another.
Having only looked at the code for 15 seconds, my guess is that user
being of type ()
is an unforeseen error in the code's structure in itself.
Thanks, that solved my issue. But should we do something for this not to happen in clippy?
Hi!
In my case this error was caused by unit "()" value in res
variable.
The following errors were reported:
error[E0425]: cannot find value `res` in this scope
--> src/routes/groups.rs:42:8
|
42 | Ok(res)
| ^^^ not found in this scope
async fn post_create_group(
claims: Claims,
State(pool): State<PgPool>,
group: Json<NewGroup>,
) -> Result<(), AppError> {
tracing::trace!("JWT: {:#?}", claims);
let res = create_group(&pool, group.name.trim(), claims.user_id).await?;
debug!("Group {} created successfully", group.name);
Ok(res)
}
create_group
fn signature
pub async fn create_group(pool: &PgPool, name: &str, user_id: Uuid) -> Result<(), AppError>
Summary
Hello everyone,
I was trying to automatically fix all the warnings of Clippy, but I got this error:
But the code works fine when executing
cargo run
.The full project can be found at github
Reproducer
I tried this code:
I expected to see this happen:
Successful. All warnings fixed
Instead, this happened: (see above)
Version
Additional Labels
No response