aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/torture/impl_block3.rs
blob: 22ce19f704d2d5b709809016abd0daf6c7c0b932 (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
struct Point {
    x: f64,
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
    y: f64,
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
}

impl Point {
    fn origin() -> Point {
        Point { x: 0.0, y: 0.0 }
    }

    fn new(x: f64, y: f64) -> Point {
        Point { x: x, y: y }
    }
}

struct Rectangle {
    p1: Point,
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
    p2: Point,
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
}

impl Rectangle {
    fn from(p1: Point, p2: Point) -> Self {
        Self { p1, p2 }
    }
}

fn main() {
    let p1 = Point::origin();
    let p2 = Point::new(3.0, 4.0);
    let rect = Rectangle::from(p1, p2);
    // { dg-warning "unused name" "" { target *-*-* } .-1 }
}