Skip to main content

Crate icb_rustc

Crate icb_rustc 

Source
Expand description

§ICB Rustc Backend

This crate provides a precise analysis of Rust source code by leveraging the rustc compiler’s internal APIs. Unlike tree‑sitter, which only performs syntactic parsing, this backend resolves all semantic information (traits, generics, macro expansions, etc.) and produces a list of facts suitable for constructing a Code Property Graph.

§Architecture

The entry point is parse_rust_crate. When the nightly feature is enabled it calls into [driver::run_analysis] which starts a rustc session, obtains the HIR, and invokes the HIR visitor implemented in [visitor]. The visitor records functions, methods, trait/struct/enum declarations, impl blocks, and call expressions as [RawNode] facts.

§Feature flags

  • nightly – enables the rustc_interface linkage. Without this flag the crate compiles as a stub that always returns an empty result. Alternatively set RUSTC_BOOTSTRAP=1 to use the internal APIs on a nightly toolchain without the feature flag.

§Limitations

  • The backend requires a nightly compiler or RUSTC_BOOTSTRAP=1.
  • Procedural macros are not expanded by the visitor; only the expanded code is visible.
  • The analysis is per‑crate; multi‑crate projects need to be handled at the workspace level (see [icb_graph::builder]).

Functions§

parse_rust_crate