]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs
Number of filtered out tests in tests summary
[rust.git] / src / test / incremental / change_private_impl_method_cc / auxiliary / point.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -Z incremental-cc
12
13 pub struct Point {
14     pub x: f32,
15     pub y: f32,
16 }
17
18 impl Point {
19     fn distance_squared(&self) -> f32 {
20         #[cfg(rpass1)]
21         return self.x + self.y;
22
23         #[cfg(rpass2)]
24         return self.x * self.x + self.y * self.y;
25     }
26
27     pub fn distance_from_origin(&self) -> f32 {
28         self.distance_squared().sqrt()
29     }
30 }
31
32 impl Point {
33     pub fn translate(&mut self, x: f32, y: f32) {
34         self.x += x;
35         self.y += y;
36     }
37 }