Skip to main content

drep/languages/definitions/
rust.rs

1//! The Rust ecosystem: clippy over `.rs`.
2
3use crate::languages::spec::{DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec};
4
5/// Rust linter - emits structured JSON via cargo's message-format.
6pub static CLIPPY: ToolSpec = ToolSpec {
7    name: "clippy",
8    command: &["cargo", "clippy", "--message-format", "json", "--quiet"],
9    local_paths: &[],
10    config_files: &["Cargo.toml"],
11    config_flag: None,
12    output_format: OutputFormat::Cargo,
13    diagnostics_stream: DiagnosticsStream::Stdout,
14    // Cargo's build lock is acquired by Cargo itself, so its wait is part of
15    // the child process. Allow the same long-running ceiling as an LLM review
16    // rather than failing a whole gate at the generic two-minute tool limit.
17    timeout_secs: 1_800,
18    timeout_context: Some(", including its Cargo build-lock wait"),
19    establishes_compilation: true,
20    serial_in_repository: true,
21    // `cargo clippy` checks a crate, not files: a path argument is rejected
22    // with "unexpected argument". See `ToolSpec::accepts_files`.
23    accepts_files: false,
24};
25
26/// Rust language entry.
27pub static RUST_LANG: LanguageSupport = LanguageSupport {
28    name: "rust",
29    display_name: "Rust",
30    extensions: &[".rs"],
31    filenames: &[],
32    filename_prefixes: &[],
33    tools: &[&CLIPPY],
34    conventions: &[
35        "unwrap/expect on values that can legitimately be None or Err",
36        "unsafe blocks, and whether their invariants are documented",
37        "Unnecessary clones and allocations in hot paths",
38        "Send/Sync correctness for types crossing threads",
39    ],
40    vendored_dirs: &["target"],
41};
42
43/// The family's entries in registration order. See `ALL_LANGUAGES`.
44pub(crate) static FAMILY: &[&LanguageSupport] = &[&RUST_LANG];