Auto merge of #115929 - matthiaskrgr:rollup-hhasy22, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #115558 (issue has since been fixed)
 - #115724 (Add myself to the mailmap)
 - #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)
 - #115908 (Do not clone MIR for const-prop lint.)
 - #115916 (Add me as on vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-09-18 11:56:46 +00:00
commit de68911f4a
16 changed files with 202 additions and 118 deletions

View File

@ -549,6 +549,8 @@ Timothy Maloney <tmaloney@pdx.edu>
Tomas Koutsky <tomas@stepnivlk.net> Tomas Koutsky <tomas@stepnivlk.net>
Torsten Weber <TorstenWeber12@gmail.com> Torsten Weber <TorstenWeber12@gmail.com>
Torsten Weber <TorstenWeber12@gmail.com> <torstenweber12@gmail.com> Torsten Weber <TorstenWeber12@gmail.com> <torstenweber12@gmail.com>
Trevor Gross <tmgross@umich.edu> <t.gross35@gmail.com>
Trevor Gross <tmgross@umich.edu> <tgross@intrepidcs.com>
Trevor Spiteri <tspiteri@ieee.org> <trevor.spiteri@um.edu.mt> Trevor Spiteri <tspiteri@ieee.org> <trevor.spiteri@um.edu.mt>
Tshepang Mbambo <tshepang@gmail.com> Tshepang Mbambo <tshepang@gmail.com>
Ty Overby <ty@pre-alpha.com> Ty Overby <ty@pre-alpha.com>

View File

@ -14,10 +14,16 @@ pub enum CacheHit {
Global, Global,
} }
#[derive(Eq, PartialEq)]
pub enum GoalEvaluationKind {
Root,
Nested { is_normalizes_to_hack: IsNormalizesToHack },
}
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
pub struct GoalEvaluation<'tcx> { pub struct GoalEvaluation<'tcx> {
pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>, pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>,
pub is_normalizes_to_hack: IsNormalizesToHack, pub kind: GoalEvaluationKind,
pub evaluation: CanonicalGoalEvaluation<'tcx>, pub evaluation: CanonicalGoalEvaluation<'tcx>,
pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>, pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
} }
@ -25,12 +31,12 @@ pub struct GoalEvaluation<'tcx> {
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
pub struct CanonicalGoalEvaluation<'tcx> { pub struct CanonicalGoalEvaluation<'tcx> {
pub goal: CanonicalInput<'tcx>, pub goal: CanonicalInput<'tcx>,
pub kind: GoalEvaluationKind<'tcx>, pub kind: CanonicalGoalEvaluationKind<'tcx>,
pub result: QueryResult<'tcx>, pub result: QueryResult<'tcx>,
} }
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
pub enum GoalEvaluationKind<'tcx> { pub enum CanonicalGoalEvaluationKind<'tcx> {
Overflow, Overflow,
CacheHit(CacheHit), CacheHit(CacheHit),
Uncached { revisions: Vec<GoalEvaluationStep<'tcx>> }, Uncached { revisions: Vec<GoalEvaluationStep<'tcx>> },
@ -52,22 +58,31 @@ pub struct GoalEvaluationStep<'tcx> {
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>, pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
/// The actual evaluation of the goal, always `ProbeKind::Root`. /// The actual evaluation of the goal, always `ProbeKind::Root`.
pub evaluation: GoalCandidate<'tcx>, pub evaluation: Probe<'tcx>,
} }
/// A self-contained computation during trait solving. This either
/// corresponds to a `EvalCtxt::probe(_X)` call or the root evaluation
/// of a goal.
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
pub struct GoalCandidate<'tcx> { pub struct Probe<'tcx> {
pub added_goals_evaluations: Vec<AddedGoalsEvaluation<'tcx>>, pub steps: Vec<ProbeStep<'tcx>>,
pub candidates: Vec<GoalCandidate<'tcx>>,
pub kind: ProbeKind<'tcx>, pub kind: ProbeKind<'tcx>,
} }
impl Debug for GoalCandidate<'_> { impl Debug for Probe<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
ProofTreeFormatter::new(f).format_candidate(self) ProofTreeFormatter::new(f).format_probe(self)
} }
} }
#[derive(Eq, PartialEq)]
pub enum ProbeStep<'tcx> {
AddGoal(Goal<'tcx, ty::Predicate<'tcx>>),
EvaluateGoals(AddedGoalsEvaluation<'tcx>),
NestedProbe(Probe<'tcx>),
}
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum ProbeKind<'tcx> { pub enum ProbeKind<'tcx> {
/// The root inference context while proving a goal. /// The root inference context while proving a goal.

View File

@ -40,9 +40,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
} }
pub(super) fn format_goal_evaluation(&mut self, eval: &GoalEvaluation<'_>) -> std::fmt::Result { pub(super) fn format_goal_evaluation(&mut self, eval: &GoalEvaluation<'_>) -> std::fmt::Result {
let goal_text = match eval.is_normalizes_to_hack { let goal_text = match eval.kind {
IsNormalizesToHack::Yes => "NORMALIZES-TO HACK GOAL", GoalEvaluationKind::Root => "ROOT GOAL",
GoalEvaluationKind::Nested { is_normalizes_to_hack } => match is_normalizes_to_hack {
IsNormalizesToHack::No => "GOAL", IsNormalizesToHack::No => "GOAL",
IsNormalizesToHack::Yes => "NORMALIZES-TO HACK GOAL",
},
}; };
writeln!(self.f, "{}: {:?}", goal_text, eval.uncanonicalized_goal)?; writeln!(self.f, "{}: {:?}", goal_text, eval.uncanonicalized_goal)?;
self.nested(|this| this.format_canonical_goal_evaluation(&eval.evaluation))?; self.nested(|this| this.format_canonical_goal_evaluation(&eval.evaluation))?;
@ -68,16 +71,16 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
writeln!(self.f, "GOAL: {:?}", eval.goal)?; writeln!(self.f, "GOAL: {:?}", eval.goal)?;
match &eval.kind { match &eval.kind {
GoalEvaluationKind::Overflow => { CanonicalGoalEvaluationKind::Overflow => {
writeln!(self.f, "OVERFLOW: {:?}", eval.result) writeln!(self.f, "OVERFLOW: {:?}", eval.result)
} }
GoalEvaluationKind::CacheHit(CacheHit::Global) => { CanonicalGoalEvaluationKind::CacheHit(CacheHit::Global) => {
writeln!(self.f, "GLOBAL CACHE HIT: {:?}", eval.result) writeln!(self.f, "GLOBAL CACHE HIT: {:?}", eval.result)
} }
GoalEvaluationKind::CacheHit(CacheHit::Provisional) => { CanonicalGoalEvaluationKind::CacheHit(CacheHit::Provisional) => {
writeln!(self.f, "PROVISIONAL CACHE HIT: {:?}", eval.result) writeln!(self.f, "PROVISIONAL CACHE HIT: {:?}", eval.result)
} }
GoalEvaluationKind::Uncached { revisions } => { CanonicalGoalEvaluationKind::Uncached { revisions } => {
for (n, step) in revisions.iter().enumerate() { for (n, step) in revisions.iter().enumerate() {
writeln!(self.f, "REVISION {n}")?; writeln!(self.f, "REVISION {n}")?;
self.nested(|this| this.format_evaluation_step(step))?; self.nested(|this| this.format_evaluation_step(step))?;
@ -92,11 +95,11 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
evaluation_step: &GoalEvaluationStep<'_>, evaluation_step: &GoalEvaluationStep<'_>,
) -> std::fmt::Result { ) -> std::fmt::Result {
writeln!(self.f, "INSTANTIATED: {:?}", evaluation_step.instantiated_goal)?; writeln!(self.f, "INSTANTIATED: {:?}", evaluation_step.instantiated_goal)?;
self.format_candidate(&evaluation_step.evaluation) self.format_probe(&evaluation_step.evaluation)
} }
pub(super) fn format_candidate(&mut self, candidate: &GoalCandidate<'_>) -> std::fmt::Result { pub(super) fn format_probe(&mut self, probe: &Probe<'_>) -> std::fmt::Result {
match &candidate.kind { match &probe.kind {
ProbeKind::Root { result } => { ProbeKind::Root { result } => {
writeln!(self.f, "ROOT RESULT: {result:?}") writeln!(self.f, "ROOT RESULT: {result:?}")
} }
@ -118,11 +121,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
}?; }?;
self.nested(|this| { self.nested(|this| {
for candidate in &candidate.candidates { for step in &probe.steps {
this.format_candidate(candidate)?; match step {
ProbeStep::AddGoal(goal) => writeln!(this.f, "ADDED GOAL: {goal:?}")?,
ProbeStep::EvaluateGoals(eval) => this.format_added_goals_evaluation(eval)?,
ProbeStep::NestedProbe(probe) => this.format_probe(probe)?,
} }
for nested in &candidate.added_goals_evaluations {
this.format_added_goals_evaluation(nested)?;
} }
Ok(()) Ok(())
}) })

View File

@ -1214,6 +1214,25 @@ macro_rules! nop_lift {
impl<'a, 'tcx> Lift<'tcx> for $ty { impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
// Assert that the set has the right type.
// Given an argument that has an interned type, the return type has the type of
// the corresponding interner set. This won't actually return anything, we're
// just doing this to compute said type!
fn _intern_set_ty_from_interned_ty<'tcx, Inner>(
_x: Interned<'tcx, Inner>,
) -> InternedSet<'tcx, Inner> {
unreachable!()
}
fn _type_eq<T>(_x: &T, _y: &T) {}
fn _test<'tcx>(x: $lifted, tcx: TyCtxt<'tcx>) {
// If `x` is a newtype around an `Interned<T>`, then `interner` is an
// interner of appropriate type. (Ideally we'd also check that `x` is a
// newtype with just that one field. Not sure how to do that.)
let interner = _intern_set_ty_from_interned_ty(x.0);
// Now check that this is the same type as `interners.$set`.
_type_eq(&interner, &tcx.interners.$set);
}
tcx.interners tcx.interners
.$set .$set
.contains_pointer_to(&InternedInSet(&*self.0.0)) .contains_pointer_to(&InternedInSet(&*self.0.0))
@ -1230,6 +1249,11 @@ macro_rules! nop_list_lift {
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
type Lifted = &'tcx List<$lifted>; type Lifted = &'tcx List<$lifted>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
// Assert that the set has the right type.
if false {
let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set;
}
if self.is_empty() { if self.is_empty() {
return Some(List::empty()); return Some(List::empty());
} }

View File

@ -105,25 +105,12 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
trace!("ConstProp starting for {:?}", def_id); trace!("ConstProp starting for {:?}", def_id);
let dummy_body = &Body::new(
body.source,
(*body.basic_blocks).to_owned(),
body.source_scopes.clone(),
body.local_decls.clone(),
Default::default(),
body.arg_count,
Default::default(),
body.span,
body.generator_kind(),
body.tainted_by_errors,
);
// FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold // FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
// constants, instead of just checking for const-folding succeeding. // constants, instead of just checking for const-folding succeeding.
// That would require a uniform one-def no-mutation analysis // That would require a uniform one-def no-mutation analysis
// and RPO (or recursing when needing the value of a local). // and RPO (or recursing when needing the value of a local).
let mut optimization_finder = ConstPropagator::new(body, dummy_body, tcx); let mut linter = ConstPropagator::new(body, tcx);
optimization_finder.visit_body(body); linter.visit_body(body);
trace!("ConstProp done for {:?}", def_id); trace!("ConstProp done for {:?}", def_id);
} }
@ -169,11 +156,7 @@ impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> {
} }
impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
fn new( fn new(body: &'mir Body<'tcx>, tcx: TyCtxt<'tcx>) -> ConstPropagator<'mir, 'tcx> {
body: &Body<'tcx>,
dummy_body: &'mir Body<'tcx>,
tcx: TyCtxt<'tcx>,
) -> ConstPropagator<'mir, 'tcx> {
let def_id = body.source.def_id(); let def_id = body.source.def_id();
let args = &GenericArgs::identity_for_item(tcx, def_id); let args = &GenericArgs::identity_for_item(tcx, def_id);
let param_env = tcx.param_env_reveal_all_normalized(def_id); let param_env = tcx.param_env_reveal_all_normalized(def_id);
@ -204,7 +187,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
ecx.push_stack_frame( ecx.push_stack_frame(
Instance::new(def_id, args), Instance::new(def_id, args),
dummy_body, body,
&ret, &ret,
StackPopCleanup::Root { cleanup: false }, StackPopCleanup::Root { cleanup: false },
) )

View File

@ -28,8 +28,8 @@ use std::ops::ControlFlow;
use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment}; use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment};
use super::inspect::ProofTreeBuilder; use super::inspect::ProofTreeBuilder;
use super::search_graph;
use super::SolverMode; use super::SolverMode;
use super::{search_graph, GoalEvaluationKind};
use super::{search_graph::SearchGraph, Goal}; use super::{search_graph::SearchGraph, Goal};
pub use select::InferCtxtSelectExt; pub use select::InferCtxtSelectExt;
@ -85,7 +85,7 @@ pub struct EvalCtxt<'a, 'tcx> {
// evaluation code. // evaluation code.
tainted: Result<(), NoSolution>, tainted: Result<(), NoSolution>,
inspect: ProofTreeBuilder<'tcx>, pub(super) inspect: ProofTreeBuilder<'tcx>,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -164,7 +164,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
Option<inspect::GoalEvaluation<'tcx>>, Option<inspect::GoalEvaluation<'tcx>>,
) { ) {
EvalCtxt::enter_root(self, generate_proof_tree, |ecx| { EvalCtxt::enter_root(self, generate_proof_tree, |ecx| {
ecx.evaluate_goal(IsNormalizesToHack::No, goal) ecx.evaluate_goal(GoalEvaluationKind::Root, goal)
}) })
} }
} }
@ -340,11 +340,11 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
/// been constrained and the certainty of the result. /// been constrained and the certainty of the result.
fn evaluate_goal( fn evaluate_goal(
&mut self, &mut self,
is_normalizes_to_hack: IsNormalizesToHack, goal_evaluation_kind: GoalEvaluationKind,
goal: Goal<'tcx, ty::Predicate<'tcx>>, goal: Goal<'tcx, ty::Predicate<'tcx>>,
) -> Result<(bool, Certainty, Vec<Goal<'tcx, ty::Predicate<'tcx>>>), NoSolution> { ) -> Result<(bool, Certainty, Vec<Goal<'tcx, ty::Predicate<'tcx>>>), NoSolution> {
let (orig_values, canonical_goal) = self.canonicalize_goal(goal); let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, is_normalizes_to_hack); let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, goal_evaluation_kind);
let encountered_overflow = self.search_graph.encountered_overflow(); let encountered_overflow = self.search_graph.encountered_overflow();
let canonical_response = EvalCtxt::evaluate_canonical_goal( let canonical_response = EvalCtxt::evaluate_canonical_goal(
self.tcx(), self.tcx(),
@ -389,7 +389,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
// solver cycle. // solver cycle.
if cfg!(debug_assertions) if cfg!(debug_assertions)
&& has_changed && has_changed
&& is_normalizes_to_hack == IsNormalizesToHack::No && !matches!(
goal_evaluation_kind,
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes }
)
&& !self.search_graph.in_cycle() && !self.search_graph.in_cycle()
{ {
// The nested evaluation has to happen with the original state // The nested evaluation has to happen with the original state
@ -561,8 +564,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
}, },
); );
let (_, certainty, instantiate_goals) = let (_, certainty, instantiate_goals) = self.evaluate_goal(
self.evaluate_goal(IsNormalizesToHack::Yes, unconstrained_goal)?; GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes },
unconstrained_goal,
)?;
self.add_goals(instantiate_goals); self.add_goals(instantiate_goals);
// Finally, equate the goal's RHS with the unconstrained var. // Finally, equate the goal's RHS with the unconstrained var.
@ -596,8 +601,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
} }
for goal in goals.goals.drain(..) { for goal in goals.goals.drain(..) {
let (has_changed, certainty, instantiate_goals) = let (has_changed, certainty, instantiate_goals) = self.evaluate_goal(
self.evaluate_goal(IsNormalizesToHack::No, goal)?; GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::No },
goal,
)?;
self.add_goals(instantiate_goals); self.add_goals(instantiate_goals);
if has_changed { if has_changed {
unchanged_certainty = None; unchanged_certainty = None;

View File

@ -24,13 +24,13 @@ where
search_graph: outer_ecx.search_graph, search_graph: outer_ecx.search_graph,
nested_goals: outer_ecx.nested_goals.clone(), nested_goals: outer_ecx.nested_goals.clone(),
tainted: outer_ecx.tainted, tainted: outer_ecx.tainted,
inspect: outer_ecx.inspect.new_goal_candidate(), inspect: outer_ecx.inspect.new_probe(),
}; };
let r = nested_ecx.infcx.probe(|_| f(&mut nested_ecx)); let r = nested_ecx.infcx.probe(|_| f(&mut nested_ecx));
if !outer_ecx.inspect.is_noop() { if !outer_ecx.inspect.is_noop() {
let probe_kind = probe_kind(&r); let probe_kind = probe_kind(&r);
nested_ecx.inspect.probe_kind(probe_kind); nested_ecx.inspect.probe_kind(probe_kind);
outer_ecx.inspect.goal_candidate(nested_ecx.inspect); outer_ecx.inspect.finish_probe(nested_ecx.inspect);
} }
r r
} }

View File

@ -7,13 +7,13 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::DumpSolverProofTree; use rustc_session::config::DumpSolverProofTree;
use super::eval_ctxt::UseGlobalCache; use super::eval_ctxt::UseGlobalCache;
use super::GenerateProofTree; use super::{GenerateProofTree, GoalEvaluationKind};
#[derive(Eq, PartialEq, Debug)] #[derive(Eq, PartialEq, Debug)]
pub struct WipGoalEvaluation<'tcx> { pub struct WipGoalEvaluation<'tcx> {
pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>, pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>,
pub kind: WipGoalEvaluationKind,
pub evaluation: Option<WipCanonicalGoalEvaluation<'tcx>>, pub evaluation: Option<WipCanonicalGoalEvaluation<'tcx>>,
pub is_normalizes_to_hack: IsNormalizesToHack,
pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>, pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
} }
@ -21,8 +21,13 @@ impl<'tcx> WipGoalEvaluation<'tcx> {
pub fn finalize(self) -> inspect::GoalEvaluation<'tcx> { pub fn finalize(self) -> inspect::GoalEvaluation<'tcx> {
inspect::GoalEvaluation { inspect::GoalEvaluation {
uncanonicalized_goal: self.uncanonicalized_goal, uncanonicalized_goal: self.uncanonicalized_goal,
kind: match self.kind {
WipGoalEvaluationKind::Root => inspect::GoalEvaluationKind::Root,
WipGoalEvaluationKind::Nested { is_normalizes_to_hack } => {
inspect::GoalEvaluationKind::Nested { is_normalizes_to_hack }
}
},
evaluation: self.evaluation.unwrap().finalize(), evaluation: self.evaluation.unwrap().finalize(),
is_normalizes_to_hack: self.is_normalizes_to_hack,
returned_goals: self.returned_goals, returned_goals: self.returned_goals,
} }
} }
@ -30,6 +35,12 @@ impl<'tcx> WipGoalEvaluation<'tcx> {
#[derive(Eq, PartialEq, Debug)] #[derive(Eq, PartialEq, Debug)]
pub enum WipGoalEvaluationKind { pub enum WipGoalEvaluationKind {
Root,
Nested { is_normalizes_to_hack: IsNormalizesToHack },
}
#[derive(Eq, PartialEq, Debug)]
pub enum WipCanonicalGoalEvaluationKind {
Overflow, Overflow,
CacheHit(CacheHit), CacheHit(CacheHit),
} }
@ -37,7 +48,7 @@ pub enum WipGoalEvaluationKind {
#[derive(Eq, PartialEq, Debug)] #[derive(Eq, PartialEq, Debug)]
pub struct WipCanonicalGoalEvaluation<'tcx> { pub struct WipCanonicalGoalEvaluation<'tcx> {
pub goal: CanonicalInput<'tcx>, pub goal: CanonicalInput<'tcx>,
pub kind: Option<WipGoalEvaluationKind>, pub kind: Option<WipCanonicalGoalEvaluationKind>,
pub revisions: Vec<WipGoalEvaluationStep<'tcx>>, pub revisions: Vec<WipGoalEvaluationStep<'tcx>>,
pub result: Option<QueryResult<'tcx>>, pub result: Option<QueryResult<'tcx>>,
} }
@ -45,11 +56,13 @@ pub struct WipCanonicalGoalEvaluation<'tcx> {
impl<'tcx> WipCanonicalGoalEvaluation<'tcx> { impl<'tcx> WipCanonicalGoalEvaluation<'tcx> {
pub fn finalize(self) -> inspect::CanonicalGoalEvaluation<'tcx> { pub fn finalize(self) -> inspect::CanonicalGoalEvaluation<'tcx> {
let kind = match self.kind { let kind = match self.kind {
Some(WipGoalEvaluationKind::Overflow) => inspect::GoalEvaluationKind::Overflow, Some(WipCanonicalGoalEvaluationKind::Overflow) => {
Some(WipGoalEvaluationKind::CacheHit(hit)) => { inspect::CanonicalGoalEvaluationKind::Overflow
inspect::GoalEvaluationKind::CacheHit(hit)
} }
None => inspect::GoalEvaluationKind::Uncached { Some(WipCanonicalGoalEvaluationKind::CacheHit(hit)) => {
inspect::CanonicalGoalEvaluationKind::CacheHit(hit)
}
None => inspect::CanonicalGoalEvaluationKind::Uncached {
revisions: self revisions: self
.revisions .revisions
.into_iter() .into_iter()
@ -87,7 +100,7 @@ impl<'tcx> WipAddedGoalsEvaluation<'tcx> {
pub struct WipGoalEvaluationStep<'tcx> { pub struct WipGoalEvaluationStep<'tcx> {
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>, pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,
pub evaluation: WipGoalCandidate<'tcx>, pub evaluation: WipProbe<'tcx>,
} }
impl<'tcx> WipGoalEvaluationStep<'tcx> { impl<'tcx> WipGoalEvaluationStep<'tcx> {
@ -102,26 +115,37 @@ impl<'tcx> WipGoalEvaluationStep<'tcx> {
} }
#[derive(Eq, PartialEq, Debug)] #[derive(Eq, PartialEq, Debug)]
pub struct WipGoalCandidate<'tcx> { pub struct WipProbe<'tcx> {
pub added_goals_evaluations: Vec<WipAddedGoalsEvaluation<'tcx>>, pub steps: Vec<WipProbeStep<'tcx>>,
pub candidates: Vec<WipGoalCandidate<'tcx>>,
pub kind: Option<ProbeKind<'tcx>>, pub kind: Option<ProbeKind<'tcx>>,
} }
impl<'tcx> WipGoalCandidate<'tcx> { impl<'tcx> WipProbe<'tcx> {
pub fn finalize(self) -> inspect::GoalCandidate<'tcx> { pub fn finalize(self) -> inspect::Probe<'tcx> {
inspect::GoalCandidate { inspect::Probe {
added_goals_evaluations: self steps: self.steps.into_iter().map(WipProbeStep::finalize).collect(),
.added_goals_evaluations
.into_iter()
.map(WipAddedGoalsEvaluation::finalize)
.collect(),
candidates: self.candidates.into_iter().map(WipGoalCandidate::finalize).collect(),
kind: self.kind.unwrap(), kind: self.kind.unwrap(),
} }
} }
} }
#[derive(Eq, PartialEq, Debug)]
pub enum WipProbeStep<'tcx> {
AddGoal(Goal<'tcx, ty::Predicate<'tcx>>),
EvaluateGoals(WipAddedGoalsEvaluation<'tcx>),
NestedProbe(WipProbe<'tcx>),
}
impl<'tcx> WipProbeStep<'tcx> {
pub fn finalize(self) -> inspect::ProbeStep<'tcx> {
match self {
WipProbeStep::AddGoal(goal) => inspect::ProbeStep::AddGoal(goal),
WipProbeStep::EvaluateGoals(eval) => inspect::ProbeStep::EvaluateGoals(eval.finalize()),
WipProbeStep::NestedProbe(probe) => inspect::ProbeStep::NestedProbe(probe.finalize()),
}
}
}
#[derive(Debug)] #[derive(Debug)]
pub enum DebugSolver<'tcx> { pub enum DebugSolver<'tcx> {
Root, Root,
@ -129,7 +153,7 @@ pub enum DebugSolver<'tcx> {
CanonicalGoalEvaluation(WipCanonicalGoalEvaluation<'tcx>), CanonicalGoalEvaluation(WipCanonicalGoalEvaluation<'tcx>),
AddedGoalsEvaluation(WipAddedGoalsEvaluation<'tcx>), AddedGoalsEvaluation(WipAddedGoalsEvaluation<'tcx>),
GoalEvaluationStep(WipGoalEvaluationStep<'tcx>), GoalEvaluationStep(WipGoalEvaluationStep<'tcx>),
GoalCandidate(WipGoalCandidate<'tcx>), Probe(WipProbe<'tcx>),
} }
impl<'tcx> From<WipGoalEvaluation<'tcx>> for DebugSolver<'tcx> { impl<'tcx> From<WipGoalEvaluation<'tcx>> for DebugSolver<'tcx> {
@ -156,9 +180,9 @@ impl<'tcx> From<WipGoalEvaluationStep<'tcx>> for DebugSolver<'tcx> {
} }
} }
impl<'tcx> From<WipGoalCandidate<'tcx>> for DebugSolver<'tcx> { impl<'tcx> From<WipProbe<'tcx>> for DebugSolver<'tcx> {
fn from(g: WipGoalCandidate<'tcx>) -> DebugSolver<'tcx> { fn from(p: WipProbe<'tcx>) -> DebugSolver<'tcx> {
DebugSolver::GoalCandidate(g) DebugSolver::Probe(p)
} }
} }
@ -249,15 +273,20 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
self.state.is_none() self.state.is_none()
} }
pub fn new_goal_evaluation( pub(super) fn new_goal_evaluation(
&mut self, &mut self,
goal: Goal<'tcx, ty::Predicate<'tcx>>, goal: Goal<'tcx, ty::Predicate<'tcx>>,
is_normalizes_to_hack: IsNormalizesToHack, kind: GoalEvaluationKind,
) -> ProofTreeBuilder<'tcx> { ) -> ProofTreeBuilder<'tcx> {
self.nested(|| WipGoalEvaluation { self.nested(|| WipGoalEvaluation {
uncanonicalized_goal: goal, uncanonicalized_goal: goal,
kind: match kind {
GoalEvaluationKind::Root => WipGoalEvaluationKind::Root,
GoalEvaluationKind::Nested { is_normalizes_to_hack } => {
WipGoalEvaluationKind::Nested { is_normalizes_to_hack }
}
},
evaluation: None, evaluation: None,
is_normalizes_to_hack,
returned_goals: vec![], returned_goals: vec![],
}) })
} }
@ -286,7 +315,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
} }
} }
pub fn goal_evaluation_kind(&mut self, kind: WipGoalEvaluationKind) { pub fn goal_evaluation_kind(&mut self, kind: WipCanonicalGoalEvaluationKind) {
if let Some(this) = self.as_mut() { if let Some(this) = self.as_mut() {
match this { match this {
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => { DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
@ -329,11 +358,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
) -> ProofTreeBuilder<'tcx> { ) -> ProofTreeBuilder<'tcx> {
self.nested(|| WipGoalEvaluationStep { self.nested(|| WipGoalEvaluationStep {
instantiated_goal, instantiated_goal,
evaluation: WipGoalCandidate { evaluation: WipProbe { steps: vec![], kind: None },
added_goals_evaluations: vec![],
candidates: vec![],
kind: None,
},
}) })
} }
pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<'tcx>) { pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<'tcx>) {
@ -350,18 +375,14 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
} }
} }
pub fn new_goal_candidate(&mut self) -> ProofTreeBuilder<'tcx> { pub fn new_probe(&mut self) -> ProofTreeBuilder<'tcx> {
self.nested(|| WipGoalCandidate { self.nested(|| WipProbe { steps: vec![], kind: None })
added_goals_evaluations: vec![],
candidates: vec![],
kind: None,
})
} }
pub fn probe_kind(&mut self, probe_kind: ProbeKind<'tcx>) { pub fn probe_kind(&mut self, probe_kind: ProbeKind<'tcx>) {
if let Some(this) = self.as_mut() { if let Some(this) = self.as_mut() {
match this { match this {
DebugSolver::GoalCandidate(this) => { DebugSolver::Probe(this) => {
assert_eq!(this.kind.replace(probe_kind), None) assert_eq!(this.kind.replace(probe_kind), None)
} }
_ => unreachable!(), _ => unreachable!(),
@ -369,17 +390,32 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
} }
} }
pub fn goal_candidate(&mut self, candidate: ProofTreeBuilder<'tcx>) { pub fn add_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) {
if let Some(this) = self.as_mut() { if let Some(this) = self.as_mut() {
match (this, candidate.state.unwrap().tree) { match this {
DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
evaluation: WipProbe { steps, .. },
..
})
| DebugSolver::Probe(WipProbe { steps, .. }) => {
steps.push(WipProbeStep::AddGoal(goal))
}
_ => unreachable!(),
}
}
}
pub fn finish_probe(&mut self, probe: ProofTreeBuilder<'tcx>) {
if let Some(this) = self.as_mut() {
match (this, probe.state.unwrap().tree) {
( (
DebugSolver::GoalCandidate(WipGoalCandidate { candidates, .. }) DebugSolver::Probe(WipProbe { steps, .. })
| DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep { | DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
evaluation: WipGoalCandidate { candidates, .. }, evaluation: WipProbe { steps, .. },
.. ..
}), }),
DebugSolver::GoalCandidate(candidate), DebugSolver::Probe(probe),
) => candidates.push(candidate), ) => steps.push(WipProbeStep::NestedProbe(probe)),
_ => unreachable!(), _ => unreachable!(),
} }
} }
@ -416,14 +452,12 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
match (this, added_goals_evaluation.state.unwrap().tree) { match (this, added_goals_evaluation.state.unwrap().tree) {
( (
DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep { DebugSolver::GoalEvaluationStep(WipGoalEvaluationStep {
evaluation: WipGoalCandidate { added_goals_evaluations, .. }, evaluation: WipProbe { steps, .. },
.. ..
}) })
| DebugSolver::GoalCandidate(WipGoalCandidate { | DebugSolver::Probe(WipProbe { steps, .. }),
added_goals_evaluations, ..
}),
DebugSolver::AddedGoalsEvaluation(added_goals_evaluation), DebugSolver::AddedGoalsEvaluation(added_goals_evaluation),
) => added_goals_evaluations.push(added_goals_evaluation), ) => steps.push(WipProbeStep::EvaluateGoals(added_goals_evaluation)),
_ => unreachable!(), _ => unreachable!(),
} }
} }

View File

@ -19,7 +19,8 @@ use rustc_infer::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::query::NoSolution;
use rustc_middle::infer::canonical::CanonicalVarInfos; use rustc_middle::infer::canonical::CanonicalVarInfos;
use rustc_middle::traits::solve::{ use rustc_middle::traits::solve::{
CanonicalResponse, Certainty, ExternalConstraintsData, Goal, QueryResult, Response, CanonicalResponse, Certainty, ExternalConstraintsData, Goal, IsNormalizesToHack, QueryResult,
Response,
}; };
use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex}; use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex};
use rustc_middle::ty::{ use rustc_middle::ty::{
@ -59,6 +60,12 @@ enum SolverMode {
Coherence, Coherence,
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum GoalEvaluationKind {
Root,
Nested { is_normalizes_to_hack: IsNormalizesToHack },
}
trait CanonicalResponseExt { trait CanonicalResponseExt {
fn has_no_inference_or_external_constraints(&self) -> bool; fn has_no_inference_or_external_constraints(&self) -> bool;
@ -228,6 +235,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
#[instrument(level = "debug", skip(self))] #[instrument(level = "debug", skip(self))]
fn add_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) { fn add_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) {
self.inspect.add_goal(goal);
self.nested_goals.goals.push(goal); self.nested_goals.goals.push(goal);
} }

View File

@ -187,7 +187,7 @@ impl<'tcx> SearchGraph<'tcx> {
last.encountered_overflow = true; last.encountered_overflow = true;
} }
inspect.goal_evaluation_kind(inspect::WipGoalEvaluationKind::Overflow); inspect.goal_evaluation_kind(inspect::WipCanonicalGoalEvaluationKind::Overflow);
return Self::response_no_constraints(tcx, input, Certainty::OVERFLOW); return Self::response_no_constraints(tcx, input, Certainty::OVERFLOW);
}; };
@ -203,7 +203,7 @@ impl<'tcx> SearchGraph<'tcx> {
available_depth, available_depth,
) )
{ {
inspect.goal_evaluation_kind(inspect::WipGoalEvaluationKind::CacheHit( inspect.goal_evaluation_kind(inspect::WipCanonicalGoalEvaluationKind::CacheHit(
CacheHit::Global, CacheHit::Global,
)); ));
self.on_cache_hit(reached_depth, encountered_overflow); self.on_cache_hit(reached_depth, encountered_overflow);
@ -240,7 +240,7 @@ impl<'tcx> SearchGraph<'tcx> {
// Finally we can return either the provisional response for that goal if we have a // Finally we can return either the provisional response for that goal if we have a
// coinductive cycle or an ambiguous result if the cycle is inductive. // coinductive cycle or an ambiguous result if the cycle is inductive.
Entry::Occupied(entry_index) => { Entry::Occupied(entry_index) => {
inspect.goal_evaluation_kind(inspect::WipGoalEvaluationKind::CacheHit( inspect.goal_evaluation_kind(inspect::WipCanonicalGoalEvaluationKind::CacheHit(
CacheHit::Provisional, CacheHit::Provisional,
)); ));

View File

@ -458,7 +458,6 @@ changelog-seen = 2
# Sets the number of codegen units to build the standard library with, # Sets the number of codegen units to build the standard library with,
# regardless of what the codegen-unit setting for the rest of the compiler is. # regardless of what the codegen-unit setting for the rest of the compiler is.
# NOTE: building with anything other than 1 is known to occasionally have bugs. # NOTE: building with anything other than 1 is known to occasionally have bugs.
# See https://github.com/rust-lang/rust/issues/83600.
#codegen-units-std = codegen-units #codegen-units-std = codegen-units
# Whether or not debug assertions are enabled for the compiler and standard library. # Whether or not debug assertions are enabled for the compiler and standard library.

View File

@ -312,6 +312,14 @@ def default_build_triple(verbose):
# non-standard string (e.g. gnuwin32 tools returns `windows32`). In # non-standard string (e.g. gnuwin32 tools returns `windows32`). In
# these cases, fall back to using sys.platform. # these cases, fall back to using sys.platform.
return 'x86_64-pc-windows-msvc' return 'x86_64-pc-windows-msvc'
elif kernel == 'AIX':
# `uname -m` returns the machine ID rather than machine hardware on AIX,
# so we are unable to use cputype to form triple. AIX 7.2 and
# above supports 32-bit and 64-bit mode simultaneously and `uname -p`
# returns `powerpc`, however we only supports `powerpc64-ibm-aix` in
# rust on AIX. For above reasons, kerneltype_mapper and cputype_mapper
# are not used to infer AIX's triple.
return 'powerpc64-ibm-aix'
else: else:
err = "unknown OS type: {}".format(kernel) err = "unknown OS type: {}".format(kernel)
sys.exit(err) sys.exit(err)

View File

@ -1,4 +1,4 @@
FROM ubuntu:22.10 FROM ubuntu:23.04
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
COPY scripts/android-base-apt-get.sh /scripts/ COPY scripts/android-base-apt-get.sh /scripts/

View File

@ -1,4 +1,4 @@
FROM ubuntu:22.10 FROM ubuntu:23.04
COPY scripts/android-base-apt-get.sh /scripts/ COPY scripts/android-base-apt-get.sh /scripts/
RUN sh /scripts/android-base-apt-get.sh RUN sh /scripts/android-base-apt-get.sh

View File

@ -2,5 +2,5 @@
set -ex set -ex
curl https://static.redox-os.org/toolchain/x86_64-unknown-redox/relibc-install.tar.gz | \ curl https://ci-mirrors.rust-lang.org/rustc/2022-11-27-relibc-install.tar.gz | \
tar --extract --gzip --directory /usr/local tar --extract --gzip --directory /usr/local

View File

@ -585,7 +585,7 @@ cc = ["@nnethercote"]
[assign] [assign]
warn_non_default_branch = true warn_non_default_branch = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html" contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = ["jyn514"] users_on_vacation = ["jyn514", "jackh726"]
[assign.adhoc_groups] [assign.adhoc_groups]
compiler-team = [ compiler-team = [