diff options
Diffstat (limited to 'src/test/ui/chalkify/type_implied_bound.rs')
-rw-r--r-- | src/test/ui/chalkify/type_implied_bound.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/chalkify/type_implied_bound.rs b/src/test/ui/chalkify/type_implied_bound.rs new file mode 100644 index 000000000..8673f5319 --- /dev/null +++ b/src/test/ui/chalkify/type_implied_bound.rs @@ -0,0 +1,29 @@ +// run-pass +// compile-flags: -Z chalk + +trait Eq { } +trait Hash: Eq { } + +impl Eq for i32 { } +impl Hash for i32 { } + +struct Set<T: Hash> { + _x: T, +} + +fn only_eq<T: Eq>() { } + +fn take_a_set<T>(_: &Set<T>) { + // `Set<T>` is an input type of `take_a_set`, hence we know that + // `T` must implement `Hash`, and we know in turn that `T` must + // implement `Eq`. + only_eq::<T>() +} + +fn main() { + let set = Set { + _x: 5, + }; + + take_a_set(&set); +} |