diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93316b9cff7b1..0bce8389d8ec2 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 8da17a056e31b..0514de3ea13fb 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 8766fd904b074..f1b1734b8b2d0 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 index 1dfaa4db24797..b6e2249e388f5 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit 1dfaa4db2479753a46a3e90f2c3c89d89d0b21f1 +Subproject commit b6e2249e388f520627544812649b77b0944e1a2e diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index a7ce2bf9048bf..7b1a61a3ffa45 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 64223b5b75896..0b8a906529466 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, /// Information about the item’s deprecation, if present. pub deprecation: Option, diff --git a/tests/rustdoc-gui/collapse-trait-impl.goml b/tests/rustdoc-gui/collapse-trait-impl.goml new file mode 100644 index 0000000000000..4db02e5239b5e --- /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 bb0015b8f9c43..e8afe8b568727 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 collapsible trait impl with a link impl AsRef 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 0000000000000..74f5f36f03f3b --- /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 bf7d769348aaf..f6478c5aa5c2f 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 b9de529f1cccd..ab0af03acc2ec 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 a19f1bebf16fd..59e933bbc81b9 100644 --- a/tests/ui/transmute/unnecessary-transmutation.stderr +++ b/tests/ui/transmute/unnecessary-transmutation.stderr @@ -239,12 +239,6 @@ error: unnecessary transmute 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 | @@ -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