summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/suggest-assign-rvalue.rs
blob: aaca9d47f0aee07bacb6c6217a31e983b80903a0 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![allow(dead_code)]
#![feature(never_type)]

#[derive(Debug, Default)]
struct Demo {}

#[derive(Debug)]
struct DemoNoDef {}

fn apple(_: u32) {}

fn banana() {
    let chaenomeles;
    apple(chaenomeles);
    //~^ ERROR used binding `chaenomeles` isn't initialized [E0381]
}

fn main() {
    let my_bool: bool = bool::default();
    println!("my_bool: {}", my_bool);

    let my_float: f32;
    println!("my_float: {}", my_float);
    //~^ ERROR used binding `my_float` isn't initialized
    let demo: Demo;
    println!("demo: {:?}", demo);
    //~^ ERROR used binding `demo` isn't initialized

    let demo_no: DemoNoDef;
    println!("demo_no: {:?}", demo_no);
    //~^ ERROR used binding `demo_no` isn't initialized

    let arr: [i32; 5];
    println!("arr: {:?}", arr);
    //~^ ERROR used binding `arr` isn't initialized
    let foo: Vec<&str>;
    println!("foo: {:?}", foo);
    //~^ ERROR used binding `foo` isn't initialized

    let my_string: String;
    println!("my_string: {}", my_string);
    //~^ ERROR used binding `my_string` isn't initialized

    let my_int: &i32;
    println!("my_int: {}", *my_int);
    //~^ ERROR used binding `my_int` isn't initialized

    let hello: &str;
    println!("hello: {}", hello);
    //~^ ERROR used binding `hello` isn't initialized

    let never: !;
    println!("never: {}", never);
    //~^ ERROR used binding `never` isn't initialized [E0381]

    banana();
}