Skip to content

Commit

Permalink
Add #[allow(clippy::unused_async)] to emitted endpoints (#703)
Browse files Browse the repository at this point in the history
* Add `#[allow(clippy::unused_async)]` to emitted endpoints

We require endpoints to be async, but it's not uncommon to have
endpoints that themselves do not need to `.await` anything. If a user
wants to enable the (off-by-default) `clippy::unused_async` lint, they
would need to add this annotation by hand to each such endpoint, or we
could just do it for them.

* fix proc macro tests
  • Loading branch information
jgallagher authored Jun 14, 2023
1 parent 9d685b0 commit a519993
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dropshot_endpoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ fn do_endpoint_inner(
for #dropshot::ApiEndpoint< #first_arg >
{
fn from(_: #name) -> Self {
#[allow(clippy::unused_async)]
#item

// The checks on the implementation require #name to be in
Expand Down Expand Up @@ -807,6 +808,7 @@ mod tests {
as dropshot::RequestContextArgument>::Context>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
pub async fn handler_xyz(
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<()>, HttpError> {
Expand Down Expand Up @@ -895,6 +897,7 @@ mod tests {

impl From<handler_xyz> for dropshot::ApiEndpoint< <dropshot::RequestContext<()> as dropshot::RequestContextArgument>::Context> {
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
pub async fn handler_xyz(_rqctx: dropshot::RequestContext<()>) ->
std::Result<dropshot::HttpResponseOk<()>, dropshot::HttpError>
{
Expand Down Expand Up @@ -998,6 +1001,7 @@ mod tests {
>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
async fn handler_xyz(
_rqctx: RequestContext<std::i32>,
q: Query<Q>,
Expand Down Expand Up @@ -1104,6 +1108,7 @@ mod tests {
>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
pub(crate) async fn handler_xyz(
_rqctx: RequestContext<()>,
q: Query<Q>,
Expand Down Expand Up @@ -1201,6 +1206,7 @@ mod tests {
as dropshot::RequestContextArgument>::Context>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
async fn handler_xyz(
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<()>, HttpError> {
Expand Down Expand Up @@ -1297,6 +1303,7 @@ mod tests {
as dropshot::RequestContextArgument>::Context>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
#[doc = r#" handle "xyz" requests "#]
async fn handler_xyz(
_rqctx: RequestContext<()>,
Expand Down Expand Up @@ -1502,6 +1509,7 @@ mod tests {
as dropshot::RequestContextArgument>::Context>
{
fn from(_: handler_xyz) -> Self {
#[allow(clippy::unused_async)]
pub async fn handler_xyz(
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<()>, HttpError> {
Expand Down

0 comments on commit a519993

Please sign in to comment.