diff --git a/chalk-solve/src/clauses.rs b/chalk-solve/src/clauses.rs index 20932413746..bd22b8ceacd 100644 --- a/chalk-solve/src/clauses.rs +++ b/chalk-solve/src/clauses.rs @@ -416,6 +416,12 @@ fn match_ty( ) -> Result<(), Floundered> { let interner = builder.interner(); Ok(match ty.data(interner) { + TyData::Apply(ApplicationTy { + name: TypeName::Scalar(_), + .. + }) => { + builder.push_fact(WellFormed::Ty(ty.clone())); + } TyData::Apply(application_ty) => match_type_name(builder, application_ty.name), TyData::Placeholder(_) => { builder.push_clause(WellFormed::Ty(ty.clone()), Some(FromEnv::Ty(ty.clone()))); diff --git a/libstd.chalk b/libstd.chalk index 6d94f246667..c94b6047924 100644 --- a/libstd.chalk +++ b/libstd.chalk @@ -10,12 +10,10 @@ trait Clone { } trait Copy where Self: Clone { } trait Sized { } -struct i32 { } impl Copy for i32 { } impl Clone for i32 { } impl Sized for i32 { } -struct u32 { } impl Copy for u32 { } impl Clone for u32 { } impl Sized for u32 { } diff --git a/tests/lowering/mod.rs b/tests/lowering/mod.rs index 8665a3f8465..10e17c38a39 100644 --- a/tests/lowering/mod.rs +++ b/tests/lowering/mod.rs @@ -471,7 +471,7 @@ fn scalars() { } error_msg { - "parse error: UnrecognizedToken { token: (8, Token(45, \"i32\"), 11), expected: [\"r#\\\"([A-Za-z]|_)([A-Za-z0-9]|_)*\\\"#\"] }" + "parse error: UnrecognizedToken { token: (8, Token(49, \"i32\"), 11), expected: [\"r#\\\"([A-Za-z]|_)([A-Za-z0-9]|_)*\\\"#\"] }" } } } diff --git a/tests/test/projection.rs b/tests/test/projection.rs index c0673344008..cde486084f1 100644 --- a/tests/test/projection.rs +++ b/tests/test/projection.rs @@ -207,7 +207,6 @@ fn projection_equality_priority2() { type Type; } - struct u32 {} struct S1 {} struct S2 {} struct S3 {} @@ -286,8 +285,6 @@ fn projection_equality_from_env() { trait Trait1 { type Type; } - - struct u32 {} } goal { @@ -314,8 +311,6 @@ fn projection_equality_nested() { trait Iterator { type Item; } - - struct u32 {} } goal { @@ -360,8 +355,6 @@ fn iterator_flatten() { { type Item = ::Item; } - - struct u32 {} } goal { diff --git a/tests/test/scalars.rs b/tests/test/scalars.rs index bbd91d521c2..d612e135f64 100644 --- a/tests/test/scalars.rs +++ b/tests/test/scalars.rs @@ -112,3 +112,27 @@ fn scalar_trait_impl() { } } + +#[test] +fn scalars_are_well_formed() { + test! { + program { } + + goal { WellFormed(i8) } yields { "Unique" } + goal { WellFormed(i16) } yields { "Unique" } + goal { WellFormed(i32) } yields { "Unique" } + goal { WellFormed(i64) } yields { "Unique" } + goal { WellFormed(i128) } yields { "Unique" } + goal { WellFormed(isize) } yields { "Unique" } + goal { WellFormed(u8) } yields { "Unique" } + goal { WellFormed(u16) } yields { "Unique" } + goal { WellFormed(u32) } yields { "Unique" } + goal { WellFormed(u64) } yields { "Unique" } + goal { WellFormed(u128) } yields { "Unique" } + goal { WellFormed(usize) } yields { "Unique" } + goal { WellFormed(f32) } yields { "Unique" } + goal { WellFormed(f64) } yields { "Unique" } + goal { WellFormed(bool) } yields { "Unique" } + goal { WellFormed(char) } yields { "Unique" } + } +}