Skip to content

Commit 1073c3f

Browse files
committed
eliminate warnings about unneeded parens in generated code
1 parent ec6f7b5 commit 1073c3f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

capnp/src/capability.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ use crate::traits::{Owned, Pipelined};
4242
#[cfg(feature = "alloc")]
4343
use crate::{Error, MessageSize};
4444

45+
/// Type alias for `dyn ClientHook`. We define this here because so that generated code
46+
/// can avoid needing to refer to `dyn` types directly; in Rust 2015 the syntax for
47+
/// `dyn` types requires extra parentheses that trigger warnings in newer editions.
48+
#[cfg(feature = "alloc")]
49+
pub type DynClientHook = dyn ClientHook;
50+
4551
/// A computation that might eventually resolve to a value of type `T` or to an error
4652
/// of type `E`. Dropping the promise cancels the computation.
4753
#[cfg(feature = "alloc")]

capnpc/src/codegen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,13 +2730,13 @@ fn generate_node(
27302730
mod_interior.push(
27312731
Branch(vec![
27322732
Line(fmt!(ctx,"impl {bracketed_params} {capnp}::capability::FromClientHook for Client{bracketed_params} {{")),
2733-
indent(Line(fmt!(ctx,"fn new(hook: Box<dyn ({capnp}::private::capability::ClientHook)>) -> Self {{"))),
2733+
indent(Line(fmt!(ctx,"fn new(hook: Box<{capnp}::capability::DynClientHook>) -> Self {{"))),
27342734
indent(indent(Line(fmt!(ctx,"Self {{ client: {capnp}::capability::Client::new(hook), {} }}", params.phantom_data_value)))),
27352735
indent(line("}")),
2736-
indent(Line(fmt!(ctx,"fn into_client_hook(self) -> Box<dyn ({capnp}::private::capability::ClientHook)> {{"))),
2736+
indent(Line(fmt!(ctx,"fn into_client_hook(self) -> Box<{capnp}::capability::DynClientHook> {{"))),
27372737
indent(indent(line("self.client.hook"))),
27382738
indent(line("}")),
2739-
indent(Line(fmt!(ctx,"fn as_client_hook(&self) -> &dyn ({capnp}::private::capability::ClientHook) {{"))),
2739+
indent(Line(fmt!(ctx,"fn as_client_hook(&self) -> &{capnp}::capability::DynClientHook {{"))),
27402740
indent(indent(line("&*self.client.hook"))),
27412741
indent(line("}")),
27422742
line("}")]));

0 commit comments

Comments
 (0)