Skip to content

Commit 2fd7fb7

Browse files
committed
Implement WellFormed for scalars
1 parent fd15068 commit 2fd7fb7

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

chalk-solve/src/clauses.rs

+6
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ fn match_ty<I: Interner>(
416416
) -> Result<(), Floundered> {
417417
let interner = builder.interner();
418418
Ok(match ty.data(interner) {
419+
TyData::Apply(ApplicationTy {
420+
name: TypeName::Scalar(_),
421+
..
422+
}) => {
423+
builder.push_fact(WellFormed::Ty(ty.clone()));
424+
}
419425
TyData::Apply(application_ty) => match_type_name(builder, application_ty.name),
420426
TyData::Placeholder(_) => {
421427
builder.push_clause(WellFormed::Ty(ty.clone()), Some(FromEnv::Ty(ty.clone())));

libstd.chalk

-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ trait Clone { }
1010
trait Copy where Self: Clone { }
1111
trait Sized { }
1212

13-
struct i32 { }
1413
impl Copy for i32 { }
1514
impl Clone for i32 { }
1615
impl Sized for i32 { }
1716

18-
struct u32 { }
1917
impl Copy for u32 { }
2018
impl Clone for u32 { }
2119
impl Sized for u32 { }

tests/lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ fn scalars() {
471471
}
472472

473473
error_msg {
474-
"parse error: UnrecognizedToken { token: (8, Token(45, \"i32\"), 11), expected: [\"r#\\\"([A-Za-z]|_)([A-Za-z0-9]|_)*\\\"#\"] }"
474+
"parse error: UnrecognizedToken { token: (8, Token(49, \"i32\"), 11), expected: [\"r#\\\"([A-Za-z]|_)([A-Za-z0-9]|_)*\\\"#\"] }"
475475
}
476476
}
477477
}

tests/test/projection.rs

-7
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ fn projection_equality_priority2() {
207207
type Type;
208208
}
209209

210-
struct u32 {}
211210
struct S1 {}
212211
struct S2 {}
213212
struct S3 {}
@@ -286,8 +285,6 @@ fn projection_equality_from_env() {
286285
trait Trait1 {
287286
type Type;
288287
}
289-
290-
struct u32 {}
291288
}
292289

293290
goal {
@@ -314,8 +311,6 @@ fn projection_equality_nested() {
314311
trait Iterator {
315312
type Item;
316313
}
317-
318-
struct u32 {}
319314
}
320315

321316
goal {
@@ -360,8 +355,6 @@ fn iterator_flatten() {
360355
{
361356
type Item = <U as Iterator>::Item;
362357
}
363-
364-
struct u32 {}
365358
}
366359

367360
goal {

tests/test/scalars.rs

+24
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,27 @@ fn scalar_trait_impl() {
112112

113113
}
114114
}
115+
116+
#[test]
117+
fn scalars_are_well_formed() {
118+
test! {
119+
program { }
120+
121+
goal { WellFormed(i8) } yields { "Unique" }
122+
goal { WellFormed(i16) } yields { "Unique" }
123+
goal { WellFormed(i32) } yields { "Unique" }
124+
goal { WellFormed(i64) } yields { "Unique" }
125+
goal { WellFormed(i128) } yields { "Unique" }
126+
goal { WellFormed(isize) } yields { "Unique" }
127+
goal { WellFormed(u8) } yields { "Unique" }
128+
goal { WellFormed(u16) } yields { "Unique" }
129+
goal { WellFormed(u32) } yields { "Unique" }
130+
goal { WellFormed(u64) } yields { "Unique" }
131+
goal { WellFormed(u128) } yields { "Unique" }
132+
goal { WellFormed(usize) } yields { "Unique" }
133+
goal { WellFormed(f32) } yields { "Unique" }
134+
goal { WellFormed(f64) } yields { "Unique" }
135+
goal { WellFormed(bool) } yields { "Unique" }
136+
goal { WellFormed(char) } yields { "Unique" }
137+
}
138+
}

0 commit comments

Comments
 (0)