Skip to content

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

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

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

Conversation

@konradweiss

@konradweiss konradweiss commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

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
konradweiss and others added 24 commits April 21, 2026 23:18
@konradweiss konradweiss added the publish-to-github-packages If added to a PR, builds from it will be published as a GitHub package label Jun 10, 2026
konradweiss and others added 5 commits June 10, 2026 16:00
gradle.properties.example is used as a blueprint for building the
releases. Thus, we need to enable it here to create a cpg-language-rust
package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-to-github-packages If added to a PR, builds from it will be published as a GitHub package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants