Skip to content

Commit

Permalink
another attempt at things!
Browse files Browse the repository at this point in the history
  • Loading branch information
pierwill committed Dec 15, 2021
1 parent 0525fc1 commit 5044ee6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions chalk-integration/src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -542,7 +542,7 @@ impl LowerWithEnv for QuantifiedInlineBound {
}

impl LowerWithEnv for [QuantifiedInlineBound] {
type Lowered = Vec<rust_ir::QuantifiedInlineBound<ChalkIr>>;
type Lowered = IndexSet<rust_ir::QuantifiedInlineBound<ChalkIr>>;

fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
fn trait_identifier(bound: &InlineBound) -> &Identifier {
Expand Down
20 changes: 10 additions & 10 deletions chalk-integration/src/lowering/program_lowerer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<T1..Tn>` will be lowered to `exists<Self> { Self: Trait<T1..Tn> }`.
let bounds: chalk_ir::Binders<Vec<chalk_ir::Binders<_>>> = env
let bounds: chalk_ir::Binders<IndexSet<chalk_ir::Binders<_>>> = env
.in_binders(
Some(chalk_ir::WithKind::new(
chalk_ir::VariableKind::Ty(TyVariableKind::General),
Expand All @@ -393,14 +393,14 @@ impl ProgramLowerer {
.collect())
},
)?;
let where_clauses: chalk_ir::Binders<Vec<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<IndexSet<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,
Expand Down
1 change: 1 addition & 0 deletions chalk-ir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions chalk-ir/src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,10 @@ pub trait HasInterner {
type Interner: Interner;
}

impl<T: HasInterner> HasInterner for indexmap::IndexSet<T> {
type Interner = T::Interner;
}

impl<T: HasInterner> HasInterner for [T] {
type Interner = T::Interner;
}
Expand Down
5 changes: 3 additions & 2 deletions chalk-solve/src/rust_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -625,11 +626,11 @@ pub struct OpaqueTyDatum<I: Interner> {
#[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, HasInterner, Visit)]
pub struct OpaqueTyDatumBound<I: Interner> {
/// Trait bounds for the opaque type. These are bounds that the hidden type must meet.
pub bounds: Binders<Vec<QuantifiedWhereClause<I>>>,
pub bounds: Binders<IndexSet<QuantifiedWhereClause<I>>>,
/// 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<Vec<QuantifiedWhereClause<I>>>,
pub where_clauses: Binders<IndexSet<QuantifiedWhereClause<I>>>,
}

// The movability of a generator: whether a generator contains self-references,
Expand Down

0 comments on commit 5044ee6

Please sign in to comment.