]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/trait-with-missing-associated-type-restriction.rs
Rollup merge of #106692 - eggyal:mv-binary_heap.rs-binary_heap/mod.rs, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / trait-with-missing-associated-type-restriction.rs
1 // These are all the possible variations of this error I could think of for.
2 // `trait-with-missing-associated-type-restriction-fixable.rs` contains the subset of these that
3 // can be fixed with `rustfix`.
4
5 trait Trait<T = Self> {
6     type A;
7
8     fn func(&self) -> Self::A;
9     fn funk(&self, _: Self::A);
10     fn funq(&self) -> Self::A {} //~ ERROR mismatched types
11 }
12
13 fn foo(_: impl Trait, x: impl Trait) {
14     qux(x.func()) //~ ERROR mismatched types
15 }
16
17 fn bar<T: Trait>(x: T) {
18     qux(x.func()) //~ ERROR mismatched types
19 }
20
21 fn foo2(x: impl Trait<i32>) {
22     qux(x.func()) //~ ERROR mismatched types
23 }
24
25 fn bar2<T: Trait<i32>>(x: T) {
26     x.funk(3); //~ ERROR mismatched types
27     qux(x.func()) //~ ERROR mismatched types
28 }
29
30 fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) {
31     qux(x.func()) //~ ERROR mismatched types
32 }
33
34 fn bat(x: &mut dyn Trait<(), A = ()>) {
35     qux(x.func()) //~ ERROR mismatched types
36 }
37
38 fn ban<T>(x: T) where T: Trait {
39     qux(x.func()) //~ ERROR mismatched types
40 }
41
42 fn qux(_: usize) {}
43
44 fn main() {}