about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-25 07:37:05 +0000
committerbors <bors@rust-lang.org>2025-05-25 07:37:05 +0000
commitaa57e46e24a4a08cc336325e92567b40b0c2ba62 (patch)
treead91cc843609eb47f88ab937a3620dc025572a93 /tests
parent3d86494a0d0131c32eb15e3a4b685707b9ff000d (diff)
parentc27b7c22148e1666633d6a19826c37fcece07569 (diff)
downloadrust-aa57e46e24a4a08cc336325e92567b40b0c2ba62.tar.gz
rust-aa57e46e24a4a08cc336325e92567b40b0c2ba62.zip
Auto merge of #141529 - jhpratt:rollup-8dle839, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#139831 (rustdoc: on mobile, make the sidebar full width and linewrap)
 - rust-lang/rust#140950 (More option optimization tests)
 - rust-lang/rust#141108 (Docs(lib): Fix `extract_if` docs)
 - rust-lang/rust#141361 (use `cfg_select!` to select the right `VaListImpl` definition)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/codegen/option-niche-eq.rs23
-rw-r--r--tests/codegen/option-niche-unfixed/option-bool-eq.rs15
-rw-r--r--tests/codegen/option-niche-unfixed/option-nonzero-eq.rs24
-rw-r--r--tests/rustdoc-gui/notable-trait.goml4
-rw-r--r--tests/rustdoc-gui/pocket-menu.goml13
-rw-r--r--tests/rustdoc-gui/sidebar-mobile.goml10
6 files changed, 60 insertions, 29 deletions
diff --git a/tests/codegen/option-niche-eq.rs b/tests/codegen/option-niche-eq.rs
index 9c5ed9ce57a..a39e2870a0f 100644
--- a/tests/codegen/option-niche-eq.rs
+++ b/tests/codegen/option-niche-eq.rs
@@ -1,3 +1,4 @@
+//@ min-llvm-version: 20
 //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
 #![crate_type = "lib"]
 
@@ -24,6 +25,18 @@ pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> b
     l == r
 }
 
+// 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
+#[no_mangle]
+pub fn non_zero_ord(a: Option<NonZero<u32>>, b: Option<NonZero<u32>>) -> bool {
+    // CHECK: start:
+    // CHECK-NEXT: icmp ult i32
+    // CHECK-NEXT: ret i1
+    a < b
+}
+
 // CHECK-LABEL: @non_null_eq
 #[no_mangle]
 pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool {
@@ -61,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
-// }
diff --git a/tests/codegen/option-niche-unfixed/option-bool-eq.rs b/tests/codegen/option-niche-unfixed/option-bool-eq.rs
new file mode 100644
index 00000000000..fa0e7836afb
--- /dev/null
+++ b/tests/codegen/option-niche-unfixed/option-bool-eq.rs
@@ -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
+}
diff --git a/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs b/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs
new file mode 100644
index 00000000000..308856cfb7e
--- /dev/null
+++ b/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs
@@ -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
+}
diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml
index 4624fb80b37..7fc70e0675d 100644
--- a/tests/rustdoc-gui/notable-trait.goml
+++ b/tests/rustdoc-gui/notable-trait.goml
@@ -244,10 +244,6 @@ click: ".sidebar-menu-toggle"
 assert: "//*[@class='sidebar shown']"
 assert-count: ("//*[@class='tooltip popover']", 0)
 assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
-// Clicking a notable trait tooltip popover should close the sidebar.
-click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
-assert-count: ("//*[@class='tooltip popover']", 1)
-assert-false: "//*[@class='sidebar shown']"
 
 // Also check the focus handling for the settings button.
 set-window-size: (1100, 600)
diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml
index 4a062fec751..073172dd8a7 100644
--- a/tests/rustdoc-gui/pocket-menu.goml
+++ b/tests/rustdoc-gui/pocket-menu.goml
@@ -68,16 +68,3 @@ assert-css: ("#settings-menu .popover", {"display": "block"})
 click: ".sidebar-menu-toggle"
 assert: "//*[@class='sidebar shown']"
 assert-css: ("#settings-menu .popover", {"display": "none"})
-// Opening the settings popover should close the sidebar.
-click: "#settings-menu a"
-assert-css: ("#settings-menu .popover", {"display": "block"})
-assert-false: "//*[@class='sidebar shown']"
-
-// Opening the settings popover at start (which async loads stuff) should also close.
-reload:
-click: ".sidebar-menu-toggle"
-assert: "//*[@class='sidebar shown']"
-assert-false: "#settings-menu .popover"
-click: "#settings-menu a"
-assert-false: "//*[@class='sidebar shown']"
-wait-for: "#settings-menu .popover"
diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml
index 4ada4837a57..6ddc07c6481 100644
--- a/tests/rustdoc-gui/sidebar-mobile.goml
+++ b/tests/rustdoc-gui/sidebar-mobile.goml
@@ -32,8 +32,8 @@ assert-css: (
     {"display": "block"}
 )
 
-// Click elsewhere.
-click: "body"
+// Click the toggle to close it
+click: ".sidebar-menu-toggle"
 assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
 
 // Open the sidebar menu, and make sure pressing Escape closes it.
@@ -57,6 +57,8 @@ scroll-to: ".block.keyword li:nth-child(1)"
 compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 544})
 
 // Now checking the background color of the sidebar.
+// Close the sidebar menu.
+press-key: "Escape"
 show-text: true
 
 define-function: (
@@ -72,6 +74,10 @@ define-function: (
             "background-color": |background|,
             "color": |color|,
         })
+        // Make sure the sidebar is full width
+        compare-elements-size: (".sidebar", "body", ["width"])
+        // Close the sidebar menu.
+        press-key: "Escape"
     },
 )