]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs
Add test for eval order for a+=b
[rust.git] / src / test / incremental / add_private_fn_at_krate_root_cc / struct_point.rs
1 // Test where we add a private item into the root of an external.
2 // crate. This should not cause anything we use to be invalidated.
3 // Regression test for #36168.
4
5 // revisions:cfail1 cfail2
6 // compile-flags: -Z query-dep-graph
7 // aux-build:point.rs
8 // build-pass (FIXME(62277): could be check-pass?)
9
10 #![feature(rustc_attrs)]
11 #![feature(stmt_expr_attributes)]
12 #![allow(dead_code)]
13 #![crate_type = "rlib"]
14
15 #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="cfail2")]
16 #![rustc_partition_reused(module="struct_point-fn_calls_free_fn", cfg="cfail2")]
17 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="cfail2")]
18 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="cfail2")]
19 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="cfail2")]
20
21 extern crate point;
22
23 /// A fn item that calls (public) methods on `Point` from the same impl
24 pub mod fn_calls_methods_in_same_impl {
25     use point::Point;
26
27     #[rustc_clean(label="typeck", cfg="cfail2")]
28     pub fn check() {
29         let x = Point { x: 2.0, y: 2.0 };
30         x.distance_from_origin();
31     }
32 }
33
34 /// A fn item that calls (public) methods on `Point` from another impl
35 pub mod fn_calls_free_fn {
36     use point::{self, Point};
37
38     #[rustc_clean(label="typeck", cfg="cfail2")]
39     pub fn check() {
40         let x = Point { x: 2.0, y: 2.0 };
41         point::distance_squared(&x);
42     }
43 }
44
45 /// A fn item that makes an instance of `Point` but does not invoke methods
46 pub mod fn_make_struct {
47     use point::Point;
48
49     #[rustc_clean(label="typeck", cfg="cfail2")]
50     pub fn make_origin() -> Point {
51         Point { x: 2.0, y: 2.0 }
52     }
53 }
54
55 /// A fn item that reads fields from `Point` but does not invoke methods
56 pub mod fn_read_field {
57     use point::Point;
58
59     #[rustc_clean(label="typeck", cfg="cfail2")]
60     pub fn get_x(p: Point) -> f32 {
61         p.x
62     }
63 }
64
65 /// A fn item that writes to a field of `Point` but does not invoke methods
66 pub mod fn_write_field {
67     use point::Point;
68
69     #[rustc_clean(label="typeck", cfg="cfail2")]
70     pub fn inc_x(p: &mut Point) {
71         p.x += 1.0;
72     }
73 }