Skip to content

Rollup of 8 pull requests #115928

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

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
86d32ef
issue has since been fixed
tshepang Sep 5, 2023
7db123d
Add myself to the mailmap
tgross35 Sep 10, 2023
074fb2c
Store target triple in environment
Kobzol Sep 12, 2023
95500f4
Make executable extension platform, rather than environment dependent
Kobzol Sep 12, 2023
f17047b
Refactor Environment
Kobzol Sep 12, 2023
a2ed508
Fix `reset_directory` function
Kobzol Sep 12, 2023
11f9283
Add a Local environment to `opt-dist`
Kobzol Sep 12, 2023
2962528
Make AIX known by bootstrap
Sep 13, 2023
fc17e09
Add comment to elaborate
Sep 13, 2023
5049a71
Adjust comment
Sep 13, 2023
122d1cc
Adjust comment
Sep 13, 2023
6c718b5
Refactor rustc-perf building
Kobzol Sep 13, 2023
f13b545
Resolve clippy warnings
Kobzol Sep 13, 2023
be9d7e0
`GoalCandidate` to `Probe`
lcnr Sep 14, 2023
a3f9530
order `added_goals_evaluation` and `nested_probes`
lcnr Sep 14, 2023
1b141b6
inspect: explicitly store added goals
lcnr Sep 14, 2023
0cb800e
differentiate root and nested goals
lcnr Sep 14, 2023
5b882ac
Bump to supported Ubuntu
Mark-Simulacrum Sep 12, 2023
abd265e
Move to older, mirrored redox install
Mark-Simulacrum Sep 13, 2023
c70ee68
Add me as on vacation
jackh726 Sep 17, 2023
3b817b2
nop_lift macros: ensure that we are using the right interner
RalfJung Sep 17, 2023
a716c96
address review comment
tshepang Sep 18, 2023
23d4457
Rollup merge of #115558 - tshepang:patch-4, r=Mark-Simulacrum
matthiaskrgr Sep 18, 2023
2239734
Rollup merge of #115724 - tgross35:mailmap, r=Mark-Simulacrum
matthiaskrgr Sep 18, 2023
afdfce3
Rollup merge of #115795 - Kobzol:opt-dist-custom, r=Mark-Simulacrum
matthiaskrgr Sep 18, 2023
d958bf3
Rollup merge of #115811 - bzEq:make-aix-known, r=Mark-Simulacrum
matthiaskrgr Sep 18, 2023
2d170f1
Rollup merge of #115838 - lcnr:added-goals, r=compiler-errors
matthiaskrgr Sep 18, 2023
c86427f
Rollup merge of #115902 - Mark-Simulacrum:bump-ci, r=albertlarsan68
matthiaskrgr Sep 18, 2023
e7d7a4d
Rollup merge of #115907 - RalfJung:interner-check, r=compiler-errors
matthiaskrgr Sep 18, 2023
8851323
Rollup merge of #115916 - jackh726:vacation, r=jackh726
matthiaskrgr Sep 18, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ jobs:
- name: dist-x86_64-msvc
env:
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"
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
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
DIST_REQUIRE_ALL_TOOLS: 1
os: windows-2019-8core-32gb
- name: dist-i686-msvc
Expand Down
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ Timothy Maloney <[email protected]>
Tomas Koutsky <[email protected]>
Torsten Weber <[email protected]>
Torsten Weber <[email protected]> <[email protected]>
Trevor Gross <[email protected]> <[email protected]>
Trevor Gross <[email protected]> <[email protected]>
Trevor Spiteri <[email protected]> <[email protected]>
Tshepang Mbambo <[email protected]>
Ty Overby <[email protected]>
Expand Down
76 changes: 72 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -858,14 +858,38 @@ dependencies = [
"winapi",
]

[[package]]
name = "darling"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
dependencies = [
"darling_core 0.14.4",
"darling_macro 0.14.4",
]

[[package]]
name = "darling"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
dependencies = [
"darling_core",
"darling_macro",
"darling_core 0.20.3",
"darling_macro 0.20.3",
]

[[package]]
name = "darling_core"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn 1.0.109",
]

[[package]]
Expand All @@ -882,13 +906,24 @@ dependencies = [
"syn 2.0.29",
]

[[package]]
name = "darling_macro"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [
"darling_core 0.14.4",
"quote",
"syn 1.0.109",
]

[[package]]
name = "darling_macro"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
dependencies = [
"darling_core",
"darling_core 0.20.3",
"quote",
"syn 2.0.29",
]
Expand Down Expand Up @@ -919,6 +954,37 @@ dependencies = [
"syn 1.0.109",
]

[[package]]
name = "derive_builder"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8"
dependencies = [
"derive_builder_macro",
]

[[package]]
name = "derive_builder_core"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
dependencies = [
"darling 0.14.4",
"proc-macro2",
"quote",
"syn 1.0.109",
]

[[package]]
name = "derive_builder_macro"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
dependencies = [
"derive_builder_core",
"syn 1.0.109",
]

[[package]]
name = "derive_more"
version = "0.99.17"
Expand All @@ -938,7 +1004,7 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d"
dependencies = [
"darling",
"darling 0.20.3",
"proc-macro2",
"quote",
"syn 2.0.29",
Expand Down Expand Up @@ -2584,6 +2650,8 @@ dependencies = [
"anyhow",
"build_helper",
"camino",
"clap",
"derive_builder",
"env_logger 0.10.0",
"fs_extra",
"glob",
Expand Down
33 changes: 24 additions & 9 deletions compiler/rustc_middle/src/traits/solve/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,29 @@ pub enum CacheHit {
Global,
}

#[derive(Eq, PartialEq)]
pub enum GoalEvaluationKind {
Root,
Nested { is_normalizes_to_hack: IsNormalizesToHack },
}

#[derive(Eq, PartialEq)]
pub struct GoalEvaluation<'tcx> {
pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>,
pub is_normalizes_to_hack: IsNormalizesToHack,
pub kind: GoalEvaluationKind,
pub evaluation: CanonicalGoalEvaluation<'tcx>,
pub returned_goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
}

#[derive(Eq, PartialEq)]
pub struct CanonicalGoalEvaluation<'tcx> {
pub goal: CanonicalInput<'tcx>,
pub kind: GoalEvaluationKind<'tcx>,
pub kind: CanonicalGoalEvaluationKind<'tcx>,
pub result: QueryResult<'tcx>,
}

#[derive(Eq, PartialEq)]
pub enum GoalEvaluationKind<'tcx> {
pub enum CanonicalGoalEvaluationKind<'tcx> {
Overflow,
CacheHit(CacheHit),
Uncached { revisions: Vec<GoalEvaluationStep<'tcx>> },
Expand All @@ -52,22 +58,31 @@ pub struct GoalEvaluationStep<'tcx> {
pub instantiated_goal: QueryInput<'tcx, ty::Predicate<'tcx>>,

/// 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)]
pub struct GoalCandidate<'tcx> {
pub added_goals_evaluations: Vec<AddedGoalsEvaluation<'tcx>>,
pub candidates: Vec<GoalCandidate<'tcx>>,
pub struct Probe<'tcx> {
pub steps: Vec<ProbeStep<'tcx>>,
pub kind: ProbeKind<'tcx>,
}

impl Debug for GoalCandidate<'_> {
impl Debug for Probe<'_> {
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)]
pub enum ProbeKind<'tcx> {
/// The root inference context while proving a goal.
Expand Down
34 changes: 19 additions & 15 deletions compiler/rustc_middle/src/traits/solve/inspect/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
}

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

match &eval.kind {
GoalEvaluationKind::Overflow => {
CanonicalGoalEvaluationKind::Overflow => {
writeln!(self.f, "OVERFLOW: {:?}", eval.result)
}
GoalEvaluationKind::CacheHit(CacheHit::Global) => {
CanonicalGoalEvaluationKind::CacheHit(CacheHit::Global) => {
writeln!(self.f, "GLOBAL CACHE HIT: {:?}", eval.result)
}
GoalEvaluationKind::CacheHit(CacheHit::Provisional) => {
CanonicalGoalEvaluationKind::CacheHit(CacheHit::Provisional) => {
writeln!(self.f, "PROVISIONAL CACHE HIT: {:?}", eval.result)
}
GoalEvaluationKind::Uncached { revisions } => {
CanonicalGoalEvaluationKind::Uncached { revisions } => {
for (n, step) in revisions.iter().enumerate() {
writeln!(self.f, "REVISION {n}")?;
self.nested(|this| this.format_evaluation_step(step))?;
Expand All @@ -92,11 +95,11 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
evaluation_step: &GoalEvaluationStep<'_>,
) -> std::fmt::Result {
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 {
match &candidate.kind {
pub(super) fn format_probe(&mut self, probe: &Probe<'_>) -> std::fmt::Result {
match &probe.kind {
ProbeKind::Root { result } => {
writeln!(self.f, "ROOT RESULT: {result:?}")
}
Expand All @@ -118,11 +121,12 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
}?;

self.nested(|this| {
for candidate in &candidate.candidates {
this.format_candidate(candidate)?;
}
for nested in &candidate.added_goals_evaluations {
this.format_added_goals_evaluation(nested)?;
for step in &probe.steps {
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)?,
}
}
Ok(())
})
Expand Down
24 changes: 24 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,25 @@ macro_rules! nop_lift {
impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $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
.$set
.contains_pointer_to(&InternedInSet(&*self.0.0))
Expand All @@ -1230,6 +1249,11 @@ macro_rules! nop_list_lift {
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
type Lifted = &'tcx List<$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() {
return Some(List::empty());
}
Expand Down
27 changes: 17 additions & 10 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use std::ops::ControlFlow;
use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment};

use super::inspect::ProofTreeBuilder;
use super::search_graph;
use super::SolverMode;
use super::{search_graph, GoalEvaluationKind};
use super::{search_graph::SearchGraph, Goal};
pub use select::InferCtxtSelectExt;

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

inspect: ProofTreeBuilder<'tcx>,
pub(super) inspect: ProofTreeBuilder<'tcx>,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
Option<inspect::GoalEvaluation<'tcx>>,
) {
EvalCtxt::enter_root(self, generate_proof_tree, |ecx| {
ecx.evaluate_goal(IsNormalizesToHack::No, goal)
ecx.evaluate_goal(GoalEvaluationKind::Root, goal)
})
}
}
Expand Down Expand Up @@ -340,11 +340,11 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
/// been constrained and the certainty of the result.
fn evaluate_goal(
&mut self,
is_normalizes_to_hack: IsNormalizesToHack,
goal_evaluation_kind: GoalEvaluationKind,
goal: Goal<'tcx, ty::Predicate<'tcx>>,
) -> Result<(bool, Certainty, Vec<Goal<'tcx, ty::Predicate<'tcx>>>), NoSolution> {
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 canonical_response = EvalCtxt::evaluate_canonical_goal(
self.tcx(),
Expand Down Expand Up @@ -389,7 +389,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
// solver cycle.
if cfg!(debug_assertions)
&& 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()
{
// The nested evaluation has to happen with the original state
Expand Down Expand Up @@ -561,8 +564,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
},
);

let (_, certainty, instantiate_goals) =
self.evaluate_goal(IsNormalizesToHack::Yes, unconstrained_goal)?;
let (_, certainty, instantiate_goals) = self.evaluate_goal(
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes },
unconstrained_goal,
)?;
self.add_goals(instantiate_goals);

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

for goal in goals.goals.drain(..) {
let (has_changed, certainty, instantiate_goals) =
self.evaluate_goal(IsNormalizesToHack::No, goal)?;
let (has_changed, certainty, instantiate_goals) = self.evaluate_goal(
GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::No },
goal,
)?;
self.add_goals(instantiate_goals);
if has_changed {
unchanged_certainty = None;
Expand Down
Loading