Skip to content

Commit d5a6c1b

Browse files
committed
rename error to error-context per latest spec
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent a245168 commit d5a6c1b

26 files changed

Lines changed: 64 additions & 64 deletions

File tree

crates/wasm-compose/src/encoding.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl<'a> TypeEncoder<'a> {
682682
}
683683
ComponentDefinedType::Future(ty) => self.future(state, *ty),
684684
ComponentDefinedType::Stream(ty) => self.stream(state, *ty),
685-
ComponentDefinedType::Error => self.error(state),
685+
ComponentDefinedType::ErrorContext => self.error_context(state),
686686
}
687687
}
688688

@@ -821,9 +821,9 @@ impl<'a> TypeEncoder<'a> {
821821
index
822822
}
823823

824-
fn error(&self, state: &mut TypeState<'a>) -> u32 {
824+
fn error_context(&self, state: &mut TypeState<'a>) -> u32 {
825825
let index = state.cur.encodable.type_count();
826-
state.cur.encodable.ty().defined_type().error();
826+
state.cur.encodable.ty().defined_type().error_context();
827827
index
828828
}
829829
}
@@ -1254,7 +1254,7 @@ impl DependencyRegistrar<'_, '_> {
12541254
ComponentDefinedType::Primitive(_)
12551255
| ComponentDefinedType::Enum(_)
12561256
| ComponentDefinedType::Flags(_)
1257-
| ComponentDefinedType::Error => {}
1257+
| ComponentDefinedType::ErrorContext => {}
12581258
ComponentDefinedType::List(t)
12591259
| ComponentDefinedType::Option(t)
12601260
| ComponentDefinedType::Stream(t) => self.val_type(*t),

crates/wasm-encoder/src/component/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ impl ComponentDefinedTypeEncoder<'_> {
684684
payload.encode(self.0);
685685
}
686686

687-
/// Define the `error` type.
688-
pub fn error(self) {
687+
/// Define the `error-context` type.
688+
pub fn error_context(self) {
689689
self.0.push(0x65);
690690
}
691691
}

crates/wasm-encoder/src/reencode/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ pub mod component_utils {
803803
wasmparser::ComponentDefinedType::Stream(t) => {
804804
defined.stream(reencoder.component_val_type(t));
805805
}
806-
wasmparser::ComponentDefinedType::Error => defined.error(),
806+
wasmparser::ComponentDefinedType::ErrorContext => defined.error_context(),
807807
}
808808
Ok(())
809809
}

crates/wasmparser/src/readers/component/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ pub enum ComponentDefinedType<'a> {
509509
Future(Option<ComponentValType>),
510510
/// A stream type with the specified payload type.
511511
Stream(ComponentValType),
512-
/// The error type.
513-
Error,
512+
/// The error-context type.
513+
ErrorContext,
514514
}
515515

516516
impl<'a> ComponentDefinedType<'a> {
@@ -552,7 +552,7 @@ impl<'a> ComponentDefinedType<'a> {
552552
0x68 => ComponentDefinedType::Borrow(reader.read()?),
553553
0x67 => ComponentDefinedType::Future(reader.read()?),
554554
0x66 => ComponentDefinedType::Stream(reader.read()?),
555-
0x65 => ComponentDefinedType::Error,
555+
0x65 => ComponentDefinedType::ErrorContext,
556556
x => return reader.invalid_leading_byte(x, "component defined type"),
557557
})
558558
}

crates/wasmparser/src/validator/component.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ impl ComponentState {
722722
ComponentDefinedType::Primitive(_)
723723
| ComponentDefinedType::Flags(_)
724724
| ComponentDefinedType::Enum(_)
725-
| ComponentDefinedType::Error => true,
725+
| ComponentDefinedType::ErrorContext => true,
726726

727727
// Referenced types of all these aggregates must all be
728728
// named.
@@ -3446,7 +3446,7 @@ impl ComponentState {
34463446
crate::ComponentDefinedType::Stream(ty) => Ok(ComponentDefinedType::Stream(
34473447
self.create_component_val_type(ty, offset)?,
34483448
)),
3449-
crate::ComponentDefinedType::Error => Ok(ComponentDefinedType::Error),
3449+
crate::ComponentDefinedType::ErrorContext => Ok(ComponentDefinedType::ErrorContext),
34503450
}
34513451
}
34523452

crates/wasmparser/src/validator/component_types.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,8 @@ pub enum ComponentDefinedType {
10451045
Future(Option<ComponentValType>),
10461046
/// A stream type with the specified payload type.
10471047
Stream(ComponentValType),
1048-
/// The error type.
1049-
Error,
1048+
/// The error-context type.
1049+
ErrorContext,
10501050
}
10511051

10521052
impl TypeData for ComponentDefinedType {
@@ -1060,7 +1060,7 @@ impl TypeData for ComponentDefinedType {
10601060
| Self::Own(_)
10611061
| Self::Future(_)
10621062
| Self::Stream(_)
1063-
| Self::Error => TypeInfo::new(),
1063+
| Self::ErrorContext => TypeInfo::new(),
10641064
Self::Borrow(_) => TypeInfo::borrow(),
10651065
Self::Record(r) => r.info,
10661066
Self::Variant(v) => v.info,
@@ -1094,7 +1094,7 @@ impl ComponentDefinedType {
10941094
| Self::Borrow(_)
10951095
| Self::Future(_)
10961096
| Self::Stream(_)
1097-
| Self::Error => false,
1097+
| Self::ErrorContext => false,
10981098
Self::Option(ty) => ty.contains_ptr(types),
10991099
Self::Result { ok, err } => {
11001100
ok.map(|ty| ty.contains_ptr(types)).unwrap_or(false)
@@ -1128,7 +1128,7 @@ impl ComponentDefinedType {
11281128
| Self::Borrow(_)
11291129
| Self::Future(_)
11301130
| Self::Stream(_)
1131-
| Self::Error => lowered_types.push(ValType::I32),
1131+
| Self::ErrorContext => lowered_types.push(ValType::I32),
11321132
Self::Option(ty) => {
11331133
Self::push_variant_wasm_types([ty].into_iter(), types, lowered_types)
11341134
}
@@ -1198,7 +1198,7 @@ impl ComponentDefinedType {
11981198
ComponentDefinedType::Borrow(_) => "borrow",
11991199
ComponentDefinedType::Future(_) => "future",
12001200
ComponentDefinedType::Stream(_) => "stream",
1201-
ComponentDefinedType::Error => "error",
1201+
ComponentDefinedType::ErrorContext => "error-context",
12021202
}
12031203
}
12041204
}
@@ -1914,7 +1914,7 @@ impl TypeAlloc {
19141914
ComponentDefinedType::Primitive(_)
19151915
| ComponentDefinedType::Flags(_)
19161916
| ComponentDefinedType::Enum(_)
1917-
| ComponentDefinedType::Error => {}
1917+
| ComponentDefinedType::ErrorContext => {}
19181918
ComponentDefinedType::Record(r) => {
19191919
for ty in r.fields.values() {
19201920
self.free_variables_valtype(ty, set);
@@ -2053,7 +2053,7 @@ impl TypeAlloc {
20532053
let ty = &self[id];
20542054
match ty {
20552055
// Primitives are always considered named
2056-
ComponentDefinedType::Primitive(_) | ComponentDefinedType::Error => true,
2056+
ComponentDefinedType::Primitive(_) | ComponentDefinedType::ErrorContext => true,
20572057

20582058
// These structures are never allowed to be anonymous, so they
20592059
// themselves must be named.
@@ -2241,7 +2241,7 @@ where
22412241
ComponentDefinedType::Primitive(_)
22422242
| ComponentDefinedType::Flags(_)
22432243
| ComponentDefinedType::Enum(_)
2244-
| ComponentDefinedType::Error => {}
2244+
| ComponentDefinedType::ErrorContext => {}
22452245
ComponentDefinedType::Record(r) => {
22462246
for ty in r.fields.values_mut() {
22472247
any_changed |= self.remap_valtype(ty, map);
@@ -3220,8 +3220,8 @@ impl<'a> SubtypeCx<'a> {
32203220
.component_val_type(a, b, offset)
32213221
.with_context(|| "type mismatch in stream"),
32223222
(Stream(_), b) => bail!(offset, "expected {}, found stream", b.desc()),
3223-
(Error, Error) => Ok(()),
3224-
(Error, b) => bail!(offset, "expected {}, found error", b.desc()),
3223+
(ErrorContext, ErrorContext) => Ok(()),
3224+
(ErrorContext, b) => bail!(offset, "expected {}, found error-context", b.desc()),
32253225
}
32263226
}
32273227

crates/wasmprinter/src/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Printer<'_, '_> {
276276
}
277277
ComponentDefinedType::Future(ty) => self.print_future_type(state, *ty)?,
278278
ComponentDefinedType::Stream(ty) => self.print_stream_type(state, *ty)?,
279-
ComponentDefinedType::Error => self.result.write_str("error")?,
279+
ComponentDefinedType::ErrorContext => self.result.write_str("error-context")?,
280280
}
281281

282282
Ok(())

crates/wit-component/src/encoding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl TypeContents {
323323
TypeDefKind::Type(t) => Self::for_type(resolve, t),
324324
TypeDefKind::Future(_) => Self::empty(),
325325
TypeDefKind::Stream(_) => Self::empty(),
326-
TypeDefKind::Error => Self::empty(),
326+
TypeDefKind::ErrorContext => Self::empty(),
327327
TypeDefKind::Unknown => unreachable!(),
328328
},
329329
Type::String => Self::STRING,

crates/wit-component/src/encoding/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub trait ValtypeEncoder<'a> {
155155
TypeDefKind::Type(ty) => self.encode_valtype(resolve, ty)?,
156156
TypeDefKind::Future(ty) => self.encode_future(resolve, ty)?,
157157
TypeDefKind::Stream(ty) => self.encode_stream(resolve, ty)?,
158-
TypeDefKind::Error => self.encode_error()?,
158+
TypeDefKind::ErrorContext => self.encode_error_context()?,
159159
TypeDefKind::Unknown => unreachable!(),
160160
TypeDefKind::Resource => {
161161
let name = ty.name.as_ref().expect("resources must be named");
@@ -329,9 +329,9 @@ pub trait ValtypeEncoder<'a> {
329329
Ok(ComponentValType::Type(index))
330330
}
331331

332-
fn encode_error(&mut self) -> Result<ComponentValType> {
332+
fn encode_error_context(&mut self) -> Result<ComponentValType> {
333333
let (index, encoder) = self.defined_type();
334-
encoder.error();
334+
encoder.error_context();
335335
Ok(ComponentValType::Type(index))
336336
}
337337
}

crates/wit-component/src/printing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl WitPrinter {
540540
TypeDefKind::Stream(_) => {
541541
todo!("document has an unnamed stream type")
542542
}
543-
TypeDefKind::Error => self.output.push_str("error"),
543+
TypeDefKind::ErrorContext => self.output.push_str("error-context"),
544544
TypeDefKind::Unknown => unreachable!(),
545545
}
546546
}
@@ -698,7 +698,7 @@ impl WitPrinter {
698698
},
699699
TypeDefKind::Future(_) => panic!("no need to declare futures"),
700700
TypeDefKind::Stream(_) => panic!("no need to declare streams"),
701-
TypeDefKind::Error => panic!("no need to declare errors"),
701+
TypeDefKind::ErrorContext => panic!("no need to declare error-contexts"),
702702
TypeDefKind::Unknown => unreachable!(),
703703
}
704704
}

0 commit comments

Comments
 (0)