Maintaining consistency between source code and its associated comments is essential for software reliability, maintainability, and user experience, particularly in the Rust programming ecosystem where comment serves as both developer guidance and an authoritative API contract. However, existing automated inconsistency detection approaches are largely tailored for object-oriented languages and fall short of addressing Rust’s unique features, such as explicit panic semantics, trait-based abstraction, and idiomatic use of option and finiteness constraints. In this paper, we introduce RustC 4 ++ , a novel hybrid framework that integrates large language model (LLM)-driven constraint extraction, static program analysis, and SMT-based bidirectional verification to detect and diagnose code-comment inconsistencies in Rust. RustC 4 ++ extends previous solutions by supporting a richer taxonomy of constraints, including interval, boundary, existence, option, and finiteness constraints, and pioneers a systematic method for propagating comment constraint across trait and implementation boundaries. Leveraging chain-of-thought prompt engineering, RustC 4 ++ robustly interprets natural language comment, maps it to formal specifications, and checks their alignment with code logic through precise static analysis and formal reasoning. We conduct extensive experiments on 17 diverse, real-world Rust projects, demonstrating that RustC 4 ++ substantially outperforms prior tools in both precision and recall, and is capable of uncovering subtle, actionable inconsistencies that have led to confirmed fixes in upstream repositories. By elevating comments to enforceable, verifiable contracts, RustC 4 ++ not only enhances code quality and comment reliability in the Rust ecosystem, but also offers generalizable techniques and insights for automated code comment analysis in other modern programming languages.
Zhang et al. (Fri,) studied this question.