Allow clippy::suspicious_else_formatting when expanding query arguments.

Expanding several query arguments in the query! macro creates several if false { ... } statements, which in turn trigger clippy's suspicious_else_formatting (https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting).
This commit allows the clippy lint so users won't be disturbed by it.
This commit is contained in:
o0Ignition0o 2020-11-15 12:24:57 +01:00 committed by Austin Bonander
parent c1e79d2675
commit 9d11c7a7f1

View File

@ -74,23 +74,26 @@ pub fn quote_args<DB: DatabaseExt>(
};
Ok(quote_spanned!(expr.span() =>
// this shouldn't actually run
if false {
use sqlx::ty_match::{WrapSameExt as _, MatchBorrowExt as _};
#[allow(clippy::suspicious_else_formatting)]
{
// this shouldn't actually run
if false {
use sqlx::ty_match::{WrapSameExt as _, MatchBorrowExt as _};
// evaluate the expression only once in case it contains moves
let _expr = sqlx::ty_match::dupe_value(#name);
// evaluate the expression only once in case it contains moves
let _expr = sqlx::ty_match::dupe_value(#name);
// if `_expr` is `Option<T>`, get `Option<$ty>`, otherwise `$ty`
let ty_check = sqlx::ty_match::WrapSame::<#param_ty, _>::new(&_expr).wrap_same();
// if `_expr` is `Option<T>`, get `Option<$ty>`, otherwise `$ty`
let ty_check = sqlx::ty_match::WrapSame::<#param_ty, _>::new(&_expr).wrap_same();
// if `_expr` is `&str`, convert `String` to `&str`
let (mut _ty_check, match_borrow) = sqlx::ty_match::MatchBorrow::new(ty_check, &_expr);
// if `_expr` is `&str`, convert `String` to `&str`
let (mut _ty_check, match_borrow) = sqlx::ty_match::MatchBorrow::new(ty_check, &_expr);
_ty_check = match_borrow.match_borrow();
_ty_check = match_borrow.match_borrow();
// this causes move-analysis to effectively ignore this block
panic!();
// this causes move-analysis to effectively ignore this block
panic!();
}
}
))
})