1 // Test where we change the body of a public, inherent method.
3 // revisions:cfail1 cfail2
4 // compile-flags: -Z query-dep-graph
5 // build-pass (FIXME(62277): could be check-pass?)
7 #![crate_type = "rlib"]
8 #![feature(rustc_attrs)]
9 #![feature(stmt_expr_attributes)]
12 #![rustc_partition_codegened(module="struct_point-point", cfg="cfail2")]
14 #![rustc_partition_reused(module="struct_point-fn_calls_changed_method", cfg="cfail2")]
15 #![rustc_partition_reused(module="struct_point-fn_calls_another_method", cfg="cfail2")]
16 #![rustc_partition_reused(module="struct_point-fn_make_struct", 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")]
27 pub fn distance_from_origin(&self) -> f32 {
29 return self.x * self.x + self.y * self.y;
32 return (self.x * self.x + self.y * self.y).sqrt();
35 pub fn x(&self) -> f32 {
41 /// A fn item that calls the method on `Point` which changed
42 pub mod fn_calls_changed_method {
45 #[rustc_clean(label="typeck", cfg="cfail2")]
47 let p = Point { x: 2.0, y: 2.0 };
48 p.distance_from_origin();
52 /// A fn item that calls a method on `Point` which did not change
53 pub mod fn_calls_another_method {
56 #[rustc_clean(label="typeck", cfg="cfail2")]
58 let p = Point { x: 2.0, y: 2.0 };
63 /// A fn item that makes an instance of `Point` but does not invoke methods
64 pub mod fn_make_struct {
67 #[rustc_clean(label="typeck", cfg="cfail2")]
68 pub fn make_origin() -> Point {
69 Point { x: 2.0, y: 2.0 }
73 /// A fn item that reads fields from `Point` but does not invoke methods
74 pub mod fn_read_field {
77 #[rustc_clean(label="typeck", cfg="cfail2")]
78 pub fn get_x(p: Point) -> f32 {
83 /// A fn item that writes to a field of `Point` but does not invoke methods
84 pub mod fn_write_field {
87 #[rustc_clean(label="typeck", cfg="cfail2")]
88 pub fn inc_x(p: &mut Point) {