Skip to content

Commit 5610d98

Browse files
committed
Auto merge of #115928 - matthiaskrgr:rollup-b88wic9, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #115558 (issue has since been fixed) - #115724 (Add myself to the mailmap) - #115795 (Refactor `opt-dist` to simplify local building) - #115811 (Make AIX known by bootstrap) - #115838 (inspect: closer to proof trees for coherence) - #115902 (Fix up a few CI images) - #115907 (nop_lift macros: ensure that we are using the right interner) - #115916 (Add me as on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 078eb11 + 8851323 commit 5610d98

File tree

30 files changed

+620
-374
lines changed

30 files changed

+620
-374
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ jobs:
393393
- name: dist-x86_64-msvc
394394
env:
395395
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --host=x86_64-pc-windows-msvc --target=x86_64-pc-windows-msvc --enable-full-tools --enable-profiler"
396-
SCRIPT: python x.py build --set rust.debug=true opt-dist && PGO_HOST=x86_64-pc-windows-msvc ./build/x86_64-pc-windows-msvc/stage0-tools-bin/opt-dist python x.py dist bootstrap --include-default-paths
396+
SCRIPT: python x.py build --set rust.debug=true opt-dist && PGO_HOST=x86_64-pc-windows-msvc ./build/x86_64-pc-windows-msvc/stage0-tools-bin/opt-dist windows-ci -- python x.py dist bootstrap --include-default-paths
397397
DIST_REQUIRE_ALL_TOOLS: 1
398398
os: windows-2019-8core-32gb
399399
- name: dist-i686-msvc

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ Timothy Maloney <[email protected]>
549549
Tomas Koutsky <[email protected]>
550550
Torsten Weber <[email protected]>
551551
552+
553+
552554
553555
Tshepang Mbambo <[email protected]>
554556
Ty Overby <[email protected]>

Cargo.lock

+72-4
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,38 @@ dependencies = [
858858
"winapi",
859859
]
860860

861+
[[package]]
862+
name = "darling"
863+
version = "0.14.4"
864+
source = "registry+https://github.com/rust-lang/crates.io-index"
865+
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
866+
dependencies = [
867+
"darling_core 0.14.4",
868+
"darling_macro 0.14.4",
869+
]
870+
861871
[[package]]
862872
name = "darling"
863873
version = "0.20.3"
864874
source = "registry+https://github.com/rust-lang/crates.io-index"
865875
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
866876
dependencies = [
867-
"darling_core",
868-
"darling_macro",
877+
"darling_core 0.20.3",
878+
"darling_macro 0.20.3",
879+
]
880+
881+
[[package]]
882+
name = "darling_core"
883+
version = "0.14.4"
884+
source = "registry+https://github.com/rust-lang/crates.io-index"
885+
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
886+
dependencies = [
887+
"fnv",
888+
"ident_case",
889+
"proc-macro2",
890+
"quote",
891+
"strsim",
892+
"syn 1.0.109",
869893
]
870894

871895
[[package]]
@@ -882,13 +906,24 @@ dependencies = [
882906
"syn 2.0.29",
883907
]
884908

909+
[[package]]
910+
name = "darling_macro"
911+
version = "0.14.4"
912+
source = "registry+https://github.com/rust-lang/crates.io-index"
913+
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
914+
dependencies = [
915+
"darling_core 0.14.4",
916+
"quote",
917+
"syn 1.0.109",
918+
]
919+
885920
[[package]]
886921
name = "darling_macro"
887922
version = "0.20.3"
888923
source = "registry+https://github.com/rust-lang/crates.io-index"
889924
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
890925
dependencies = [
891-
"darling_core",
926+
"darling_core 0.20.3",
892927
"quote",
893928
"syn 2.0.29",
894929
]
@@ -919,6 +954,37 @@ dependencies = [
919954
"syn 1.0.109",
920955
]
921956

957+
[[package]]
958+
name = "derive_builder"
959+
version = "0.12.0"
960+
source = "registry+https://github.com/rust-lang/crates.io-index"
961+
checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8"
962+
dependencies = [
963+
"derive_builder_macro",
964+
]
965+
966+
[[package]]
967+
name = "derive_builder_core"
968+
version = "0.12.0"
969+
source = "registry+https://github.com/rust-lang/crates.io-index"
970+
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
971+
dependencies = [
972+
"darling 0.14.4",
973+
"proc-macro2",
974+
"quote",
975+
"syn 1.0.109",
976+
]
977+
978+
[[package]]
979+
name = "derive_builder_macro"
980+
version = "0.12.0"
981+
source = "registry+https://github.com/rust-lang/crates.io-index"
982+
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
983+
dependencies = [
984+
"derive_builder_core",
985+
"syn 1.0.109",
986+
]
987+
922988
[[package]]
923989
name = "derive_more"
924990
version = "0.99.17"
@@ -938,7 +1004,7 @@ version = "0.1.6"
9381004
source = "registry+https://github.com/rust-lang/crates.io-index"
9391005
checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d"
9401006
dependencies = [
941-
"darling",
1007+
"darling 0.20.3",
9421008
"proc-macro2",
9431009
"quote",
9441010
"syn 2.0.29",
@@ -2584,6 +2650,8 @@ dependencies = [
25842650
"anyhow",
25852651
"build_helper",
25862652
"camino",
2653+
"clap",
2654+
"derive_builder",
25872655
"env_logger 0.10.0",
25882656
"fs_extra",
25892657
"glob",

compiler/rustc_middle/src/traits/solve/inspect.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,29 @@ pub enum CacheHit {
1414
Global,
1515
}
1616

17+
#[derive(Eq, PartialEq)]
18+
pub enum GoalEvaluationKind {
19+
Root,
20+
Nested { is_normalizes_to_hack: IsNormalizesToHack },
21+
}
22+
1723
#[derive(Eq, PartialEq)]
1824
pub struct GoalEvaluation<'tcx> {
1925
pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>,
20-
pub is_normalizes_to_hack: IsNormalizesToHack,
26+
pub kind: GoalEvaluationKind,
2127
pub evaluation: CanonicalGoalEvaluation<'tcx>,
2228
pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
2329
}
2430

2531
#[derive(Eq, PartialEq)]
2632
pub struct CanonicalGoalEvaluation<'tcx> {
2733
pub goal: CanonicalInput<'tcx>,
28-
pub kind: GoalEvaluationKind<'tcx>,
34+
pub kind: CanonicalGoalEvaluationKind<'tcx>,
2935
pub result: QueryResult<'tcx>,
3036
}
3137

3238
#[derive(Eq, PartialEq)]
33-
pub enum GoalEvaluationKind<'tcx> {
39+
pub enum CanonicalGoalEvaluationKind<'tcx> {
3440
Overflow,
3541
CacheHit(CacheHit),
3642
Uncached { revisions: Vec<GoalEvaluationStep<'tcx>> },
@@ -52,22 +58,31 @@ pub struct GoalEvaluationStep<'tcx> {
5258
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
5359

5460
/// The actual evaluation of the goal, always `ProbeKind::Root`.
55-
pub evaluation: GoalCandidate<'tcx>,
61+
pub evaluation: Probe<'tcx>,
5662
}
5763

64+
/// A self-contained computation during trait solving. This either
65+
/// corresponds to a `EvalCtxt::probe(_X)` call or the root evaluation
66+
/// of a goal.
5867
#[derive(Eq, PartialEq)]
59-
pub struct GoalCandidate<'tcx> {
60-
pub added_goals_evaluations: Vec<AddedGoalsEvaluation<'tcx>>,
61-
pub candidates: Vec<GoalCandidate<'tcx>>,
68+
pub struct Probe<'tcx> {
69+
pub steps: Vec<ProbeStep<'tcx>>,
6270
pub kind: ProbeKind<'tcx>,
6371
}
6472

65-
impl Debug for GoalCandidate<'_> {
73+
impl Debug for Probe<'_> {
6674
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67-
ProofTreeFormatter::new(f).format_candidate(self)
75+
ProofTreeFormatter::new(f).format_probe(self)
6876
}
6977
}
7078

79+
#[derive(Eq, PartialEq)]
80+
pub enum ProbeStep<'tcx> {
81+
AddGoal(Goal<'tcx, ty::Predicate<'tcx>>),
82+
EvaluateGoals(AddedGoalsEvaluation<'tcx>),
83+
NestedProbe(Probe<'tcx>),
84+
}
85+
7186
#[derive(Debug, PartialEq, Eq)]
7287
pub enum ProbeKind<'tcx> {
7388
/// The root inference context while proving a goal.

compiler/rustc_middle/src/traits/solve/inspect/format.rs

+19-15
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
4040
}
4141

4242
pub(super) fn format_goal_evaluation(&mut self, eval: &GoalEvaluation<'_>) -> std::fmt::Result {
43-
let goal_text = match eval.is_normalizes_to_hack {
44-
IsNormalizesToHack::Yes => "NORMALIZES-TO HACK GOAL",
45-
IsNormalizesToHack::No => "GOAL",
43+
let goal_text = match eval.kind {
44+
GoalEvaluationKind::Root => "ROOT GOAL",
45+
GoalEvaluationKind::Nested { is_normalizes_to_hack } => match is_normalizes_to_hack {
46+
IsNormalizesToHack::No => "GOAL",
47+
IsNormalizesToHack::Yes => "NORMALIZES-TO HACK GOAL",
48+
},
4649
};
4750
writeln!(self.f, "{}: {:?}", goal_text, eval.uncanonicalized_goal)?;
4851
self.nested(|this| this.format_canonical_goal_evaluation(&eval.evaluation))?;
@@ -68,16 +71,16 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
6871
writeln!(self.f, "GOAL: {:?}", eval.goal)?;
6972

7073
match &eval.kind {
71-
GoalEvaluationKind::Overflow => {
74+
CanonicalGoalEvaluationKind::Overflow => {
7275
writeln!(self.f, "OVERFLOW: {:?}", eval.result)
7376
}
74-
GoalEvaluationKind::CacheHit(CacheHit::Global) => {
77+
CanonicalGoalEvaluationKind::CacheHit(CacheHit::Global) => {
7578
writeln!(self.f, "GLOBAL CACHE HIT: {:?}", eval.result)
7679
}
77-
GoalEvaluationKind::CacheHit(CacheHit::Provisional) => {
80+
CanonicalGoalEvaluationKind::CacheHit(CacheHit::Provisional) => {
7881
writeln!(self.f, "PROVISIONAL CACHE HIT: {:?}", eval.result)
7982
}
80-
GoalEvaluationKind::Uncached { revisions } => {
83+
CanonicalGoalEvaluationKind::Uncached { revisions } => {
8184
for (n, step) in revisions.iter().enumerate() {
8285
writeln!(self.f, "REVISION {n}")?;
8386
self.nested(|this| this.format_evaluation_step(step))?;
@@ -92,11 +95,11 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
9295
evaluation_step: &GoalEvaluationStep<'_>,
9396
) -> std::fmt::Result {
9497
writeln!(self.f, "INSTANTIATED: {:?}", evaluation_step.instantiated_goal)?;
95-
self.format_candidate(&evaluation_step.evaluation)
98+
self.format_probe(&evaluation_step.evaluation)
9699
}
97100

98-
pub(super) fn format_candidate(&mut self, candidate: &GoalCandidate<'_>) -> std::fmt::Result {
99-
match &candidate.kind {
101+
pub(super) fn format_probe(&mut self, probe: &Probe<'_>) -> std::fmt::Result {
102+
match &probe.kind {
100103
ProbeKind::Root { result } => {
101104
writeln!(self.f, "ROOT RESULT: {result:?}")
102105
}
@@ -118,11 +121,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
118121
}?;
119122

120123
self.nested(|this| {
121-
for candidate in &candidate.candidates {
122-
this.format_candidate(candidate)?;
123-
}
124-
for nested in &candidate.added_goals_evaluations {
125-
this.format_added_goals_evaluation(nested)?;
124+
for step in &probe.steps {
125+
match step {
126+
ProbeStep::AddGoal(goal) => writeln!(this.f, "ADDED GOAL: {goal:?}")?,
127+
ProbeStep::EvaluateGoals(eval) => this.format_added_goals_evaluation(eval)?,
128+
ProbeStep::NestedProbe(probe) => this.format_probe(probe)?,
129+
}
126130
}
127131
Ok(())
128132
})

compiler/rustc_middle/src/ty/context.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,25 @@ macro_rules! nop_lift {
12141214
impl<'a, 'tcx> Lift<'tcx> for $ty {
12151215
type Lifted = $lifted;
12161216
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
1217+
// Assert that the set has the right type.
1218+
// Given an argument that has an interned type, the return type has the type of
1219+
// the corresponding interner set. This won't actually return anything, we're
1220+
// just doing this to compute said type!
1221+
fn _intern_set_ty_from_interned_ty<'tcx, Inner>(
1222+
_x: Interned<'tcx, Inner>,
1223+
) -> InternedSet<'tcx, Inner> {
1224+
unreachable!()
1225+
}
1226+
fn _type_eq<T>(_x: &T, _y: &T) {}
1227+
fn _test<'tcx>(x: $lifted, tcx: TyCtxt<'tcx>) {
1228+
// If `x` is a newtype around an `Interned<T>`, then `interner` is an
1229+
// interner of appropriate type. (Ideally we'd also check that `x` is a
1230+
// newtype with just that one field. Not sure how to do that.)
1231+
let interner = _intern_set_ty_from_interned_ty(x.0);
1232+
// Now check that this is the same type as `interners.$set`.
1233+
_type_eq(&interner, &tcx.interners.$set);
1234+
}
1235+
12171236
tcx.interners
12181237
.$set
12191238
.contains_pointer_to(&InternedInSet(&*self.0.0))
@@ -1230,6 +1249,11 @@ macro_rules! nop_list_lift {
12301249
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
12311250
type Lifted = &'tcx List<$lifted>;
12321251
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
1252+
// Assert that the set has the right type.
1253+
if false {
1254+
let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set;
1255+
}
1256+
12331257
if self.is_empty() {
12341258
return Some(List::empty());
12351259
}

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ use std::ops::ControlFlow;
2828
use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment};
2929

3030
use super::inspect::ProofTreeBuilder;
31-
use super::search_graph;
3231
use super::SolverMode;
32+
use super::{search_graph, GoalEvaluationKind};
3333
use super::{search_graph::SearchGraph, Goal};
3434
pub use select::InferCtxtSelectExt;
3535

@@ -85,7 +85,7 @@ pub struct EvalCtxt<'a, 'tcx> {
8585
// evaluation code.
8686
tainted: Result<(), NoSolution>,
8787

88-
inspect: ProofTreeBuilder<'tcx>,
88+
pub(super) inspect: ProofTreeBuilder<'tcx>,
8989
}
9090

9191
#[derive(Debug, Clone)]
@@ -164,7 +164,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
164164
Option<inspect::GoalEvaluation<'tcx>>,
165165
) {
166166
EvalCtxt::enter_root(self, generate_proof_tree, |ecx| {
167-
ecx.evaluate_goal(IsNormalizesToHack::No, goal)
167+
ecx.evaluate_goal(GoalEvaluationKind::Root, goal)
168168
})
169169
}
170170
}
@@ -340,11 +340,11 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
340340
/// been constrained and the certainty of the result.
341341
fn evaluate_goal(
342342
&mut self,
343-
is_normalizes_to_hack: IsNormalizesToHack,
343+
goal_evaluation_kind: GoalEvaluationKind,
344344
goal: Goal<'tcx, ty::Predicate<'tcx>>,
345345
) -> Result<(bool, Certainty, Vec<Goal<'tcx, ty::Predicate<'tcx>>>), NoSolution> {
346346
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
347-
let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, is_normalizes_to_hack);
347+
let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, goal_evaluation_kind);
348348
let encountered_overflow = self.search_graph.encountered_overflow();
349349
let canonical_response = EvalCtxt::evaluate_canonical_goal(
350350
self.tcx(),
@@ -389,7 +389,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
389389
// solver cycle.
390390
if cfg!(debug_assertions)
391391
&& has_changed
392-
&& is_normalizes_to_hack == IsNormalizesToHack::No
392+
&& !matches!(
393+
goal_evaluation_kind,
394+
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes }
395+
)
393396
&& !self.search_graph.in_cycle()
394397
{
395398
// The nested evaluation has to happen with the original state
@@ -561,8 +564,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
561564
},
562565
);
563566

564-
let (_, certainty, instantiate_goals) =
565-
self.evaluate_goal(IsNormalizesToHack::Yes, unconstrained_goal)?;
567+
let (_, certainty, instantiate_goals) = self.evaluate_goal(
568+
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes },
569+
unconstrained_goal,
570+
)?;
566571
self.add_goals(instantiate_goals);
567572

568573
// Finally, equate the goal's RHS with the unconstrained var.
@@ -596,8 +601,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
596601
}
597602

598603
for goal in goals.goals.drain(..) {
599-
let (has_changed, certainty, instantiate_goals) =
600-
self.evaluate_goal(IsNormalizesToHack::No, goal)?;
604+
let (has_changed, certainty, instantiate_goals) = self.evaluate_goal(
605+
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::No },
606+
goal,
607+
)?;
601608
self.add_goals(instantiate_goals);
602609
if has_changed {
603610
unchanged_certainty = None;

0 commit comments

Comments
 (0)