Skip to content

Rustc dev guide subtree update #139283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
249e5b5
Fix rib example
sagudev Jan 7, 2025
a4b76e3
Adapt to rust-lang/rust#136466:
y1lan Mar 16, 2025
9a2d1fd
Following commit 401dd84 in the Rust project
y1lan Mar 16, 2025
3e448fd
Add chapter Remarks on perma-unstable features
xizheyin Mar 5, 2025
7faf2a5
Merge pull request #2268 from xizheyin/issue-137421
jieyouxu Mar 18, 2025
74698d7
Add Fuchsia ping group notice
Kobzol Mar 18, 2025
9ff4936
Reorder RfL tests page to move the "what if it breaks" section to the…
Kobzol Mar 18, 2025
c987d34
Add Fuchsia ping group page
Kobzol Mar 18, 2025
a9f46f1
Merge pull request #2294 from Kobzol/ping-group
Kobzol Mar 18, 2025
4f053a9
add new section on the `rustdoc` test suite
lolbinarycat Mar 18, 2025
3668c36
add htmldocck.md to SUMMARY.md
lolbinarycat Mar 18, 2025
a172f23
htmldocck: expand limitations and mention compiletest directives
lolbinarycat Mar 18, 2025
6893f0a
rustdoc test suite: clean up wording and intro
lolbinarycat Mar 18, 2025
1081d98
rename htmldocck.md -> rustdoc-test-suite.md
lolbinarycat Mar 18, 2025
40b9be0
clean up wording/grammar and mention double quotes
lolbinarycat Mar 18, 2025
7f29b47
normalize link titles
lolbinarycat Mar 18, 2025
eeda54f
update filename in link
lolbinarycat Mar 18, 2025
88478ac
Set linkcheck in `ci.yml`
Kobzol Mar 19, 2025
beb1c00
Merge pull request #2296 from jieyouxu/no-external-linkcheck
jieyouxu Mar 19, 2025
2daaf49
use correct code block markers
tshepang Mar 19, 2025
a9d3ed5
Merge pull request #2297 from rust-lang/tshepang-patch-1
tshepang Mar 19, 2025
594eed9
Merge pull request #2295 from lolbinarycat/rustdoc-htmldocck
jieyouxu Mar 20, 2025
904ec4d
Merge pull request #2199 from sagudev/patch-1
petrochenkov Mar 20, 2025
2de68a1
Update `ParamEnv` section for `TypingEnv` changes
BoxyUwU Mar 20, 2025
957aacd
Move Fuchsia and RfL under `ecosystem-test-jobs/` folder
jieyouxu Mar 21, 2025
d58ccd8
Stub out codegen backend test pages
jieyouxu Mar 21, 2025
cbcd286
Merge pull request #2265 from BoxyUwU/typing_env
lcnr Mar 21, 2025
ee6a159
doc: fix reference to #create-a-configtoml
chiichen Mar 23, 2025
dd91e28
Merge pull request #2300 from chiichen/dev/master/correct-config-to-b…
jieyouxu Mar 24, 2025
b34181a
Merge pull request #2299 from jieyouxu/test-jobs-reorg
jieyouxu Mar 24, 2025
de8b6be
add needed break
tshepang Mar 24, 2025
b08943a
Merge pull request #2302 from rust-lang/tshepang-patch-1
tshepang Mar 24, 2025
62ec34b
typo
tshepang Mar 24, 2025
8e0de0b
Merge pull request #2303 from rust-lang/tshepang-patch-2
tshepang Mar 24, 2025
a9a21bd
Delete from_method from rustc_on_unimplemented documentation
mejrs Mar 27, 2025
524d020
Merge pull request #2305 from mejrs/delete_from_method
tshepang Mar 27, 2025
cdbb219
Fix code generation link
spastorino Mar 28, 2025
8ab4141
Merge pull request #2306 from spastorino/fix-codegen-link
GuillaumeGomez Mar 28, 2025
5952f01
Fix trivial typo of `BoundVariableKind`
samueltardieu Mar 28, 2025
1be4bb4
Merge pull request #2307 from samueltardieu/push-xvxvkunupkmp
BoxyUwU Mar 28, 2025
865a5a7
mention that know-bug test directive takes arguments
tshepang Mar 29, 2025
70cbe19
Merge pull request #2288 from rust-lang/tshepang-known-bug-takes-args
jieyouxu Mar 29, 2025
9448b79
Merge pull request #2289 from y1lan/fix_compiler_err_of_examples
tshepang Mar 29, 2025
1faf7ff
update rustc-{driver,interface} examples
tshepang Mar 29, 2025
904fedf
Merge pull request #2308 from rust-lang/update-examples
tshepang Mar 29, 2025
471a2a8
example assumes a static exists
tshepang Mar 29, 2025
69f51ea
Merge pull request #2309 from rust-lang/restore-static
tshepang Mar 29, 2025
9302f4d
add rustfmt settings file
tshepang Mar 29, 2025
a27ec85
Merge pull request #2310 from rust-lang/add-rustfmt-file
jieyouxu Mar 30, 2025
ebae4c6
Fix partial clone link
clubby789 Mar 30, 2025
9f8e25f
Merge pull request #2311 from clubby789/partial-clone-link
jieyouxu Mar 30, 2025
05d5fda
Preparing for merge from rustc
jieyouxu Apr 2, 2025
cae5d8a
Merge from rustc
jieyouxu Apr 2, 2025
ead4d4c
Merge pull request #2313 from jieyouxu/rustc-pull
jieyouxu Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/doc/rustc-dev-guide/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
MDBOOK_LINKCHECK2_VERSION: 0.9.1
MDBOOK_MERMAID_VERSION: 0.12.6
MDBOOK_TOC_VERSION: 0.11.2
MDBOOK_OUTPUT__LINKCHECK__FOLLOW_WEB_LINKS: ${{ github.event_name != 'pull_request' }}
DEPLOY_DIR: book/html
BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion src/doc/rustc-dev-guide/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ warning-policy = "error"
"/diagnostics/sessiondiagnostic.html" = "diagnostic-structs.html"
"/diagnostics/diagnostic-codes.html" = "error-codes.html"
"/miri.html" = "const-eval/interpret.html"
"/tests/integration.html" = "ecosystem.html"
"/tests/fuchsia.html" = "ecosystem-test-jobs/fuchsia.html"
"/tests/headers.html" = "directives.html"
"/tests/integration.html" = "ecosystem.html"
"/tests/rust-for-linux.html" = "ecosystem-test-jobs/rust-for-linux.html"
155 changes: 30 additions & 125 deletions src/doc/rustc-dev-guide/ci/date-check/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use std::{
collections::BTreeMap,
convert::TryInto as _,
env, fmt, fs,
path::{Path, PathBuf},
process,
str::FromStr,
};
use std::collections::BTreeMap;
use std::convert::TryInto as _;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{env, fmt, fs, process};

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

impl Date {
fn months_since(self, other: Date) -> Option<u32> {
let self_chrono = Utc
.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0)
.unwrap();
let other_chrono = Utc
.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0)
.unwrap();
let self_chrono =
Utc.with_ymd_and_hms(self.year.try_into().unwrap(), self.month, 1, 0, 0, 0).unwrap();
let other_chrono =
Utc.with_ymd_and_hms(other.year.try_into().unwrap(), other.month, 1, 0, 0, 0).unwrap();
let duration_since = self_chrono.signed_duration_since(other_chrono);
let months_since = duration_since.num_days() / 30;
if months_since < 0 {
None
} else {
Some(months_since.try_into().unwrap())
}
if months_since < 0 { None } else { Some(months_since.try_into().unwrap()) }
}
}

Expand Down Expand Up @@ -66,26 +57,18 @@ fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)>
date_regex
.captures_iter(text)
.filter_map(|cap| {
if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) = (
cap.name("m1"),
cap.name("y1"),
cap.name("m2"),
cap.name("y2"),
) {
if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) =
(cap.name("m1"), cap.name("y1"), cap.name("m2"), cap.name("y2"))
{
let year = year.as_str().parse().expect("year");
let month = Month::from_str(month.as_str())
.expect("month")
.number_from_month();
let month = Month::from_str(month.as_str()).expect("month").number_from_month();
Some((cap.get(0).expect("all").range(), Date { year, month }))
} else {
None
}
})
.map(|(byte_range, date)| {
line += text[end_of_last_cap..byte_range.end]
.chars()
.filter(|c| *c == '\n')
.count();
line += text[end_of_last_cap..byte_range.end].chars().filter(|c| *c == '\n').count();
end_of_last_cap = byte_range.end;
(line, date)
})
Expand Down Expand Up @@ -138,10 +121,7 @@ fn main() {
let root_dir_path = Path::new(&root_dir);
let glob_pat = format!("{}/**/*.md", root_dir);
let today_chrono = Utc::now().date_naive();
let current_month = Date {
year: today_chrono.year_ce().1,
month: today_chrono.month(),
};
let current_month = Date { year: today_chrono.year_ce().1, month: today_chrono.month() };

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

for (path, dates) in dates_by_file {
println!(
"- {}",
path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),
);
println!("- {}", path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),);
for (line, date) in dates {
println!(" - [ ] line {}: {}", line, date);
}
Expand All @@ -191,14 +168,8 @@ mod tests {

#[test]
fn test_months_since() {
let date1 = Date {
year: 2020,
month: 3,
};
let date2 = Date {
year: 2021,
month: 1,
};
let date1 = Date { year: 2020, month: 3 };
let date2 = Date { year: 2021, month: 1 };
assert_eq!(date2.months_since(date1), Some(10));
}

Expand Down Expand Up @@ -273,83 +244,17 @@ Test8
assert_eq!(
collect_dates_from_file(&make_date_regex(), text),
vec![
(
3,
Date {
year: 2021,
month: 1,
}
),
(
6,
Date {
year: 2021,
month: 2,
}
),
(
9,
Date {
year: 2021,
month: 3,
}
),
(
11,
Date {
year: 2021,
month: 4,
}
),
(
17,
Date {
year: 2021,
month: 5,
}
),
(
20,
Date {
year: 2021,
month: 1,
}
),
(
23,
Date {
year: 2021,
month: 2,
}
),
(
26,
Date {
year: 2021,
month: 3,
}
),
(
28,
Date {
year: 2021,
month: 4,
}
),
(
34,
Date {
year: 2021,
month: 5,
}
),
(
38,
Date {
year: 2021,
month: 6,
}
),
(3, Date { year: 2021, month: 1 }),
(6, Date { year: 2021, month: 2 }),
(9, Date { year: 2021, month: 3 }),
(11, Date { year: 2021, month: 4 }),
(17, Date { year: 2021, month: 5 }),
(20, Date { year: 2021, month: 1 }),
(23, Date { year: 2021, month: 2 }),
(26, Date { year: 2021, month: 3 }),
(28, Date { year: 2021, month: 4 }),
(34, Date { year: 2021, month: 5 }),
(38, Date { year: 2021, month: 6 }),
],
);
}
Expand Down
16 changes: 7 additions & 9 deletions src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tested with nightly-2025-02-13
// Tested with nightly-2025-03-28

#![feature(rustc_private)]

Expand Down Expand Up @@ -34,9 +34,9 @@ impl rustc_span::source_map::FileLoader for MyFileLoader {
fn read_file(&self, path: &Path) -> io::Result<String> {
if path == Path::new("main.rs") {
Ok(r#"
static MESSAGE: &str = "Hello, World!";
fn main() {
let message = "Hello, World!";
println!("{message}");
println!("{MESSAGE}");
}
"#
.to_string())
Expand Down Expand Up @@ -71,14 +71,12 @@ impl rustc_driver::Callbacks for MyCallbacks {

fn after_analysis(&mut self, _compiler: &Compiler, tcx: TyCtxt<'_>) -> Compilation {
// Analyze the program and inspect the types of definitions.
for id in tcx.hir().items() {
let hir = tcx.hir();
let item = hir.item(id);
for id in tcx.hir_free_items() {
let item = &tcx.hir_item(id);
match item.kind {
rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => {
let name = item.ident;
rustc_hir::ItemKind::Static(ident, ..) | rustc_hir::ItemKind::Fn { ident, .. } => {
let ty = tcx.type_of(item.hir_id().owner.def_id);
println!("{name:?}:\t{ty:?}")
println!("{ident:?}:\t{ty:?}")
}
_ => (),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tested with nightly-2025-02-13
// Tested with nightly-2025-03-28

#![feature(rustc_private)]

Expand All @@ -20,7 +20,7 @@ use std::path::Path;
use std::sync::Arc;

use rustc_ast_pretty::pprust::item_to_string;
use rustc_driver::{run_compiler, Compilation};
use rustc_driver::{Compilation, run_compiler};
use rustc_interface::interface::{Compiler, Config};
use rustc_middle::ty::TyCtxt;

Expand Down Expand Up @@ -70,11 +70,9 @@ impl rustc_driver::Callbacks for MyCallbacks {
}

fn after_analysis(&mut self, _compiler: &Compiler, tcx: TyCtxt<'_>) -> Compilation {
// Every compilation contains a single crate.
let hir_krate = tcx.hir();
// Iterate over the top-level items in the crate, looking for the main function.
for id in hir_krate.items() {
let item = hir_krate.item(id);
for id in tcx.hir_free_items() {
let item = &tcx.hir_item(id);
// Use pattern-matching to find a specific node inside the main function.
if let rustc_hir::ItemKind::Fn { body, .. } = item.kind {
let expr = &tcx.hir_body(body).value;
Expand Down
13 changes: 6 additions & 7 deletions src/doc/rustc-dev-guide/examples/rustc-interface-example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tested with nightly-2025-02-13
// Tested with nightly-2025-03-28

#![feature(rustc_private)]

Expand Down Expand Up @@ -64,14 +64,13 @@ fn main() {
println!("{krate:?}");
// Analyze the program and inspect the types of definitions.
rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
for id in tcx.hir().items() {
let hir = tcx.hir();
let item = hir.item(id);
for id in tcx.hir_free_items() {
let item = tcx.hir_item(id);
match item.kind {
rustc_hir::ItemKind::Static(_, _, _) | rustc_hir::ItemKind::Fn { .. } => {
let name = item.ident;
rustc_hir::ItemKind::Static(ident, ..)
| rustc_hir::ItemKind::Fn { ident, .. } => {
let ty = tcx.type_of(item.hir_id().owner.def_id);
println!("{name:?}:\t{ty:?}")
println!("{ident:?}:\t{ty:?}")
}
_ => (),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tested with nightly-2025-02-13
// Tested with nightly-2025-03-28

#![feature(rustc_private)]

Expand Down Expand Up @@ -86,8 +86,10 @@ fn main() {
rustc_interface::run_compiler(config, |compiler| {
let krate = rustc_interface::passes::parse(&compiler.sess);
rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| {
// Run the analysis phase on the local crate to trigger the type error.
let _ = tcx.analysis(());
// Iterate all the items defined and perform type checking.
tcx.par_hir_body_owners(|item_def_id| {
tcx.ensure_ok().typeck(item_def_id);
});
});
// If the compiler has encountered errors when this closure returns, it will abort (!) the program.
// We avoid this by resetting the error count before returning
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
493c38ba371929579fe136df26eccd9516347c7a
ae9173d7dd4a31806c950c90dcc331f1508b4d17
7 changes: 7 additions & 0 deletions src/doc/rustc-dev-guide/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# matches that of rust-lang/rust
style_edition = "2024"
use_small_heuristics = "Max"
merge_derives = false
group_imports = "StdExternalCrate"
imports_granularity = "Module"
use_field_init_shorthand = true
Loading
Loading