From eb482f49b005d1125dfaf6277d1c398b1cbd6fba Mon Sep 17 00:00:00 2001 From: Yusuf Simonson Date: Sun, 18 Nov 2018 17:02:20 -0500 Subject: [PATCH 1/5] Fixed deprecation notices --- capnp/src/any_pointer.rs | 2 +- capnp/src/capability_list.rs | 2 +- capnp/src/data_list.rs | 2 +- capnp/src/enum_list.rs | 2 +- capnp/src/list_list.rs | 2 +- capnp/src/primitive_list.rs | 2 +- capnp/src/private/layout.rs | 8 ++--- capnp/src/struct_list.rs | 2 +- capnp/src/text_list.rs | 2 +- capnpc/src/codegen.rs | 4 +-- capnpc/src/schema_capnp.rs | 70 ++++++++++++++++++------------------ 11 files changed, 49 insertions(+), 49 deletions(-) diff --git a/capnp/src/any_pointer.rs b/capnp/src/any_pointer.rs index 9f46e0c51..a06f1bb68 100644 --- a/capnp/src/any_pointer.rs +++ b/capnp/src/any_pointer.rs @@ -157,7 +157,7 @@ impl <'a> Builder<'a> { } #[inline] - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnp/src/capability_list.rs b/capnp/src/capability_list.rs index 36a031831..430d4564c 100644 --- a/capnp/src/capability_list.rs +++ b/capnp/src/capability_list.rs @@ -101,7 +101,7 @@ impl <'a, T> Builder<'a, T> where T: FromClientHook { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/data_list.rs b/capnp/src/data_list.rs index 58e41967e..d0fe126e9 100644 --- a/capnp/src/data_list.rs +++ b/capnp/src/data_list.rs @@ -81,7 +81,7 @@ impl <'a> Builder<'a> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnp/src/enum_list.rs b/capnp/src/enum_list.rs index cbf1bae8d..061eb7185 100644 --- a/capnp/src/enum_list.rs +++ b/capnp/src/enum_list.rs @@ -90,7 +90,7 @@ impl <'a, T : ToU16 + FromU16> Builder<'a, T> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/list_list.rs b/capnp/src/list_list.rs index 2cf1cb39f..804f0e181 100644 --- a/capnp/src/list_list.rs +++ b/capnp/src/list_list.rs @@ -92,7 +92,7 @@ impl <'a, T> Builder<'a, T> where T: for<'b> ::traits::Owned<'b> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/primitive_list.rs b/capnp/src/primitive_list.rs index 66ce10b44..3c90942dc 100644 --- a/capnp/src/primitive_list.rs +++ b/capnp/src/primitive_list.rs @@ -89,7 +89,7 @@ impl <'a, T> Builder<'a, T> where T: PrimitiveElement { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/private/layout.rs b/capnp/src/private/layout.rs index 6ed860696..6f2abdcd8 100644 --- a/capnp/src/private/layout.rs +++ b/capnp/src/private/layout.rs @@ -2192,7 +2192,7 @@ pub enum CapTableBuilder { } impl CapTableBuilder { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> CapTableReader { self.into_reader() } @@ -2610,7 +2610,7 @@ impl <'a> PointerBuilder<'a> { } } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> PointerReader<'a> { self.into_reader() } @@ -2803,7 +2803,7 @@ pub struct StructBuilder<'a> { } impl <'a> StructBuilder<'a> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> StructReader<'a> { self.into_reader() } @@ -3102,7 +3102,7 @@ impl <'a> ListBuilder<'a> { } } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> ListReader<'a> { self.into_reader() } diff --git a/capnp/src/struct_list.rs b/capnp/src/struct_list.rs index 0184df89f..db02adb95 100644 --- a/capnp/src/struct_list.rs +++ b/capnp/src/struct_list.rs @@ -102,7 +102,7 @@ impl <'a, T> Builder<'a, T> where T: for<'b> ::traits::OwnedStruct<'b> { pub fn len(&self) -> u32 { self.builder.len() } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a, T> { self.into_reader() } diff --git a/capnp/src/text_list.rs b/capnp/src/text_list.rs index c588dc52b..11442c653 100644 --- a/capnp/src/text_list.rs +++ b/capnp/src/text_list.rs @@ -86,7 +86,7 @@ impl <'a> Builder<'a> { self.builder.borrow().get_pointer_element(index).set_text(value); } - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a> { self.into_reader() } diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index bab6fbaaf..3b742e6dc 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -1345,7 +1345,7 @@ fn generate_node(gen: &GeneratorContext, Line(format!("impl <'a,{0}> Builder<'a,{0}> {1} {{", params.params, params.where_clause)), Indent( Box::new(Branch(vec![ - Line("#[deprecated(since=\"capnpc-v0.9.2\", note=\"use into_reader()\")]".to_string()), + Line("#[deprecated(since=\"0.9.2\", note=\"use into_reader()\")]".to_string()), Line(format!("pub fn as_reader(self) -> Reader<'a,{}> {{", params.params)), Indent(Box::new(Line("self.into_reader()".to_string()))), Line("}".to_string()), @@ -1665,7 +1665,7 @@ fn generate_node(gen: &GeneratorContext, )) }), Indent(Box::new(Branch( vec!( - Line("#[deprecated(since=\"capnpc-v0.9.2\", note=\"use into_client()\")]".to_string()), + Line("#[deprecated(since=\"0.9.2\", note=\"use into_client()\")]".to_string()), Line(format!("pub fn from_server<_T: ::capnp::private::capability::ServerHook>(self) -> Client{} {{", bracketed_params)), Indent( Box::new(Line("self.into_client::<_T>()".to_string()))), diff --git a/capnpc/src/schema_capnp.rs b/capnpc/src/schema_capnp.rs index a4cb6c74d..cc525ac28 100644 --- a/capnpc/src/schema_capnp.rs +++ b/capnpc/src/schema_capnp.rs @@ -162,7 +162,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -471,7 +471,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -608,7 +608,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -760,7 +760,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -915,7 +915,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1073,7 +1073,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1254,7 +1254,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1394,7 +1394,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1549,7 +1549,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -1751,7 +1751,7 @@ pub mod node { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2021,7 +2021,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2250,7 +2250,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2417,7 +2417,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2554,7 +2554,7 @@ pub mod field { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2715,7 +2715,7 @@ pub mod enumerant { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -2875,7 +2875,7 @@ pub mod superclass { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3059,7 +3059,7 @@ pub mod method { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3378,7 +3378,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3712,7 +3712,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -3852,7 +3852,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4000,7 +4000,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4148,7 +4148,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4308,7 +4308,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4493,7 +4493,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4662,7 +4662,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4793,7 +4793,7 @@ pub mod type_ { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -4921,7 +4921,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5072,7 +5072,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5253,7 +5253,7 @@ pub mod brand { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5528,7 +5528,7 @@ pub mod value { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -5910,7 +5910,7 @@ pub mod annotation { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6114,7 +6114,7 @@ pub mod capnp_version { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6277,7 +6277,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6468,7 +6468,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } @@ -6627,7 +6627,7 @@ pub mod code_generator_request { } impl <'a,> Builder<'a,> { - #[deprecated(since="capnpc-v0.9.2", note="use into_reader()")] + #[deprecated(since="0.9.2", note="use into_reader()")] pub fn as_reader(self) -> Reader<'a,> { self.into_reader() } From 427eaa722b1437817565942818ba24ae121a171f Mon Sep 17 00:00:00 2001 From: Yusuf Simonson Date: Sun, 18 Nov 2018 17:20:38 -0500 Subject: [PATCH 2/5] Ignore clippy warnings on deprecated methods --- capnpc/src/codegen.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index 3b742e6dc..f1cbac581 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -1346,6 +1346,7 @@ fn generate_node(gen: &GeneratorContext, Indent( Box::new(Branch(vec![ Line("#[deprecated(since=\"0.9.2\", note=\"use into_reader()\")]".to_string()), + Line("#[allow(clippy::wrong_self_convention)]".to_string()), Line(format!("pub fn as_reader(self) -> Reader<'a,{}> {{", params.params)), Indent(Box::new(Line("self.into_reader()".to_string()))), Line("}".to_string()), @@ -1666,6 +1667,7 @@ fn generate_node(gen: &GeneratorContext, }), Indent(Box::new(Branch( vec!( Line("#[deprecated(since=\"0.9.2\", note=\"use into_client()\")]".to_string()), + Line("#[allow(clippy::wrong_self_convention)]".to_string()), Line(format!("pub fn from_server<_T: ::capnp::private::capability::ServerHook>(self) -> Client{} {{", bracketed_params)), Indent( Box::new(Line("self.into_client::<_T>()".to_string()))), From b02d7c35e6c5a825223bbb2f6e4a66454029c07d Mon Sep 17 00:00:00 2001 From: Yusuf Simonson Date: Sun, 18 Nov 2018 17:53:40 -0500 Subject: [PATCH 3/5] Handle unit types in function signatures and returns --- capnpc/src/codegen.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index f1cbac581..a3f56179a 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -335,7 +335,8 @@ fn prim_default(value: &schema_capnp::value::Reader) -> ::capnp::Result ::capnp::Result<(String, FormattedText)> { use schema_capnp::*; @@ -381,8 +382,24 @@ pub fn getter_text(gen: &GeneratorContext, _ => format!("::capnp::Result<{}>", typ), }; + let result_type = if is_fn { + if result_type == "()" { + "".to_string() + } else { + format!("-> {}", result_type) + } + } else { + result_type + }; + let getter_code = match (try!(raw_type.which()), default) { - (type_::Void(()), value::Void(())) => Line("()".to_string()), + (type_::Void(()), value::Void(())) => { + if is_fn { + Line("".to_string()) + } else { + Line("()".to_string()) + } + }, (type_::Bool(()), value::Bool(b)) => { if b { Line(format!("self.{}.get_bool_field_mask({}, true)", member, offset)) @@ -790,7 +807,7 @@ fn generate_union(gen: &GeneratorContext, let field_name = try!(field.get_name()); let enumerant_name = capitalize_first_letter(field_name); - let (ty, get) = try!(getter_text(gen, field, is_reader)); + let (ty, get) = try!(getter_text(gen, field, is_reader, false)); getter_interior.push(Branch(vec![ Line(format!("{} => {{", dvalue)), @@ -1109,20 +1126,19 @@ fn generate_node(gen: &GeneratorContext, if !is_union_field { pipeline_impl_interior.push(try!(generate_pipeline_getter(gen, field))); - let (ty, get) = try!(getter_text(gen, &field, true)); + let (ty, get) = try!(getter_text(gen, &field, true, true)); reader_members.push( Branch(vec!( Line("#[inline]".to_string()), - Line(format!("pub fn get_{}(self) -> {} {{", styled_name, ty)), + Line(format!("pub fn get_{}(self) {} {{", styled_name, ty)), Indent(Box::new(get)), Line("}".to_string())))); - let (ty_b, get_b) = try!(getter_text(gen, &field, false)); - + let (ty_b, get_b) = try!(getter_text(gen, &field, false, true)); builder_members.push( Branch(vec!( Line("#[inline]".to_string()), - Line(format!("pub fn get_{}(self) -> {} {{", styled_name, ty_b)), + Line(format!("pub fn get_{}(self) {} {{", styled_name, ty_b)), Indent(Box::new(get_b)), Line("}".to_string())))); From 1aad96651a9c5ba953c193dbaab6749f2bef2a16 Mon Sep 17 00:00:00 2001 From: Yusuf Simonson Date: Sun, 18 Nov 2018 19:08:28 -0500 Subject: [PATCH 4/5] Fixed type signature code generation for groups --- capnpc/src/codegen.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index a3f56179a..c6abc94a4 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -343,13 +343,24 @@ pub fn getter_text(gen: &GeneratorContext, match try!(field.which()) { field::Group(group) => { let the_mod = gen.scope_map[&group.get_type_id()].join("::"); - if is_reader { - Ok((format!("{}::Reader<'a>", the_mod), - Line("::capnp::traits::FromStructReader::new(self.reader)".to_string()))) + + let mut result_type = if is_reader { + format!("{}::Reader<'a>", the_mod) } else { - Ok((format!("{}::Builder<'a>", the_mod), - Line("::capnp::traits::FromStructBuilder::new(self.builder)".to_string()))) + format!("{}::Builder<'a>", the_mod) + }; + + if is_fn { + result_type = format!("-> {}", result_type); } + + let getter_code = if is_reader { + Line("::capnp::traits::FromStructReader::new(self.reader)".to_string()) + } else { + Line("::capnp::traits::FromStructBuilder::new(self.builder)".to_string()) + }; + + Ok((result_type, getter_code)) } field::Slot(reg_field) => { let offset = reg_field.get_offset() as usize; @@ -371,7 +382,7 @@ pub fn getter_text(gen: &GeneratorContext, let default_value = try!(reg_field.get_default_value()); let default = try!(default_value.which()); - let result_type = match try!(raw_type.which()) { + let mut result_type = match try!(raw_type.which()) { type_::Enum(_) => format!("::std::result::Result<{},::capnp::NotInSchema>", typ), type_::AnyPointer(_) if !try!(raw_type.is_parameter()) => typ.clone(), type_::Interface(_) => { @@ -382,15 +393,13 @@ pub fn getter_text(gen: &GeneratorContext, _ => format!("::capnp::Result<{}>", typ), }; - let result_type = if is_fn { - if result_type == "()" { + if is_fn { + result_type = if result_type == "()" { "".to_string() } else { format!("-> {}", result_type) } - } else { - result_type - }; + } let getter_code = match (try!(raw_type.which()), default) { (type_::Void(()), value::Void(())) => { From 91292e71c06ef507a4f90f5e81ada07f50b3891f Mon Sep 17 00:00:00 2001 From: Yusuf Simonson Date: Sun, 18 Nov 2018 19:19:03 -0500 Subject: [PATCH 5/5] Revert "Ignore clippy warnings on deprecated methods", due to https://github.com/rust-lang/rust/issues/54406 This reverts commit 427eaa722b1437817565942818ba24ae121a171f. --- capnpc/src/codegen.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/capnpc/src/codegen.rs b/capnpc/src/codegen.rs index c6abc94a4..856dd9dbf 100644 --- a/capnpc/src/codegen.rs +++ b/capnpc/src/codegen.rs @@ -1371,7 +1371,6 @@ fn generate_node(gen: &GeneratorContext, Indent( Box::new(Branch(vec![ Line("#[deprecated(since=\"0.9.2\", note=\"use into_reader()\")]".to_string()), - Line("#[allow(clippy::wrong_self_convention)]".to_string()), Line(format!("pub fn as_reader(self) -> Reader<'a,{}> {{", params.params)), Indent(Box::new(Line("self.into_reader()".to_string()))), Line("}".to_string()), @@ -1692,7 +1691,6 @@ fn generate_node(gen: &GeneratorContext, }), Indent(Box::new(Branch( vec!( Line("#[deprecated(since=\"0.9.2\", note=\"use into_client()\")]".to_string()), - Line("#[allow(clippy::wrong_self_convention)]".to_string()), Line(format!("pub fn from_server<_T: ::capnp::private::capability::ServerHook>(self) -> Client{} {{", bracketed_params)), Indent( Box::new(Line("self.into_client::<_T>()".to_string()))),