-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unused endpoints should produce a lint warning (#116)
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021 Oxide Computer Company | ||
|
||
// For whatever reason, trybuild overrides the default disposition for the | ||
// dead_code lint from "warn" to "allow" so we explicitly deny it here. | ||
#![deny(dead_code)] | ||
|
||
use dropshot::endpoint; | ||
use dropshot::HttpError; | ||
use dropshot::HttpResponseOk; | ||
use dropshot::RequestContext; | ||
use std::sync::Arc; | ||
|
||
// At some point we'd expect to see code like: | ||
// ``` | ||
// let mut api = ApiDescription::new(); | ||
// api.register(unused_endpoint).unwrap(); | ||
// ``` | ||
// Defining but not using the endpoint should cause a warning. | ||
#[endpoint { | ||
method = GET, | ||
path = "/test", | ||
}] | ||
async fn unused_endpoint( | ||
_rqctx: Arc<RequestContext<()>>, | ||
) -> Result<HttpResponseOk<()>, HttpError> { | ||
Ok(HttpResponseOk(())) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: constant is never used: `unused_endpoint` | ||
--> $DIR/unused_endpoint.rs:23:10 | ||
| | ||
23 | async fn unused_endpoint( | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused_endpoint.rs:5:9 | ||
| | ||
5 | #![deny(dead_code)] | ||
| ^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters