Skip to content

Commit 7322d98

Browse files
authored
Rollup merge of #149095 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update Subtree update of `rustc-dev-guide` to rust-lang/rustc-dev-guide@61ad195. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
2 parents 3dde8a5 + 239cf98 commit 7322d98

File tree

19 files changed

+373
-185
lines changed

19 files changed

+373
-185
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
BASE_SHA: ${{ github.event.pull_request.base.sha }}
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
2626
with:
2727
# linkcheck needs the base commit.
2828
fetch-depth: 0
@@ -83,8 +83,18 @@ jobs:
8383
git commit -m "Deploy ${GITHUB_SHA} to gh-pages"
8484
git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages
8585
86+
- name: Cache sembr build
87+
uses: actions/cache@v4
88+
with:
89+
path: |
90+
~/.cargo/registry/index/
91+
~/.cargo/registry/cache/
92+
~/.cargo/git/db/
93+
ci/sembr/target/
94+
key: sembr-${{ hashFiles('ci/sembr/Cargo.lock') }}
95+
8696
- name: Check if files comply with semantic line breaks
8797
continue-on-error: true
8898
run: |
8999
# using split_inclusive that uses regex feature that uses an unstable feature
90-
RUSTC_BOOTSTRAP=1 cargo run --manifest-path ci/sembr/Cargo.toml src
100+
RUSTC_BOOTSTRAP=1 cargo run --release --manifest-path ci/sembr/Cargo.toml src

src/doc/rustc-dev-guide/.github/workflows/date-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Checkout repo
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919

2020
- name: Ensure Rust is up-to-date
2121
run: |

src/doc/rustc-dev-guide/ci/sembr/Cargo.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = 4
44

55
[[package]]
66
name = "aho-corasick"
7-
version = "1.1.3"
7+
version = "1.1.4"
88
source = "registry+https://github.com/rust-lang/crates.io-index"
9-
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
9+
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
1010
dependencies = [
1111
"memchr",
1212
]
@@ -69,29 +69,29 @@ checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
6969

7070
[[package]]
7171
name = "bstr"
72-
version = "1.12.0"
72+
version = "1.12.1"
7373
source = "registry+https://github.com/rust-lang/crates.io-index"
74-
checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
74+
checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab"
7575
dependencies = [
7676
"memchr",
7777
"serde",
7878
]
7979

8080
[[package]]
8181
name = "clap"
82-
version = "4.5.50"
82+
version = "4.5.51"
8383
source = "registry+https://github.com/rust-lang/crates.io-index"
84-
checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623"
84+
checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
8585
dependencies = [
8686
"clap_builder",
8787
"clap_derive",
8888
]
8989

9090
[[package]]
9191
name = "clap_builder"
92-
version = "4.5.50"
92+
version = "4.5.51"
9393
source = "registry+https://github.com/rust-lang/crates.io-index"
94-
checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0"
94+
checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
9595
dependencies = [
9696
"anstream",
9797
"anstyle",
@@ -184,9 +184,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
184184

185185
[[package]]
186186
name = "ignore"
187-
version = "0.4.24"
187+
version = "0.4.25"
188188
source = "registry+https://github.com/rust-lang/crates.io-index"
189-
checksum = "81776e6f9464432afcc28d03e52eb101c93b6f0566f52aef2427663e700f0403"
189+
checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a"
190190
dependencies = [
191191
"crossbeam-deque",
192192
"globset",
@@ -243,9 +243,9 @@ dependencies = [
243243

244244
[[package]]
245245
name = "quote"
246-
version = "1.0.41"
246+
version = "1.0.42"
247247
source = "registry+https://github.com/rust-lang/crates.io-index"
248-
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
248+
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
249249
dependencies = [
250250
"proc-macro2",
251251
]
@@ -336,9 +336,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
336336

337337
[[package]]
338338
name = "syn"
339-
version = "2.0.108"
339+
version = "2.0.110"
340340
source = "registry+https://github.com/rust-lang/crates.io-index"
341-
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
341+
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
342342
dependencies = [
343343
"proc-macro2",
344344
"quote",
@@ -347,9 +347,9 @@ dependencies = [
347347

348348
[[package]]
349349
name = "unicode-ident"
350-
version = "1.0.20"
350+
version = "1.0.22"
351351
source = "registry+https://github.com/rust-lang/crates.io-index"
352-
checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
352+
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
353353

354354
[[package]]
355355
name = "utf8parse"

src/doc/rustc-dev-guide/ci/sembr/src/main.rs

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ struct Cli {
2222
show_diff: bool,
2323
}
2424

25-
static REGEX_IGNORE: LazyLock<Regex> =
26-
LazyLock::new(|| Regex::new(r"^\s*(\d\.|\-|\*)\s+").unwrap());
27-
static REGEX_IGNORE_END: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)$").unwrap());
25+
static REGEX_IGNORE_END: LazyLock<Regex> =
26+
LazyLock::new(|| Regex::new(r"(\.|\?|;|!|,|\-)$").unwrap());
2827
static REGEX_IGNORE_LINK_TARGETS: LazyLock<Regex> =
2928
LazyLock::new(|| Regex::new(r"^\[.+\]: ").unwrap());
3029
static REGEX_SPLIT: LazyLock<Regex> =
31-
LazyLock::new(|| Regex::new(r"([^\.]\.|[^r]\?|;|!)\s+").unwrap());
30+
LazyLock::new(|| Regex::new(r"([^\.\d\-\*]\.|[^r]\?|;|!)\s").unwrap());
31+
// list elements, numbered (1.) or not (- and *)
32+
static REGEX_LIST_ENTRY: LazyLock<Regex> =
33+
LazyLock::new(|| Regex::new(r"^\s*(\d\.|\-|\*)\s+").unwrap());
3234

3335
fn main() -> Result<()> {
3436
let cli = Cli::parse();
@@ -99,7 +101,6 @@ fn ignore(line: &str, in_code_block: bool) -> bool {
99101
|| line.trim_start().starts_with('>')
100102
|| line.starts_with('#')
101103
|| line.trim().is_empty()
102-
|| REGEX_IGNORE.is_match(line)
103104
|| REGEX_IGNORE_LINK_TARGETS.is_match(line)
104105
}
105106

@@ -120,11 +121,19 @@ fn comply(content: &str) -> String {
120121
continue;
121122
}
122123
if REGEX_SPLIT.is_match(&line) {
123-
let indent = line.find(|ch: char| !ch.is_whitespace()).unwrap();
124-
let new_lines: Vec<_> = line
125-
.split_inclusive(&*REGEX_SPLIT)
126-
.map(|portion| format!("{:indent$}{}", "", portion.trim()))
124+
let indent = if let Some(regex_match) = REGEX_LIST_ENTRY.find(&line) {
125+
regex_match.len()
126+
} else {
127+
line.find(|ch: char| !ch.is_whitespace()).unwrap()
128+
};
129+
let mut newly_split_lines = line.split_inclusive(&*REGEX_SPLIT);
130+
let first = newly_split_lines.next().unwrap().trim_end().to_owned();
131+
let mut remaining: Vec<_> = newly_split_lines
132+
.map(|portion| format!("{:indent$}{}", "", portion.trim_end()))
127133
.collect();
134+
let mut new_lines = Vec::new();
135+
new_lines.push(first);
136+
new_lines.append(&mut remaining);
128137
new_content.splice(new_n..=new_n, new_lines.clone());
129138
new_n += new_lines.len() - 1;
130139
}
@@ -168,7 +177,10 @@ fn lengthen_lines(content: &str, limit: usize) -> String {
168177
let Some(next_line) = content.get(n + 1) else {
169178
continue;
170179
};
171-
if ignore(next_line, in_code_block) || REGEX_IGNORE_END.is_match(line) {
180+
if ignore(next_line, in_code_block)
181+
|| REGEX_LIST_ENTRY.is_match(next_line)
182+
|| REGEX_IGNORE_END.is_match(line)
183+
{
172184
continue;
173185
}
174186
if line.len() + next_line.len() < limit {
@@ -182,42 +194,47 @@ fn lengthen_lines(content: &str, limit: usize) -> String {
182194

183195
#[test]
184196
fn test_sembr() {
185-
let original = "\
197+
let original = "
186198
# some. heading
187-
must! be; split? and. normalizes space
188-
1. ignore numbered
199+
must! be; split?
200+
1. ignore a dot after number. but no further
189201
ignore | tables
190202
ignore e.g. and
191203
ignore i.e. and
192204
ignore E.g. too
193-
- ignore. list
194-
* ignore. list
205+
- list. entry
206+
* list. entry
195207
```
196208
some code. block
197209
```
198210
sentence with *italics* should not be ignored. truly.
199211
git log main.. compiler
212+
foo. bar. baz
200213
";
201-
let expected = "\
214+
let expected = "
202215
# some. heading
203216
must!
204217
be;
205218
split?
206-
and.
207-
normalizes space
208-
1. ignore numbered
219+
1. ignore a dot after number.
220+
but no further
209221
ignore | tables
210222
ignore e.g. and
211223
ignore i.e. and
212224
ignore E.g. too
213-
- ignore. list
214-
* ignore. list
225+
- list.
226+
entry
227+
* list.
228+
entry
215229
```
216230
some code. block
217231
```
218232
sentence with *italics* should not be ignored.
219233
truly.
220234
git log main.. compiler
235+
foo.
236+
bar.
237+
baz
221238
";
222239
assert_eq!(expected, comply(original));
223240
}
@@ -230,12 +247,28 @@ short sentences
230247
<div class='warning'>
231248
a bit of text inside
232249
</div>
250+
preserve next line
251+
1. one
252+
253+
preserve next line
254+
- two
255+
256+
preserve next line
257+
* three
233258
";
234259
let expected = "\
235260
do not split short sentences
236261
<div class='warning'>
237262
a bit of text inside
238263
</div>
264+
preserve next line
265+
1. one
266+
267+
preserve next line
268+
- two
269+
270+
preserve next line
271+
* three
239272
";
240273
assert_eq!(expected, lengthen_lines(original, 50));
241274
}
@@ -263,13 +296,13 @@ fn test_prettify_ignore_link_targets() {
263296

264297
#[test]
265298
fn test_sembr_then_prettify() {
266-
let original = "\
299+
let original = "
267300
hi there. do
268301
not split
269302
short sentences.
270303
hi again.
271304
";
272-
let expected = "\
305+
let expected = "
273306
hi there.
274307
do
275308
not split
@@ -278,15 +311,15 @@ hi again.
278311
";
279312
let processed = comply(original);
280313
assert_eq!(expected, processed);
281-
let expected = "\
314+
let expected = "
282315
hi there.
283316
do not split
284317
short sentences.
285318
hi again.
286319
";
287320
let processed = lengthen_lines(&processed, 50);
288321
assert_eq!(expected, processed);
289-
let expected = "\
322+
let expected = "
290323
hi there.
291324
do not split short sentences.
292325
hi again.
@@ -297,12 +330,12 @@ hi again.
297330

298331
#[test]
299332
fn test_sembr_question_mark() {
300-
let original = "\
333+
let original = "
301334
o? whatever
302335
r? @reviewer
303336
r? @reviewer
304337
";
305-
let expected = "\
338+
let expected = "
306339
o?
307340
whatever
308341
r? @reviewer
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8401398e1f14a24670ee1a3203713dc2f0f8b3a8
1+
cc328c12382f05d8ddf6ffc8139deb7985270ad8

src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ This instructs `git` to perform a "shallow clone", cloning the repository but tr
6868
the last `N` commits.
6969

7070
Passing `--depth 1` tells `git` to clone the repository but truncate the history to the latest
71-
commit that is on the `master` branch, which is usually fine for browsing the source code or
71+
commit that is on the `main` branch, which is usually fine for browsing the source code or
7272
building the compiler.
7373

7474
```bash
@@ -172,7 +172,7 @@ You can install it with `cargo install --path src/tools/x`.
172172

173173
To clarify that this is another global installed binary util, which is
174174
similar to the one declared in section [What is `x.py`](#what-is-xpy), but
175-
it works as an independent process to execute the `x.py` rather than calling the
175+
it works as an independent process to execute the `x.py` rather than calling the
176176
shell to run the platform related scripts.
177177

178178
## Create a `bootstrap.toml`

src/doc/rustc-dev-guide/src/building/suggested.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ lets you use `cargo fmt`.
296296
[the section on vscode]: suggested.md#configuring-rust-analyzer-for-rustc
297297
[the section on rustup]: how-to-build-and-run.md?highlight=rustup#creating-a-rustup-toolchain
298298

299-
## Faster Builds with CI-rustc
299+
## Faster Builds with CI-rustc
300300

301301
If you are not working on the compiler, you often don't need to build the compiler tree.
302302
For example, you can skip building the compiler and only build the `library` tree or the
@@ -389,7 +389,7 @@ times, and having to update each clone individually.
389389
Fortunately, Git has a better solution called [worktrees]. This lets you create
390390
multiple "working trees", which all share the same Git database. Moreover,
391391
because all of the worktrees share the same object database, if you update a
392-
branch (e.g. master) in any of them, you can use the new commits from any of the
392+
branch (e.g. `main`) in any of them, you can use the new commits from any of the
393393
worktrees. One caveat, though, is that submodules do not get shared. They will
394394
still be cloned multiple times.
395395

@@ -403,10 +403,10 @@ command:
403403
git worktree add ../rust2
404404
```
405405

406-
Creating a new worktree for a new branch based on `master` looks like:
406+
Creating a new worktree for a new branch based on `main` looks like:
407407

408408
```bash
409-
git worktree add -b my-feature ../rust2 master
409+
git worktree add -b my-feature ../rust2 main
410410
```
411411

412412
You can then use that rust2 folder as a separate workspace for modifying and

0 commit comments

Comments
 (0)