Skip to content

Commit

Permalink
update trait {decls,impls} with a safe prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jun 29, 2023
1 parent 7e83206 commit 91fb04d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 88 deletions.
4 changes: 2 additions & 2 deletions tests/associated_type_normalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use formality::test_where_clause;

const MIRROR: &str = "[
crate core {
trait Mirror<> where [] {
safe trait Mirror<> where [] {
type Assoc<> : [] where [];
}
impl<ty T> Mirror<> for T where [] {
safe impl<ty T> Mirror<> for T where [] {
type Assoc<> = T where [];
}
}
Expand Down
50 changes: 25 additions & 25 deletions tests/coherence_orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ fn test_orphan_CoreTrait_for_CoreStruct_in_Foo() {
expect_test::expect![[r#"
Err(
Error {
context: "orphan_check(impl <> CoreTrait < > for (rigid (adt CoreStruct)) where [] { })",
context: "orphan_check(safe impl <> CoreTrait < > for (rigid (adt CoreStruct)) where [] { })",
source: "failed to prove {@ IsLocal(CoreTrait((rigid (adt CoreStruct))))} given {}, got {}",
},
)
"#]]
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<> where [] {}
safe trait CoreTrait<> where [] {}
struct CoreStruct<> where [] {}
},
crate foo {
impl<> CoreTrait<> for CoreStruct<> where [] {}
safe impl<> CoreTrait<> for CoreStruct<> where [] {}
}
]",
));
Expand All @@ -31,19 +31,19 @@ fn test_orphan_neg_CoreTrait_for_CoreStruct_in_Foo() {
expect_test::expect![[r#"
Err(
Error {
context: "orphan_check_neg(impl <> ! CoreTrait < > for (rigid (adt CoreStruct)) where [] {})",
context: "orphan_check_neg(safe impl <> ! CoreTrait < > for (rigid (adt CoreStruct)) where [] {})",
source: "failed to prove {@ IsLocal(CoreTrait((rigid (adt CoreStruct))))} given {}, got {}",
},
)
"#]]
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<> where [] {}
safe trait CoreTrait<> where [] {}
struct CoreStruct<> where [] {}
},
crate foo {
impl<> !CoreTrait<> for CoreStruct<> where [] {}
safe impl<> !CoreTrait<> for CoreStruct<> where [] {}
}
]",
));
Expand All @@ -54,27 +54,27 @@ fn test_orphan_mirror_CoreStruct() {
expect_test::expect![[r#"
Err(
Error {
context: "orphan_check(impl <> CoreTrait < > for (alias (Mirror :: Assoc) (rigid (adt CoreStruct))) where [] { })",
context: "orphan_check(safe impl <> CoreTrait < > for (alias (Mirror :: Assoc) (rigid (adt CoreStruct))) where [] { })",
source: "failed to prove {@ IsLocal(CoreTrait((alias (Mirror :: Assoc) (rigid (adt CoreStruct)))))} given {}, got {}",
},
)
"#]]
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<> where [] {}
safe trait CoreTrait<> where [] {}
struct CoreStruct<> where [] {}
trait Mirror<> where [] {
safe trait Mirror<> where [] {
type Assoc<> : [] where [];
}
impl<ty T> Mirror<> for T where [] {
safe impl<ty T> Mirror<> for T where [] {
type Assoc<> = T where [];
}
},
crate foo {
impl<> CoreTrait<> for <CoreStruct<> as Mirror<>>::Assoc<> where [] {}
safe impl<> CoreTrait<> for <CoreStruct<> as Mirror<>>::Assoc<> where [] {}
}
]",
));
Expand All @@ -93,19 +93,19 @@ fn test_orphan_mirror_FooStruct() {
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<> where [] {}
safe trait CoreTrait<> where [] {}
trait Mirror<> where [] {
safe trait Mirror<> where [] {
type Assoc<> : [] where [];
}
impl<ty T> Mirror<> for T where [] {
safe impl<ty T> Mirror<> for T where [] {
type Assoc<> = T where [];
}
},
crate foo {
struct FooStruct<> where [] {}
impl<> CoreTrait<> for <FooStruct<> as Mirror<>>::Assoc<> where [] {}
safe impl<> CoreTrait<> for <FooStruct<> as Mirror<>>::Assoc<> where [] {}
}
]",
));
Expand All @@ -119,27 +119,27 @@ fn test_orphan_alias_to_unit() {
expect_test::expect![[r#"
Err(
Error {
context: "orphan_check(impl <> CoreTrait < > for (alias (Unit :: Assoc) (rigid (adt FooStruct))) where [] { })",
context: "orphan_check(safe impl <> CoreTrait < > for (alias (Unit :: Assoc) (rigid (adt FooStruct))) where [] { })",
source: "failed to prove {@ IsLocal(CoreTrait((alias (Unit :: Assoc) (rigid (adt FooStruct)))))} given {}, got {}",
},
)
"#]]
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<> where [] {}
safe trait CoreTrait<> where [] {}
trait Unit<> where [] {
safe trait Unit<> where [] {
type Assoc<> : [] where [];
}
impl<ty T> Unit<> for T where [] {
safe impl<ty T> Unit<> for T where [] {
type Assoc<> = () where [];
}
},
crate foo {
struct FooStruct<> where [] {}
impl<> CoreTrait<> for <FooStruct<> as Unit<>>::Assoc<> where [] {}
safe impl<> CoreTrait<> for <FooStruct<> as Unit<>>::Assoc<> where [] {}
}
]",
));
Expand All @@ -150,19 +150,19 @@ fn test_orphan_uncovered_T() {
expect_test::expect![[r#"
Err(
Error {
context: "orphan_check(impl <ty> CoreTrait < (rigid (adt FooStruct)) > for ^ty0_0 where [] { })",
context: "orphan_check(safe impl <ty> CoreTrait < (rigid (adt FooStruct)) > for ^ty0_0 where [] { })",
source: "failed to prove {@ IsLocal(CoreTrait(!ty_1, (rigid (adt FooStruct))))} given {}, got {}",
},
)
"#]]
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<ty T> where [] {}
safe trait CoreTrait<ty T> where [] {}
},
crate foo {
struct FooStruct<> where [] {}
impl<ty T> CoreTrait<FooStruct<>> for T where [] {}
safe impl<ty T> CoreTrait<FooStruct<>> for T where [] {}
}
]",
));
Expand All @@ -178,12 +178,12 @@ fn test_orphan_covered_VecT() {
.assert_debug_eq(&test_program_ok(
"[
crate core {
trait CoreTrait<ty T> where [] {}
safe trait CoreTrait<ty T> where [] {}
struct Vec<ty T> where [] {}
},
crate foo {
struct FooStruct<> where [] {}
impl<ty T> CoreTrait<FooStruct<>> for Vec<T> where [] {}
safe impl<ty T> CoreTrait<FooStruct<>> for Vec<T> where [] {}
}
]",
));
Expand Down
Loading

0 comments on commit 91fb04d

Please sign in to comment.