Skip to content

Commit 59f2ad3

Browse files
committed
avoid ambiguous associated item in TryFrom implementations
1 parent c1b4c3a commit 59f2ad3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

capnpc/src/codegen.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,7 @@ fn generate_node(
19371937
))),
19381938
Indent(Box::new(Branch(vec![
19391939
Line(
1940-
"fn try_from(value: u16) -> ::core::result::Result<Self, Self::Error> {"
1941-
.to_string(),
1940+
format!("fn try_from(value: u16) -> ::core::result::Result<Self, <{last_name} as ::core::convert::TryFrom<u16>>::Error> {{")
19421941
),
19431942
Indent(Box::new(Branch(vec![
19441943
Line("match value {".to_string()),

capnpc/test/test.capnp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ enum TestEnum {
106106
garply @7;
107107
}
108108

109+
enum TestEnumWithTrickyNames {
110+
foo @0;
111+
bar @1;
112+
error @2;
113+
}
114+
109115
struct TestAllTypes {
110116
voidField @0 : Void;
111117
boolField @1 : Bool;

0 commit comments

Comments
 (0)