From 5044ee610031e9cb82a5ac4e7dbb0010eff15ec9 Mon Sep 17 00:00:00 2001 From: pierwill Date: Wed, 15 Dec 2021 15:59:21 -0600 Subject: [PATCH] another attempt at things! --- Cargo.lock | 1 + chalk-integration/src/lowering.rs | 4 ++-- .../src/lowering/program_lowerer.rs | 20 +++++++++---------- chalk-ir/Cargo.toml | 1 + chalk-ir/src/interner.rs | 4 ++++ chalk-solve/src/rust_ir.rs | 5 +++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fdf3e898fa..fa2e2dfbb07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,6 +154,7 @@ version = "0.76.0-dev.0" dependencies = [ "bitflags", "chalk-derive", + "indexmap", "lazy_static", ] diff --git a/chalk-integration/src/lowering.rs b/chalk-integration/src/lowering.rs index 7c00bab8e45..e2b46fdd729 100644 --- a/chalk-integration/src/lowering.rs +++ b/chalk-integration/src/lowering.rs @@ -8,7 +8,7 @@ use chalk_ir::{ }; use chalk_parse::ast::*; use chalk_solve::rust_ir::{self, IntoWhereClauses}; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use program_lowerer::ProgramLowerer; use string_cache::DefaultAtom as Atom; use tracing::debug; @@ -542,7 +542,7 @@ impl LowerWithEnv for QuantifiedInlineBound { } impl LowerWithEnv for [QuantifiedInlineBound] { - type Lowered = Vec>; + type Lowered = IndexSet>; fn lower(&self, env: &Env) -> LowerResult { fn trait_identifier(bound: &InlineBound) -> &Identifier { diff --git a/chalk-integration/src/lowering/program_lowerer.rs b/chalk-integration/src/lowering/program_lowerer.rs index 6ccf0cf814f..b573e579c0d 100644 --- a/chalk-integration/src/lowering/program_lowerer.rs +++ b/chalk-integration/src/lowering/program_lowerer.rs @@ -8,7 +8,7 @@ use chalk_solve::rust_ir::{ self, Anonymize, AssociatedTyValueId, GeneratorDatum, GeneratorInputOutputDatum, GeneratorWitnessDatum, GeneratorWitnessExistential, OpaqueTyDatum, OpaqueTyDatumBound, }; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use rust_ir::IntoWhereClauses; use std::collections::HashSet; use std::sync::Arc; @@ -367,7 +367,7 @@ impl ProgramLowerer { // Introduce a variable to represent the hidden "self type". This will be used in the bounds. // So the `impl Trait` will be lowered to `exists { Self: Trait }`. - let bounds: chalk_ir::Binders>> = env + let bounds: chalk_ir::Binders>> = env .in_binders( Some(chalk_ir::WithKind::new( chalk_ir::VariableKind::Ty(TyVariableKind::General), @@ -393,14 +393,14 @@ impl ProgramLowerer { .collect()) }, )?; - let where_clauses: chalk_ir::Binders>> = env - .in_binders( - Some(chalk_ir::WithKind::new( - chalk_ir::VariableKind::Ty(TyVariableKind::General), - Atom::from(FIXME_SELF), - )), - |env| opaque_ty.where_clauses.lower(env), - )?; + let where_clauses: chalk_ir::Binders>> = + env.in_binders( + Some(chalk_ir::WithKind::new( + chalk_ir::VariableKind::Ty(TyVariableKind::General), + Atom::from(FIXME_SELF), + )), + |env| opaque_ty.where_clauses.lower(env), + )?; Ok(OpaqueTyDatumBound { bounds, diff --git a/chalk-ir/Cargo.toml b/chalk-ir/Cargo.toml index 783b701d446..488c325acf5 100644 --- a/chalk-ir/Cargo.toml +++ b/chalk-ir/Cargo.toml @@ -13,3 +13,4 @@ edition = "2018" lazy_static = "1.4.0" bitflags = "1.2.1" chalk-derive = { version = "0.76.0-dev.0", path = "../chalk-derive" } +indexmap = "1.7.0" diff --git a/chalk-ir/src/interner.rs b/chalk-ir/src/interner.rs index f8b3c58980f..af771c739a4 100644 --- a/chalk-ir/src/interner.rs +++ b/chalk-ir/src/interner.rs @@ -665,6 +665,10 @@ pub trait HasInterner { type Interner: Interner; } +impl HasInterner for indexmap::IndexSet { + type Interner = T::Interner; +} + impl HasInterner for [T] { type Interner = T::Interner; } diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 612d05203e9..d2133568024 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -11,6 +11,7 @@ use chalk_ir::{ GenericArg, ImplId, OpaqueTyId, ProjectionTy, QuantifiedWhereClause, Substitution, ToGenericArg, TraitId, TraitRef, Ty, TyKind, VariableKind, WhereClause, WithKind, }; +use indexmap::IndexSet; use std::iter; use std::ops::ControlFlow; @@ -625,11 +626,11 @@ pub struct OpaqueTyDatum { #[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, HasInterner, Visit)] pub struct OpaqueTyDatumBound { /// Trait bounds for the opaque type. These are bounds that the hidden type must meet. - pub bounds: Binders>>, + pub bounds: Binders>>, /// Where clauses that inform well-formedness conditions for the opaque type. /// These are conditions on the generic parameters of the opaque type which must be true /// for a reference to the opaque type to be well-formed. - pub where_clauses: Binders>>, + pub where_clauses: Binders>>, } // The movability of a generator: whether a generator contains self-references,