summaryrefslogtreecommitdiffstats
path: root/tests/ui/typeck/typeck_type_placeholder_item_help.rs
blob: 914f8a2b28b343f1d1428ea700a31ffcb401c7ba (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
// This test checks that it proper item type will be suggested when
// using the `_` type placeholder.

fn test1() -> _ { Some(42) }
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types

const TEST2: _ = 42u32;
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants

const TEST3: _ = Some(42);
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants

const TEST4: fn() -> _ = 42;
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
//~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items

trait Test5 {
    const TEST5: _ = 42;
    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
}

struct Test6;

impl Test6 {
    const TEST6: _ = 13;
    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
}

pub fn main() {
    let _: Option<usize> = test1();
    let _: f64 = test1();
    let _: Option<i32> = test1();
}