Skip to content

Commit

Permalink
avoid ambiguous associated item in TryFrom implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Jan 30, 2023
1 parent c1b4c3a commit 59f2ad3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions capnpc/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,8 +1937,7 @@ fn generate_node(
))),
Indent(Box::new(Branch(vec![
Line(
"fn try_from(value: u16) -> ::core::result::Result<Self, Self::Error> {"
.to_string(),
format!("fn try_from(value: u16) -> ::core::result::Result<Self, <{last_name} as ::core::convert::TryFrom<u16>>::Error> {{")
),
Indent(Box::new(Branch(vec![
Line("match value {".to_string()),
Expand Down
6 changes: 6 additions & 0 deletions capnpc/test/test.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ enum TestEnum {
garply @7;
}

enum TestEnumWithTrickyNames {
foo @0;
bar @1;
error @2;
}

struct TestAllTypes {
voidField @0 : Void;
boolField @1 : Bool;
Expand Down

0 comments on commit 59f2ad3

Please sign in to comment.