Skip to content

Commit 7662478

Browse files
committed
Fix up from merge; address feedback; some tests still failing
1 parent c2082df commit 7662478

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

chalk-ir/src/visit/boring_impls.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
//! The more interesting impls of `Visit` remain in the `visit` module.
66
77
use crate::{
8-
AssocTypeId, ClausePriority, DebruijnIndex, Goals, ImplId, Interner, OpaqueTyId, Parameter,
9-
ParameterKind, PlaceholderIndex, ProgramClause, ProgramClauseData, ProgramClauses,
10-
QuantifiedWhereClauses, QuantifierKind, StructId, Substitution, SuperVisit, TraitId,
11-
UniverseIndex, Visit, VisitResult, Visitor,
8+
AssocTypeId, ClausePriority, DebruijnIndex, FloatTy, Goals, ImplId, IntTy, Interner,
9+
OpaqueTyId, Parameter, ParameterKind, PlaceholderIndex, ProgramClause, ProgramClauseData,
10+
ProgramClauses, QuantifiedWhereClauses, QuantifierKind, Scalar, StructId, Substitution,
11+
SuperVisit, TraitId, UintTy, UniverseIndex, Visit, VisitResult, Visitor,
1212
};
1313
use chalk_engine::{context::Context, ExClause, FlounderedSubgoal, Literal};
1414
use std::{marker::PhantomData, sync::Arc};
@@ -207,6 +207,10 @@ const_visit!(chalk_engine::TableIndex);
207207
const_visit!(chalk_engine::TimeStamp);
208208
const_visit!(ClausePriority);
209209
const_visit!(());
210+
const_visit!(Scalar);
211+
const_visit!(UintTy);
212+
const_visit!(IntTy);
213+
const_visit!(FloatTy);
210214

211215
#[macro_export]
212216
macro_rules! id_visit {

chalk-parse/src/parser.lalrpop

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ TyWithoutFor: Ty = {
204204
},
205205
<n:Id> "<" <a:Comma<Parameter>> ">" => Ty::Apply { name: n, args: a },
206206
<p:ProjectionTy> => Ty::Projection { proj: p },
207-
<a:AliasTy> => Ty::Alias { alias: a },
208207
"(" <t:TupleOrParensInner> ")" => t,
209208
};
210209

tests/test/projection.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ fn projection_equality() {
129129
trait Trait2<T> { }
130130
impl<T, U> Trait2<T> for U where U: Trait1<Type = T> {}
131131

132-
struct Foo {}
133132
struct S {}
134133
impl Trait1 for S {
135-
type Type = Foo;
134+
type Type = u32;
136135
}
137136
}
138137

@@ -144,7 +143,7 @@ fn projection_equality() {
144143
// this is wrong, chalk#234
145144
"Ambiguous"
146145
} yields[SolverChoice::recursive()] {
147-
"Unique; substitution [?0 := u32]"
146+
"Unique; substitution [?0 := Uint(U32)]"
148147
}
149148

150149
goal {
@@ -155,7 +154,7 @@ fn projection_equality() {
155154
// this is wrong, chalk#234
156155
"Ambiguous"
157156
} yields[SolverChoice::recursive()] {
158-
"Unique; substitution [?0 := u32]"
157+
"Unique; substitution [?0 := Uint(U32)]"
159158
}
160159
}
161160
}
@@ -168,7 +167,6 @@ fn projection_equality_priority1() {
168167
type Type;
169168
}
170169

171-
struct u32 {}
172170
struct S1 {}
173171
struct S2 {}
174172
struct S3 {}
@@ -196,7 +194,7 @@ fn projection_equality_priority1() {
196194
// constrained `T` at all? I can't come up with
197195
// an example where that's the case, so maybe
198196
// not. -Niko
199-
"Unique; substitution [?0 := S2, ?1 := u32]"
197+
"Unique; substitution [?0 := S2, ?1 := Uint(U32)]"
200198
}
201199
}
202200
}
@@ -276,7 +274,7 @@ fn projection_equality_priority2() {
276274
} yields[SolverChoice::recursive()] {
277275
// Constraining Out1 = S1 gives us only one choice, use the impl,
278276
// and the recursive solver prefers the normalized form.
279-
"Unique; substitution [?0 := S1, ?1 := u32], lifetime constraints []"
277+
"Unique; substitution [?0 := S1, ?1 := Uint(U32)], lifetime constraints []"
280278
}
281279
}
282280
}
@@ -301,7 +299,7 @@ fn projection_equality_from_env() {
301299
// this is wrong, chalk#234
302300
"Ambiguous"
303301
} yields[SolverChoice::recursive()] {
304-
"Unique; substitution [?0 := u32]"
302+
"Unique; substitution [?0 := Uint(U32)]"
305303
}
306304
}
307305
}
@@ -329,7 +327,7 @@ fn projection_equality_nested() {
329327
// this is wrong, chalk#234
330328
"Ambiguous"
331329
} yields[SolverChoice::recursive()] {
332-
"Unique; substitution [?0 := u32]"
330+
"Unique; substitution [?0 := Uint(U32)]"
333331
}
334332
}
335333
}
@@ -371,7 +369,7 @@ fn iterator_flatten() {
371369
// this is wrong, chalk#234
372370
"Ambiguous"
373371
} yields[SolverChoice::recursive()] {
374-
"Unique; substitution [?0 := u32]"
372+
"Unique; substitution [?0 := Uint(U32)]"
375373
}
376374
}
377375
}

tests/test/scalars.rs

+27
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fn scalar_trait_impl() {
4848
test! {
4949
program {
5050
trait Foo { }
51+
trait UnsignedFoo { }
5152

5253
impl Foo for i8 { }
5354
impl Foo for i16 { }
@@ -65,6 +66,14 @@ fn scalar_trait_impl() {
6566
impl Foo for f64 { }
6667
impl Foo for bool { }
6768
impl Foo for char { }
69+
70+
impl UnsignedFoo for u8 { }
71+
impl UnsignedFoo for u16 { }
72+
impl UnsignedFoo for u32 { }
73+
impl UnsignedFoo for u64 { }
74+
impl UnsignedFoo for u128 { }
75+
impl UnsignedFoo for usize { }
76+
6877
}
6978

7079
goal { i8: Foo } yields { "Unique" }
@@ -83,5 +92,23 @@ fn scalar_trait_impl() {
8392
goal { f64: Foo } yields { "Unique" }
8493
goal { bool: Foo } yields { "Unique" }
8594
goal { char: Foo } yields { "Unique" }
95+
96+
goal { i8: UnsignedFoo } yields { "No possible solution" }
97+
goal { i16: UnsignedFoo } yields { "No possible solution" }
98+
goal { i32: UnsignedFoo } yields { "No possible solution" }
99+
goal { i64: UnsignedFoo } yields { "No possible solution" }
100+
goal { i128: UnsignedFoo } yields { "No possible solution" }
101+
goal { isize: UnsignedFoo } yields { "No possible solution" }
102+
goal { u8: UnsignedFoo } yields { "Unique" }
103+
goal { u16: UnsignedFoo } yields { "Unique" }
104+
goal { u32: UnsignedFoo } yields { "Unique" }
105+
goal { u64: UnsignedFoo } yields { "Unique" }
106+
goal { u128: UnsignedFoo } yields { "Unique" }
107+
goal { usize: UnsignedFoo } yields { "Unique" }
108+
goal { f32: UnsignedFoo } yields { "No possible solution" }
109+
goal { f64: UnsignedFoo } yields { "No possible solution" }
110+
goal { bool: UnsignedFoo } yields { "No possible solution" }
111+
goal { char: UnsignedFoo } yields { "No possible solution" }
112+
86113
}
87114
}

0 commit comments

Comments
 (0)