diff --git a/compiler-core/generated/schema_capnp.rs b/compiler-core/generated/schema_capnp.rs index 9273e8720de..a0908fdab01 100644 --- a/compiler-core/generated/schema_capnp.rs +++ b/compiler-core/generated/schema_capnp.rs @@ -708,11 +708,19 @@ pub mod module { pub fn get_contains_echo(self) -> bool { self.reader.get_bool_field(1) } + #[inline] + pub fn get_references(self) -> ::capnp::Result> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(11), ::core::option::Option::None) + } + #[inline] + pub fn has_references(&self) -> bool { + !self.reader.get_pointer_field(11).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: 1, pointers: 11 }; + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 1, pointers: 12 }; } impl <> ::capnp::traits::HasTypeId for Builder<'_,> { const TYPE_ID: u64 = _private::TYPE_ID; @@ -954,6 +962,22 @@ pub mod module { pub fn set_contains_echo(&mut self, value: bool) { self.builder.set_bool_field(1, value); } + #[inline] + pub fn get_references(self) -> ::capnp::Result> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(11), ::core::option::Option::None) + } + #[inline] + pub fn set_references(&mut self, value: crate::schema_capnp::references::Reader<'_>) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(11), value, false) + } + #[inline] + pub fn init_references(self, ) -> crate::schema_capnp::references::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(11), 0) + } + #[inline] + pub fn has_references(&self) -> bool { + !self.builder.is_pointer_field_null(11) + } } pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } @@ -969,117 +993,127 @@ pub mod module { pub fn get_required_version(&self) -> crate::schema_capnp::version::Pipeline { ::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(8)) } + pub fn get_references(&self) -> crate::schema_capnp::references::Pipeline { + ::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(11)) + } } mod _private { - pub static ENCODED_NODE: [::capnp::Word; 305] = [ + pub static ENCODED_NODE: [::capnp::Word; 321] = [ ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), ::capnp::word(129, 5, 219, 80, 68, 149, 82, 154), ::capnp::word(13, 0, 0, 0, 1, 0, 1, 0), ::capnp::word(190, 237, 188, 253, 156, 169, 51, 181), - ::capnp::word(11, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 7, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), ::capnp::word(21, 0, 0, 0, 162, 0, 0, 0), ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(25, 0, 0, 0, 223, 2, 0, 0), + ::capnp::word(25, 0, 0, 0, 23, 3, 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, 77, 111, 100), ::capnp::word(117, 108, 101, 0, 0, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), - ::capnp::word(52, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(56, 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(93, 1, 0, 0, 42, 0, 0, 0), + ::capnp::word(121, 1, 0, 0, 42, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(88, 1, 0, 0, 3, 0, 1, 0), - ::capnp::word(100, 1, 0, 0, 2, 0, 1, 0), + ::capnp::word(116, 1, 0, 0, 3, 0, 1, 0), + ::capnp::word(128, 1, 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(97, 1, 0, 0, 50, 0, 0, 0), + ::capnp::word(125, 1, 0, 0, 50, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(92, 1, 0, 0, 3, 0, 1, 0), - ::capnp::word(168, 1, 0, 0, 2, 0, 1, 0), + ::capnp::word(120, 1, 0, 0, 3, 0, 1, 0), + ::capnp::word(196, 1, 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(165, 1, 0, 0, 58, 0, 0, 0), + ::capnp::word(193, 1, 0, 0, 58, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(160, 1, 0, 0, 3, 0, 1, 0), - ::capnp::word(236, 1, 0, 0, 2, 0, 1, 0), + ::capnp::word(188, 1, 0, 0, 3, 0, 1, 0), + ::capnp::word(8, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(3, 0, 0, 0, 3, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(233, 1, 0, 0, 82, 0, 0, 0), + ::capnp::word(5, 2, 0, 0, 82, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(232, 1, 0, 0, 3, 0, 1, 0), - ::capnp::word(52, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(4, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(80, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(4, 0, 0, 0, 4, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 4, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(49, 2, 0, 0, 66, 0, 0, 0), + ::capnp::word(77, 2, 0, 0, 66, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(44, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(56, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(72, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(84, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(5, 0, 0, 0, 5, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 5, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(53, 2, 0, 0, 146, 0, 0, 0), + ::capnp::word(81, 2, 0, 0, 146, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(56, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(132, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(84, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(160, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(6, 0, 0, 0, 6, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 6, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(129, 2, 0, 0, 98, 0, 0, 0), + ::capnp::word(157, 2, 0, 0, 98, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(128, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(140, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(156, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(168, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(7, 0, 0, 0, 7, 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(137, 2, 0, 0, 66, 0, 0, 0), + ::capnp::word(165, 2, 0, 0, 66, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(132, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(144, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(160, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(172, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(8, 0, 0, 0, 0, 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(141, 2, 0, 0, 90, 0, 0, 0), + ::capnp::word(169, 2, 0, 0, 90, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(140, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(152, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(168, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(180, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(9, 0, 0, 0, 8, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 9, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(149, 2, 0, 0, 130, 0, 0, 0), + ::capnp::word(177, 2, 0, 0, 130, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(148, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(160, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(176, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(188, 2, 0, 0, 2, 0, 1, 0), ::capnp::word(10, 0, 0, 0, 9, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 10, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(157, 2, 0, 0, 98, 0, 0, 0), + ::capnp::word(185, 2, 0, 0, 98, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(156, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(232, 2, 0, 0, 2, 0, 1, 0), + ::capnp::word(184, 2, 0, 0, 3, 0, 1, 0), + ::capnp::word(4, 3, 0, 0, 2, 0, 1, 0), ::capnp::word(11, 0, 0, 0, 10, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 11, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(229, 2, 0, 0, 114, 0, 0, 0), + ::capnp::word(1, 3, 0, 0, 114, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(228, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(0, 3, 0, 0, 2, 0, 1, 0), + ::capnp::word(0, 3, 0, 0, 3, 0, 1, 0), + ::capnp::word(28, 3, 0, 0, 2, 0, 1, 0), ::capnp::word(12, 0, 0, 0, 1, 0, 0, 0), ::capnp::word(0, 0, 1, 0, 12, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(253, 2, 0, 0, 106, 0, 0, 0), + ::capnp::word(25, 3, 0, 0, 106, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(24, 3, 0, 0, 3, 0, 1, 0), + ::capnp::word(36, 3, 0, 0, 2, 0, 1, 0), + ::capnp::word(13, 0, 0, 0, 11, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 13, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(33, 3, 0, 0, 90, 0, 0, 0), ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(252, 2, 0, 0, 3, 0, 1, 0), - ::capnp::word(8, 3, 0, 0, 2, 0, 1, 0), + ::capnp::word(32, 3, 0, 0, 3, 0, 1, 0), + ::capnp::word(44, 3, 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), @@ -1277,6 +1311,15 @@ pub mod module { ::capnp::word(1, 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(114, 101, 102, 101, 114, 101, 110, 99), + ::capnp::word(101, 115, 0, 0, 0, 0, 0, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(101, 145, 82, 27, 227, 203, 200, 215), + ::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 { @@ -1293,6 +1336,7 @@ pub mod module { 10 => <::capnp::struct_list::Owned> as ::capnp::introspect::Introspect>::introspect(), 11 => <::capnp::text_list::Owned as ::capnp::introspect::Introspect>::introspect(), 12 => ::introspect(), + 13 => ::introspect(), _ => panic!("invalid field index {}", index), } } @@ -1305,13 +1349,561 @@ pub mod module { members_by_discriminant: MEMBERS_BY_DISCRIMINANT, members_by_name: MEMBERS_BY_NAME, }; - pub static NONUNION_MEMBERS : &[u16] = &[0,1,2,3,4,5,6,7,8,9,10,11,12]; + pub static NONUNION_MEMBERS : &[u16] = &[0,1,2,3,4,5,6,7,8,9,10,11,12,13]; pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; - pub static MEMBERS_BY_NAME : &[u16] = &[3,12,11,8,6,0,4,9,7,10,1,5,2]; + pub static MEMBERS_BY_NAME : &[u16] = &[3,12,11,8,6,0,4,13,9,7,10,1,5,2]; pub const TYPE_ID: u64 = 0x9a52_9544_50db_0581; } } +pub mod references { + #[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 <'a,> Reader<'a,> { + pub fn reborrow(&self) -> Reader<'_,> { + Self { .. *self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_imported_modules(self) -> ::capnp::Result<::capnp::text_list::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn has_imported_modules(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_value_references(self) -> ::capnp::Result<::capnp::struct_list::Reader<'a,crate::schema_capnp::value_reference::Owned>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn has_value_references(&self) -> bool { + !self.reader.get_pointer_field(1).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: 0, pointers: 2 }; + } + 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 get_imported_modules(self) -> ::capnp::Result<::capnp::text_list::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn set_imported_modules(&mut self, value: impl ::capnp::traits::SetterInput<::capnp::text_list::Owned>) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(0), value, false) + } + #[inline] + pub fn init_imported_modules(self, size: u32) -> ::capnp::text_list::Builder<'a> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), size) + } + #[inline] + pub fn has_imported_modules(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_value_references(self) -> ::capnp::Result<::capnp::struct_list::Builder<'a,crate::schema_capnp::value_reference::Owned>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn set_value_references(&mut self, value: ::capnp::struct_list::Reader<'_,crate::schema_capnp::value_reference::Owned>) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(1), value, false) + } + #[inline] + pub fn init_value_references(self, size: u32) -> ::capnp::struct_list::Builder<'a,crate::schema_capnp::value_reference::Owned> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), size) + } + #[inline] + pub fn has_value_references(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + } + + 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; 57] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(101, 145, 82, 27, 227, 203, 200, 215), + ::capnp::word(13, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(190, 237, 188, 253, 156, 169, 51, 181), + ::capnp::word(2, 0, 7, 0, 0, 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(29, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(25, 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, 82, 101, 102), + ::capnp::word(101, 114, 101, 110, 99, 101, 115, 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, 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(41, 0, 0, 0, 130, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(40, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(68, 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(65, 0, 0, 0, 130, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(64, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(92, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(105, 109, 112, 111, 114, 116, 101, 100), + ::capnp::word(77, 111, 100, 117, 108, 101, 115, 0), + ::capnp::word(14, 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, 3, 0, 1, 0), + ::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(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(14, 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(118, 97, 108, 117, 101, 82, 101, 102), + ::capnp::word(101, 114, 101, 110, 99, 101, 115, 0), + ::capnp::word(14, 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, 3, 0, 1, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(104, 93, 146, 250, 170, 165, 141, 205), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(14, 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 => <::capnp::text_list::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => <::capnp::struct_list::Owned as ::capnp::introspect::Introspect>::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] = &[0,1]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; + pub static MEMBERS_BY_NAME : &[u16] = &[0,1]; + pub const TYPE_ID: u64 = 0xd7c8_cbe3_1b52_9165; + } +} + +pub mod value_reference { + #[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 <'a,> Reader<'a,> { + pub fn reborrow(&self) -> Reader<'_,> { + Self { .. *self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_module(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn has_module(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_name(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn has_name(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + #[inline] + pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Reader<'a,crate::schema_capnp::src_span::Owned>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None) + } + #[inline] + pub fn has_references(&self) -> bool { + !self.reader.get_pointer_field(2).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: 0, pointers: 3 }; + } + 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 get_module(self) -> ::capnp::Result<::capnp::text::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn set_module(&mut self, value: impl ::capnp::traits::SetterInput<::capnp::text::Owned>) { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(0), value, false).unwrap() + } + #[inline] + pub fn init_module(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(0).init_text(size) + } + #[inline] + pub fn has_module(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_name(self) -> ::capnp::Result<::capnp::text::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn set_name(&mut self, value: impl ::capnp::traits::SetterInput<::capnp::text::Owned>) { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(1), value, false).unwrap() + } + #[inline] + pub fn init_name(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(1).init_text(size) + } + #[inline] + pub fn has_name(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + #[inline] + pub fn get_references(self) -> ::capnp::Result<::capnp::struct_list::Builder<'a,crate::schema_capnp::src_span::Owned>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None) + } + #[inline] + pub fn set_references(&mut self, value: ::capnp::struct_list::Reader<'_,crate::schema_capnp::src_span::Owned>) -> ::capnp::Result<()> { + ::capnp::traits::SetterInput::set_pointer_builder(self.builder.reborrow().get_pointer_field(2), value, false) + } + #[inline] + pub fn init_references(self, size: u32) -> ::capnp::struct_list::Builder<'a,crate::schema_capnp::src_span::Owned> { + ::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), size) + } + #[inline] + pub fn has_references(&self) -> bool { + !self.builder.is_pointer_field_null(2) + } + } + + 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; 68] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(104, 93, 146, 250, 170, 165, 141, 205), + ::capnp::word(13, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(190, 237, 188, 253, 156, 169, 51, 181), + ::capnp::word(3, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 226, 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, 175, 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, 86, 97, 108), + ::capnp::word(117, 101, 82, 101, 102, 101, 114, 101), + ::capnp::word(110, 99, 101, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(12, 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(69, 0, 0, 0, 58, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(64, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(76, 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(73, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(68, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(80, 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(77, 0, 0, 0, 90, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(76, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(104, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(109, 111, 100, 117, 108, 101, 0, 0), + ::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(0, 0, 0, 0, 0, 0, 0, 0), + ::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(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), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::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(114, 101, 102, 101, 114, 101, 110, 99), + ::capnp::word(101, 115, 0, 0, 0, 0, 0, 0), + ::capnp::word(14, 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, 3, 0, 1, 0), + ::capnp::word(16, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(176, 122, 119, 83, 72, 147, 59, 230), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(14, 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 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 2 => <::capnp::struct_list::Owned as ::capnp::introspect::Introspect>::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] = &[0,1,2]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; + pub static MEMBERS_BY_NAME : &[u16] = &[0,1,2]; + pub const TYPE_ID: u64 = 0xcd8d_a5aa_fa92_5d68; + } +} + pub mod type_alias_constructor { #[derive(Copy, Clone)] pub struct Owned(()); diff --git a/compiler-core/schema.capnp b/compiler-core/schema.capnp index bd62cb645f7..b30a92e272d 100644 --- a/compiler-core/schema.capnp +++ b/compiler-core/schema.capnp @@ -33,6 +33,18 @@ struct Module { typeAliases @10 :List(Property(TypeAliasConstructor)); documentation @11 :List(Text); containsEcho @12 :Bool; + references @13 :References; +} + +struct References { + importedModules @0 :List(Text); + valueReferences @1 :List(ValueReference); +} + +struct ValueReference { + module @0 :Text; + name @1 :Text; + references @2 :List(SrcSpan); } struct TypeAliasConstructor { diff --git a/compiler-core/src/analyse.rs b/compiler-core/src/analyse.rs index 91adfd3ff9d..0af316e7568 100644 --- a/compiler-core/src/analyse.rs +++ b/compiler-core/src/analyse.rs @@ -9,10 +9,10 @@ use crate::{ ast::{ self, Arg, BitArrayOption, CustomType, Definition, DefinitionLocation, Function, GroupedStatements, Import, ModuleConstant, Publicity, RecordConstructor, - RecordConstructorArg, References, SrcSpan, Statement, TypeAlias, TypeAst, - TypeAstConstructor, TypeAstFn, TypeAstHole, TypeAstTuple, TypeAstVar, TypedDefinition, - TypedExpr, TypedFunction, TypedModule, UntypedArg, UntypedCustomType, UntypedFunction, - UntypedImport, UntypedModule, UntypedModuleConstant, UntypedStatement, UntypedTypeAlias, + RecordConstructorArg, SrcSpan, Statement, TypeAlias, TypeAst, TypeAstConstructor, + TypeAstFn, TypeAstHole, TypeAstTuple, TypeAstVar, TypedDefinition, TypedExpr, + TypedFunction, TypedModule, UntypedArg, UntypedCustomType, UntypedFunction, UntypedImport, + UntypedModule, UntypedModuleConstant, UntypedStatement, UntypedTypeAlias, }, build::{Origin, Outcome, Target}, call_graph::{CallGraphNode, into_dependency_order}, @@ -22,8 +22,8 @@ use crate::{ parse::SpannedString, type_::{ self, AccessorsMap, Deprecation, ModuleInterface, Opaque, PatternConstructor, - RecordAccessor, Type, TypeAliasConstructor, TypeConstructor, TypeValueConstructor, - TypeValueConstructorField, TypeVariantConstructors, ValueConstructor, + RecordAccessor, References, Type, TypeAliasConstructor, TypeConstructor, + TypeValueConstructor, TypeValueConstructorField, TypeVariantConstructors, ValueConstructor, ValueConstructorVariant, Warning, environment::*, error::{Error, FeatureKind, MissingAnnotation, Named, Problems, convert_unify_error}, @@ -340,12 +340,12 @@ impl<'a, A> ModuleAnalyzer<'a, A> { type_aliases, documentation, contains_echo: echo_found, + references: References { + imported_modules: env.imported_modules.into_keys().collect(), + value_references: env.references, + }, }, names: type_names, - references: References { - imported_modules: env.imported_modules.into_keys().collect(), - value_references: env.references, - }, }; match Vec1::try_from_vec(self.problems.take_errors()) { diff --git a/compiler-core/src/ast.rs b/compiler-core/src/ast.rs index c5a52e9f461..9cc934e79a3 100644 --- a/compiler-core/src/ast.rs +++ b/compiler-core/src/ast.rs @@ -20,7 +20,6 @@ use crate::type_::printer::Names; use crate::type_::{ self, Deprecation, ModuleValueConstructor, PatternConstructor, Type, ValueConstructor, }; -use std::collections::{HashMap, HashSet}; use std::sync::Arc; use ecow::EcoString; @@ -51,7 +50,6 @@ pub struct Module { pub type_info: Info, pub definitions: Vec, pub names: Names, - pub references: References, } impl TypedModule { @@ -68,12 +66,6 @@ impl TypedModule { } } -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct References { - pub imported_modules: HashSet, - pub value_references: HashMap<(EcoString, EcoString), Vec>, -} - /// The `@target(erlang)` and `@target(javascript)` attributes can be used to /// mark a definition as only being for a specific target. /// diff --git a/compiler-core/src/build/package_loader/tests.rs b/compiler-core/src/build/package_loader/tests.rs index a4271826ea0..705f59b1a6b 100644 --- a/compiler-core/src/build/package_loader/tests.rs +++ b/compiler-core/src/build/package_loader/tests.rs @@ -64,6 +64,7 @@ fn write_cache( type_aliases: Default::default(), documentation: Default::default(), contains_echo: false, + references: Default::default(), }; let path = Utf8Path::new("/artefact").join(format!("{name}.cache")); fs.write_bytes( diff --git a/compiler-core/src/language_server/engine.rs b/compiler-core/src/language_server/engine.rs index 746fee6072d..85d4bb8a8f7 100644 --- a/compiler-core/src/language_server/engine.rs +++ b/compiler-core/src/language_server/engine.rs @@ -769,7 +769,8 @@ where ¶ms, module_name, name, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::Function, ), Located::Expression(TypedExpr::ModuleSelect { @@ -782,7 +783,8 @@ where ¶ms, module_name, label, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::Function, ), Located::ModuleStatement( @@ -795,7 +797,8 @@ where ¶ms, &module.name, name, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::Function, ), Located::Expression(TypedExpr::Var { @@ -814,7 +817,8 @@ where ¶ms, module_name, name, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::CustomTypeVariant, ), Located::Expression(TypedExpr::ModuleSelect { @@ -826,7 +830,8 @@ where ¶ms, module_name, label, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::CustomTypeVariant, ), Located::VariantConstructorDefinition(RecordConstructor { name, .. }) => { @@ -834,7 +839,8 @@ where ¶ms, &module.name, name, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::CustomTypeVariant, ) } @@ -845,7 +851,8 @@ where ¶ms, &constructor.module, &constructor.name, - &this.compiler.modules, + this.compiler.project_compiler.get_importable_modules(), + &this.compiler.sources, Named::CustomTypeVariant, ), _ => None, diff --git a/compiler-core/src/language_server/rename.rs b/compiler-core/src/language_server/rename.rs index 4086ea79b4a..91bed8d4f2f 100644 --- a/compiler-core/src/language_server/rename.rs +++ b/compiler-core/src/language_server/rename.rs @@ -8,10 +8,10 @@ use crate::{ ast::{self, SrcSpan, TypedModule, visit::Visit}, build::Module, line_numbers::LineNumbers, - type_::{ValueConstructor, ValueConstructorVariant, error::Named}, + type_::{ModuleInterface, ValueConstructor, ValueConstructorVariant, error::Named}, }; -use super::TextEdits; +use super::{TextEdits, compiler::ModuleSourceInformation}; fn workspace_edit(uri: Url, edits: Vec) -> WorkspaceEdit { let mut changes = HashMap::new(); @@ -69,7 +69,8 @@ pub fn rename_module_value( params: &RenameParams, module_name: &EcoString, name: &EcoString, - modules: &HashMap, + modules: &im::HashMap, + sources: &HashMap, name_kind: Named, ) -> Option { if name::check_name_case( @@ -91,11 +92,14 @@ pub fn rename_module_value( }; for module in modules.values() { - if &module.name == module_name - || module.ast.references.imported_modules.contains(module_name) - { + if &module.name == module_name || module.references.imported_modules.contains(module_name) { + let Some(source_information) = sources.get(&module.name) else { + continue; + }; + rename_references_in_module( module, + source_information, &mut workspace_edit, module_name, name, @@ -108,14 +112,14 @@ pub fn rename_module_value( } fn rename_references_in_module( - module: &Module, + module: &ModuleInterface, + source_information: &ModuleSourceInformation, workspace_edit: &mut WorkspaceEdit, module_name: &EcoString, name: &EcoString, new_name: String, ) { let Some(references) = module - .ast .references .value_references .get(&(module_name.clone(), name.clone())) @@ -123,14 +127,13 @@ fn rename_references_in_module( return; }; - let line_numbers = LineNumbers::new(&module.code); - let mut edits = TextEdits::new(&line_numbers); + let mut edits = TextEdits::new(&source_information.line_numbers); references .iter() .for_each(|location| edits.replace(*location, new_name.clone())); - let Some(uri) = url_from_path(module.input_path.as_str()) else { + let Some(uri) = url_from_path(source_information.path.as_str()) else { return; }; diff --git a/compiler-core/src/metadata/module_decoder.rs b/compiler-core/src/metadata/module_decoder.rs index 5884e5b4eb9..966a92f0165 100755 --- a/compiler-core/src/metadata/module_decoder.rs +++ b/compiler-core/src/metadata/module_decoder.rs @@ -14,14 +14,14 @@ use crate::{ line_numbers::LineNumbers, schema_capnp::{self as schema, *}, type_::{ - self, AccessorsMap, Deprecation, FieldMap, ModuleInterface, Opaque, RecordAccessor, Type, - TypeAliasConstructor, TypeConstructor, TypeValueConstructor, TypeValueConstructorField, - TypeVariantConstructors, ValueConstructor, ValueConstructorVariant, - expression::Implementations, + self, AccessorsMap, Deprecation, FieldMap, ModuleInterface, Opaque, RecordAccessor, + References, Type, TypeAliasConstructor, TypeConstructor, TypeValueConstructor, + TypeValueConstructorField, TypeVariantConstructors, ValueConstructor, + ValueConstructorVariant, expression::Implementations, }, uid::UniqueIdGenerator, }; -use std::{collections::HashMap, io::BufRead, sync::Arc}; +use std::{collections::HashMap, collections::HashSet, io::BufRead, sync::Arc}; macro_rules! read_vec { ($reader:expr, $self:expr, $method:ident) => {{ @@ -87,6 +87,7 @@ impl ModuleDecoder { type_aliases: read_hashmap!(reader.get_type_aliases()?, self, type_alias_constructor), documentation: self.string_list(reader.get_documentation()?)?, contains_echo: reader.get_contains_echo(), + references: self.references(reader.get_references()?)?, }) } @@ -108,6 +109,35 @@ impl ModuleDecoder { .map_err(|_| capnp::Error::failed("String contains non-utf8 characters".into()).into()) } + fn references(&self, reader: references::Reader<'_>) -> Result { + Ok(References { + imported_modules: self.string_set(reader.get_imported_modules()?)?, + value_references: self.value_references(reader.get_value_references()?)?, + }) + } + + fn string_set(&self, reader: text_list::Reader<'_>) -> Result> { + let mut set = HashSet::with_capacity(reader.len() as usize); + for reader in reader.into_iter() { + let _ = set.insert(self.string(reader?)?); + } + Ok(set) + } + + fn value_references( + &self, + reader: capnp::struct_list::Reader<'_, value_reference::Owned>, + ) -> Result>> { + let mut map = HashMap::with_capacity(reader.len() as usize); + for prop in reader.into_iter() { + let module = self.string(prop.get_module()?)?; + let name = self.string(prop.get_name()?)?; + let references = read_vec!(prop.get_references()?, self, src_span); + let _ = map.insert((module, name), references); + } + Ok(map) + } + fn type_constructor( &mut self, reader: &type_constructor::Reader<'_>, diff --git a/compiler-core/src/metadata/module_encoder.rs b/compiler-core/src/metadata/module_encoder.rs index e5bf4c44491..1c3ad093527 100644 --- a/compiler-core/src/metadata/module_encoder.rs +++ b/compiler-core/src/metadata/module_encoder.rs @@ -52,6 +52,7 @@ impl<'a> ModuleEncoder<'a> { self.set_version(&mut module); self.set_module_documentation(&mut module); self.set_module_type_aliases(&mut module); + self.set_module_references(&mut module); capnp::serialize_packed::write_message(&mut buffer, &message).expect("capnp encode"); Ok(buffer) @@ -197,6 +198,32 @@ impl<'a> ModuleEncoder<'a> { } } + fn set_module_references(&mut self, module: &mut module::Builder<'_>) { + let references = &self.data.references; + let mut builder = module.reborrow().init_references(); + let mut imported_modules = builder + .reborrow() + .init_imported_modules(references.imported_modules.len() as u32); + for (i, module) in references.imported_modules.iter().enumerate() { + imported_modules.set(i as u32, module); + } + + let mut value_references = builder + .reborrow() + .init_value_references(references.value_references.len() as u32); + for (i, ((module, name), references)) in references.value_references.iter().enumerate() { + let mut builder = value_references.reborrow().get(i as u32); + builder.set_module(module); + builder.set_name(name); + let mut references_builder = + builder.reborrow().init_references(references.len() as u32); + for (i, reference) in references.iter().enumerate() { + let builder = references_builder.reborrow().get(i as u32); + self.build_src_span(builder, *reference); + } + } + } + fn set_version(&mut self, module: &mut module::Builder<'_>) { let mut version = module.reborrow().init_required_version(); version.set_major(self.data.minimum_required_version.major); diff --git a/compiler-core/src/metadata/tests.rs b/compiler-core/src/metadata/tests.rs index 23383fa58c3..94f893b60cb 100644 --- a/compiler-core/src/metadata/tests.rs +++ b/compiler-core/src/metadata/tests.rs @@ -11,9 +11,9 @@ use crate::{ build::Origin, line_numbers::LineNumbers, type_::{ - self, Deprecation, ModuleInterface, Opaque, Type, TypeAliasConstructor, TypeConstructor, - TypeValueConstructor, TypeValueConstructorField, TypeVariantConstructors, ValueConstructor, - ValueConstructorVariant, expression::Implementations, prelude, + self, Deprecation, ModuleInterface, Opaque, References, Type, TypeAliasConstructor, + TypeConstructor, TypeValueConstructor, TypeValueConstructorField, TypeVariantConstructors, + ValueConstructor, ValueConstructorVariant, expression::Implementations, prelude, }, uid::UniqueIdGenerator, }; @@ -68,6 +68,8 @@ fn constant_module(constant: TypedConstant) -> ModuleInterface { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), } } @@ -105,6 +107,8 @@ fn empty_module() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -131,6 +135,8 @@ fn with_line_numbers() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -165,6 +171,8 @@ fn module_with_private_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -199,6 +207,8 @@ fn module_with_app_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -233,6 +243,8 @@ fn module_with_fn_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -267,6 +279,8 @@ fn module_with_tuple_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -307,6 +321,7 @@ fn module_with_generic_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), } } @@ -347,6 +362,7 @@ fn module_with_type_links() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), } } @@ -387,6 +403,7 @@ fn module_with_type_constructor_documentation() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), } } @@ -430,6 +447,7 @@ fn module_with_type_constructor_origin() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), } } @@ -466,6 +484,8 @@ fn module_type_to_constructors_mapping() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -517,6 +537,8 @@ fn module_fn_value() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -569,6 +591,8 @@ fn deprecated_module_fn_value() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -619,6 +643,8 @@ fn private_module_fn_value() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -671,6 +697,8 @@ fn module_fn_value_regression() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -722,6 +750,8 @@ fn module_fn_value_with_field_map() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -768,6 +798,8 @@ fn record_value() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -818,6 +850,8 @@ fn record_value_with_field_map() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -889,6 +923,8 @@ fn accessors() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -960,6 +996,7 @@ fn private_accessors() { minimum_required_version: Version::new(0, 1, 0), type_aliases: HashMap::new(), documentation: Vec::new(), + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1188,6 +1225,8 @@ fn constant_var() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1383,6 +1422,8 @@ fn deprecated_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -1433,6 +1474,7 @@ fn module_fn_value_with_external_implementations() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1456,6 +1498,7 @@ fn module_containing_echo() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: true, + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1509,6 +1552,8 @@ fn internal_module_fn() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1565,6 +1610,8 @@ fn internal_annotated_module_fn() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); @@ -1613,6 +1660,8 @@ fn type_variable_ids_in_constructors_are_shared() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; let expected = HashMap::from([( @@ -1681,6 +1730,7 @@ fn type_with_inferred_variant() { minimum_required_version: Version::new(0, 1, 0), type_aliases: HashMap::new(), documentation: Vec::new(), + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -1715,6 +1765,8 @@ fn module_with_type_aliases() { .into(), documentation: Vec::new(), contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -1741,6 +1793,8 @@ fn module_with_documentation() { "And finally, a third".into(), ], contains_echo: false, + + references: References::default(), }; assert_eq!(roundtrip(&module), module); } @@ -1775,6 +1829,52 @@ fn module_with_opaque_type() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), + }; + + assert_eq!(roundtrip(&module), module); +} + +#[test] +fn module_with_references() { + let module = ModuleInterface { + warnings: vec![], + is_internal: false, + package: "some_package".into(), + origin: Origin::Src, + name: "a".into(), + types: HashMap::new(), + types_value_constructors: HashMap::new(), + accessors: HashMap::new(), + values: HashMap::new(), + line_numbers: LineNumbers::new(""), + src_path: "some_path".into(), + minimum_required_version: Version::new(0, 1, 0), + type_aliases: HashMap::new(), + documentation: Vec::new(), + contains_echo: false, + references: References { + imported_modules: ["some_module".into(), "some_other_module".into()].into(), + value_references: [ + ( + ("some_module".into(), "some_function".into()), + vec![SrcSpan::new(1, 6), SrcSpan::new(7, 11)], + ), + ( + ("some_other_module".into(), "some_constant".into()), + vec![SrcSpan::new(6, 9), SrcSpan::new(90, 108)], + ), + ( + ("some_other_module".into(), "SomeTypeVariant".into()), + vec![ + SrcSpan::new(26, 35), + SrcSpan::new(152, 204), + SrcSpan::new(0, 8), + ], + ), + ] + .into(), + }, }; assert_eq!(roundtrip(&module), module); diff --git a/compiler-core/src/parse.rs b/compiler-core/src/parse.rs index 7349746da1b..adc4ed1dde5 100644 --- a/compiler-core/src/parse.rs +++ b/compiler-core/src/parse.rs @@ -243,7 +243,6 @@ where type_info: (), definitions, names: Default::default(), - references: Default::default(), }; Ok(Parsed { module, diff --git a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__const_string_concat.snap b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__const_string_concat.snap index 59c29e1eaa5..6b7d2acca51 100644 --- a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__const_string_concat.snap +++ b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__const_string_concat.snap @@ -101,10 +101,6 @@ Parsed { type_variables: {}, local_value_constructors: {}, }, - references: References { - imported_modules: {}, - value_references: {}, - }, }, extra: ModuleExtra { module_comments: [], diff --git a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__deprecation_attribute_on_type_variant.snap b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__deprecation_attribute_on_type_variant.snap index 32f8b4fcb0a..46bf2af06c0 100644 --- a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__deprecation_attribute_on_type_variant.snap +++ b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__deprecation_attribute_on_type_variant.snap @@ -70,10 +70,6 @@ Parsed { type_variables: {}, local_value_constructors: {}, }, - references: References { - imported_modules: {}, - value_references: {}, - }, }, extra: ModuleExtra { module_comments: [], diff --git a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__import_type.snap b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__import_type.snap index 9e7cef8413b..58a85c0f5df 100644 --- a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__import_type.snap +++ b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__import_type.snap @@ -70,10 +70,6 @@ Parsed { type_variables: {}, local_value_constructors: {}, }, - references: References { - imported_modules: {}, - value_references: {}, - }, }, extra: ModuleExtra { module_comments: [], diff --git a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__record_access_no_label.snap b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__record_access_no_label.snap index 2513ad75803..ad0330040fa 100644 --- a/compiler-core/src/parse/snapshots/gleam_core__parse__tests__record_access_no_label.snap +++ b/compiler-core/src/parse/snapshots/gleam_core__parse__tests__record_access_no_label.snap @@ -164,10 +164,6 @@ Parsed { type_variables: {}, local_value_constructors: {}, }, - references: References { - imported_modules: {}, - value_references: {}, - }, }, extra: ModuleExtra { module_comments: [], diff --git a/compiler-core/src/type_.rs b/compiler-core/src/type_.rs index 8471753a05e..aeb8bb34c4c 100644 --- a/compiler-core/src/type_.rs +++ b/compiler-core/src/type_.rs @@ -891,6 +891,7 @@ pub struct ModuleInterface { pub documentation: Vec, /// Wether there's any echo in the module. pub contains_echo: bool, + pub references: References, } impl ModuleInterface { @@ -899,6 +900,12 @@ impl ModuleInterface { } } +#[derive(Debug, Clone, PartialEq, Eq, Default)] +pub struct References { + pub imported_modules: HashSet, + pub value_references: HashMap<(EcoString, EcoString), Vec>, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Opaque { Opaque, diff --git a/compiler-core/src/type_/prelude.rs b/compiler-core/src/type_/prelude.rs index 63eeee10545..abc7e74256b 100644 --- a/compiler-core/src/type_/prelude.rs +++ b/compiler-core/src/type_/prelude.rs @@ -9,7 +9,7 @@ use crate::{ }; use super::{ - ModuleInterface, Opaque, Type, TypeConstructor, TypeValueConstructor, + ModuleInterface, Opaque, References, Type, TypeConstructor, TypeValueConstructor, TypeValueConstructorField, TypeVar, TypeVariantConstructors, ValueConstructor, ValueConstructorVariant, }; @@ -245,6 +245,7 @@ pub fn build_prelude(ids: &UniqueIdGenerator) -> ModuleInterface { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default(), }; for t in PreludeType::iter() { diff --git a/compiler-core/src/type_/tests.rs b/compiler-core/src/type_/tests.rs index 271d40cf7d6..2cfe8913c3d 100644 --- a/compiler-core/src/type_/tests.rs +++ b/compiler-core/src/type_/tests.rs @@ -786,7 +786,6 @@ fn infer_module_type_retention_test() { definitions: vec![], type_info: (), names: Default::default(), - references: Default::default(), }; let direct_dependencies = HashMap::from_iter(vec![]); let ids = UniqueIdGenerator::new(); @@ -887,6 +886,7 @@ fn infer_module_type_retention_test() { type_aliases: HashMap::new(), documentation: Vec::new(), contains_echo: false, + references: References::default() } ); }