Skip to content

Conversation

@alexcrocha
Copy link
Contributor

@alexcrocha alexcrocha commented Jan 15, 2026

Description

This PR introduces ruby-rbs-sys, a Rust crate providing FFI bindings to the RBS C parser. A follow-up PR (#2808) adds ruby-rbs, a safe wrapper on top of these bindings.

Motivation

Enables Rust-based tooling to parse RBS type signatures, supporting use cases like IDE tooling, language servers, and static analysis tools.

Why Two Crates?

Following the Rust -sys package convention, we split the bindings into two crates:

  • ruby-rbs-sys: Low-level FFI bindings generated by bindgen. Exposes the raw C API with no safety guarantees.
  • ruby-rbs: Safe, idiomatic Rust wrapper with proper lifetimes and ergonomic APIs.

Consumers should use ruby-rbs for a safe API. This pattern is also used by ruby-prism.

ruby-rbs-sys Overview

  • build.rs compiles the C parser source using the cc crate
  • Bindings generated at build time via bindgen
  • Uses an allowlist to expose specific types and functions

CI

Adds CI configuration to build and test the Rust crates.

This establishes the foundation for using RBS functionality from Rust.

- Generated FFI bindings via bindgen from RBS C headers
- Set up build configuration to link with the RBS library
- Added initial tests for basic functionality (constant pool, parser)
- Configured workspace structure in rust/Cargo.toml

The -sys crate follows Rust conventions for FFI bindings, keeping raw
unsafe bindings separate from future safe API wrappers.

Future commits will add a separate safe wrapper crate on top of these
bindings.
@alexcrocha alexcrocha marked this pull request as ready for review January 15, 2026 01:39
Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@soutaro soutaro merged commit 4f279da into ruby:master Jan 15, 2026
24 checks passed
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.

2 participants