Skip to content

Commit 395cb66

Browse files
authored
Merge pull request #109 from bmisiak/patch-1
Switch from try!() to ? in generated code to make it work in Rust 2018
2 parents 3502749 + d8948de commit 395cb66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

capnpc/src/codegen.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ fn generate_node(gen: &GeneratorContext,
11541154
Indent(Box::new(Line("::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))".to_string()))),
11551155
Line("}".to_string()),
11561156
Line(format!("fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>) -> ::capnp::Result<Builder<'a,{}>> {{", params.params)),
1157-
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(try!(builder.get_struct(_private::STRUCT_SIZE, ::std::ptr::null()))))".to_string()))),
1157+
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, ::std::ptr::null())?))".to_string()))),
11581158
Line("}".to_string()))))),
11591159
Line("}".to_string()),
11601160
BlankLine]);
@@ -1218,7 +1218,7 @@ fn generate_node(gen: &GeneratorContext,
12181218
Indent(
12191219
Box::new(Branch(vec!(
12201220
Line(format!("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>) -> ::capnp::Result<Reader<'a,{}>> {{",params.params)),
1221-
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::traits::FromStructReader::new(try!(reader.get_struct(::std::ptr::null()))))".to_string()))),
1221+
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(::std::ptr::null())?))".to_string()))),
12221222
Line("}".to_string()))))),
12231223
Line("}".to_string()),
12241224
BlankLine,
@@ -1551,7 +1551,7 @@ fn generate_node(gen: &GeneratorContext,
15511551
Indent(
15521552
Box::new(Branch(vec![
15531553
Line(format!("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>) -> ::capnp::Result<Client<{}>> {{",params.params)),
1554-
Indent(Box::new(Line(format!("::std::result::Result::Ok(::capnp::capability::FromClientHook::new(try!(reader.get_capability())))")))),
1554+
Indent(Box::new(Line(format!("::std::result::Result::Ok(::capnp::capability::FromClientHook::new(reader.get_capability()?))")))),
15551555
Line("}".to_string())]))),
15561556
Line("}".to_string()))));
15571557

@@ -1565,7 +1565,7 @@ fn generate_node(gen: &GeneratorContext,
15651565
Indent(Box::new(Line("unimplemented!()".to_string()))),
15661566
Line("}".to_string()),
15671567
Line(format!("fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>) -> ::capnp::Result<Client<{}>> {{", params.params)),
1568-
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::capability::FromClientHook::new(try!(builder.get_capability())))".to_string()))),
1568+
Indent(Box::new(Line("::std::result::Result::Ok(::capnp::capability::FromClientHook::new(builder.get_capability()?))".to_string()))),
15691569
Line("}".to_string())]))),
15701570
Line("}".to_string()),
15711571
BlankLine]));

0 commit comments

Comments
 (0)