Skip to content

Commit 5957cfc

Browse files
authored
Rollup merge of rust-lang#37693 - michaelwoerister:ich-tests, r=brson
ICH: Add test case for call expressions. r? @nikomatsakis
2 parents 09b8837 + 669102f commit 5957cfc

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
// Copyright 2016 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+
12+
// This test case tests the incremental compilation hash (ICH) implementation
13+
// for function and method call expressions.
14+
15+
// The general pattern followed here is: Change one thing between rev1 and rev2
16+
// and make sure that the hash has changed, then change nothing between rev2 and
17+
// rev3 and make sure that the hash has not changed.
18+
19+
// must-compile-successfully
20+
// revisions: cfail1 cfail2 cfail3
21+
// compile-flags: -Z query-dep-graph
22+
23+
24+
#![allow(warnings)]
25+
#![feature(rustc_attrs)]
26+
#![crate_type="rlib"]
27+
28+
fn callee1(_x: u32, _y: i64) {}
29+
fn callee2(_x: u32, _y: i64) {}
30+
31+
32+
// Change Callee (Function) ----------------------------------------------------
33+
#[cfg(cfail1)]
34+
pub fn change_callee_function() {
35+
callee1(1, 2)
36+
}
37+
38+
#[cfg(not(cfail1))]
39+
#[rustc_dirty(label="Hir", cfg="cfail2")]
40+
#[rustc_clean(label="Hir", cfg="cfail3")]
41+
#[rustc_metadata_dirty(cfg="cfail2")]
42+
#[rustc_metadata_clean(cfg="cfail3")]
43+
pub fn change_callee_function() {
44+
callee2(1, 2)
45+
}
46+
47+
48+
49+
// Change Argument (Function) --------------------------------------------------
50+
#[cfg(cfail1)]
51+
pub fn change_argument_function() {
52+
callee1(1, 2)
53+
}
54+
55+
#[cfg(not(cfail1))]
56+
#[rustc_dirty(label="Hir", cfg="cfail2")]
57+
#[rustc_clean(label="Hir", cfg="cfail3")]
58+
#[rustc_metadata_dirty(cfg="cfail2")]
59+
#[rustc_metadata_clean(cfg="cfail3")]
60+
pub fn change_argument_function() {
61+
callee1(1, 3)
62+
}
63+
64+
65+
66+
// Change Callee Indirectly (Function) -----------------------------------------
67+
mod change_callee_indirectly_function {
68+
#[cfg(cfail1)]
69+
use super::callee1 as callee;
70+
#[cfg(not(cfail1))]
71+
use super::callee2 as callee;
72+
73+
#[rustc_dirty(label="Hir", cfg="cfail2")]
74+
#[rustc_clean(label="Hir", cfg="cfail3")]
75+
#[rustc_metadata_dirty(cfg="cfail2")]
76+
#[rustc_metadata_clean(cfg="cfail3")]
77+
pub fn change_callee_indirectly_function() {
78+
callee(1, 2)
79+
}
80+
}
81+
82+
83+
struct Struct;
84+
impl Struct {
85+
fn method1(&self, _x: char, _y: bool) {}
86+
fn method2(&self, _x: char, _y: bool) {}
87+
}
88+
89+
// Change Callee (Method) ------------------------------------------------------
90+
#[cfg(cfail1)]
91+
pub fn change_callee_method() {
92+
let s = Struct;
93+
s.method1('x', true);
94+
}
95+
96+
#[cfg(not(cfail1))]
97+
#[rustc_dirty(label="Hir", cfg="cfail2")]
98+
#[rustc_clean(label="Hir", cfg="cfail3")]
99+
#[rustc_metadata_dirty(cfg="cfail2")]
100+
#[rustc_metadata_clean(cfg="cfail3")]
101+
pub fn change_callee_method() {
102+
let s = Struct;
103+
s.method2('x', true);
104+
}
105+
106+
107+
108+
// Change Argument (Method) ----------------------------------------------------
109+
#[cfg(cfail1)]
110+
pub fn change_argument_method() {
111+
let s = Struct;
112+
s.method1('x', true);
113+
}
114+
115+
#[cfg(not(cfail1))]
116+
#[rustc_dirty(label="Hir", cfg="cfail2")]
117+
#[rustc_clean(label="Hir", cfg="cfail3")]
118+
#[rustc_metadata_dirty(cfg="cfail2")]
119+
#[rustc_metadata_clean(cfg="cfail3")]
120+
pub fn change_argument_method() {
121+
let s = Struct;
122+
s.method1('y', true);
123+
}
124+
125+
126+
127+
// Change Callee (Method, UFCS) ------------------------------------------------
128+
#[cfg(cfail1)]
129+
pub fn change_ufcs_callee_method() {
130+
let s = Struct;
131+
Struct::method1(&s, 'x', true);
132+
}
133+
134+
#[cfg(not(cfail1))]
135+
#[rustc_dirty(label="Hir", cfg="cfail2")]
136+
#[rustc_clean(label="Hir", cfg="cfail3")]
137+
#[rustc_metadata_dirty(cfg="cfail2")]
138+
#[rustc_metadata_clean(cfg="cfail3")]
139+
pub fn change_ufcs_callee_method() {
140+
let s = Struct;
141+
Struct::method2(&s, 'x', true);
142+
}
143+
144+
145+
146+
// Change Argument (Method, UFCS) ----------------------------------------------
147+
#[cfg(cfail1)]
148+
pub fn change_argument_method_ufcs() {
149+
let s = Struct;
150+
Struct::method1(&s, 'x', true);
151+
}
152+
153+
#[cfg(not(cfail1))]
154+
#[rustc_dirty(label="Hir", cfg="cfail2")]
155+
#[rustc_clean(label="Hir", cfg="cfail3")]
156+
#[rustc_metadata_dirty(cfg="cfail2")]
157+
#[rustc_metadata_clean(cfg="cfail3")]
158+
pub fn change_argument_method_ufcs() {
159+
let s = Struct;
160+
Struct::method1(&s, 'x', false);
161+
}
162+
163+
164+
165+
// Change To UFCS --------------------------------------------------------------
166+
#[cfg(cfail1)]
167+
pub fn change_to_ufcs() {
168+
let s = Struct;
169+
s.method1('x', true);
170+
}
171+
172+
#[cfg(not(cfail1))]
173+
#[rustc_dirty(label="Hir", cfg="cfail2")]
174+
#[rustc_clean(label="Hir", cfg="cfail3")]
175+
#[rustc_metadata_dirty(cfg="cfail2")]
176+
#[rustc_metadata_clean(cfg="cfail3")]
177+
pub fn change_to_ufcs() {
178+
let s = Struct;
179+
Struct::method1(&s, 'x', true);
180+
}
181+
182+
183+
struct Struct2;
184+
impl Struct2 {
185+
fn method1(&self, _x: char, _y: bool) {}
186+
}
187+
188+
// Change UFCS Callee Indirectly -----------------------------------------------
189+
mod change_ufcs_callee_indirectly {
190+
#[cfg(cfail1)]
191+
use super::Struct as Struct;
192+
#[cfg(not(cfail1))]
193+
use super::Struct2 as Struct;
194+
195+
#[rustc_dirty(label="Hir", cfg="cfail2")]
196+
#[rustc_clean(label="Hir", cfg="cfail3")]
197+
#[rustc_metadata_dirty(cfg="cfail2")]
198+
#[rustc_metadata_clean(cfg="cfail3")]
199+
pub fn change_ufcs_callee_indirectly() {
200+
let s = Struct;
201+
Struct::method1(&s, 'q', false)
202+
}
203+
}

0 commit comments

Comments
 (0)