@@ -1062,7 +1062,7 @@ pub enum ComponentDefinedType {
1062
1062
/// A future type with the specified payload type.
1063
1063
Future ( Option < ComponentValType > ) ,
1064
1064
/// A stream type with the specified payload type.
1065
- Stream ( ComponentValType ) ,
1065
+ Stream ( Option < ComponentValType > ) ,
1066
1066
/// The error-context type.
1067
1067
ErrorContext ,
1068
1068
}
@@ -1950,9 +1950,7 @@ impl TypeAlloc {
1950
1950
}
1951
1951
}
1952
1952
}
1953
- ComponentDefinedType :: List ( ty)
1954
- | ComponentDefinedType :: Option ( ty)
1955
- | ComponentDefinedType :: Stream ( ty) => {
1953
+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty) => {
1956
1954
self . free_variables_valtype ( ty, set) ;
1957
1955
}
1958
1956
ComponentDefinedType :: Result { ok, err } => {
@@ -1971,6 +1969,11 @@ impl TypeAlloc {
1971
1969
self . free_variables_valtype ( ty, set) ;
1972
1970
}
1973
1971
}
1972
+ ComponentDefinedType :: Stream ( ty) => {
1973
+ if let Some ( ty) = ty {
1974
+ self . free_variables_valtype ( ty, set) ;
1975
+ }
1976
+ }
1974
1977
}
1975
1978
}
1976
1979
@@ -2094,9 +2097,9 @@ impl TypeAlloc {
2094
2097
. map ( |t| self . type_named_valtype ( t, set) )
2095
2098
. unwrap_or ( true )
2096
2099
}
2097
- ComponentDefinedType :: List ( ty)
2098
- | ComponentDefinedType :: Option ( ty)
2099
- | ComponentDefinedType :: Stream ( ty ) => self . type_named_valtype ( ty , set ) ,
2100
+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty ) => {
2101
+ self . type_named_valtype ( ty, set )
2102
+ }
2100
2103
2101
2104
// own/borrow themselves don't have to be named, but the resource
2102
2105
// they refer to must be named.
@@ -2108,6 +2111,11 @@ impl TypeAlloc {
2108
2111
. as_ref ( )
2109
2112
. map ( |ty| self . type_named_valtype ( ty, set) )
2110
2113
. unwrap_or ( true ) ,
2114
+
2115
+ ComponentDefinedType :: Stream ( ty) => ty
2116
+ . as_ref ( )
2117
+ . map ( |ty| self . type_named_valtype ( ty, set) )
2118
+ . unwrap_or ( true ) ,
2111
2119
}
2112
2120
}
2113
2121
@@ -2277,9 +2285,7 @@ where
2277
2285
}
2278
2286
}
2279
2287
}
2280
- ComponentDefinedType :: List ( ty)
2281
- | ComponentDefinedType :: Option ( ty)
2282
- | ComponentDefinedType :: Stream ( ty) => {
2288
+ ComponentDefinedType :: List ( ty) | ComponentDefinedType :: Option ( ty) => {
2283
2289
any_changed |= self . remap_valtype ( ty, map) ;
2284
2290
}
2285
2291
ComponentDefinedType :: Result { ok, err } => {
@@ -2293,7 +2299,7 @@ where
2293
2299
ComponentDefinedType :: Own ( id) | ComponentDefinedType :: Borrow ( id) => {
2294
2300
any_changed |= self . remap_resource_id ( id, map) ;
2295
2301
}
2296
- ComponentDefinedType :: Future ( ty) => {
2302
+ ComponentDefinedType :: Future ( ty) | ComponentDefinedType :: Stream ( ty ) => {
2297
2303
if let Some ( ty) = ty {
2298
2304
any_changed |= self . remap_valtype ( ty, map) ;
2299
2305
}
@@ -3234,9 +3240,14 @@ impl<'a> SubtypeCx<'a> {
3234
3240
( Some ( _) , None ) => bail ! ( offset, "expected future type to not be present" ) ,
3235
3241
} ,
3236
3242
( Future ( _) , b) => bail ! ( offset, "expected {}, found future" , b. desc( ) ) ,
3237
- ( Stream ( a) , Stream ( b) ) => self
3238
- . component_val_type ( a, b, offset)
3239
- . with_context ( || "type mismatch in stream" ) ,
3243
+ ( Stream ( a) , Stream ( b) ) => match ( a, b) {
3244
+ ( None , None ) => Ok ( ( ) ) ,
3245
+ ( Some ( a) , Some ( b) ) => self
3246
+ . component_val_type ( a, b, offset)
3247
+ . with_context ( || "type mismatch in stream" ) ,
3248
+ ( None , Some ( _) ) => bail ! ( offset, "expected stream type, but found none" ) ,
3249
+ ( Some ( _) , None ) => bail ! ( offset, "expected stream type to not be present" ) ,
3250
+ } ,
3240
3251
( Stream ( _) , b) => bail ! ( offset, "expected {}, found stream" , b. desc( ) ) ,
3241
3252
( ErrorContext , ErrorContext ) => Ok ( ( ) ) ,
3242
3253
( ErrorContext , b) => bail ! ( offset, "expected {}, found error-context" , b. desc( ) ) ,
0 commit comments