Skip to content

Add Rust language frontend leveraging Rust Analyzer internals for parsing and inference#2560

Draft
konradweiss wants to merge 85 commits into
mainfrom
feature/language-rust
Draft

Add Rust language frontend leveraging Rust Analyzer internals for parsing and inference#2560
konradweiss wants to merge 85 commits into
mainfrom
feature/language-rust

Conversation

@konradweiss
Copy link
Copy Markdown
Collaborator

@konradweiss konradweiss commented Feb 11, 2026

This PR implements a Rust language frontend by leveraging the rust-analyzer internals for parsing and analysis. The AST is generated in Rust and sent over UniFFI bindings to the Kotlin handling code. In Kotlin, the rust-analyzer AST is translated into the CPG internal AST, types are assigned, and the pass system builds additional edges to represent semantic information about the code.

This work is still in progress and does not yet cover all language constructs and functionality. For example, types are parsed but type inference is currently not applied. Further improvements and missing features will be addressed in subsequent updates.

All pub struct from rust analyzer, for feature coverage tracking (updating this list is in progress):
Needed support for parser nodes:

  • AssocItemList
  • BinExpr
  • BlockExpr
  • BreakExpr
  • CallExpr
  • CastExpr
  • Const
  • ContinueExpr
  • ExprStmt
  • FieldExpr
  • Fn
  • ForExpr
  • IfExpr
  • Impl
  • IndexExpr
  • ItemList
  • LetExpr
  • LetStmt
  • Literal
  • LoopExpr
  • MacroCall
  • MacroExpr
  • MethodCallExpr
  • Module
  • Name
  • NameRef
  • Param
  • ParamList
  • ParenExpr
  • ParenType
  • Path
  • PathExpr
  • PathSegment
  • PathType
  • PrefixExpr
  • PtrType
  • RangeExpr
  • RecordField
  • RecordFieldList
  • RefExpr
  • RefType
  • RetType
  • ReturnExpr
  • SelfParam
  • SourceFile
  • StmtList
  • Struct
  • Trait
  • WhileExpr
  • ArgList
  • ClosureExpr
  • ArrayExpr
  • ArrayType
  • Enum
  • IdentPat
  • LetElse
  • MatchArm
  • MatchArmList
  • MatchExpr
  • MatchGuard
  • PathPat
  • RangePat
  • RecordExpr
  • RecordExprField
  • RecordExprFieldList
  • RecordPat
  • RecordPatField
  • RecordPatFieldList
  • RefPat
  • TryExpr
  • TupleExpr
  • TupleField
  • TupleFieldList
  • TuplePat
  • TupleStructPat
  • TupleType
  • UnderscoreExpr
  • WildcardPat
  • Use
  • UseTree
  • UseTreeList

Nodes for additional coverage:

  • FnPtrType
  • ImplTraitType
  • InferType
  • TryBlockModifier
  • TypeAlias
  • Union
  • Abi
  • AsmClobberAbi
  • AsmConst
  • AsmDirSpec
  • AsmExpr
  • AsmLabel
  • AsmOperandExpr
  • AsmOperandNamed
  • AsmOption
  • AsmOptions
  • AsmRegOperand
  • AsmRegSpec
  • AsmSym
  • AssocTypeArg
  • Attr
  • AwaitExpr
  • BecomeExpr
  • BoxPat
  • ConstArg
  • ConstBlockPat
  • ConstParam
  • DynTraitType
  • ExternBlock
  • ExternCrate
  • ExternItemList
  • ForBinder
  • ForType
  • FormatArgsArg
  • FormatArgsArgName
  • FormatArgsExpr
  • GenericArgList
  • GenericParamList
  • Label
  • Lifetime
  • LifetimeArg
  • LifetimeParam
  • LiteralPat
  • MacroDef
  • MacroItems
  • MacroPat
  • MacroRules
  • MacroStmts
  • MacroType
  • Meta
  • NeverType
  • OffsetOfExpr
  • OrPat
  • ParenPat
  • ParenthesizedArgList
  • Rename
  • RestPat
  • ReturnTypeSyntax
  • SlicePat
  • SliceType
  • Static
  • TokenTree
  • TypeAnchor
  • TypeArg
  • TypeBound
  • TypeBoundList
  • TypeParam
  • UseBoundGenericArgs
  • Variant
  • VariantList
  • Visibility
  • WhereClause
  • WherePred
  • YeetExpr
  • YieldExpr

…h structs that are prohibited if there are cycles in the structural definition
… sequence and unwrapping them when adding declarations
… import nodes, but whether the impacted calls invoke the right target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants