Skip to content

Commit f01b544

Browse files
committed
Auto merge of #123010 - matthiaskrgr:rollup-bh9dtqe, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #120557 (Add rust-lldb pretty printing for Path and PathBuf) - #121051 (Introduce infrastructure for generating target docs) - #122892 (fix(bootstrap/dist): use versioned dirs when vendoring) - #122896 (Update stdarch submodule) - #122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.) - #122970 (Use `chunk_by` when building `ReverseSccGraph`) - #123003 (CFI: Handle dyn with no principal) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0824b30 + 3014ac3 commit f01b544

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1382
-148
lines changed

Cargo.lock

+36
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,12 @@ version = "0.3.1"
15851585
source = "registry+https://github.com/rust-lang/crates.io-index"
15861586
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
15871587

1588+
[[package]]
1589+
name = "glob-match"
1590+
version = "0.2.1"
1591+
source = "registry+https://github.com/rust-lang/crates.io-index"
1592+
checksum = "9985c9503b412198aa4197559e9a318524ebc4519c229bfa05a535828c950b9d"
1593+
15881594
[[package]]
15891595
name = "globset"
15901596
version = "0.4.13"
@@ -5057,6 +5063,19 @@ dependencies = [
50575063
"serde",
50585064
]
50595065

5066+
[[package]]
5067+
name = "serde_yaml"
5068+
version = "0.9.31"
5069+
source = "registry+https://github.com/rust-lang/crates.io-index"
5070+
checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e"
5071+
dependencies = [
5072+
"indexmap",
5073+
"itoa",
5074+
"ryu",
5075+
"serde",
5076+
"unsafe-libyaml",
5077+
]
5078+
50605079
[[package]]
50615080
name = "sha1"
50625081
version = "0.10.6"
@@ -5419,6 +5438,17 @@ dependencies = [
54195438
"xattr",
54205439
]
54215440

5441+
[[package]]
5442+
name = "target-docs"
5443+
version = "0.1.0"
5444+
dependencies = [
5445+
"eyre",
5446+
"glob-match",
5447+
"serde",
5448+
"serde_json",
5449+
"serde_yaml",
5450+
]
5451+
54225452
[[package]]
54235453
name = "tempfile"
54245454
version = "3.10.1"
@@ -6065,6 +6095,12 @@ dependencies = [
60656095
"diff",
60666096
]
60676097

6098+
[[package]]
6099+
name = "unsafe-libyaml"
6100+
version = "0.2.10"
6101+
source = "registry+https://github.com/rust-lang/crates.io-index"
6102+
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
6103+
60686104
[[package]]
60696105
name = "unstable-book-gen"
60706106
version = "0.1.0"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ members = [
4646
"src/tools/rustdoc-gui-test",
4747
"src/tools/opt-dist",
4848
"src/tools/coverage-dump",
49+
"src/tools/target-docs",
4950
]
5051

5152
exclude = [

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::constraints::ConstraintSccIndex;
22
use crate::RegionInferenceContext;
3-
use itertools::Itertools;
43
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
54
use rustc_data_structures::graph::vec_graph::VecGraph;
65
use rustc_data_structures::graph::WithSuccessors;
@@ -48,16 +47,16 @@ impl RegionInferenceContext<'_> {
4847
.universal_regions
4948
.universal_regions()
5049
.map(|region| (self.constraint_sccs.scc(region), region))
51-
.collect_vec();
50+
.collect::<Vec<_>>();
5251
paired_scc_regions.sort();
5352
let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect();
5453

5554
let mut scc_regions = FxIndexMap::default();
5655
let mut start = 0;
57-
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
58-
let group_size = group.count();
59-
scc_regions.insert(scc, start..start + group_size);
60-
start += group_size;
56+
for chunk in paired_scc_regions.chunk_by(|&(scc1, _), &(scc2, _)| scc1 == scc2) {
57+
let (scc, _) = chunk[0];
58+
scc_regions.insert(scc, start..start + chunk.len());
59+
start += chunk.len();
6160
}
6261

6362
self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });

compiler/rustc_middle/src/ty/print/pretty.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
804804
}
805805
ty::Str => p!("str"),
806806
ty::Coroutine(did, args) => {
807-
p!(write("{{"));
807+
p!("{{");
808808
let coroutine_kind = self.tcx().coroutine_kind(did).unwrap();
809809
let should_print_movability = self.should_print_verbose()
810810
|| matches!(coroutine_kind, hir::CoroutineKind::Coroutine(_));
@@ -818,17 +818,25 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
818818

819819
if !self.should_print_verbose() {
820820
p!(write("{}", coroutine_kind));
821-
// FIXME(eddyb) should use `def_span`.
822-
if let Some(did) = did.as_local() {
823-
let span = self.tcx().def_span(did);
821+
if coroutine_kind.is_fn_like() {
822+
// If we are printing an `async fn` coroutine type, then give the path
823+
// of the fn, instead of its span, because that will in most cases be
824+
// more helpful for the reader than just a source location.
825+
//
826+
// This will look like:
827+
// {async fn body of some_fn()}
828+
let did_of_the_fn_item = self.tcx().parent(did);
829+
p!(" of ", print_def_path(did_of_the_fn_item, args), "()");
830+
} else if let Some(local_did) = did.as_local() {
831+
let span = self.tcx().def_span(local_did);
824832
p!(write(
825833
"@{}",
826834
// This may end up in stderr diagnostics but it may also be emitted
827835
// into MIR. Hence we use the remapped path if available
828836
self.tcx().sess.source_map().span_to_embeddable_string(span)
829837
));
830838
} else {
831-
p!(write("@"), print_def_path(did, args));
839+
p!("@", print_def_path(did, args));
832840
}
833841
} else {
834842
p!(print_def_path(did, args));

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,8 @@ fn transform_predicates<'tcx>(
747747
tcx: TyCtxt<'tcx>,
748748
predicates: &List<ty::PolyExistentialPredicate<'tcx>>,
749749
) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
750-
let predicates: Vec<ty::PolyExistentialPredicate<'tcx>> = predicates
751-
.iter()
752-
.filter_map(|predicate| match predicate.skip_binder() {
750+
tcx.mk_poly_existential_predicates_from_iter(predicates.iter().filter_map(|predicate| {
751+
match predicate.skip_binder() {
753752
ty::ExistentialPredicate::Trait(trait_ref) => {
754753
let trait_ref = ty::TraitRef::identity(tcx, trait_ref.def_id);
755754
Some(ty::Binder::dummy(ty::ExistentialPredicate::Trait(
@@ -758,9 +757,8 @@ fn transform_predicates<'tcx>(
758757
}
759758
ty::ExistentialPredicate::Projection(..) => None,
760759
ty::ExistentialPredicate::AutoTrait(..) => Some(predicate),
761-
})
762-
.collect();
763-
tcx.mk_poly_existential_predicates(&predicates)
760+
}
761+
}))
764762
}
765763

766764
/// Transforms args for being encoded and used in the substitution dictionary.
@@ -1171,14 +1169,17 @@ fn strip_receiver_auto<'tcx>(
11711169
let ty::Dynamic(preds, lifetime, kind) = ty.kind() else {
11721170
bug!("Tried to strip auto traits from non-dynamic type {ty}");
11731171
};
1174-
let filtered_preds =
1175-
if preds.principal().is_some() {
1172+
let new_rcvr = if preds.principal().is_some() {
1173+
let filtered_preds =
11761174
tcx.mk_poly_existential_predicates_from_iter(preds.into_iter().filter(|pred| {
11771175
!matches!(pred.skip_binder(), ty::ExistentialPredicate::AutoTrait(..))
1178-
}))
1179-
} else {
1180-
ty::List::empty()
1181-
};
1182-
let new_rcvr = Ty::new_dynamic(tcx, filtered_preds, *lifetime, *kind);
1176+
}));
1177+
Ty::new_dynamic(tcx, filtered_preds, *lifetime, *kind)
1178+
} else {
1179+
// If there's no principal type, re-encode it as a unit, since we don't know anything
1180+
// about it. This technically discards the knowledge that it was a type that was made
1181+
// into a trait object at some point, but that's not a lot.
1182+
tcx.types.unit
1183+
};
11831184
tcx.mk_args_trait(new_rcvr, args.into_iter().skip(1))
11841185
}

compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub fn target() -> Target {
66
Target {
77
llvm_target: tvos_llvm_target(arch).into(),
88
metadata: crate::spec::TargetMetadata {
9-
description: None,
10-
tier: None,
11-
host_tools: None,
9+
description: Some("ARM64 tvOS".into()),
10+
tier: Some(2),
11+
host_tools: Some(false),
1212
std: None,
1313
},
1414
pointer_width: 64,

compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ pub fn target() -> Target {
1818
Target {
1919
llvm_target: "i686-pc-windows-gnu".into(),
2020
metadata: crate::spec::TargetMetadata {
21-
description: None,
22-
tier: None,
23-
host_tools: None,
24-
std: None,
21+
description: Some("32-bit MinGW (Windows 7+)".into()),
22+
tier: Some(1),
23+
host_tools: Some(true),
24+
std: Some(true),
2525
},
2626
pointer_width: 32,
2727
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ pub fn target() -> Target {
44
Target {
55
llvm_target: "loongarch64-unknown-linux-gnu".into(),
66
metadata: crate::spec::TargetMetadata {
7-
description: None,
8-
tier: None,
9-
host_tools: None,
10-
std: None,
7+
description: Some("LoongArch64 Linux, LP64D ABI (kernel 5.19, glibc 2.36)".into()),
8+
tier: Some(2),
9+
host_tools: Some(true),
10+
std: Some(true),
1111
},
1212
pointer_width: 64,
1313
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),

compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-ibm-aix".into(),
1313
metadata: crate::spec::TargetMetadata {
14-
description: None,
15-
tier: None,
16-
host_tools: None,
17-
std: None,
14+
description: Some("64-bit AIX (7.2 and newer)".into()),
15+
tier: Some(3),
16+
host_tools: Some(true),
17+
std: Some(true),
1818
},
1919
pointer_width: 64,
2020
data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@
270270
#![feature(arm_target_feature)]
271271
#![feature(avx512_target_feature)]
272272
#![feature(hexagon_target_feature)]
273+
#![feature(loongarch_target_feature)]
273274
#![feature(mips_target_feature)]
274275
#![feature(powerpc_target_feature)]
275276
#![feature(riscv_target_feature)]

library/stdarch

Submodule stdarch updated 68 files

src/bootstrap/src/core/build_steps/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ impl Step for PlainSourceTarball {
10031003
// Vendor all Cargo dependencies
10041004
let mut cmd = Command::new(&builder.initial_cargo);
10051005
cmd.arg("vendor")
1006+
.arg("--versioned-dirs")
10061007
.arg("--sync")
10071008
.arg(builder.src.join("./src/tools/cargo/Cargo.toml"))
10081009
.arg("--sync")

src/bootstrap/src/core/build_steps/doc.rs

+27-4
Original file line numberDiff line numberDiff line change
@@ -1147,14 +1147,17 @@ impl Step for RustcBook {
11471147

11481148
/// Builds the rustc book.
11491149
///
1150-
/// The lints are auto-generated by a tool, and then merged into the book
1150+
/// The lints and target docs are auto-generated by a tool, and then merged into the book
11511151
/// in the "md-doc" directory in the build output directory. Then
11521152
/// "rustbook" is used to convert it to HTML.
11531153
fn run(self, builder: &Builder<'_>) {
11541154
let out_base = builder.md_doc_out(self.target).join("rustc");
11551155
t!(fs::create_dir_all(&out_base));
1156-
let out_listing = out_base.join("src/lints");
1157-
builder.cp_link_r(&builder.src.join("src/doc/rustc"), &out_base);
1156+
let out_lints_listing = out_base.join("src/lints");
1157+
let out_src_listing = out_base.join("src");
1158+
1159+
// target-docs will be modifying the files in-place, so we need an actual copy.
1160+
builder.cp_r(&builder.src.join("src/doc/rustc"), &out_base);
11581161
builder.info(&format!("Generating lint docs ({})", self.target));
11591162

11601163
let rustc = builder.rustc(self.compiler);
@@ -1165,7 +1168,7 @@ impl Step for RustcBook {
11651168
cmd.arg("--src");
11661169
cmd.arg(builder.src.join("compiler"));
11671170
cmd.arg("--out");
1168-
cmd.arg(&out_listing);
1171+
cmd.arg(&out_lints_listing);
11691172
cmd.arg("--rustc");
11701173
cmd.arg(&rustc);
11711174
cmd.arg("--rustc-target").arg(self.target.rustc_target_arg());
@@ -1194,6 +1197,26 @@ impl Step for RustcBook {
11941197
builder.run(&mut cmd);
11951198
drop(doc_generator_guard);
11961199

1200+
// Run target-docs generator
1201+
let mut cmd = builder.tool_cmd(Tool::TargetDocs);
1202+
cmd.arg(builder.src.join("src/doc/rustc/target_infos"));
1203+
cmd.arg(&out_src_listing);
1204+
cmd.env("RUSTC", &rustc);
1205+
// For now, we just check that the files are correct but do not generate output.
1206+
// Let the user override it to TARGET_CHECK_ONLY=0 for testing, but use 1 by default.
1207+
// See https://github.com/rust-lang/rust/issues/120745 for more info.
1208+
cmd.env("TARGET_CHECK_ONLY", std::env::var("TARGET_CHECK_ONLY").unwrap_or("1".to_owned()));
1209+
1210+
let doc_generator_guard = builder.msg(
1211+
Kind::Run,
1212+
self.compiler.stage,
1213+
"target-docs",
1214+
self.compiler.host,
1215+
self.target,
1216+
);
1217+
builder.run(&mut cmd);
1218+
drop(doc_generator_guard);
1219+
11971220
// Run rustbook/mdbook to generate the HTML pages.
11981221
builder.ensure(RustbookSrc {
11991222
target: self.target,

src/bootstrap/src/core/build_steps/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ bootstrap_tool!(
301301
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
302302
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
303303
LintDocs, "src/tools/lint-docs", "lint-docs";
304+
TargetDocs, "src/tools/target-docs", "target-docs";
304305
JsonDocCk, "src/tools/jsondocck", "jsondocck";
305306
JsonDocLint, "src/tools/jsondoclint", "jsondoclint";
306307
HtmlChecker, "src/tools/html-checker", "html-checker";

0 commit comments

Comments
 (0)