Rust: Codegen.

This commit is contained in:
Geoffrey White
2025-08-26 16:48:44 +01:00
parent c7947a0afa
commit 152ae1d29b
42 changed files with 575 additions and 1110 deletions

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs cf4f3f6b3fd0dee0d8b35f346695cfd3e080ca328ca1726ce851f6abfbabc631 cf4f3f6b3fd0dee0d8b35f346695cfd3e080ca328ca1726ce851f6abfbabc631
top.rs ef1e4ee1ec10669092c216f95bc34a1740e1fadfc4f3ad91ef14dccc5f2a7490 ef1e4ee1ec10669092c216f95bc34a1740e1fadfc4f3ad91ef14dccc5f2a7490

View File

@@ -331,17 +331,6 @@ pub struct Addressable {
_unused: ()
}
impl Addressable {
pub fn emit_extended_canonical_path(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("addressable_extended_canonical_paths", vec![id.into(), value.into()]);
}
pub fn emit_crate_origin(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("addressable_crate_origins", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for Addressable {
fn class_name() -> &'static str { "Addressable" }
}
@@ -1949,6 +1938,42 @@ impl From<trap::Label<Path>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct PathAstNode {
_unused: ()
}
impl trap::TrapClass for PathAstNode {
fn class_name() -> &'static str { "PathAstNode" }
}
impl From<trap::Label<PathAstNode>> for trap::Label<AstNode> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathAstNode>> for trap::Label<Locatable> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathAstNode>> for trap::Label<Element> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct PathSegment {
pub id: trap::TrapId<PathSegment>,
@@ -2076,53 +2101,6 @@ impl From<trap::Label<Rename>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct Resolvable {
_unused: ()
}
impl Resolvable {
pub fn emit_resolved_path(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("resolvable_resolved_paths", vec![id.into(), value.into()]);
}
pub fn emit_resolved_crate_origin(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
out.add_tuple("resolvable_resolved_crate_origins", vec![id.into(), value.into()]);
}
}
impl trap::TrapClass for Resolvable {
fn class_name() -> &'static str { "Resolvable" }
}
impl From<trap::Label<Resolvable>> for trap::Label<AstNode> {
fn from(value: trap::Label<Resolvable>) -> Self {
// SAFETY: this is safe because in the dbscheme Resolvable is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Resolvable>> for trap::Label<Locatable> {
fn from(value: trap::Label<Resolvable>) -> Self {
// SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Resolvable>> for trap::Label<Element> {
fn from(value: trap::Label<Resolvable>) -> Self {
// SAFETY: this is safe because in the dbscheme Resolvable is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct RetTypeRepr {
pub id: trap::TrapId<RetTypeRepr>,
@@ -6940,51 +6918,6 @@ impl From<trap::Label<ParenTypeRepr>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct PathAstNode {
_unused: ()
}
impl trap::TrapClass for PathAstNode {
fn class_name() -> &'static str { "PathAstNode" }
}
impl From<trap::Label<PathAstNode>> for trap::Label<Resolvable> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathAstNode>> for trap::Label<AstNode> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathAstNode>> for trap::Label<Locatable> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathAstNode>> for trap::Label<Element> {
fn from(value: trap::Label<PathAstNode>) -> Self {
// SAFETY: this is safe because in the dbscheme PathAstNode is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct PathExprBase {
_unused: ()
@@ -7030,6 +6963,74 @@ impl From<trap::Label<PathExprBase>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct PathPat {
pub id: trap::TrapId<PathPat>,
pub path: Option<trap::Label<Path>>,
}
impl trap::TrapEntry for PathPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("path_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for PathPat {
fn class_name() -> &'static str { "PathPat" }
}
impl From<trap::Label<PathPat>> for trap::Label<Pat> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<Element> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct PathTypeRepr {
pub id: trap::TrapId<PathTypeRepr>,
@@ -7885,6 +7886,78 @@ impl From<trap::Label<SliceTypeRepr>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct StructExpr {
pub id: trap::TrapId<StructExpr>,
pub path: Option<trap::Label<Path>>,
pub struct_expr_field_list: Option<trap::Label<StructExprFieldList>>,
}
impl trap::TrapEntry for StructExpr {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("struct_exprs", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_expr_field_list {
out.add_tuple("struct_expr_struct_expr_field_lists", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for StructExpr {
fn class_name() -> &'static str { "StructExpr" }
}
impl From<trap::Label<StructExpr>> for trap::Label<Expr> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Expr
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<AstNode> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<Locatable> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<Element> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct StructFieldList {
pub id: trap::TrapId<StructFieldList>,
@@ -7944,6 +8017,78 @@ impl From<trap::Label<StructFieldList>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct StructPat {
pub id: trap::TrapId<StructPat>,
pub path: Option<trap::Label<Path>>,
pub struct_pat_field_list: Option<trap::Label<StructPatFieldList>>,
}
impl trap::TrapEntry for StructPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("struct_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_pat_field_list {
out.add_tuple("struct_pat_struct_pat_field_lists", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for StructPat {
fn class_name() -> &'static str { "StructPat" }
}
impl From<trap::Label<StructPat>> for trap::Label<Pat> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<Element> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct TryExpr {
pub id: trap::TrapId<TryExpr>,
@@ -8188,6 +8333,78 @@ impl From<trap::Label<TuplePat>> for trap::Label<Element> {
}
}
#[derive(Debug)]
pub struct TupleStructPat {
pub id: trap::TrapId<TupleStructPat>,
pub path: Option<trap::Label<Path>>,
pub fields: Vec<trap::Label<Pat>>,
}
impl trap::TrapEntry for TupleStructPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("tuple_struct_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
for (i, v) in self.fields.into_iter().enumerate() {
out.add_tuple("tuple_struct_pat_fields", vec![id.into(), i.into(), v.into()]);
}
}
}
impl trap::TrapClass for TupleStructPat {
fn class_name() -> &'static str { "TupleStructPat" }
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Pat> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Element> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct TupleTypeRepr {
pub id: trap::TrapId<TupleTypeRepr>,
@@ -9775,15 +9992,6 @@ impl From<trap::Label<MethodCallExpr>> for trap::Label<Element> {
}
}
impl From<trap::Label<MethodCallExpr>> for trap::Label<Resolvable> {
fn from(value: trap::Label<MethodCallExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct Module {
pub id: trap::TrapId<Module>,
@@ -9954,254 +10162,6 @@ impl From<trap::Label<PathExpr>> for trap::Label<PathAstNode> {
}
}
impl From<trap::Label<PathExpr>> for trap::Label<Resolvable> {
fn from(value: trap::Label<PathExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme PathExpr is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct PathPat {
pub id: trap::TrapId<PathPat>,
pub path: Option<trap::Label<Path>>,
}
impl trap::TrapEntry for PathPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("path_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for PathPat {
fn class_name() -> &'static str { "PathPat" }
}
impl From<trap::Label<PathPat>> for trap::Label<Pat> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<Element> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<PathPat>> for trap::Label<Resolvable> {
fn from(value: trap::Label<PathPat>) -> Self {
// SAFETY: this is safe because in the dbscheme PathPat is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct StructExpr {
pub id: trap::TrapId<StructExpr>,
pub path: Option<trap::Label<Path>>,
pub struct_expr_field_list: Option<trap::Label<StructExprFieldList>>,
}
impl trap::TrapEntry for StructExpr {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("struct_exprs", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_expr_field_list {
out.add_tuple("struct_expr_struct_expr_field_lists", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for StructExpr {
fn class_name() -> &'static str { "StructExpr" }
}
impl From<trap::Label<StructExpr>> for trap::Label<Expr> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Expr
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<AstNode> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<Locatable> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<Element> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructExpr>> for trap::Label<Resolvable> {
fn from(value: trap::Label<StructExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme StructExpr is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct StructPat {
pub id: trap::TrapId<StructPat>,
pub path: Option<trap::Label<Path>>,
pub struct_pat_field_list: Option<trap::Label<StructPatFieldList>>,
}
impl trap::TrapEntry for StructPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("struct_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
if let Some(v) = self.struct_pat_field_list {
out.add_tuple("struct_pat_struct_pat_field_lists", vec![id.into(), v.into()]);
}
}
}
impl trap::TrapClass for StructPat {
fn class_name() -> &'static str { "StructPat" }
}
impl From<trap::Label<StructPat>> for trap::Label<Pat> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<Element> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<StructPat>> for trap::Label<Resolvable> {
fn from(value: trap::Label<StructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme StructPat is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct Trait {
pub id: trap::TrapId<Trait>,
@@ -10408,87 +10368,6 @@ impl From<trap::Label<TraitAlias>> for trap::Label<Addressable> {
}
}
#[derive(Debug)]
pub struct TupleStructPat {
pub id: trap::TrapId<TupleStructPat>,
pub path: Option<trap::Label<Path>>,
pub fields: Vec<trap::Label<Pat>>,
}
impl trap::TrapEntry for TupleStructPat {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("tuple_struct_pats", vec![id.into()]);
if let Some(v) = self.path {
out.add_tuple("path_ast_node_paths", vec![id.into(), v.into()]);
}
for (i, v) in self.fields.into_iter().enumerate() {
out.add_tuple("tuple_struct_pat_fields", vec![id.into(), i.into(), v.into()]);
}
}
}
impl trap::TrapClass for TupleStructPat {
fn class_name() -> &'static str { "TupleStructPat" }
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Pat> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Pat
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<AstNode> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Locatable> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Element> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<PathAstNode> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of PathAstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<TupleStructPat>> for trap::Label<Resolvable> {
fn from(value: trap::Label<TupleStructPat>) -> Self {
// SAFETY: this is safe because in the dbscheme TupleStructPat is a subclass of Resolvable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct Use {
pub id: trap::TrapId<Use>,