1 // Test where we change the *signature* of a public, inherent method.
3 // revisions:cfail1 cfail2
4 // compile-flags: -Z query-dep-graph
7 #![crate_type = "rlib"]
8 #![feature(rustc_attrs)]
9 #![feature(stmt_expr_attributes)]
12 // These are expected to require codegen.
13 #![rustc_partition_codegened(module="struct_point-point", cfg="cfail2")]
14 #![rustc_partition_codegened(module="struct_point-fn_calls_changed_method", cfg="cfail2")]
16 #![rustc_partition_reused(module="struct_point-fn_calls_another_method", cfg="cfail2")]
17 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="cfail2")]
18 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="cfail2")]
19 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="cfail2")]
29 pub fn distance_from_point(&self, p: Option<Point>) -> f32 {
30 let p = p.unwrap_or(Point { x: 0.0, y: 0.0 });
31 let x_diff = self.x - p.x;
32 let y_diff = self.y - p.y;
33 return x_diff * x_diff + y_diff * y_diff;
37 pub fn distance_from_point(&self, p: Option<&Point>) -> f32 {
38 const ORIGIN: &Point = &Point { x: 0.0, y: 0.0 };
39 let p = p.unwrap_or(ORIGIN);
40 let x_diff = self.x - p.x;
41 let y_diff = self.y - p.y;
42 return x_diff * x_diff + y_diff * y_diff;
45 pub fn x(&self) -> f32 {
51 /// A fn item that calls the method that was changed
52 pub mod fn_calls_changed_method {
55 #[rustc_clean(except="typeck,optimized_mir", cfg="cfail2")]
57 let p = Point { x: 2.0, y: 2.0 };
58 p.distance_from_point(None);
62 /// A fn item that calls a method that was not changed
63 pub mod fn_calls_another_method {
66 #[rustc_clean(cfg="cfail2")]
68 let p = Point { x: 2.0, y: 2.0 };
73 /// A fn item that makes an instance of `Point` but does not invoke methods
74 pub mod fn_make_struct {
77 #[rustc_clean(cfg="cfail2")]
78 pub fn make_origin() -> Point {
79 Point { x: 2.0, y: 2.0 }
83 /// A fn item that reads fields from `Point` but does not invoke methods
84 pub mod fn_read_field {
87 #[rustc_clean(cfg="cfail2")]
88 pub fn get_x(p: Point) -> f32 {
93 /// A fn item that writes to a field of `Point` but does not invoke methods
94 pub mod fn_write_field {
97 #[rustc_clean(cfg="cfail2")]
98 pub fn inc_x(p: &mut Point) {