Skip to content

Commit 1ca8168

Browse files
committed
Implement WellFormed for scalars
1 parent fd15068 commit 1ca8168

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
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/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)