Skip to content

Commit 5044ee6

Browse files
committed
another attempt at things!
1 parent 0525fc1 commit 5044ee6

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chalk-integration/src/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chalk_ir::{
88
};
99
use chalk_parse::ast::*;
1010
use chalk_solve::rust_ir::{self, IntoWhereClauses};
11-
use indexmap::IndexMap;
11+
use indexmap::{IndexMap, IndexSet};
1212
use program_lowerer::ProgramLowerer;
1313
use string_cache::DefaultAtom as Atom;
1414
use tracing::debug;
@@ -542,7 +542,7 @@ impl LowerWithEnv for QuantifiedInlineBound {
542542
}
543543

544544
impl LowerWithEnv for [QuantifiedInlineBound] {
545-
type Lowered = Vec<rust_ir::QuantifiedInlineBound<ChalkIr>>;
545+
type Lowered = IndexSet<rust_ir::QuantifiedInlineBound<ChalkIr>>;
546546

547547
fn lower(&self, env: &Env) -> LowerResult<Self::Lowered> {
548548
fn trait_identifier(bound: &InlineBound) -> &Identifier {

chalk-integration/src/lowering/program_lowerer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chalk_solve::rust_ir::{
88
self, Anonymize, AssociatedTyValueId, GeneratorDatum, GeneratorInputOutputDatum,
99
GeneratorWitnessDatum, GeneratorWitnessExistential, OpaqueTyDatum, OpaqueTyDatumBound,
1010
};
11-
use indexmap::IndexMap;
11+
use indexmap::{IndexMap, IndexSet};
1212
use rust_ir::IntoWhereClauses;
1313
use std::collections::HashSet;
1414
use std::sync::Arc;
@@ -367,7 +367,7 @@ impl ProgramLowerer {
367367

368368
// Introduce a variable to represent the hidden "self type". This will be used in the bounds.
369369
// So the `impl Trait<T1..Tn>` will be lowered to `exists<Self> { Self: Trait<T1..Tn> }`.
370-
let bounds: chalk_ir::Binders<Vec<chalk_ir::Binders<_>>> = env
370+
let bounds: chalk_ir::Binders<IndexSet<chalk_ir::Binders<_>>> = env
371371
.in_binders(
372372
Some(chalk_ir::WithKind::new(
373373
chalk_ir::VariableKind::Ty(TyVariableKind::General),
@@ -393,14 +393,14 @@ impl ProgramLowerer {
393393
.collect())
394394
},
395395
)?;
396-
let where_clauses: chalk_ir::Binders<Vec<chalk_ir::Binders<_>>> = env
397-
.in_binders(
398-
Some(chalk_ir::WithKind::new(
399-
chalk_ir::VariableKind::Ty(TyVariableKind::General),
400-
Atom::from(FIXME_SELF),
401-
)),
402-
|env| opaque_ty.where_clauses.lower(env),
403-
)?;
396+
let where_clauses: chalk_ir::Binders<IndexSet<chalk_ir::Binders<_>>> =
397+
env.in_binders(
398+
Some(chalk_ir::WithKind::new(
399+
chalk_ir::VariableKind::Ty(TyVariableKind::General),
400+
Atom::from(FIXME_SELF),
401+
)),
402+
|env| opaque_ty.where_clauses.lower(env),
403+
)?;
404404

405405
Ok(OpaqueTyDatumBound {
406406
bounds,

chalk-ir/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ edition = "2018"
1313
lazy_static = "1.4.0"
1414
bitflags = "1.2.1"
1515
chalk-derive = { version = "0.76.0-dev.0", path = "../chalk-derive" }
16+
indexmap = "1.7.0"

chalk-ir/src/interner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ pub trait HasInterner {
665665
type Interner: Interner;
666666
}
667667

668+
impl<T: HasInterner> HasInterner for indexmap::IndexSet<T> {
669+
type Interner = T::Interner;
670+
}
671+
668672
impl<T: HasInterner> HasInterner for [T] {
669673
type Interner = T::Interner;
670674
}

chalk-solve/src/rust_ir.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use chalk_ir::{
1111
GenericArg, ImplId, OpaqueTyId, ProjectionTy, QuantifiedWhereClause, Substitution,
1212
ToGenericArg, TraitId, TraitRef, Ty, TyKind, VariableKind, WhereClause, WithKind,
1313
};
14+
use indexmap::IndexSet;
1415
use std::iter;
1516
use std::ops::ControlFlow;
1617

@@ -625,11 +626,11 @@ pub struct OpaqueTyDatum<I: Interner> {
625626
#[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, HasInterner, Visit)]
626627
pub struct OpaqueTyDatumBound<I: Interner> {
627628
/// Trait bounds for the opaque type. These are bounds that the hidden type must meet.
628-
pub bounds: Binders<Vec<QuantifiedWhereClause<I>>>,
629+
pub bounds: Binders<IndexSet<QuantifiedWhereClause<I>>>,
629630
/// Where clauses that inform well-formedness conditions for the opaque type.
630631
/// These are conditions on the generic parameters of the opaque type which must be true
631632
/// for a reference to the opaque type to be well-formed.
632-
pub where_clauses: Binders<Vec<QuantifiedWhereClause<I>>>,
633+
pub where_clauses: Binders<IndexSet<QuantifiedWhereClause<I>>>,
633634
}
634635

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

0 commit comments

Comments
 (0)