File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
tests/runtime/rust/equal-types Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -338,9 +338,9 @@ impl Types {
338338 ( TypeDefKind :: Handle ( _) , _) => false ,
339339 ( TypeDefKind :: Unknown , _) => unreachable ! ( ) ,
340340
341- // TODO: for now consider all resources not-equal to each other.
342- // This is because the same type id can be used for both an imported
343- // and exported resource where those should be distinct types.
341+ // Resources are only equal if their original ids are equal,
342+ // otherwise all resources are un-equal to each other.
343+ ( TypeDefKind :: Resource , TypeDefKind :: Resource ) => a == b ,
344344 ( TypeDefKind :: Resource , _) => false ,
345345 }
346346 }
Original file line number Diff line number Diff line change @@ -56,3 +56,24 @@ impl HGuest for Component {
5656 x
5757 }
5858}
59+
60+ const _: ( ) = {
61+ use crate :: exports:: test:: equal_types:: resources:: * ;
62+
63+ struct GuestResource ;
64+
65+ impl Guest for Component {
66+ type R1 = GuestResource ;
67+
68+ // Intentionally swap the 1/2 relative to WIT to ensure that the types
69+ // are equivalent.
70+ fn alias_own ( x : T2 ) -> T1 {
71+ x
72+ }
73+ fn alias_aggregate ( x : Option < T2 > ) -> Option < T1 > {
74+ x
75+ }
76+ }
77+
78+ impl GuestR1 for GuestResource { }
79+ } ;
Original file line number Diff line number Diff line change @@ -41,9 +41,20 @@ interface blah {
4141 alias-type : func (x : r1 ) -> r2 ;
4242}
4343
44+ interface resources {
45+ resource r1 ;
46+ type r2 = r1 ;
47+
48+ record t1 { a : r1 }
49+ record t2 { a : r2 }
50+ alias-own : func (x : t1 ) -> t2 ;
51+ alias-aggregate : func (x : option <t1 >) -> option <t2 >;
52+ }
53+
4454world host {
4555 export blah ;
4656 export blag ;
57+ export resources ;
4758}
4859world proxy {
4960 import blag ;
You can’t perform that action at this time.
0 commit comments