about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-22 05:27:04 +0000
committerbors <bors@rust-lang.org>2025-05-22 05:27:04 +0000
commit2cd37831b0706c9f2d6e7e20eb556dc7548bf732 (patch)
tree8eae85e0b199c35535351d335d0b2a6a8dc6d48e
parent6eef33bb399cabfab16aa4e0825895f5f32f4e26 (diff)
parenta31a39833afd0853c60629a8b6585b72b55685d1 (diff)
downloadrust-2cd37831b0706c9f2d6e7e20eb556dc7548bf732.tar.gz
rust-2cd37831b0706c9f2d6e7e20eb556dc7548bf732.zip
Auto merge of #141379 - matthiaskrgr:rollup-g1cz0ic, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #140431 (dont handle bool transmute)
 - #140868 (rustdoc: Fix links with inline code in trait impl docs)
 - #141323 (Add bors environment to CI)
 - #141337 (bump stdarch)
 - #141364 (rustdoc-json: Remove false docs and add test for inline attribute)
 - #141370 (add doc alias `replace_first` for `str::replacen`)

r? `@ghost`
`@rustbot` modify labels: rollup
-rw-r--r--.github/workflows/ci.yml9
-rw-r--r--compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs3
-rw-r--r--library/alloc/src/str.rs1
m---------library/stdarch0
-rw-r--r--src/librustdoc/html/static/js/main.js4
-rw-r--r--src/rustdoc-json-types/lib.rs8
-rw-r--r--tests/rustdoc-gui/collapse-trait-impl.goml26
-rw-r--r--tests/rustdoc-gui/src/test_docs/lib.rs1
-rw-r--r--tests/rustdoc-json/attrs/inline.rs11
-rw-r--r--tests/ui/transmute/unnecessary-transmutation.fixed6
-rw-r--r--tests/ui/transmute/unnecessary-transmutation.rs4
-rw-r--r--tests/ui/transmute/unnecessary-transmutation.stderr8
12 files changed, 59 insertions, 22 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 93316b9cff7..0bce8389d8e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -73,6 +73,15 @@ jobs:
     needs: [ calculate_matrix ]
     runs-on: "${{ matrix.os }}"
     timeout-minutes: 360
+    # The bors environment contains secrets required for elevated workflows (try and auto builds),
+    # which need to access e.g. S3 and upload artifacts. We want to provide access to that
+    # environment only on the try/auto branches, which are only accessible to bors.
+    # This also ensures that PR CI (which doesn't get write access to S3) works, as it cannot
+    # access the environment.
+    #
+    # We only enable the environment for the rust-lang/rust repository, so that rust-lang-ci/rust
+    # CI works until we migrate off it (since that repository doesn't contain the environment).
+    environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
     env:
       CI_JOB_NAME: ${{ matrix.name }}
       CI_JOB_DOC_URL: ${{ matrix.doc_url }}
diff --git a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
index 8da17a056e3..0514de3ea13 100644
--- a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
+++ b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs
@@ -9,6 +9,7 @@ use crate::errors::UnnecessaryTransmute as Error;
 
 /// Check for transmutes that overlap with stdlib methods.
 /// For example, transmuting `[u8; 4]` to `u32`.
+/// We chose not to lint u8 -> bool transmutes, see #140431
 pub(super) struct CheckUnnecessaryTransmutes;
 
 impl<'tcx> crate::MirLint<'tcx> for CheckUnnecessaryTransmutes {
@@ -98,8 +99,6 @@ impl<'a, 'tcx> UnnecessaryTransmuteChecker<'a, 'tcx> {
             (Uint(_), Float(ty)) => err(format!("{}::from_bits({arg})", ty.name_str())),
             // bool → { x8 }
             (Bool, Int(..) | Uint(..)) => err(format!("({arg}) as {}", fn_sig.output())),
-            // u8 → bool
-            (Uint(_), Bool) => err(format!("({arg} == 1)")),
             _ => return None,
         })
     }
diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs
index 8766fd904b0..f1b1734b8b2 100644
--- a/library/alloc/src/str.rs
+++ b/library/alloc/src/str.rs
@@ -320,6 +320,7 @@ impl str {
     /// ```
     #[cfg(not(no_global_oom_handling))]
     #[rustc_allow_incoherent_impl]
+    #[doc(alias = "replace_first")]
     #[must_use = "this returns the replaced string as a new allocation, \
                   without modifying the original"]
     #[stable(feature = "str_replacen", since = "1.16.0")]
diff --git a/library/stdarch b/library/stdarch
-Subproject 1dfaa4db2479753a46a3e90f2c3c89d89d0b21f
+Subproject b6e2249e388f520627544812649b77b0944e1a2
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index a7ce2bf9048..7b1a61a3ffa 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1179,8 +1179,10 @@ function preLoadCss(cssUrl) {
 
     onEachLazy(document.querySelectorAll(".toggle > summary:not(.hideme)"), el => {
         // @ts-expect-error
+        // Clicking on the summary's contents should not collapse it,
+        // but links within should still fire.
         el.addEventListener("click", e => {
-            if (e.target.tagName !== "SUMMARY" && e.target.tagName !== "A") {
+            if (!e.target.matches("summary, a, a *")) {
                 e.preventDefault();
             }
         });
diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
index 64223b5b758..0b8a9065294 100644
--- a/src/rustdoc-json-types/lib.rs
+++ b/src/rustdoc-json-types/lib.rs
@@ -180,19 +180,13 @@ pub struct Item {
     ///
     /// Does not include `#[deprecated]` attributes: see the [`Self::deprecation`] field instead.
     ///
-    /// Some attributes appear in pretty-printed Rust form, regardless of their formatting
+    /// Attributes appear in pretty-printed Rust form, regardless of their formatting
     /// in the original source code. For example:
     /// - `#[non_exhaustive]` and `#[must_use]` are represented as themselves.
     /// - `#[no_mangle]` and `#[export_name]` are also represented as themselves.
     /// - `#[repr(C)]` and other reprs also appear as themselves,
     ///   though potentially with a different order: e.g. `repr(i8, C)` may become `repr(C, i8)`.
     ///   Multiple repr attributes on the same item may be combined into an equivalent single attr.
-    ///
-    /// Other attributes may appear debug-printed. For example:
-    /// - `#[inline]` becomes something similar to `#[attr="Inline(Hint)"]`.
-    ///
-    /// As an internal implementation detail subject to change, this debug-printing format
-    /// is currently equivalent to the HIR pretty-printing of parsed attributes.
     pub attrs: Vec<String>,
     /// Information about the item’s deprecation, if present.
     pub deprecation: Option<Deprecation>,
diff --git a/tests/rustdoc-gui/collapse-trait-impl.goml b/tests/rustdoc-gui/collapse-trait-impl.goml
new file mode 100644
index 00000000000..4db02e5239b
--- /dev/null
+++ b/tests/rustdoc-gui/collapse-trait-impl.goml
@@ -0,0 +1,26 @@
+// Checks that individual trait impls can only be collapsed via clicking directly on the summary element
+
+go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
+assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
+
+// Collapse the trait impl doc. The actual clickable area is outside the element, hence offset.
+click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5})
+assert-attribute-false: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
+click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5})
+assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
+
+// Clicks on the text should be ignored
+click: "summary:has(#trait-impl-link-in-summary) > .impl"
+assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
+
+// But links should still work
+click: "summary:has(#trait-impl-link-in-summary) a:has(#trait-impl-link-in-summary)"
+assert-window-property-false: ({"pageYOffset": "0"})
+assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
+
+// As well as clicks on elements within links
+go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
+assert-window-property: ({"pageYOffset": "0"})
+click: "#trait-impl-link-in-summary"
+assert-window-property-false: ({"pageYOffset": "0"})
+assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index bb0015b8f9c..e8afe8b5687 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -79,6 +79,7 @@ impl Foo {
     pub fn warning2() {}
 }
 
+/// <a href="#implementations"><code id="trait-impl-link-in-summary">A collapsible trait impl with a link</code></a>
 impl AsRef<str> for Foo {
     fn as_ref(&self) -> &str {
         "hello"
diff --git a/tests/rustdoc-json/attrs/inline.rs b/tests/rustdoc-json/attrs/inline.rs
new file mode 100644
index 00000000000..74f5f36f03f
--- /dev/null
+++ b/tests/rustdoc-json/attrs/inline.rs
@@ -0,0 +1,11 @@
+//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[inline]"]'
+#[inline]
+pub fn just_inline() {}
+
+//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[inline(always)]"]'
+#[inline(always)]
+pub fn inline_always() {}
+
+//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[inline(never)]"]'
+#[inline(never)]
+pub fn inline_never() {}
diff --git a/tests/ui/transmute/unnecessary-transmutation.fixed b/tests/ui/transmute/unnecessary-transmutation.fixed
index bf7d769348a..f6478c5aa5c 100644
--- a/tests/ui/transmute/unnecessary-transmutation.fixed
+++ b/tests/ui/transmute/unnecessary-transmutation.fixed
@@ -81,13 +81,13 @@ fn main() {
         let y: i64 = f64::to_bits(1f64).cast_signed();
         //~^ ERROR
 
-        let z: bool = (1u8 == 1);
-        //~^ ERROR
+        let z: bool = transmute(1u8);
+        // clippy
         let z: u8 = (z) as u8;
         //~^ ERROR
 
         let z: bool = transmute(1i8);
-        // no error!
+        // clippy
         let z: i8 = (z) as i8;
         //~^ ERROR
     }
diff --git a/tests/ui/transmute/unnecessary-transmutation.rs b/tests/ui/transmute/unnecessary-transmutation.rs
index b9de529f1cc..ab0af03acc2 100644
--- a/tests/ui/transmute/unnecessary-transmutation.rs
+++ b/tests/ui/transmute/unnecessary-transmutation.rs
@@ -82,12 +82,12 @@ fn main() {
         //~^ ERROR
 
         let z: bool = transmute(1u8);
-        //~^ ERROR
+        // clippy
         let z: u8 = transmute(z);
         //~^ ERROR
 
         let z: bool = transmute(1i8);
-        // no error!
+        // clippy
         let z: i8 = transmute(z);
         //~^ ERROR
     }
diff --git a/tests/ui/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.stderr
index a19f1bebf16..59e933bbc81 100644
--- a/tests/ui/transmute/unnecessary-transmutation.stderr
+++ b/tests/ui/transmute/unnecessary-transmutation.stderr
@@ -240,12 +240,6 @@ LL |         let y: i64 = transmute(1f64);
    |                      ^^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(1f64).cast_signed()`
 
 error: unnecessary transmute
-  --> $DIR/unnecessary-transmutation.rs:84:23
-   |
-LL |         let z: bool = transmute(1u8);
-   |                       ^^^^^^^^^^^^^^ help: replace this with: `(1u8 == 1)`
-
-error: unnecessary transmute
   --> $DIR/unnecessary-transmutation.rs:86:21
    |
 LL |         let z: u8 = transmute(z);
@@ -257,5 +251,5 @@ error: unnecessary transmute
 LL |         let z: i8 = transmute(z);
    |                     ^^^^^^^^^^^^ help: replace this with: `(z) as i8`
 
-error: aborting due to 36 previous errors
+error: aborting due to 35 previous errors