summaryrefslogtreecommitdiffstats
path: root/src/test/ui/inference/need_type_info/type-alias.rs
blob: f921b046b6cac524f36cee427b81e2c56f0ada09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Test the inference errors in case the relevant path
// uses a type alias.
//
// Regression test for #97698.
struct Ty<T>(T);
impl<T> Ty<T> {
    fn new() {}
}

type DirectAlias<T> = Ty<T>;
fn direct_alias() {
    DirectAlias::new()
    //~^ ERROR type annotations needed
}

type IndirectAlias<T> = Ty<Box<T>>;
fn indirect_alias() {
    IndirectAlias::new();
    // FIXME: This should also emit an error.
    //
    // Added it separately as `type-alias-indirect.rs`
    // where it does error.
}

struct TyDefault<T, U = u32>(T, U);
impl<T> TyDefault<T> {
    fn new() {}
}

type DirectButWithDefaultAlias<T> = TyDefault<T>;
fn direct_but_with_default_alias() {
    DirectButWithDefaultAlias::new();
    //~^ ERROR type annotations needed
}

fn main() {}