]> git.lizzy.rs Git - rust.git/blob - tests/ui/inference/need_type_info/type-alias.rs
Auto merge of #107021 - matthiaskrgr:rollup-0dzxfyi, r=matthiaskrgr
[rust.git] / tests / ui / inference / need_type_info / type-alias.rs
1 // Test the inference errors in case the relevant path
2 // uses a type alias.
3 //
4 // Regression test for #97698.
5 struct Ty<T>(T);
6 impl<T> Ty<T> {
7     fn new() {}
8 }
9
10 type DirectAlias<T> = Ty<T>;
11 fn direct_alias() {
12     DirectAlias::new()
13     //~^ ERROR type annotations needed
14 }
15
16 type IndirectAlias<T> = Ty<Box<T>>;
17 fn indirect_alias() {
18     IndirectAlias::new();
19     // FIXME: This should also emit an error.
20     //
21     // Added it separately as `type-alias-indirect.rs`
22     // where it does error.
23 }
24
25 struct TyDefault<T, U = u32>(T, U);
26 impl<T> TyDefault<T> {
27     fn new() {}
28 }
29
30 type DirectButWithDefaultAlias<T> = TyDefault<T>;
31 fn direct_but_with_default_alias() {
32     DirectButWithDefaultAlias::new();
33     //~^ ERROR type annotations needed
34 }
35
36 fn main() {}