Skip to content

Commit 1f0d2e0

Browse files
authored
Unrolled build for rust-lang#139283
Rollup merge of rust-lang#139283 - BoxyUwU:rdg-push, r=jieyouxu Rustc dev guide subtree update r? ``@jieyouxu`` ``@Kobzol``
2 parents 946aea0 + ead4d4c commit 1f0d2e0

37 files changed

+543
-410
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
MDBOOK_LINKCHECK2_VERSION: 0.9.1
1919
MDBOOK_MERMAID_VERSION: 0.12.6
2020
MDBOOK_TOC_VERSION: 0.11.2
21+
MDBOOK_OUTPUT__LINKCHECK__FOLLOW_WEB_LINKS: ${{ github.event_name != 'pull_request' }}
2122
DEPLOY_DIR: book/html
2223
BASE_SHA: ${{ github.event.pull_request.base.sha }}
2324
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: src/doc/rustc-dev-guide/book.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,7 @@ warning-policy = "error"
6262
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
6363
"/diagnostics/diagnostic-codes.html" = "error-codes.html"
6464
"/miri.html" = "const-eval/interpret.html"
65-
"/tests/integration.html" = "ecosystem.html"
65+
"/tests/fuchsia.html" = "ecosystem-test-jobs/fuchsia.html"
6666
"/tests/headers.html" = "directives.html"
67+
"/tests/integration.html" = "ecosystem.html"
68+
"/tests/rust-for-linux.html" = "ecosystem-test-jobs/rust-for-linux.html"

Diff for: src/doc/rustc-dev-guide/ci/date-check/src/main.rs

+30-125
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
use std::{
2-
collections::BTreeMap,
3-
convert::TryInto as _,
4-
env, fmt, fs,
5-
path::{Path, PathBuf},
6-
process,
7-
str::FromStr,
8-
};
1+
use std::collections::BTreeMap;
2+
use std::convert::TryInto as _;
3+
use std::path::{Path, PathBuf};
4+
use std::str::FromStr;
5+
use std::{env, fmt, fs, process};
96

107
use chrono::{Datelike as _, Month, TimeZone as _, Utc};
118
use glob::glob;
@@ -19,19 +16,13 @@ struct Date {
1916

2017
impl Date {
2118
fn months_since(self, other: Date) -> Option<u32> {
22-
let self_chrono = Utc
23-
.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0)
24-
.unwrap();
25-
let other_chrono = Utc
26-
.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0)
27-
.unwrap();
19+
let self_chrono =
20+
Utc.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0).unwrap();
21+
let other_chrono =
22+
Utc.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0).unwrap();
2823
let duration_since = self_chrono.signed_duration_since(other_chrono);
2924
let months_since = duration_since.num_days() / 30;
30-
if months_since < 0 {
31-
None
32-
} else {
33-
Some(months_since.try_into().unwrap())
34-
}
25+
if months_since < 0 { None } else { Some(months_since.try_into().unwrap()) }
3526
}
3627
}
3728

@@ -66,26 +57,18 @@ fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)>
6657
date_regex
6758
.captures_iter(text)
6859
.filter_map(|cap| {
69-
if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) = (
70-
cap.name("m1"),
71-
cap.name("y1"),
72-
cap.name("m2"),
73-
cap.name("y2"),
74-
) {
60+
if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) =
61+
(cap.name("m1"), cap.name("y1"), cap.name("m2"), cap.name("y2"))
62+
{
7563
let year = year.as_str().parse().expect("year");
76-
let month = Month::from_str(month.as_str())
77-
.expect("month")
78-
.number_from_month();
64+
let month = Month::from_str(month.as_str()).expect("month").number_from_month();
7965
Some((cap.get(0).expect("all").range(), Date { year, month }))
8066
} else {
8167
None
8268
}
8369
})
8470
.map(|(byte_range, date)| {
85-
line += text[end_of_last_cap..byte_range.end]
86-
.chars()
87-
.filter(|c| *c == '\n')
88-
.count();
71+
line += text[end_of_last_cap..byte_range.end].chars().filter(|c| *c == '\n').count();
8972
end_of_last_cap = byte_range.end;
9073
(line, date)
9174
})
@@ -138,10 +121,7 @@ fn main() {
138121
let root_dir_path = Path::new(&root_dir);
139122
let glob_pat = format!("{}/**/*.md", root_dir);
140123
let today_chrono = Utc::now().date_naive();
141-
let current_month = Date {
142-
year: today_chrono.year_ce().1,
143-
month: today_chrono.month(),
144-
};
124+
let current_month = Date { year: today_chrono.year_ce().1, month: today_chrono.month() };
145125

146126
let dates_by_file = collect_dates(glob(&glob_pat).unwrap().map(Result::unwrap));
147127
let dates_by_file: BTreeMap<_, _> =
@@ -173,10 +153,7 @@ fn main() {
173153
println!();
174154

175155
for (path, dates) in dates_by_file {
176-
println!(
177-
"- {}",
178-
path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),
179-
);
156+
println!("- {}", path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),);
180157
for (line, date) in dates {
181158
println!(" - [ ] line {}: {}", line, date);
182159
}
@@ -191,14 +168,8 @@ mod tests {
191168

192169
#[test]
193170
fn test_months_since() {
194-
let date1 = Date {
195-
year: 2020,
196-
month: 3,
197-
};
198-
let date2 = Date {
199-
year: 2021,
200-
month: 1,
201-
};
171+
let date1 = Date { year: 2020, month: 3 };
172+
let date2 = Date { year: 2021, month: 1 };
202173
assert_eq!(date2.months_since(date1), Some(10));
203174
}
204175

@@ -273,83 +244,17 @@ Test8
273244
assert_eq!(
274245
collect_dates_from_file(&make_date_regex(), text),
275246
vec![
276-
(
277-
3,
278-
Date {
279-
year: 2021,
280-
month: 1,
281-
}
282-
),
283-
(
284-
6,
285-
Date {
286-
year: 2021,
287-
month: 2,
288-
}
289-
),
290-
(
291-
9,
292-
Date {
293-
year: 2021,
294-
month: 3,
295-
}
296-
),
297-
(
298-
11,
299-
Date {
300-
year: 2021,
301-
month: 4,
302-
}
303-
),
304-
(
305-
17,
306-
Date {
307-
year: 2021,
308-
month: 5,
309-
}
310-
),
311-
(
312-
20,
313-
Date {
314-
year: 2021,
315-
month: 1,
316-
}
317-
),
318-
(
319-
23,
320-
Date {
321-
year: 2021,
322-
month: 2,
323-
}
324-
),
325-
(
326-
26,
327-
Date {
328-
year: 2021,
329-
month: 3,
330-
}
331-
),
332-
(
333-
28,
334-
Date {
335-
year: 2021,
336-
month: 4,
337-
}
338-
),
339-
(
340-
34,
341-
Date {
342-
year: 2021,
343-
month: 5,
344-
}
345-
),
346-
(
347-
38,
348-
Date {
349-
year: 2021,
350-
month: 6,
351-
}
352-
),
247+
(3, Date { year: 2021, month: 1 }),
248+
(6, Date { year: 2021, month: 2 }),
249+
(9, Date { year: 2021, month: 3 }),
250+
(11, Date { year: 2021, month: 4 }),
251+
(17, Date { year: 2021, month: 5 }),
252+
(20, Date { year: 2021, month: 1 }),
253+
(23, Date { year: 2021, month: 2 }),
254+
(26, Date { year: 2021, month: 3 }),
255+
(28, Date { year: 2021, month: 4 }),
256+
(34, Date { year: 2021, month: 5 }),
257+
(38, Date { year: 2021, month: 6 }),
353258
],
354259
);
355260
}

Diff for: src/doc/rustc-dev-guide/examples/rustc-driver-example.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Tested with nightly-2025-02-13
1+
// Tested with nightly-2025-03-28
22

33
#![feature(rustc_private)]
44

@@ -34,9 +34,9 @@ impl rustc_span::source_map::FileLoader for MyFileLoader {
3434
fn read_file(&self, path: &Path) -> io::Result<String> {
3535
if path == Path::new("main.rs") {
3636
Ok(r#"
37+
static MESSAGE: &str = "Hello, World!";
3738
fn main() {
38-
let message = "Hello, World!";
39-
println!("{message}");
39+
println!("{MESSAGE}");
4040
}
4141
"#
4242
.to_string())
@@ -71,14 +71,12 @@ impl rustc_driver::Callbacks for MyCallbacks {
7171

7272
fn after_analysis(&mut self, _compiler: &Compiler, tcx: TyCtxt<'_>) -> Compilation {
7373
// Analyze the program and inspect the types of definitions.
74-
for id in tcx.hir().items() {
75-
let hir = tcx.hir();
76-
let item = hir.item(id);
74+
for id in tcx.hir_free_items() {
75+
let item = &tcx.hir_item(id);
7776
match item.kind {
78-
rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => {
79-
let name = item.ident;
77+
rustc_hir::ItemKind::Static(ident, ..) | rustc_hir::ItemKind::Fn { ident, .. } => {
8078
let ty = tcx.type_of(item.hir_id().owner.def_id);
81-
println!("{name:?}:\t{ty:?}")
79+
println!("{ident:?}:\t{ty:?}")
8280
}
8381
_ => (),
8482
}

Diff for: src/doc/rustc-dev-guide/examples/rustc-driver-interacting-with-the-ast.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Tested with nightly-2025-02-13
1+
// Tested with nightly-2025-03-28
22

33
#![feature(rustc_private)]
44

@@ -20,7 +20,7 @@ use std::path::Path;
2020
use std::sync::Arc;
2121

2222
use rustc_ast_pretty::pprust::item_to_string;
23-
use rustc_driver::{run_compiler, Compilation};
23+
use rustc_driver::{Compilation, run_compiler};
2424
use rustc_interface::interface::{Compiler, Config};
2525
use rustc_middle::ty::TyCtxt;
2626

@@ -70,11 +70,9 @@ impl rustc_driver::Callbacks for MyCallbacks {
7070
}
7171

7272
fn after_analysis(&mut self, _compiler: &Compiler, tcx: TyCtxt<'_>) -> Compilation {
73-
// Every compilation contains a single crate.
74-
let hir_krate = tcx.hir();
7573
// Iterate over the top-level items in the crate, looking for the main function.
76-
for id in hir_krate.items() {
77-
let item = hir_krate.item(id);
74+
for id in tcx.hir_free_items() {
75+
let item = &tcx.hir_item(id);
7876
// Use pattern-matching to find a specific node inside the main function.
7977
if let rustc_hir::ItemKind::Fn { body, .. } = item.kind {
8078
let expr = &tcx.hir_body(body).value;

Diff for: src/doc/rustc-dev-guide/examples/rustc-interface-example.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Tested with nightly-2025-02-13
1+
// Tested with nightly-2025-03-28
22

33
#![feature(rustc_private)]
44

@@ -64,14 +64,13 @@ fn main() {
6464
println!("{krate:?}");
6565
// Analyze the program and inspect the types of definitions.
6666
rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
67-
for id in tcx.hir().items() {
68-
let hir = tcx.hir();
69-
let item = hir.item(id);
67+
for id in tcx.hir_free_items() {
68+
let item = tcx.hir_item(id);
7069
match item.kind {
71-
rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => {
72-
let name = item.ident;
70+
rustc_hir::ItemKind::Static(ident, ..)
71+
| rustc_hir::ItemKind::Fn { ident, .. } => {
7372
let ty = tcx.type_of(item.hir_id().owner.def_id);
74-
println!("{name:?}:\t{ty:?}")
73+
println!("{ident:?}:\t{ty:?}")
7574
}
7675
_ => (),
7776
}

Diff for: src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Tested with nightly-2025-02-13
1+
// Tested with nightly-2025-03-28
22

33
#![feature(rustc_private)]
44

@@ -86,8 +86,10 @@ fn main() {
8686
rustc_interface::run_compiler(config, |compiler| {
8787
let krate = rustc_interface::passes::parse(&compiler.sess);
8888
rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
89-
// Run the analysis phase on the local crate to trigger the type error.
90-
let _ = tcx.analysis(());
89+
// Iterate all the items defined and perform type checking.
90+
tcx.par_hir_body_owners(|item_def_id| {
91+
tcx.ensure_ok().typeck(item_def_id);
92+
});
9193
});
9294
// If the compiler has encountered errors when this closure returns, it will abort (!) the program.
9395
// We avoid this by resetting the error count before returning

Diff for: src/doc/rustc-dev-guide/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
493c38ba371929579fe136df26eccd9516347c7a
1+
ae9173d7dd4a31806c950c90dcc331f1508b4d17

Diff for: src/doc/rustc-dev-guide/rustfmt.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# matches that of rust-lang/rust
2+
style_edition = "2024"
3+
use_small_heuristics = "Max"
4+
merge_derives = false
5+
group_imports = "StdExternalCrate"
6+
imports_granularity = "Module"
7+
use_field_init_shorthand = true

0 commit comments

Comments
 (0)