Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 88d021a

Browse files
committed
Auto merge of rust-lang#136002 - joboet:rollup-f7cf3xs, r=joboet
Rollup of 6 pull requests Successful merges: - rust-lang#135728 (document order of items in iterator from drain) - rust-lang#135829 (Rustc dev guide subtree update) - rust-lang#135886 (Document purpose of closure in from_fn.rs more clearly) - rust-lang#135977 (Fix `FormattingOptions` instantiation with `Default`) - rust-lang#135983 (Doc difference between extend and extend_from_slice) - rust-lang#135985 (Rename test to `unresolvable-upvar-issue-87987.rs` and add some notes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1e9b017 + aa83880 commit 88d021a

39 files changed

+253
-154
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,9 +2571,11 @@ impl<T, A: Allocator> Vec<T, A> {
25712571
self.len += count;
25722572
}
25732573

2574-
/// Removes the specified range from the vector in bulk, returning all
2575-
/// removed elements as an iterator. If the iterator is dropped before
2576-
/// being fully consumed, it drops the remaining removed elements.
2574+
/// Removes the subslice indicated by the given range from the vector,
2575+
/// returning a double-ended iterator over the removed subslice.
2576+
///
2577+
/// If the iterator is dropped before being fully consumed,
2578+
/// it drops the remaining removed elements.
25772579
///
25782580
/// The returned iterator keeps a mutable borrow on the vector to optimize
25792581
/// its implementation.

library/core/src/fmt/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ pub enum DebugAsHex {
288288
///
289289
/// `FormattingOptions` is a [`Formatter`] without an attached [`Write`] trait.
290290
/// It is mainly used to construct `Formatter` instances.
291-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
291+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
292292
#[unstable(feature = "formatting_options", issue = "118117")]
293293
pub struct FormattingOptions {
294294
flags: u32,
@@ -508,6 +508,15 @@ impl FormattingOptions {
508508
}
509509
}
510510

511+
#[unstable(feature = "formatting_options", issue = "118117")]
512+
impl Default for FormattingOptions {
513+
/// Same as [`FormattingOptions::new()`].
514+
fn default() -> Self {
515+
// The `#[derive(Default)]` implementation would set `fill` to `\0` instead of space.
516+
Self::new()
517+
}
518+
}
519+
511520
/// Configuration for formatting.
512521
///
513522
/// A `Formatter` represents various options related to formatting. Users do not

library/core/src/iter/sources/from_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::fmt;
22

3-
/// Creates a new iterator where each iteration calls the provided closure
4-
/// `F: FnMut() -> Option<T>`.
3+
/// Creates an iterator with the provided closure
4+
/// `F: FnMut() -> Option<T>` as its `[next](Iterator::next)` method.
55
///
66
/// The iterator will yield the `T`s returned from the closure.
77
///

library/core/tests/fmt/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ fn test_maybe_uninit_short() {
5151
assert_eq!(format!("{x:?}"), "MaybeUninit<u32>");
5252
}
5353

54+
#[test]
55+
fn formatting_options_ctor() {
56+
use core::fmt::FormattingOptions;
57+
assert_eq!(FormattingOptions::new(), FormattingOptions::default());
58+
}
59+
5460
#[test]
5561
fn formatting_options_flags() {
5662
use core::fmt::*;

src/doc/rustc-dev-guide/.github/workflows/ci.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ jobs:
3535
~/.cargo/bin
3636
key: ${{ runner.os }}-${{ env.MDBOOK_VERSION }}--${{ env.MDBOOK_LINKCHECK2_VERSION }}--${{ env.MDBOOK_TOC_VERSION }}--${{ env.MDBOOK_MERMAID_VERSION }}
3737

38-
- name: Cache linkcheck
39-
uses: actions/cache@v4
38+
- name: Restore cached Linkcheck
39+
if: github.event_name == 'schedule'
40+
id: cache-linkcheck-restore
41+
uses: actions/cache/restore@v4
4042
with:
41-
path: |
42-
~/book/linkcheck
43-
key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }}
43+
path: book/linkcheck/cache.json
44+
key: linkcheck--${{ env.MDBOOK_LINKCHECK2_VERSION }}
4445

4546
- name: Install latest nightly Rust toolchain
4647
if: steps.mdbook-cache.outputs.cache-hit != 'true'
@@ -59,6 +60,14 @@ jobs:
5960
- name: Check build
6061
run: ENABLE_LINKCHECK=1 mdbook build
6162

63+
- name: Save cached Linkcheck
64+
id: cache-linkcheck-save
65+
if: ${{ !cancelled() && github.event_name == 'schedule' }}
66+
uses: actions/cache/save@v4
67+
with:
68+
path: book/linkcheck/cache.json
69+
key: linkcheck--${{ env.MDBOOK_LINKCHECK2_VERSION }}
70+
6271
- name: Deploy to gh-pages
6372
if: github.event_name == 'push'
6473
run: |
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: rustc-pull
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Run at 04:00 UTC every Monday
7+
- cron: '0 4 * * 1'
8+
9+
jobs:
10+
pull:
11+
if: github.repository == 'rust-lang/rustc-dev-guide'
12+
runs-on: ubuntu-latest
13+
outputs:
14+
pr_url: ${{ steps.update-pr.outputs.pr_url }}
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
# We need the full history for josh to work
22+
fetch-depth: '0'
23+
- name: Install stable Rust toolchain
24+
run: rustup update stable
25+
- uses: Swatinem/rust-cache@v2
26+
with:
27+
workspaces: "josh-sync"
28+
# Cache the josh directory with checked out rustc
29+
cache-directories: "/home/runner/.cache/rustc-dev-guide-josh"
30+
- name: Install josh
31+
run: RUSTFLAGS="--cap-lints warn" cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
32+
- name: Setup bot git name and email
33+
run: |
34+
git config --global user.name 'The rustc-dev-guide Cronjob Bot'
35+
git config --global user.email 'github-actions@github.com'
36+
- name: Perform rustc-pull
37+
run: cargo run --manifest-path josh-sync/Cargo.toml -- rustc-pull
38+
- name: Push changes to a branch
39+
run: |
40+
# Update a sticky branch that is used only for rustc pulls
41+
BRANCH="rustc-pull"
42+
git switch -c $BRANCH
43+
git push -u origin $BRANCH --force
44+
- name: Create pull request
45+
id: update-pr
46+
run: |
47+
# Check if an open pull request for an rustc pull update already exists
48+
# If it does, the previous push has just updated it
49+
# If not, we create it now
50+
RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`
51+
if [[ "$RESULT" -eq 0 ]]; then
52+
echo "Creating new pull request"
53+
PR_URL=gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
54+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
55+
else
56+
PR_URL=gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].url' --json url,title
57+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
58+
fi
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
send-zulip-message:
62+
needs: [pull]
63+
if: ${{ !cancelled() }}
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Compute message
67+
id: message
68+
run: |
69+
if [ "${{ needs.pull.result }}" == "failure" ];
70+
then
71+
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
72+
echo "message=Rustc pull sync failed. Check out the [workflow URL]($WORKFLOW_URL)." >> $GITHUB_OUTPUT
73+
else
74+
echo "message=Rustc pull sync succeeded. Check out the [PR](${{ needs.pull.outputs.pr_url }})." >> $GITHUB_OUTPUT
75+
fi
76+
- name: Send a Zulip message about updated PR
77+
uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5
78+
with:
79+
api-key: ${{ secrets.ZULIP_API_TOKEN }}
80+
email: "rustc-dev-guide-gha-notif-bot@rust-lang.zulipchat.com"
81+
organization-url: "https://rust-lang.zulipchat.com"
82+
to: 196385
83+
type: "stream"
84+
topic: "Subtree sync automation"
85+
content: ${{ steps.message.outputs.message }}

src/doc/rustc-dev-guide/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ ci/date-check/target/
44

55
# Generated by check-in.sh
66
pulls.json
7+
8+
josh-sync/target

src/doc/rustc-dev-guide/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ including the `<!-- toc -->` marker at the place where you want the TOC.
7474

7575
This repository is linked to `rust-lang/rust` as a [josh](https://josh-project.github.io/josh/intro.html) subtree. You can use the following commands to synchronize the subtree in both directions.
7676

77+
You'll need to install `josh-proxy` locally via
78+
79+
```
80+
cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
81+
```
82+
Older versions of `josh-proxy` may not round trip commits losslessly so it is important to install this exact version.
83+
7784
### Pull changes from `rust-lang/rust` into this repository
7885
1) Checkout a new branch that will be used to create a PR into `rust-lang/rustc-dev-guide`
7986
2) Run the pull command

src/doc/rustc-dev-guide/book.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ exclude = [
5252
# 500 is returned for HEAD request
5353
"code\\.visualstudio\\.com/docs/editor/tasks",
5454
]
55-
cache-timeout = 86400
55+
# The scheduled CI runs every day and so we need to reuse a part of the cache
56+
# in order to face "Server returned 429 Too Many Requests" errors for github.com.
57+
cache-timeout = 90000
5658
warning-policy = "error"
5759

5860
[output.html.redirect]

src/doc/rustc-dev-guide/josh-sync/src/sync.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ impl GitSync {
4545
let josh_url =
4646
format!("http://localhost:{JOSH_PORT}/{UPSTREAM_REPO}.git@{commit}{JOSH_FILTER}.git");
4747

48+
let previous_base_commit = sh.read_file("rust-version")?.trim().to_string();
49+
if previous_base_commit == commit {
50+
return Err(anyhow::anyhow!("No changes since last pull"));
51+
}
52+
4853
// Update rust-version file. As a separate commit, since making it part of
4954
// the merge has confused the heck out of josh in the past.
5055
// We pass `--no-verify` to avoid running git hooks.
@@ -76,12 +81,22 @@ impl GitSync {
7681
};
7782
let num_roots_before = num_roots()?;
7883

84+
let sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
85+
7986
// Merge the fetched commit.
8087
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
8188
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
8289
.run()
8390
.context("FAILED to merge new commits, something went wrong")?;
8491

92+
let current_sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
93+
if current_sha == sha {
94+
cmd!(sh, "git reset --hard HEAD^")
95+
.run()
96+
.expect("FAILED to clean up after creating the preparation commit");
97+
return Err(anyhow::anyhow!("No merge was performed, nothing to pull. Rolled back the preparation commit."));
98+
}
99+
85100
// Check that the number of roots did not increase.
86101
if num_roots()? != num_roots_before {
87102
bail!("Josh created a new root commit. This is probably not the history you want.");

0 commit comments

Comments
 (0)