diff --git a/compiler-core/generated/schema_capnp.rs b/compiler-core/generated/schema_capnp.rs index b0a3a3bbce9..ec76c94e7a6 100644 --- a/compiler-core/generated/schema_capnp.rs +++ b/compiler-core/generated/schema_capnp.rs @@ -3436,6 +3436,255 @@ pub mod record_accessor { } } +pub mod inferred_variant { + pub use self::Which::{Unknown,Inferred}; + + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } } + impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> } + impl <> ::core::marker::Copy for Reader<'_,> {} + impl <> ::core::clone::Clone for Reader<'_,> { + fn clone(&self) -> Self { *self } + } + + impl <> ::capnp::traits::HasTypeId for Reader<'_,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + impl <> ::core::fmt::Debug for Reader<'_,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f) + } + } + + impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> { + fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> { + fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> { + self.reader + } + } + + impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> { + fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) { + self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table)) + } + } + + impl <> Reader<'_,> { + pub fn reborrow(&self) -> Reader<'_,> { + Self { .. *self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn which(self) -> ::core::result::Result { + match self.reader.get_data_field::(0) { + 0 => { + ::core::result::Result::Ok(Unknown( + () + )) + } + 1 => { + ::core::result::Result::Ok(Inferred( + self.reader.get_data_field::(1) + )) + } + x => ::core::result::Result::Err(::capnp::NotInSchema(x)) + } + } + } + + pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } + impl <> ::capnp::traits::HasStructSize for Builder<'_,> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 1, pointers: 0 }; + } + impl <> ::capnp::traits::HasTypeId for Builder<'_,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> { + fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) { + self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table)) + } + } + + impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> { + fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self { + builder.init_struct(::STRUCT_SIZE).into() + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result { + ::core::result::Result::Ok(builder.get_struct(::STRUCT_SIZE, default)?.into()) + } + } + + impl <> ::capnp::traits::SetterInput> for Reader<'_,> { + fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) } + } + + impl <'a,> Builder<'a,> { + pub fn into_reader(self) -> Reader<'a,> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_,> { + Builder { builder: self.builder.reborrow() } + } + pub fn reborrow_as_reader(&self) -> Reader<'_,> { + self.builder.as_reader().into() + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn set_unknown(&mut self, _value: ()) { + self.builder.set_data_field::(0, 0); + } + #[inline] + pub fn set_inferred(&mut self, value: u16) { + self.builder.set_data_field::(0, 1); + self.builder.set_data_field::(1, value); + } + #[inline] + pub fn which(self) -> ::core::result::Result { + match self.builder.get_data_field::(0) { + 0 => { + ::core::result::Result::Ok(Unknown( + () + )) + } + 1 => { + ::core::result::Result::Ok(Inferred( + self.builder.get_data_field::(1) + )) + } + x => ::core::result::Result::Err(::capnp::NotInSchema(x)) + } + } + } + + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { _typeless: typeless, } + } + } + impl Pipeline { + } + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 49] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(153, 102, 38, 126, 162, 160, 201, 166), + ::capnp::word(13, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(190, 237, 188, 253, 156, 169, 51, 181), + ::capnp::word(0, 0, 7, 0, 0, 0, 2, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 234, 0, 0, 0), + ::capnp::word(33, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(29, 0, 0, 0, 119, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(115, 99, 104, 101, 109, 97, 46, 99), + ::capnp::word(97, 112, 110, 112, 58, 73, 110, 102), + ::capnp::word(101, 114, 114, 101, 100, 86, 97, 114), + ::capnp::word(105, 97, 110, 116, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(8, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 255, 255, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(41, 0, 0, 0, 66, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(36, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(48, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 254, 255, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(45, 0, 0, 0, 74, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(44, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(56, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(117, 110, 107, 110, 111, 119, 110, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(105, 110, 102, 101, 114, 114, 101, 100), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(7, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(7, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <() as ::capnp::introspect::Introspect>::introspect(), + 1 => ::introspect(), + _ => panic!("invalid field index {}", index), + } + } + pub fn get_annotation_types(child_index: Option, index: u32) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) + } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + members_by_name: MEMBERS_BY_NAME, + }; + pub static NONUNION_MEMBERS : &[u16] = &[]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[0,1]; + pub static MEMBERS_BY_NAME : &[u16] = &[1,0]; + pub const TYPE_ID: u64 = 0xa6c9_a0a2_7e26_6699; + } + pub enum Which { + Unknown(()), + Inferred(u16), + } + pub type WhichReader = Which; + pub type WhichBuilder = Which; +} + pub mod type_ { pub use self::Which::{App,Fn,Var,Tuple}; @@ -3529,7 +3778,7 @@ pub mod type_ { pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } impl <> ::capnp::traits::HasStructSize for Builder<'_,> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 4 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 5 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -3586,6 +3835,7 @@ pub mod type_ { self.builder.reborrow().get_pointer_field(1).clear(); self.builder.reborrow().get_pointer_field(2).clear(); self.builder.reborrow().get_pointer_field(3).clear(); + self.builder.reborrow().get_pointer_field(4).clear(); self.builder.into() } #[inline] @@ -3649,7 +3899,7 @@ pub mod type_ { ::capnp::word(0, 7, 151, 64, 46, 128, 246, 130), ::capnp::word(13, 0, 0, 0, 1, 0, 2, 0), ::capnp::word(190, 237, 188, 253, 156, 169, 51, 181), - ::capnp::word(4, 0, 7, 0, 0, 0, 4, 0), + ::capnp::word(5, 0, 7, 0, 0, 0, 4, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 146, 0, 0, 0), ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), @@ -3820,11 +4070,19 @@ pub mod type_ { pub fn has_package(&self) -> bool { !self.reader.get_pointer_field(3).is_null() } + #[inline] + pub fn get_inferred_variant(self) -> ::capnp::Result> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(4), ::core::option::Option::None) + } + #[inline] + pub fn has_inferred_variant(&self) -> bool { + !self.reader.get_pointer_field(4).is_null() + } } pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } impl <> ::capnp::traits::HasStructSize for Builder<'_,> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 4 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 5 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -3938,6 +4196,22 @@ pub mod type_ { pub fn has_package(&self) -> bool { !self.builder.is_pointer_field_null(3) } + #[inline] + pub fn get_inferred_variant(self) -> ::capnp::Result> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(4), ::core::option::Option::None) + } + #[inline] + pub fn set_inferred_variant(&mut self, value: crate::schema_capnp::inferred_variant::Reader<'_>) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(4), value, false) + } + #[inline] + pub fn init_inferred_variant(self, ) -> crate::schema_capnp::inferred_variant::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(4), 0) + } + #[inline] + pub fn has_inferred_variant(&self) -> bool { + !self.builder.is_pointer_field_null(4) + } } pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } @@ -3947,53 +4221,63 @@ pub mod type_ { } } impl Pipeline { + pub fn get_inferred_variant(&self) -> crate::schema_capnp::inferred_variant::Pipeline { + ::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(4)) + } } mod _private { - pub static ENCODED_NODE: [::capnp::Word; 81] = [ + pub static ENCODED_NODE: [::capnp::Word; 97] = [ ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), ::capnp::word(112, 148, 53, 107, 90, 14, 28, 212), ::capnp::word(18, 0, 0, 0, 1, 0, 2, 0), ::capnp::word(0, 7, 151, 64, 46, 128, 246, 130), - ::capnp::word(4, 0, 7, 0, 1, 0, 0, 0), + ::capnp::word(5, 0, 7, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 178, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(21, 0, 0, 0, 231, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 31, 1, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(115, 99, 104, 101, 109, 97, 46, 99), ::capnp::word(97, 112, 110, 112, 58, 84, 121, 112), ::capnp::word(101, 46, 97, 112, 112, 0, 0, 0), - ::capnp::word(16, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(20, 0, 0, 0, 3, 0, 4, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(97, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(125, 0, 0, 0, 42, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(92, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(104, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(120, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(132, 0, 0, 0, 2, 0, 1, 0), ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(101, 0, 0, 0, 58, 0, 0, 0), + ::capnp::word(129, 0, 0, 0, 58, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(96, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(108, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(124, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(136, 0, 0, 0, 2, 0, 1, 0), ::capnp::word(2, 0, 0, 0, 2, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(105, 0, 0, 0, 90, 0, 0, 0), + ::capnp::word(133, 0, 0, 0, 90, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(104, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(132, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(132, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(160, 0, 0, 0, 2, 0, 1, 0), ::capnp::word(3, 0, 0, 0, 3, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 7, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(129, 0, 0, 0, 66, 0, 0, 0), + ::capnp::word(157, 0, 0, 0, 66, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(124, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(136, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(152, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(164, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(4, 0, 0, 0, 4, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 8, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(161, 0, 0, 0, 130, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(160, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(172, 0, 0, 0, 2, 0, 1, 0), ::capnp::word(110, 97, 109, 101, 0, 0, 0, 0), ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), @@ -4031,6 +4315,15 @@ pub mod type_ { ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(105, 110, 102, 101, 114, 114, 101, 100), + ::capnp::word(86, 97, 114, 105, 97, 110, 116, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(153, 102, 38, 126, 162, 160, 201, 166), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ]; pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { match index { @@ -4038,6 +4331,7 @@ pub mod type_ { 1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), 2 => <::capnp::struct_list::Owned as ::capnp::introspect::Introspect>::introspect(), 3 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 4 => ::introspect(), _ => panic!("invalid field index {}", index), } } @@ -4050,9 +4344,9 @@ pub mod type_ { members_by_discriminant: MEMBERS_BY_DISCRIMINANT, members_by_name: MEMBERS_BY_NAME, }; - pub static NONUNION_MEMBERS : &[u16] = &[0,1,2,3]; + pub static NONUNION_MEMBERS : &[u16] = &[0,1,2,3,4]; pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; - pub static MEMBERS_BY_NAME : &[u16] = &[1,0,3,2]; + pub static MEMBERS_BY_NAME : &[u16] = &[4,1,0,3,2]; pub const TYPE_ID: u64 = 0xd41c_0e5a_6b35_9470; } } @@ -4138,7 +4432,7 @@ pub mod type_ { pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } impl <> ::capnp::traits::HasStructSize for Builder<'_,> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 4 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 5 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -4239,7 +4533,7 @@ pub mod type_ { ::capnp::word(107, 183, 96, 119, 140, 121, 242, 130), ::capnp::word(18, 0, 0, 0, 1, 0, 2, 0), ::capnp::word(0, 7, 151, 64, 46, 128, 246, 130), - ::capnp::word(4, 0, 7, 0, 1, 0, 0, 0), + ::capnp::word(5, 0, 7, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 170, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), @@ -4379,7 +4673,7 @@ pub mod type_ { pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } impl <> ::capnp::traits::HasStructSize for Builder<'_,> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 4 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 5 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -4453,7 +4747,7 @@ pub mod type_ { ::capnp::word(54, 132, 226, 31, 115, 14, 218, 204), ::capnp::word(18, 0, 0, 0, 1, 0, 2, 0), ::capnp::word(0, 7, 151, 64, 46, 128, 246, 130), - ::capnp::word(4, 0, 7, 0, 1, 0, 0, 0), + ::capnp::word(5, 0, 7, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 178, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), @@ -4576,7 +4870,7 @@ pub mod type_ { pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } impl <> ::capnp::traits::HasStructSize for Builder<'_,> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 4 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 2, pointers: 5 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -4658,7 +4952,7 @@ pub mod type_ { ::capnp::word(61, 216, 21, 128, 12, 226, 23, 140), ::capnp::word(18, 0, 0, 0, 1, 0, 2, 0), ::capnp::word(0, 7, 151, 64, 46, 128, 246, 130), - ::capnp::word(4, 0, 7, 0, 1, 0, 0, 0), + ::capnp::word(5, 0, 7, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 194, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), diff --git a/compiler-core/schema.capnp b/compiler-core/schema.capnp index a7e43497521..c8e65ecca27 100644 --- a/compiler-core/schema.capnp +++ b/compiler-core/schema.capnp @@ -81,6 +81,15 @@ struct RecordAccessor { label @2 :Text; } +# UInt16 cannot be used as a generic parameter to Option, +# so we need to create a custom type for this. +struct InferredVariant { + union { + unknown @0 :Void; + inferred @1 :UInt16; + } +} + struct Type { union { app :group { @@ -88,6 +97,7 @@ struct Type { module @1 :Text; parameters @2 :List(Type); package @7 :Text; + inferredVariant @8 :InferredVariant; } fn :group { diff --git a/compiler-core/src/lib.rs b/compiler-core/src/lib.rs index 832d754cd95..ef1e86d88c9 100644 --- a/compiler-core/src/lib.rs +++ b/compiler-core/src/lib.rs @@ -107,7 +107,8 @@ mod schema_capnp { unused_qualifications, clippy::all, clippy::unwrap_used, - missing_debug_implementations + missing_debug_implementations, + missing_copy_implementations )] include!("../generated/schema_capnp.rs"); } diff --git a/compiler-core/src/metadata/module_decoder.rs b/compiler-core/src/metadata/module_decoder.rs index a031a28253b..18e01c8a176 100755 --- a/compiler-core/src/metadata/module_decoder.rs +++ b/compiler-core/src/metadata/module_decoder.rs @@ -135,13 +135,15 @@ impl ModuleDecoder { let module = self.string(reader.get_module()?)?; let name = self.string(reader.get_name()?)?; let args = read_vec!(&reader.get_parameters()?, self, type_); + let inferred_variant = self.inferred_variant(&reader.get_inferred_variant()?)?; + Ok(Arc::new(Type::Named { publicity: Publicity::Public, package, module, name, args, - inferred_variant: None, + inferred_variant, })) } @@ -220,6 +222,14 @@ impl ModuleDecoder { }) } + fn inferred_variant(&mut self, reader: &inferred_variant::Reader<'_>) -> Result> { + use schema::inferred_variant::Which; + match reader.which()? { + Which::Unknown(_) => Ok(None), + Which::Inferred(variant) => Ok(Some(variant)), + } + } + fn value_constructor( &mut self, reader: &value_constructor::Reader<'_>, diff --git a/compiler-core/src/metadata/module_encoder.rs b/compiler-core/src/metadata/module_encoder.rs index 3a693edd5e1..9f6fbd53ad1 100644 --- a/compiler-core/src/metadata/module_encoder.rs +++ b/compiler-core/src/metadata/module_encoder.rs @@ -524,12 +524,18 @@ impl<'a> ModuleEncoder<'a> { args, module, package, + inferred_variant, .. } => { let mut app = builder.init_app(); app.set_name(name); app.set_module(module); app.set_package(package); + let mut variant_builder = app.reborrow().init_inferred_variant(); + match inferred_variant { + Some(variant) => variant_builder.set_inferred(*variant), + None => variant_builder.set_unknown(()), + } self.build_types(app.reborrow().init_parameters(args.len() as u32), args); } diff --git a/compiler-core/src/metadata/tests.rs b/compiler-core/src/metadata/tests.rs index 8ab14f0a7f7..ea941362f95 100644 --- a/compiler-core/src/metadata/tests.rs +++ b/compiler-core/src/metadata/tests.rs @@ -1454,3 +1454,41 @@ fn type_variable_ids_in_constructors_are_shared() { assert_eq!(roundtrip(&module).types_value_constructors, expected); } + +#[test] +fn type_with_inferred_variant() { + let module = ModuleInterface { + warnings: vec![], + is_internal: false, + package: "some_package".into(), + origin: Origin::Src, + name: "a/b".into(), + types: [( + "Wibble".into(), + TypeConstructor { + type_: Arc::new(Type::Named { + publicity: Publicity::Public, + package: "some_package".into(), + module: "the/module".into(), + name: "Wibble".into(), + args: Vec::new(), + inferred_variant: Some(1), + }), + publicity: Publicity::Public, + origin: Default::default(), + module: "the/module".into(), + parameters: vec![], + deprecation: Deprecation::NotDeprecated, + documentation: None, + }, + )] + .into(), + types_value_constructors: HashMap::new(), + values: HashMap::new(), + accessors: HashMap::new(), + line_numbers: LineNumbers::new(""), + src_path: "some_path".into(), + minimum_required_version: Version::new(0, 1, 0), + }; + assert_eq!(roundtrip(&module), module); +}