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.
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.
11 // Test where we change the *signature* of a public, inherent method.
13 // revisions:rpass1 rpass2
14 // compile-flags: -Z query-dep-graph
16 #![feature(rustc_attrs)]
17 #![feature(stmt_expr_attributes)]
20 // These are expected to require translation.
21 #![rustc_partition_translated(module="struct_point-point", cfg="rpass2")]
22 #![rustc_partition_translated(module="struct_point-fn_calls_changed_method", cfg="rpass2")]
24 #![rustc_partition_reused(module="struct_point-fn_calls_another_method", cfg="rpass2")]
25 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="rpass2")]
26 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="rpass2")]
27 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="rpass2")]
37 pub fn distance_from_point(&self, p: Option<Point>) -> f32 {
38 let p = p.unwrap_or(Point { x: 0.0, y: 0.0 });
39 let x_diff = self.x - p.x;
40 let y_diff = self.y - p.y;
41 return x_diff * x_diff + y_diff * y_diff;
45 pub fn distance_from_point(&self, p: Option<&Point>) -> f32 {
46 const ORIGIN: &Point = &Point { x: 0.0, y: 0.0 };
47 let p = p.unwrap_or(ORIGIN);
48 let x_diff = self.x - p.x;
49 let y_diff = self.y - p.y;
50 return x_diff * x_diff + y_diff * y_diff;
53 pub fn x(&self) -> f32 {
59 /// A fn item that calls the method that was changed
60 mod fn_calls_changed_method {
63 #[rustc_dirty(label="TypeckTables", cfg="rpass2")]
65 let p = Point { x: 2.0, y: 2.0 };
66 p.distance_from_point(None);
70 /// A fn item that calls a method that was not changed
71 mod fn_calls_another_method {
74 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
76 let p = Point { x: 2.0, y: 2.0 };
81 /// A fn item that makes an instance of `Point` but does not invoke methods
85 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
86 pub fn make_origin() -> Point {
87 Point { x: 2.0, y: 2.0 }
91 /// A fn item that reads fields from `Point` but does not invoke methods
95 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
96 pub fn get_x(p: Point) -> f32 {
101 /// A fn item that writes to a field of `Point` but does not invoke methods
105 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
106 pub fn inc_x(p: &mut Point) {