Skip to content

Code Analysis Rust Inherent Functions

Tu Shaokun edited this page Nov 7, 2026 · 5 revisions

Rust explicit inherent-function source candidates

Draft #1265, head 20ce8f32ad9002c408abeb11a6fedec539aba004, extends Go Draft #1264 in native stack #1262. Original Rust/Go, #1252 and team commits/authorship/PR ownership are preserved. Not in Labs, approved, merged, released or installed. Labs remains bf0a29e7664f52973d06a8e6a608df2db1ecbd39.

Developer investigation

Before, serde_json src/value/from.rs:60 Number::from_f64(f) stopped at an unknown target. Now it follows use crate::number::Number to src/number.rs:183:5. The real upstream version pair removes #[inline] and edits documentation, while the function body stays unchanged. Its owned-definition change now exposes three verified source callers per side, compared with zero in the parent. The overall investigation stays partial/exit 1; this is not complete impact or runtime reachability.

Regex's string and bytes modules have distinct Regex::new functions: src/regex/string.rs:125 → 180:5 and src/regex/bytes.rs:123 → 178:5. Nominal module identity keeps the same spelling from conflating them. rustc controls also established a wrong-target counterexample: a tuple enum variant may share an inherent function's name and wins at the call; such calls remain unknown rather than jumping to that function.

Frozen evidence and remaining gaps

Scope Parent Candidate
Four design observations, three physical sites; serde repeated under two profiles 0 correct / 0 wrong / 4 missed 4 correct / 0 wrong / 0 missed
Reserved generic Map::new: two physical sites, two profiles 4 known-source misses 4 known-source misses
Trait deserialize and external cfg-dependent alias controls 4 reasonable unknowns 4 reasonable unknowns
Supplemental changed from_f64, three callers per side 0 base / 0 head 3 base / 3 head, all navigation valid

Pins: regex 9870c06e6c772daaad7ab612faab29130753e41c; serde_json d2fce19685bf0e3d493a9d785665137654c79e6d → 4d4f53c3b7de3259b6a8a15ef4d5f4edb47af32f. Both projects were exposed in earlier free-function studies. Source answers precede rule design; the map file was reserved before implementation and inspected after the first rule, before extraction. These are not blind repositories. The supplemental pair's initial source list omitted old value/de.rs:54; its direct-source correction is retained explicitly. Paired observations overlap the design corpus and must not be added as independent accuracy evidence.

Additional output contains 1,205 regex / 22 default-serde / 23 arbitrary-serde inherent source candidates without independent whole-project grading. All old correct targets and function inventories remain. Six calls inside an arbitrary_precision nested method are now excluded under default features, with the exact excluded region disclosed. Pinned answers, commands, source/ZIP scores, correction and preservation records.

Language contract

rust-source-direct-v2, adapter revision 2, adds rust-inherent-source-candidate through the existing module/use/local-Cargo path resolver. Unique receiver-free inherent functions on monomorphic nominal owners are source candidates. Trait impl functions are not entered in the registry. Generic scopes, conditional alternatives and enum variant precedence prevent unsupported binding; calls from inside trait implementations may still name an explicit inherent function. Old v1 captures keep their original free-function scope and are readable by both distributions.

Generic/specialized owners, type aliases, Self, receiver/trait dispatch, visibility and argument applicability remain unproved. Separate type/value namespace ambiguity may conservatively miss a valid call. Reserved Map<String, Value> calls are known misses. Macros, build-script cfg, generated/external dependency source and full Cargo build/resolve semantics remain opaque or unsupported. Nested call records describe source containment, not separately attributed execution.

Profiles still disclose local crate targets, tests=false, target/custom cfg, local feature propagation, parsed/excluded files, conditional definitions, opaque macros and missing modules. Cargo metadata is offline/no-deps/locked over captured manifests and zero-byte source stubs. No upstream source, build script, proc macro or test executes. Default and arbitrary_precision serde profiles select the same from_f64 definition with different inline branches.

Reproduction and delivery

python3 benchmarks/code-analysis-rust-inherent-functions/run.py \
  --cli archify/bin/archify.mjs --samples-root /fixed/samples --out /runs/source

Use #1264's CLI and --expect baseline for the parent; use the extracted ZIP entrypoint for package replay. Three checks and three questions exit 0; the paired task remains partial/exit 1. Checks deliberately use --fail-on never, not a claim that findings are absent. The large regex question preserves 207 calls, 40 included and 167 omitted.

Three raw captures are byte-identical and four questions agree after only install/output path normalization. Historical v1 reader parity also passes. Canonical Node 22.23.3 / zlib 1.3.1-e00f703 builds match all 168 tracked module files. ZIP SHA256 247ddbe320f03c28e9b3f5af4698ae8535c21224615eb45e817c7088ad0b9a3b.

Existing rustc/cargo 1.89.0; declared floor remains 1.71+. No new toolchain or dependency installed. Missing rustc/cargo both exit 2 with extract/rust-unavailable and installation/override guidance. rust-analyzer is absent; authored rustc controls are not a real-project compiler/RA target audit. The legacy shared helper executable caused cross-version output during replay; contents-keyed caches isolate versions and allow identical source/ZIP reuse. Observed current cache: 103,840 KiB including dependencies. Fresh setup/download costs were not controlled; per-command cache-dependent times are recorded without speedup claims.

Separate validation states

  • Local: full six-language module suite 380/380 and Rust 14/14, zero skips; core smoke 19/19 and release identity pass. Runtime commit 1a1f6677e; later commits only freeze replay/evidence and archive.
  • Package: extracted Rust/question/change selection 42/42, zero skips; source/ZIP questions, paired references, exit statuses and v1 reader parity pass.
  • Remote: final-head CI 42410170694 completed success at20ce8f32ad9002c408abeb11a6fedec539aba004. Both full-regression and browser shards, WebM, ZIP freshness, maintained Node lanes, three-platform package jobs and both Windows lanes passed. Deployment jobs skipped. Analysis-suite execution counts are reported separately from overall CI.
  • Integration: Draft, not Labs/approved/merged/released/installed. Original PRs remain separately owned.

Next: independently grade additional source candidates, investigate generic/type-alias owner paths, and retain Go's 37 known compiler-confirmed method misses alongside the JS/TS/Python/Java source-backed backlog.

Optional independent audit started after publication

After this Draft evidence was frozen, the optional official rust-analyzer1.89.0 component was installed into the existing stable toolchain (executable35,248,592 bytes; rust-src was already present). Audit-only copies use separately generated Cargo.lock files because the fixed originals contain none; default offline setup initially failed for an uncached automod dependency, so explicit lock generation/fetch was needed. Further LSP definition comparisons are in progress, with check-on-save, build scripts and proc macros disabled. These setup facts are separate from the Draft's earlier no-new-toolchain validation and do not yet establish an accuracy result.

Clone this wiki locally