]>
Commit | Line | Data |
---|---|---|
c30ab7b3 SL |
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 | ||
abe05a73 | 14 | // revisions:cfail1 cfail2 |
c30ab7b3 SL |
15 | // compile-flags: -Z query-dep-graph |
16 | // aux-build:point.rs | |
abe05a73 | 17 | // must-compile-successfully |
c30ab7b3 | 18 | |
abe05a73 | 19 | #![crate_type = "rlib"] |
c30ab7b3 SL |
20 | #![feature(rustc_attrs)] |
21 | #![feature(stmt_expr_attributes)] | |
22 | #![allow(dead_code)] | |
23 | ||
abe05a73 XL |
24 | #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="cfail2")] |
25 | #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="cfail2")] | |
26 | #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="cfail2")] | |
476ff2be | 27 | |
abe05a73 XL |
28 | #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="cfail2")] |
29 | #![rustc_partition_reused(module="struct_point-fn_calls_methods_in_another_impl", cfg="cfail2")] | |
c30ab7b3 SL |
30 | |
31 | extern crate point; | |
32 | ||
33 | /// A fn item that calls (public) methods on `Point` from the same impl which changed | |
abe05a73 | 34 | pub mod fn_calls_methods_in_same_impl { |
c30ab7b3 SL |
35 | use point::Point; |
36 | ||
abe05a73 | 37 | #[rustc_clean(label="TypeckTables", cfg="cfail2")] |
c30ab7b3 SL |
38 | pub fn check() { |
39 | let x = Point { x: 2.0, y: 2.0 }; | |
40 | x.distance_from_origin(); | |
41 | } | |
42 | } | |
43 | ||
44 | /// A fn item that calls (public) methods on `Point` from another impl | |
abe05a73 | 45 | pub mod fn_calls_methods_in_another_impl { |
c30ab7b3 SL |
46 | use point::Point; |
47 | ||
abe05a73 | 48 | #[rustc_clean(label="TypeckTables", cfg="cfail2")] |
476ff2be | 49 | pub fn dirty() { |
c30ab7b3 SL |
50 | let mut x = Point { x: 2.0, y: 2.0 }; |
51 | x.translate(3.0, 3.0); | |
52 | } | |
53 | } | |
54 | ||
55 | /// A fn item that makes an instance of `Point` but does not invoke methods | |
abe05a73 | 56 | pub mod fn_make_struct { |
c30ab7b3 SL |
57 | use point::Point; |
58 | ||
abe05a73 | 59 | #[rustc_clean(label="TypeckTables", cfg="cfail2")] |
c30ab7b3 SL |
60 | pub fn make_origin() -> Point { |
61 | Point { x: 2.0, y: 2.0 } | |
62 | } | |
63 | } | |
64 | ||
65 | /// A fn item that reads fields from `Point` but does not invoke methods | |
abe05a73 | 66 | pub mod fn_read_field { |
c30ab7b3 SL |
67 | use point::Point; |
68 | ||
abe05a73 | 69 | #[rustc_clean(label="TypeckTables", cfg="cfail2")] |
c30ab7b3 SL |
70 | pub fn get_x(p: Point) -> f32 { |
71 | p.x | |
72 | } | |
73 | } | |
74 | ||
75 | /// A fn item that writes to a field of `Point` but does not invoke methods | |
abe05a73 | 76 | pub mod fn_write_field { |
c30ab7b3 SL |
77 | use point::Point; |
78 | ||
abe05a73 | 79 | #[rustc_clean(label="TypeckTables", cfg="cfail2")] |
c30ab7b3 SL |
80 | pub fn inc_x(p: &mut Point) { |
81 | p.x += 1.0; | |
82 | } | |
83 | } |