Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
bebcb9d
Add test for Ord impl for Option::NonZero
clubby789 May 12, 2025
5eb47ee
Add failing tests for some Option optimizations
clubby789 May 12, 2025
5326fc9
rustdoc: on mobile, make the sidebar full width and linewrap
lolbinarycat Apr 15, 2025
d29d1a3
Docs(lib/alloc/vec): Add the missing `an` to `extract_if`'s first sen…
PaulDance May 17, 2025
cd5772e
Docs(lib/coll/hm): Reword `extract_if` to use `element` instead of `v…
PaulDance May 17, 2025
35f8473
Docs(lib/coll/btm): Split `extract_if`'s first sentence from the foll…
PaulDance May 17, 2025
9205ee2
Docs(lib/extract_if): Unify paragraph about closure actions
PaulDance May 17, 2025
014434e
Docs(lib/extract_if): Unify paragraph about elements mutation
PaulDance May 17, 2025
a9330dd
Docs(lib/coll/hm): Add kv pair to `extract_if`'s first sentence
PaulDance May 17, 2025
b1d7480
Docs(lib/extract_if): Unify example description
PaulDance May 17, 2025
1eba1b5
rustdoc: rip out all the gui tests for <100% width mobile sidebar
lolbinarycat May 22, 2025
89a8abc
use `cfg_select!` to select the right `VaListImpl` definition
folkertdev May 21, 2025
bcca611
rustdoc-gui test: apply suggestions from code review
lolbinarycat May 23, 2025
045ac21
Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=Guil…
jhpratt May 25, 2025
3f91bbc
Rollup merge of #140950 - clubby789:nonzero-ord-test, r=Mark-Simulacrum
jhpratt May 25, 2025
3338ff7
Rollup merge of #141108 - PaulDance:fix-extract_if-docs, r=Mark-Simul…
jhpratt May 25, 2025
c27b7c2
Rollup merge of #141361 - folkertdev:varargs-cfg, r=workingjubilee
jhpratt May 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add failing tests for some Option optimizations
  • Loading branch information
clubby789 committed May 12, 2025
commit 5eb47eeb851d4428642197cea3a566bcfa5f726a
13 changes: 2 additions & 11 deletions tests/codegen/option-niche-eq.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ min-llvm-version: 20
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
#![crate_type = "lib"]

Expand All @@ -24,7 +25,7 @@ pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> b
l == r
}

// Test for #49892
// FIXME(#49892)
// This currently relies on a manual implementation of `PartialOrd`/`Ord` for `Option`
// Once LLVM is better able to optimize this pattern, we can return to using a derive.
// CHECK-LABEL: @non_zero_ord
Expand Down Expand Up @@ -73,13 +74,3 @@ pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool {
// CHECK-NEXT: ret i1
l == r
}

// FIXME: This should work too
// // FIXME-CHECK-LABEL: @bool_eq
// #[no_mangle]
// pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool {
// // FIXME-CHECK: start:
// // FIXME-CHECK-NEXT: icmp eq i8
// // FIXME-CHECK-NEXT: ret i1
// l == r
// }
15 changes: 15 additions & 0 deletions tests/codegen/option-niche-unfixed/option-bool-eq.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ should-fail
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
//! FIXME(#49892)
//! Tests that LLVM does not fully optimize comparisons of `Option<bool>`.
//! If this starts passing, it can be moved to `tests/codegen/option-niche-eq.rs`
#![crate_type = "lib"]

// CHECK-LABEL: @bool_eq
#[no_mangle]
pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool {
// CHECK: start:
// CHECK-NEXT: icmp eq i8
// CHECK-NEXT: ret i1
l == r
}
24 changes: 24 additions & 0 deletions tests/codegen/option-niche-unfixed/option-nonzero-eq.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ should-fail
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
//! FIXME(#49892)
//! Test that the derived implementation of `PartialEq` for `Option` is not fully
//! optimized by LLVM. If this starts passing, the test and manual impl should
//! be removed.
#![crate_type = "lib"]

use std::num::NonZero;

#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Option<T> {
None,
Some(T),
}

// CHECK-LABEL: @non_zero_eq
#[no_mangle]
pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool {
// CHECK: start:
// CHECK-NEXT: icmp eq i32
// CHECK-NEXT: ret i1
l == r
}
Loading