Skip to content

Commit efb8dd1

Browse files
committed
remove the blanket impl of UpcastFrom<()>
This was kind of surprising.
1 parent bddb2d0 commit efb8dd1

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

crates/formality-core/src/cast.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,9 @@ impl DowncastTo<()> for () {
232232
}
233233
}
234234

235-
impl<T> UpcastFrom<()> for T
236-
where
237-
T: Default,
238-
{
235+
impl UpcastFrom<()> for () {
239236
fn upcast_from((): ()) -> Self {
240-
Default::default()
237+
()
241238
}
242239
}
243240

crates/formality-prove/src/prove/env.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use formality_core::{cast_impl, visit::CoreVisit, Set, To, Upcast};
1+
use formality_core::{cast_impl, visit::CoreVisit, Set, To, Upcast, UpcastFrom};
22
use formality_macros::term;
33
use formality_types::{
44
grammar::{
@@ -232,3 +232,9 @@ impl CoreVisit<crate::FormalityLang> for Env {
232232
assert_eq!(s.len(), self.variables.len());
233233
}
234234
}
235+
236+
impl UpcastFrom<()> for Env {
237+
fn upcast_from((): ()) -> Self {
238+
Env::default()
239+
}
240+
}

crates/formality-prove/src/test/adt_wf.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use formality_types::{
55
rust::term,
66
};
77

8-
use crate::{decls::Decls, prove::prove};
8+
use crate::{decls::Decls, prove::prove, Env};
99

1010
fn decls() -> Decls {
1111
Decls {
@@ -20,7 +20,12 @@ fn decls() -> Decls {
2020
fn well_formed_adt() {
2121
let assumptions: Wcs = Wcs::t();
2222
let goal: Parameter = term("X<u32>");
23-
let constraints = prove(decls(), (), assumptions, Relation::WellFormed(goal));
23+
let constraints = prove(
24+
decls(),
25+
Env::default(),
26+
assumptions,
27+
Relation::WellFormed(goal),
28+
);
2429
expect![[r#"
2530
{
2631
Constraints {
@@ -40,7 +45,12 @@ fn well_formed_adt() {
4045
fn not_well_formed_adt() {
4146
let assumptions: Wcs = Wcs::t();
4247
let goal: Parameter = term("X<u64>");
43-
let constraints = prove(decls(), (), assumptions, Relation::WellFormed(goal));
48+
let constraints = prove(
49+
decls(),
50+
Env::default(),
51+
assumptions,
52+
Relation::WellFormed(goal),
53+
);
4454
expect![[r#"
4555
{}
4656
"#]]

crates/formality-types/src/grammar/wc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ impl DowncastTo<(Wc, Wcs)> for Wcs {
9494
}
9595
}
9696

97+
impl UpcastFrom<()> for Wcs {
98+
fn upcast_from((): ()) -> Self {
99+
Wcs::default()
100+
}
101+
}
102+
97103
impl DowncastTo<()> for Wcs {
98104
fn downcast_to(&self) -> Option<()> {
99105
if self.set.is_empty() {

0 commit comments

Comments
 (0)