diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-20 19:31:35 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-20 19:32:13 +0100 |
commit | d5bb9c038a98282c3b6421c24a196a36e7720634 (patch) | |
tree | f3ea3ab6b25e0b72c69113a9bc9439c97f7e9724 /tests/doctests.md | |
parent | ce4cdcc21f86246474969051f6e0345f900086c3 (diff) |
test that same-named generics need same bounds
Diffstat (limited to 'tests/doctests.md')
-rw-r--r-- | tests/doctests.md | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/doctests.md b/tests/doctests.md index ef557fe..3318dba 100644 --- a/tests/doctests.md +++ b/tests/doctests.md @@ -1,4 +1,4 @@ -Tests that the object-safety assertion via `impl dyn` is working: +## If the dynamized trait isn't object safe you get a compile error ```rust compile_fail trait ObjectUnsafe: Sized {} @@ -17,3 +17,40 @@ trait Trait { fn f(&self) -> Self::A; } ``` + +## Same-named method generics must have same trait bounds + +Works: + +```rust +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A: std::fmt::Display>(&self, a: A) -> Self::A; + fn b<A: std::fmt::Display>(&self, a: A) -> Self::A; +} +``` + +```rust +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A>(&self, a: A) -> Self::A; + fn b<B: std::fmt::Display>(&self, a: B) -> Self::A; +} +``` + + +Fails: + +```rust compile_fail +#[dynamize::dynamize] +trait Trait { + type A: std::error::Error; + + fn a<A>(&self, a: A) -> Self::A; + fn b<A: std::fmt::Display>(&self, a: A) -> Self::A; +} +``` |