Skip to content

Preserve first-element semantics in max_element translations - #479

Merged
nunoplopes merged 7 commits into
masterfrom
copilot/fix-std-max-element-translation
Oct 8, 2026
Merged

nunoplopes merged 7 commits into
masterfrom
copilot/fix-std-max-element-translation

Conversation

Copilot AI commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

std::max_element returns the first iterator when multiple elements share the maximum, but the Rust translations selected the last. This affected vector rules f42/f94 and algorithm rule f8.

  • Tie-breaking: Updated refcount and unsafe translations to compare values first, then prefer the lower iterator index.
value_a.cmp(value_b).then_with(|| index_b.cmp(index_a))

Copilot AI linked an issue Oct 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix incorrect std::max_element translation for vectors Preserve first-element semantics in max_element translations Oct 7, 2026
Copilot AI requested a review from nunoplopes October 7, 2026 18:48
@nunoplopes
nunoplopes marked this pull request as ready for review October 8, 2026 07:16
@nunoplopes
nunoplopes merged commit 77eb95f into master Oct 8, 2026
9 checks passed
@nunoplopes
nunoplopes deleted the copilot/fix-std-max-element-translation branch October 8, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect std::max_element translation

2 participants