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)]
18 #![feature(static_in_const)]
21 // These are expected to require translation.
22 #![rustc_partition_translated(module="struct_point-point", cfg="rpass2")]
23 #![rustc_partition_translated(module="struct_point-fn_calls_changed_method", cfg="rpass2")]
25 #![rustc_partition_reused(module="struct_point-fn_calls_another_method", cfg="rpass2")]
26 #![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="rpass2")]
27 #![rustc_partition_reused(module="struct_point-fn_read_field", cfg="rpass2")]
28 #![rustc_partition_reused(module="struct_point-fn_write_field", cfg="rpass2")]
38 pub fn distance_from_point(&self, p: Option<Point>) -> f32 {
39 let p = p.unwrap_or(Point { x: 0.0, y: 0.0 });
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;
46 pub fn distance_from_point(&self, p: Option<&Point>) -> f32 {
47 const ORIGIN: &Point = &Point { x: 0.0, y: 0.0 };
48 let p = p.unwrap_or(ORIGIN);
49 let x_diff = self.x - p.x;
50 let y_diff = self.y - p.y;
51 return x_diff * x_diff + y_diff * y_diff;
54 pub fn x(&self) -> f32 {
60 /// A fn item that calls the method that was changed
61 mod fn_calls_changed_method {
64 #[rustc_dirty(label="TypeckTables", cfg="rpass2")]
66 let p = Point { x: 2.0, y: 2.0 };
67 p.distance_from_point(None);
71 /// A fn item that calls a method that was not changed
72 mod fn_calls_another_method {
75 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
77 let p = Point { x: 2.0, y: 2.0 };
82 /// A fn item that makes an instance of `Point` but does not invoke methods
86 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
87 pub fn make_origin() -> Point {
88 Point { x: 2.0, y: 2.0 }
92 /// A fn item that reads fields from `Point` but does not invoke methods
96 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
97 pub fn get_x(p: Point) -> f32 {
102 /// A fn item that writes to a field of `Point` but does not invoke methods
106 #[rustc_clean(label="TypeckTables", cfg="rpass2")]
107 pub fn inc_x(p: &mut Point) {