]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / trait-with-missing-associated-type-restriction-fixable.rs
1 // run-rustfix
2 #![allow(unused)] // for the fixed file
3
4 trait Trait<T = Self> {
5     type A;
6
7     fn func(&self) -> Self::A;
8 }
9
10 struct S<T>(T);
11 impl<K> S<K> {
12     fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) {
13         qux(x.func()) //~ ERROR mismatched types
14     }
15
16     fn ban<T>(x: T) where T: Trait {
17         qux(x.func()) //~ ERROR mismatched types
18     }
19 }
20
21 fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) {
22     qux(x.func()) //~ ERROR mismatched types
23 }
24
25 fn bar<T: Trait>(x: T) {
26     qux(x.func()) //~ ERROR mismatched types
27 }
28
29 fn foo2(x: impl Trait<i32>) {
30     qux(x.func()) //~ ERROR mismatched types
31 }
32
33 fn bar2<T: Trait<i32>>(x: T) {
34     qux(x.func()) //~ ERROR mismatched types
35 }
36
37 fn ban<T>(x: T) where T: Trait {
38     qux(x.func()) //~ ERROR mismatched types
39 }
40
41 fn qux(_: usize) {}
42
43 fn main() {}