Skip to content

Commit

Permalink
Merge branch 'main' into dap/api-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco committed Oct 29, 2024
2 parents e747169 + 203bff4 commit 58b1361
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 41 deletions.
63 changes: 35 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions dropshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rustls = "0.22.4"
rustls-pemfile = "2.1.3"
scopeguard = "1.2.0"
semver = "1.0.23"
serde_json = "1.0.128"
serde_json = "1.0.132"
serde_path_to_error = "0.1.16"
serde_urlencoded = "0.7.1"
sha1 = "0.10.6"
Expand All @@ -43,7 +43,7 @@ slog-async = "2.8.0"
slog-bunyan = "2.5.0"
slog-json = "2.6.1"
slog-term = "2.9.1"
thiserror = "1.0.64"
thiserror = "1.0.65"
tokio-rustls = "0.25.0"
toml = "0.8.19"
waitgroup = "0.1.2"
Expand All @@ -58,7 +58,7 @@ version = "^0.12.1-dev"
path = "../dropshot_endpoint"

[dependencies.hyper]
version = "1.4.1"
version = "1.5.0"
features = [ "full" ]

[dependencies.hyper-util]
Expand All @@ -70,7 +70,7 @@ version = "2.0.0"
features = [ "skip_serializing_defaults" ]

[dependencies.serde]
version = "1.0.210"
version = "1.0.213"
features = [ "derive" ]

[dependencies.tokio]
Expand All @@ -83,26 +83,26 @@ optional = true
default-features = false

[dependencies.uuid]
version = "1.10.0"
version = "1.11.0"
features = [ "serde", "v4" ]

[dependencies.schemars]
version = "0.8.21"
features = [ "uuid1" ]

[dev-dependencies]
anyhow = "1.0.89"
anyhow = "1.0.91"
async-channel = "2.3.1"
buf-list = "1.0.3"
expectorate = "1.1.0"
hyper-rustls = "0.26.0"
hyper-staticfile = "0.10"
lazy_static = "1.5.0"
libc = "0.2.159"
libc = "0.2.161"
mime_guess = "2.0.5"
subprocess = "0.2.9"
tempfile = "3.13"
trybuild = "1.0.99"
trybuild = "1.0.101"
# Used by the https examples and tests
pem = "3.0"
rcgen = "0.13.1"
Expand Down
4 changes: 2 additions & 2 deletions dropshot_endpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ version = "1.0"
features = [ "derive" ]

[dependencies.syn]
version = "2.0.79"
version = "2.0.85"
features = [ "full", "visit", "extra-traits" ]

[dev-dependencies]
expectorate = "1.1.0"
prettyplease = "0.2.22"
prettyplease = "0.2.25"
schema = "0.1.0"
21 changes: 20 additions & 1 deletion dropshot_endpoint/src/api_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,27 @@ impl<'ast> ApiParser<'ast> {
let mut supertraits = item_trait.supertraits.clone();
supertraits.push(parse_quote!('static));

// Also add dead_code if the visibility is not `pub`. (If it is `pub`,
// then it is expected to be exported, and so the dead code warning
// won't fire.)
//
// Why check for non-`pub` visibility? Because there is a downside to
// allow(dead_code): it also applies to any items defined within the
// trait. For example, if a provided method on the trait defines an
// unused function inside of it, then allow(dead_code) would suppress
// that.
//
// It would be ideal if there were a way to say "allow(dead_code), but
// don't propagate this to child items", but sadly there isn't as of
// Rust 1.81.
let mut attrs = item_trait.attrs.clone();
if !matches!(item_trait.vis, syn::Visibility::Public(_)) {
attrs.push(parse_quote!(#[allow(dead_code)]));
}

// Everything else about the trait stays the same -- just the items change.
let out_trait = ItemTraitPartParsed {
attrs,
supertraits,
items: out_items.collect(),
..item_trait.clone()
Expand Down Expand Up @@ -1773,7 +1792,7 @@ mod tests {
let (item, errors) = do_trait(
quote! {},
quote! {
trait MyTrait {
pub trait MyTrait {
type Context;

#[endpoint {
Expand Down
1 change: 1 addition & 0 deletions dropshot_endpoint/tests/output/api_trait_basic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(dead_code)]
trait MyTrait: 'static {
type Context: dropshot::ServerContext;
fn handler_xyz(
Expand Down
1 change: 1 addition & 0 deletions dropshot_endpoint/tests/output/api_trait_no_endpoints.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(dead_code)]
pub(crate) trait MyTrait: 'static {
type Context: dropshot::ServerContext;
}
Expand Down
4 changes: 2 additions & 2 deletions dropshot_endpoint/tests/output/api_trait_operation_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trait MyTrait: 'static {
pub trait MyTrait: 'static {
type Context: dropshot::ServerContext;
fn handler_xyz(
rqctx: RequestContext<Self::Context>,
Expand All @@ -12,7 +12,7 @@ trait MyTrait: 'static {
}
/// Support module for the Dropshot API trait [`MyTrait`](MyTrait).
#[automatically_derived]
mod my_trait_mod {
pub mod my_trait_mod {
use super::*;
const _: fn() = || {
trait TypeEq {
Expand Down

0 comments on commit 58b1361

Please sign in to comment.