Skip to content

Commit 202d803

Browse files
committed
Lower opaque type kind
1 parent 0a93698 commit 202d803

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

chalk-integration/src/lowering.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,11 @@ impl LowerTypeKind for TraitDefn {
614614

615615
impl LowerTypeKind for OpaqueTyDefn {
616616
fn lower_type_kind(&self) -> LowerResult<TypeKind> {
617+
let binders: Vec<_> = self.parameter_kinds.iter().map(|p| p.lower()).collect();
617618
Ok(TypeKind {
618619
sort: TypeSort::Opaque,
619620
name: self.identifier.str,
620-
binders: chalk_ir::Binders::new(
621-
vec![], //TODO do we need binders here?
622-
(),
623-
),
621+
binders: chalk_ir::Binders::new(binders.anonymize(), ()),
624622
})
625623
}
626624
}

chalk-solve/src/clauses/program_clauses.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ impl<I: Interner> ToProgramClauses<I> for OpaqueTyDatum<I> {
142142
ApplicationTy {
143143
name: TypeName::OpaqueType(self.opaque_ty_id),
144144
substitution,
145-
}
146-
.cast(interner),
145+
},
147146
);
148147

149148
builder.push_binders(&self.bound, |builder, opaque_ty_bound| {

tests/test/existential_types.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,42 @@ use super::*;
66
fn opaque_bounds() {
77
test! {
88
program {
9-
trait Direct { }
10-
trait Indirect { }
119
struct Ty { }
12-
impl Direct for Ty { }
13-
impl Indirect for Ty { }
1410

15-
opaque type T: Direct = Ty;
11+
trait Clone { }
12+
opaque type T: Clone = Ty;
1613
}
1714

1815
goal {
19-
T: Direct
16+
T: Clone
2017
} yields {
2118
"Unique; substitution []"
2219
}
20+
}
21+
}
22+
23+
#[test]
24+
fn opaque_reveal() {
25+
test! {
26+
program {
27+
struct Ty { }
28+
trait Trait { }
29+
impl Trait for Ty { }
30+
31+
trait Clone { }
32+
opaque type T: Clone = Ty;
33+
}
2334

2435
goal {
2536
if (Reveal) {
26-
T: Indirect
37+
T: Trait
2738
}
2839
} yields {
2940
"Unique; substitution []"
3041
}
3142

3243
goal {
33-
T: Indirect
44+
T: Trait
3445
} yields {
3546
"No possible solution"
3647
}

0 commit comments

Comments
 (0)