Skip to content

Commit 2cd3783

Browse files
committed
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
2 parents 6eef33b + a31a398 commit 2cd3783

File tree

12 files changed

+60
-23
lines changed

12 files changed

+60
-23
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ jobs:
7373
needs: [ calculate_matrix ]
7474
runs-on: "${{ matrix.os }}"
7575
timeout-minutes: 360
76+
# The bors environment contains secrets required for elevated workflows (try and auto builds),
77+
# which need to access e.g. S3 and upload artifacts. We want to provide access to that
78+
# environment only on the try/auto branches, which are only accessible to bors.
79+
# This also ensures that PR CI (which doesn't get write access to S3) works, as it cannot
80+
# access the environment.
81+
#
82+
# We only enable the environment for the rust-lang/rust repository, so that rust-lang-ci/rust
83+
# CI works until we migrate off it (since that repository doesn't contain the environment).
84+
environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
7685
env:
7786
CI_JOB_NAME: ${{ matrix.name }}
7887
CI_JOB_DOC_URL: ${{ matrix.doc_url }}

compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::errors::UnnecessaryTransmute as Error;
99

1010
/// Check for transmutes that overlap with stdlib methods.
1111
/// For example, transmuting `[u8; 4]` to `u32`.
12+
/// We chose not to lint u8 -> bool transmutes, see #140431
1213
pub(super) struct CheckUnnecessaryTransmutes;
1314

1415
impl<'tcx> crate::MirLint<'tcx> for CheckUnnecessaryTransmutes {
@@ -98,8 +99,6 @@ impl<'a, 'tcx> UnnecessaryTransmuteChecker<'a, 'tcx> {
9899
(Uint(_), Float(ty)) => err(format!("{}::from_bits({arg})", ty.name_str())),
99100
// bool → { x8 }
100101
(Bool, Int(..) | Uint(..)) => err(format!("({arg}) as {}", fn_sig.output())),
101-
// u8 → bool
102-
(Uint(_), Bool) => err(format!("({arg} == 1)")),
103102
_ => return None,
104103
})
105104
}

library/alloc/src/str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ impl str {
320320
/// ```
321321
#[cfg(not(no_global_oom_handling))]
322322
#[rustc_allow_incoherent_impl]
323+
#[doc(alias = "replace_first")]
323324
#[must_use = "this returns the replaced string as a new allocation, \
324325
without modifying the original"]
325326
#[stable(feature = "str_replacen", since = "1.16.0")]

src/librustdoc/html/static/js/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,10 @@ function preLoadCss(cssUrl) {
11791179

11801180
onEachLazy(document.querySelectorAll(".toggle > summary:not(.hideme)"), el => {
11811181
// @ts-expect-error
1182+
// Clicking on the summary's contents should not collapse it,
1183+
// but links within should still fire.
11821184
el.addEventListener("click", e => {
1183-
if (e.target.tagName !== "SUMMARY" && e.target.tagName !== "A") {
1185+
if (!e.target.matches("summary, a, a *")) {
11841186
e.preventDefault();
11851187
}
11861188
});

src/rustdoc-json-types/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,13 @@ pub struct Item {
180180
///
181181
/// Does not include `#[deprecated]` attributes: see the [`Self::deprecation`] field instead.
182182
///
183-
/// Some attributes appear in pretty-printed Rust form, regardless of their formatting
183+
/// Attributes appear in pretty-printed Rust form, regardless of their formatting
184184
/// in the original source code. For example:
185185
/// - `#[non_exhaustive]` and `#[must_use]` are represented as themselves.
186186
/// - `#[no_mangle]` and `#[export_name]` are also represented as themselves.
187187
/// - `#[repr(C)]` and other reprs also appear as themselves,
188188
/// though potentially with a different order: e.g. `repr(i8, C)` may become `repr(C, i8)`.
189189
/// Multiple repr attributes on the same item may be combined into an equivalent single attr.
190-
///
191-
/// Other attributes may appear debug-printed. For example:
192-
/// - `#[inline]` becomes something similar to `#[attr="Inline(Hint)"]`.
193-
///
194-
/// As an internal implementation detail subject to change, this debug-printing format
195-
/// is currently equivalent to the HIR pretty-printing of parsed attributes.
196190
pub attrs: Vec<String>,
197191
/// Information about the item’s deprecation, if present.
198192
pub deprecation: Option<Deprecation>,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Checks that individual trait impls can only be collapsed via clicking directly on the summary element
2+
3+
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
4+
assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
5+
6+
// Collapse the trait impl doc. The actual clickable area is outside the element, hence offset.
7+
click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5})
8+
assert-attribute-false: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
9+
click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5})
10+
assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
11+
12+
// Clicks on the text should be ignored
13+
click: "summary:has(#trait-impl-link-in-summary) > .impl"
14+
assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
15+
16+
// But links should still work
17+
click: "summary:has(#trait-impl-link-in-summary) a:has(#trait-impl-link-in-summary)"
18+
assert-window-property-false: ({"pageYOffset": "0"})
19+
assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})
20+
21+
// As well as clicks on elements within links
22+
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
23+
assert-window-property: ({"pageYOffset": "0"})
24+
click: "#trait-impl-link-in-summary"
25+
assert-window-property-false: ({"pageYOffset": "0"})
26+
assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""})

tests/rustdoc-gui/src/test_docs/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl Foo {
7979
pub fn warning2() {}
8080
}
8181

82+
/// <a href="#implementations"><code id="trait-impl-link-in-summary">A collapsible trait impl with a link</code></a>
8283
impl AsRef<str> for Foo {
8384
fn as_ref(&self) -> &str {
8485
"hello"

tests/rustdoc-json/attrs/inline.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[inline]"]'
2+
#[inline]
3+
pub fn just_inline() {}
4+
5+
//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[inline(always)]"]'
6+
#[inline(always)]
7+
pub fn inline_always() {}
8+
9+
//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[inline(never)]"]'
10+
#[inline(never)]
11+
pub fn inline_never() {}

tests/ui/transmute/unnecessary-transmutation.fixed

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ fn main() {
8181
let y: i64 = f64::to_bits(1f64).cast_signed();
8282
//~^ ERROR
8383

84-
let z: bool = (1u8 == 1);
85-
//~^ ERROR
84+
let z: bool = transmute(1u8);
85+
// clippy
8686
let z: u8 = (z) as u8;
8787
//~^ ERROR
8888

8989
let z: bool = transmute(1i8);
90-
// no error!
90+
// clippy
9191
let z: i8 = (z) as i8;
9292
//~^ ERROR
9393
}

tests/ui/transmute/unnecessary-transmutation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ fn main() {
8282
//~^ ERROR
8383

8484
let z: bool = transmute(1u8);
85-
//~^ ERROR
85+
// clippy
8686
let z: u8 = transmute(z);
8787
//~^ ERROR
8888

8989
let z: bool = transmute(1i8);
90-
// no error!
90+
// clippy
9191
let z: i8 = transmute(z);
9292
//~^ ERROR
9393
}

tests/ui/transmute/unnecessary-transmutation.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ error: unnecessary transmute
239239
LL | let y: i64 = transmute(1f64);
240240
| ^^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(1f64).cast_signed()`
241241

242-
error: unnecessary transmute
243-
--> $DIR/unnecessary-transmutation.rs:84:23
244-
|
245-
LL | let z: bool = transmute(1u8);
246-
| ^^^^^^^^^^^^^^ help: replace this with: `(1u8 == 1)`
247-
248242
error: unnecessary transmute
249243
--> $DIR/unnecessary-transmutation.rs:86:21
250244
|
@@ -257,5 +251,5 @@ error: unnecessary transmute
257251
LL | let z: i8 = transmute(z);
258252
| ^^^^^^^^^^^^ help: replace this with: `(z) as i8`
259253

260-
error: aborting due to 36 previous errors
254+
error: aborting due to 35 previous errors
261255

0 commit comments

Comments
 (0)