Paper commentary
CRUSTPairs: A Cross-Language Dataset of Paired C and Rust Solutions
Paired C and Rust solutions for cross-language matching
- Problem No dataset paired C and Rust at the level of whole solutions to a shared problem. Without paired data, cross-language retrieval models for C-to-Rust migration could not be trained or measured properly.
- Method CRUSTPairs pairs accepted C and Rust submissions from competitive programming archives. The authors finetune UniXcoder with a symmetric contrastive objective that ranks each C solution against its Rust counterpart within a batch.
- Results Finetuned UniXcoder reaches MRR 0.79 on the test split. Lexical TF-IDF over shared identifiers reaches MRR 0.21 and zero-shot UniXcoder reaches 0.19.
Why C-to-Rust matching lacks paired data
That check misses a translation that passes every test yet still renders its source unfaithfully. The check is weakest for legacy C, because legacy C is what most often lacks tests. The complementary question asks whether two programs in two languages are the same program.
CodeNet and POJ-104 group solutions by problem, but they don't ship an aligned bilingual corpus. Table I lists CodeNet with 55 languages and xCodeEval with 17 languages, and neither pairs C with Rust. Table I shows that CRUSTPairs is the only corpus pairing C with Rust at solution granularity. None of the corpora the authors surveyed includes Rust, which leaves the language pair without paired data.
The pretrained encoders that cross-language retrieval builds on, CodeBERT and UniXcoder, saw little or no Rust during pretraining. Because they saw so little Rust, they have little Rust to draw on when matching C against it. Cross-language clone detection faces the same gap, since CLCDSA matches type-4 clones across Java, C# and Python. CLCDSA stops short of Rust, so it doesn't answer the C-to-Rust question either.
A lexical TF-IDF baseline over shared identifiers beats a pretrained code model zero-shot. The authors attribute this to competitive programmers reusing variable names across languages. Without a paired corpus, the authors can't measure how much of that match comes from identifiers rather than structure.
Building 1857 pairs and their tiers
The authors draw their pairs from two competitive programming archives, xCodeEval and IBM Project CodeNet. Each pair is one problem with one accepted C submission and one accepted Rust submission.
The authors started from an initial 2013 pairs and removed 127 of them. The removals were 2 confirmed mis-pairs, 69 AtCoder easy and hard variants with near-identical statements, and 54 further suspicious pairs. The 69 variants were flagged by description embedding similarity above 0.90, and the 54 suspicious pairs fell between 0.80 and 0.90.
The authors dropped a further 29 textbook reference implementations, because they carried the only copyleft content and had no problem statement. That leaves 1857 pairs, and each record keeps its own licence, so filtering on origin is the only way to get a commercially usable subset.
Each pair gets a difficulty score, which is the cosine similarity between the zero-shot SFR-Embedding-Code-400M_R embeddings of its C and Rust sides. The authors used SFR rather than UniXcoder so the tiers couldn't be defined by the family that gets finetuned.
The frozen split is stratified by source and difficulty at 80/10/10, giving 1485 train, 185 validation and 187 test pairs. CodeNet pairs skew easy, with 241 easy, 408 medium and 190 hard pairs. xCodeEval pairs skew hard, with 224 easy, 520 medium and 274 hard pairs. Per-tier reporting therefore needs a split that controls for both source and difficulty.
Finetuning UniXcoder with paired contrastive training
UniXcoder gets trained so that each C solution sits closer to its Rust counterpart than to the other solutions in the batch. For a batch of N pairs, the model builds an N×N cosine similarity matrix and ranks each pair against the other N−1. The ranking runs in both the C-to-Rust and Rust-to-C directions, so the objective is symmetric. The negatives come from the same batch, so batch size controls how many negatives each step sees.
The authors hold batch size at 32 for every run and every machine, so the numbers stay comparable.
Each side is mean-pooled over non-padding tokens and L2-normalised, and inputs are truncated at 512 tokens. That adapter has 295K trainable parameters, which is 0.23% of the 126M in the base model. Full finetuning also uses weight decay 0.01 and gradient checkpointing.
Each run keeps the checkpoint with the best validation MRR, and that checkpoint is the one evaluated on test. The LoRA runs use seeds 42 through 45, and their reported figures are means over four seeds.
Retrieval against lexical and zero-shot baselines
Each C implementation queries a pool of 187 Rust implementations from the test split. The score is mean reciprocal rank, so each query contributes the reciprocal of its counterpart's rank. MRR@10 instead gives zero credit beyond rank ten, and the two diverge in the zero-shot regime. Chance sits at MRR 0.031 for this pool size, and it serves as the denominator for every ratio the authors report.
Lexical TF-IDF over shared identifiers reaches MRR 0.206 without using any model. The lexical baseline therefore beats the pretrained code model, because competitive programmers reuse variable names across languages. The variable n is shared by 85 of the 187 test pairs. The variable i is shared by 84 pairs. The authors argue that generic embeddings and lexical matching both fail to solve the task.
LoRA finetuning reaches MRR 0.724 on the same test split. LoRA reaches 3.8 times the zero-shot score.
The LoRA runs use four seeds, with a standard deviation of 0.011 on MRR. The other rows are single runs, so the authors report no seed spread for them.
Difficulty tiers and identifier renaming
Retrieval MRR drops from the easy tier to the hard tier for every configuration in the table. Zero-shot UniXcoder scores 0.328 on easy pairs, 0.186 on medium pairs and 0.053 on hard pairs. The hard-tier score of 0.053 is 1.7 times the chance MRR of 0.031. Only one of the 47 hard pairs reaches rank 1 for zero-shot UniXcoder. SFR defined the tiers, but the scored models are UniXcoder-based, so the ordering belongs to the pairs.
Renaming user identifiers to positional names keeps the control structure, the types, the library calls and the string constants unchanged. The finetuned models keep 96–97% of their MRR after renaming. Zero-shot UniXcoder keeps 66%, which is less than the 76% that lexical TF-IDF keeps. The authors read this as finetuning learning structure rather than names.
They describe zero-shot UniXcoder as leaning on names more than TF-IDF does, a weaker version of the same matching.
On hard pairs, both finetuned models score higher once identifiers are renamed. The authors argue that a shared name on a structurally divergent pair is more often coincidence than signal.
Limitations of what the results verify
Equivalence is inherited from upstream acceptance, not verified, because the dataset ships no tests or expected I/O. Both submissions were accepted upstream, which is evidence of functional equivalence but not a check of it. The entry-point renaming means the code doesn't compile standalone, so the authors can't run the pairs as they stand.
Upstream identifiers are absent, so pairs can't be traced back to the originating submission.
The LoRA rows are means over four seeds, with σ = 0.011 on MRR. The other reported rows are single runs, so their variance is unmeasured. An earlier release's tier labels matched regenerated labels for only 89% of individual pairs. The disagreement was 204 of 1857 labels, spread in both directions across adjacent tiers. Bidirectional movement means the per-pair scores differed between runs, since threshold movement alone can only reassign in one direction.
The pairs are short, single-file, I/O-driven competitive programming solutions, so the results may not transfer to systems code. Pre-training contamination is possible because both archives are public.
Paper info
- Authors
- Hejlek, Vojtech, Almeida, Leonardo Jesus, Lopes, Alneu de Andrade
- Venue
- arXiv · Preprint
- First published
- 2026-11-9
- Added
- 2026-11-10
- Updated
- 2026-11-9
- Version
- v1
- arXiv
- 2611.11711
- Category
- cs.SE · cs.LG
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
C-to-Rust migration is an active agenda, but no dataset pairs the two languages at the level of whole solutions to a shared problem. We present CRUSTPairs, 1857 C/Rust implementation pairs drawn from competitive programming archives, normalised, deduplicated, and stratified into difficulty tiers by zero-shot cross-language embedding similarity, with perrecord provenance and licensing. Cross-language retrieval is hard on this data, and harder than a single baseline would suggest: TF-IDF over shared identifiers reaches MRR 0.21 and so beats a pretrained code model at 0.19, which on the hardest quarter of the data scores 1.7x chance. Finetuning reaches 0.79, and lifts that hardest quarter 10x. Renaming every user identifier settles what is being learned: the finetuned models keep 96-97% of their accuracy without them, while the pretrained model keeps 66\% - less than the lexical baseline does - and on structurally divergent pairs the finetuned models are better without identifiers than with them.
Quote from the paper
Hejlek, Vojtech, Almeida, Leonardo Jesus, Lopes, Alneu de Andrade (2026). CRUSTPairs: A Cross-Language Dataset of Paired C and Rust Solutions. arXiv:2611.11711v1. https://arxiv.org/abs/2611.11711v1
BibTeX
@misc{vojtech2026crustpairs,
title = {{CRUSTPairs: A Cross-Language Dataset of Paired C and Rust Solutions}},
author = {Hejlek, Vojtech and Almeida, Leonardo Jesus and Lopes, Alneu de Andrade},
year = {2026},
eprint = {2611.11711},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.11711v1}
}