]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/change_private_fn_cc/struct_point.rs
Lazily resolve type-alias-impl-trait defining uses
[rust.git] / src / test / incremental / change_private_fn_cc / struct_point.rs
1 // Test where we change the body of a private method in an impl.
2 // We then test what sort of functions must be rebuilt as a result.
3
4 // revisions:cfail1 cfail2
5 // compile-flags: -Z query-dep-graph
6 // aux-build:point.rs
7 // build-pass (FIXME(62277): could be check-pass?)
8
9 #![crate_type = "rlib"]
10 #![feature(rustc_attrs)]
11 #![feature(stmt_expr_attributes)]
12 #![allow(dead_code)]
13
14 #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="cfail2")]
15 #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_another_impl", cfg="cfail2")]
16 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="cfail2")]
17 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="cfail2")]
18 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="cfail2")]
19
20 extern crate point;
21
22 /// A fn item that calls (public) methods on `Point` from the same impl which changed
23 pub mod fn_calls_methods_in_same_impl {
24     use point::Point;
25
26     #[rustc_clean(cfg="cfail2")]
27     pub fn check() {
28         let x = Point { x: 2.0, y: 2.0 };
29         x.distance_from_origin();
30     }
31 }
32
33 /// A fn item that calls (public) methods on `Point` from another impl
34 pub mod fn_calls_methods_in_another_impl {
35     use point::Point;
36
37     #[rustc_clean(cfg="cfail2")]
38     pub fn check() {
39         let mut x = Point { x: 2.0, y: 2.0 };
40         x.translate(3.0, 3.0);
41     }
42 }
43
44 /// A fn item that makes an instance of `Point` but does not invoke methods
45 pub mod fn_make_struct {
46     use point::Point;
47
48     #[rustc_clean(cfg="cfail2")]
49     pub fn make_origin() -> Point {
50         Point { x: 2.0, y: 2.0 }
51     }
52 }
53
54 /// A fn item that reads fields from `Point` but does not invoke methods
55 pub mod fn_read_field {
56     use point::Point;
57
58     #[rustc_clean(cfg="cfail2")]
59     pub fn get_x(p: Point) -> f32 {
60         p.x
61     }
62 }
63
64 /// A fn item that writes to a field of `Point` but does not invoke methods
65 pub mod fn_write_field {
66     use point::Point;
67
68     #[rustc_clean(cfg="cfail2")]
69     pub fn inc_x(p: &mut Point) {
70         p.x += 1.0;
71     }
72 }