]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/change_private_fn_cc/struct_point.rs
d58a9bacdb53ca4c7ed10f500ea7b65257cc8815
[rust.git] / src / test / incremental / change_private_fn_cc / struct_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 // Test where we change the body of a private method in an impl.
12 // We then test what sort of functions must be rebuilt as a result.
13
14 // revisions:rpass1 rpass2
15 // compile-flags: -Z query-dep-graph
16 // aux-build:point.rs
17
18 // ignore-test -- ignored until red/green restores cross-crate tracking fidelity
19
20 #![feature(rustc_attrs)]
21 #![feature(stmt_expr_attributes)]
22 #![allow(dead_code)]
23
24 #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="rpass2")]
25 #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_another_impl", cfg="rpass2")]
26 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="rpass2")]
27 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="rpass2")]
28 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="rpass2")]
29
30 extern crate point;
31
32 /// A fn item that calls (public) methods on `Point` from the same impl which changed
33 mod fn_calls_methods_in_same_impl {
34     use point::Point;
35
36     #[rustc_clean(label="TypeckTables", cfg="rpass2")]
37     pub fn check() {
38         let x = Point { x: 2.0, y: 2.0 };
39         x.distance_from_origin();
40     }
41 }
42
43 /// A fn item that calls (public) methods on `Point` from another impl
44 mod fn_calls_methods_in_another_impl {
45     use point::Point;
46
47     #[rustc_clean(label="TypeckTables", cfg="rpass2")]
48     pub fn check() {
49         let mut x = Point { x: 2.0, y: 2.0 };
50         x.translate(3.0, 3.0);
51     }
52 }
53
54 /// A fn item that makes an instance of `Point` but does not invoke methods
55 mod fn_make_struct {
56     use point::Point;
57
58     #[rustc_clean(label="TypeckTables", cfg="rpass2")]
59     pub fn make_origin() -> Point {
60         Point { x: 2.0, y: 2.0 }
61     }
62 }
63
64 /// A fn item that reads fields from `Point` but does not invoke methods
65 mod fn_read_field {
66     use point::Point;
67
68     #[rustc_clean(label="TypeckTables", cfg="rpass2")]
69     pub fn get_x(p: Point) -> f32 {
70         p.x
71     }
72 }
73
74 /// A fn item that writes to a field of `Point` but does not invoke methods
75 mod fn_write_field {
76     use point::Point;
77
78     #[rustc_clean(label="TypeckTables", cfg="rpass2")]
79     pub fn inc_x(p: &mut Point) {
80         p.x += 1.0;
81     }
82 }
83
84 fn main() {
85 }