Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c938007

Browse files
committedNov 17, 2016
add test for hashing trait impls
1 parent ab79438 commit c938007

File tree

1 file changed

+404
-0
lines changed

1 file changed

+404
-0
lines changed
 
Lines changed: 404 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,404 @@
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 let 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+
#![feature(specialization)]
27+
#![crate_type="rlib"]
28+
29+
struct Foo;
30+
31+
// Change Method Name -----------------------------------------------------------
32+
33+
#[cfg(cfail1)]
34+
pub trait ChangeMethodNameTrait {
35+
fn method_name();
36+
}
37+
38+
#[cfg(cfail1)]
39+
impl ChangeMethodNameTrait for Foo {
40+
fn method_name() { }
41+
}
42+
43+
#[cfg(not(cfail1))]
44+
#[rustc_dirty(label="Hir", cfg="cfail2")]
45+
#[rustc_clean(label="Hir", cfg="cfail3")]
46+
#[rustc_metadata_dirty(cfg="cfail2")]
47+
#[rustc_metadata_clean(cfg="cfail3")]
48+
pub trait ChangeMethodNameTrait {
49+
#[rustc_dirty(label="Hir", cfg="cfail2")]
50+
#[rustc_clean(label="Hir", cfg="cfail3")]
51+
#[rustc_metadata_dirty(cfg="cfail2")]
52+
#[rustc_metadata_clean(cfg="cfail3")]
53+
fn method_name2();
54+
}
55+
56+
#[cfg(not(cfail1))]
57+
#[rustc_dirty(label="Hir", cfg="cfail2")]
58+
#[rustc_clean(label="Hir", cfg="cfail3")]
59+
#[rustc_metadata_dirty(cfg="cfail2")]
60+
#[rustc_metadata_clean(cfg="cfail3")]
61+
impl ChangeMethodNameTrait for Foo {
62+
#[rustc_dirty(label="Hir", cfg="cfail2")]
63+
#[rustc_clean(label="Hir", cfg="cfail3")]
64+
#[rustc_metadata_dirty(cfg="cfail2")]
65+
#[rustc_metadata_clean(cfg="cfail3")]
66+
fn method_name2() { }
67+
}
68+
69+
// Change Method Body -----------------------------------------------------------
70+
//
71+
// This should affect the method itself, but not the trait.
72+
73+
pub trait ChangeMethodBodyTrait {
74+
fn method_name();
75+
}
76+
77+
#[cfg(cfail1)]
78+
impl ChangeMethodBodyTrait for Foo {
79+
fn method_name() { }
80+
}
81+
82+
#[cfg(not(cfail1))]
83+
#[rustc_clean(label="Hir", cfg="cfail2")]
84+
#[rustc_clean(label="Hir", cfg="cfail3")]
85+
#[rustc_metadata_clean(cfg="cfail2")]
86+
#[rustc_metadata_clean(cfg="cfail3")]
87+
impl ChangeMethodBodyTrait for Foo {
88+
#[rustc_dirty(label="Hir", cfg="cfail2")]
89+
#[rustc_clean(label="Hir", cfg="cfail3")]
90+
#[rustc_metadata_dirty(cfg="cfail2")]
91+
#[rustc_metadata_clean(cfg="cfail3")]
92+
fn method_name() {
93+
()
94+
}
95+
}
96+
97+
// Change Method Selfness -----------------------------------------------------------
98+
99+
#[cfg(cfail1)]
100+
pub trait ChangeMethodSelfnessTrait {
101+
fn method_name();
102+
}
103+
104+
#[cfg(cfail1)]
105+
impl ChangeMethodSelfnessTrait for Foo {
106+
fn method_name() { }
107+
}
108+
109+
#[cfg(not(cfail1))]
110+
pub trait ChangeMethodSelfnessTrait {
111+
fn method_name(&self);
112+
}
113+
114+
#[cfg(not(cfail1))]
115+
#[rustc_dirty(label="Hir", cfg="cfail2")]
116+
#[rustc_clean(label="Hir", cfg="cfail3")]
117+
#[rustc_metadata_dirty(cfg="cfail2")]
118+
#[rustc_metadata_clean(cfg="cfail3")]
119+
impl ChangeMethodSelfnessTrait for Foo {
120+
#[rustc_dirty(label="Hir", cfg="cfail2")]
121+
#[rustc_clean(label="Hir", cfg="cfail3")]
122+
#[rustc_metadata_dirty(cfg="cfail2")]
123+
#[rustc_metadata_clean(cfg="cfail3")]
124+
fn method_name(&self) {
125+
()
126+
}
127+
}
128+
129+
// Change Method Selfness -----------------------------------------------------------
130+
131+
#[cfg(cfail1)]
132+
pub trait RemoveMethodSelfnessTrait {
133+
fn method_name(&self);
134+
}
135+
136+
#[cfg(cfail1)]
137+
impl RemoveMethodSelfnessTrait for Foo {
138+
fn method_name(&self) { }
139+
}
140+
141+
#[cfg(not(cfail1))]
142+
pub trait RemoveMethodSelfnessTrait {
143+
fn method_name();
144+
}
145+
146+
#[cfg(not(cfail1))]
147+
#[rustc_dirty(label="Hir", cfg="cfail2")]
148+
#[rustc_clean(label="Hir", cfg="cfail3")]
149+
#[rustc_metadata_dirty(cfg="cfail2")]
150+
#[rustc_metadata_clean(cfg="cfail3")]
151+
impl RemoveMethodSelfnessTrait for Foo {
152+
#[rustc_dirty(label="Hir", cfg="cfail2")]
153+
#[rustc_clean(label="Hir", cfg="cfail3")]
154+
#[rustc_metadata_dirty(cfg="cfail2")]
155+
#[rustc_metadata_clean(cfg="cfail3")]
156+
fn method_name() {
157+
()
158+
}
159+
}
160+
161+
// Change Method Selfmutness -----------------------------------------------------------
162+
163+
#[cfg(cfail1)]
164+
pub trait ChangeMethodSelfmutnessTrait {
165+
fn method_name(&self);
166+
}
167+
168+
#[cfg(cfail1)]
169+
impl ChangeMethodSelfmutnessTrait for Foo {
170+
fn method_name(&self) { }
171+
}
172+
173+
#[cfg(not(cfail1))]
174+
pub trait ChangeMethodSelfmutnessTrait {
175+
fn method_name(&mut self);
176+
}
177+
178+
#[cfg(not(cfail1))]
179+
#[rustc_clean(label="Hir", cfg="cfail2")]
180+
#[rustc_clean(label="Hir", cfg="cfail3")]
181+
#[rustc_metadata_dirty(cfg="cfail2")]
182+
#[rustc_metadata_clean(cfg="cfail3")]
183+
impl ChangeMethodSelfmutnessTrait for Foo {
184+
#[rustc_dirty(label="Hir", cfg="cfail2")]
185+
#[rustc_clean(label="Hir", cfg="cfail3")]
186+
#[rustc_metadata_dirty(cfg="cfail2")]
187+
#[rustc_metadata_clean(cfg="cfail3")]
188+
fn method_name(&mut self) {
189+
()
190+
}
191+
}
192+
193+
// Change item kind -----------------------------------------------------------
194+
195+
#[cfg(cfail1)]
196+
pub trait ChangeItemKindTrait {
197+
fn name();
198+
}
199+
200+
#[cfg(cfail1)]
201+
impl ChangeItemKindTrait for Foo {
202+
fn name() { }
203+
}
204+
205+
#[cfg(not(cfail1))]
206+
pub trait ChangeItemKindTrait {
207+
type name;
208+
}
209+
210+
#[cfg(not(cfail1))]
211+
#[rustc_dirty(label="Hir", cfg="cfail2")]
212+
#[rustc_clean(label="Hir", cfg="cfail3")]
213+
#[rustc_metadata_dirty(cfg="cfail2")]
214+
#[rustc_metadata_clean(cfg="cfail3")]
215+
impl ChangeItemKindTrait for Foo {
216+
type name = ();
217+
}
218+
219+
// Remove item -----------------------------------------------------------
220+
221+
#[cfg(cfail1)]
222+
pub trait RemoveItemTrait {
223+
type TypeName;
224+
fn method_name();
225+
}
226+
227+
#[cfg(cfail1)]
228+
impl RemoveItemTrait for Foo {
229+
type TypeName = ();
230+
fn method_name() { }
231+
}
232+
233+
#[cfg(not(cfail1))]
234+
pub trait RemoveItemTrait {
235+
type TypeName;
236+
}
237+
238+
#[cfg(not(cfail1))]
239+
#[rustc_dirty(label="Hir", cfg="cfail2")]
240+
#[rustc_clean(label="Hir", cfg="cfail3")]
241+
#[rustc_metadata_dirty(cfg="cfail2")]
242+
#[rustc_metadata_clean(cfg="cfail3")]
243+
impl RemoveItemTrait for Foo {
244+
type TypeName = ();
245+
}
246+
247+
// Add item -----------------------------------------------------------
248+
249+
#[cfg(cfail1)]
250+
pub trait AddItemTrait {
251+
type TypeName;
252+
}
253+
254+
#[cfg(cfail1)]
255+
impl AddItemTrait for Foo {
256+
type TypeName = ();
257+
}
258+
259+
#[cfg(not(cfail1))]
260+
pub trait AddItemTrait {
261+
type TypeName;
262+
fn method_name();
263+
}
264+
265+
#[cfg(not(cfail1))]
266+
#[rustc_dirty(label="Hir", cfg="cfail2")]
267+
#[rustc_clean(label="Hir", cfg="cfail3")]
268+
#[rustc_metadata_dirty(cfg="cfail2")]
269+
#[rustc_metadata_clean(cfg="cfail3")]
270+
impl AddItemTrait for Foo {
271+
type TypeName = ();
272+
fn method_name() { }
273+
}
274+
275+
// Change has-value -----------------------------------------------------------
276+
277+
#[cfg(cfail1)]
278+
pub trait ChangeHasValueTrait {
279+
fn method_name();
280+
}
281+
282+
#[cfg(cfail1)]
283+
impl ChangeHasValueTrait for Foo {
284+
fn method_name() { }
285+
}
286+
287+
#[cfg(not(cfail1))]
288+
#[rustc_dirty(label="Hir", cfg="cfail2")]
289+
#[rustc_clean(label="Hir", cfg="cfail3")]
290+
#[rustc_metadata_dirty(cfg="cfail2")]
291+
#[rustc_metadata_clean(cfg="cfail3")]
292+
pub trait ChangeHasValueTrait {
293+
fn method_name() { }
294+
}
295+
296+
#[cfg(not(cfail1))]
297+
#[rustc_clean(label="Hir", cfg="cfail2")]
298+
#[rustc_clean(label="Hir", cfg="cfail3")]
299+
#[rustc_metadata_dirty(cfg="cfail2")]
300+
#[rustc_metadata_clean(cfg="cfail3")]
301+
impl ChangeHasValueTrait for Foo {
302+
fn method_name() { }
303+
}
304+
305+
// Add default
306+
307+
pub trait AddDefaultTrait {
308+
fn method_name();
309+
}
310+
311+
#[cfg(cfail1)]
312+
impl AddDefaultTrait for Foo {
313+
fn method_name() { }
314+
}
315+
316+
#[cfg(not(cfail1))]
317+
#[rustc_dirty(label="Hir", cfg="cfail2")]
318+
#[rustc_clean(label="Hir", cfg="cfail3")]
319+
#[rustc_metadata_dirty(cfg="cfail2")]
320+
#[rustc_metadata_clean(cfg="cfail3")]
321+
impl AddDefaultTrait for Foo {
322+
default fn method_name() { }
323+
}
324+
325+
// Remove default
326+
327+
pub trait RemoveDefaultTrait {
328+
fn method_name();
329+
}
330+
331+
#[cfg(cfail1)]
332+
impl RemoveDefaultTrait for Foo {
333+
default fn method_name() { }
334+
}
335+
336+
#[cfg(not(cfail1))]
337+
#[rustc_dirty(label="Hir", cfg="cfail2")]
338+
#[rustc_clean(label="Hir", cfg="cfail3")]
339+
#[rustc_metadata_dirty(cfg="cfail2")]
340+
#[rustc_metadata_clean(cfg="cfail3")]
341+
impl RemoveDefaultTrait for Foo {
342+
fn method_name() { }
343+
}
344+
345+
// Add arguments
346+
347+
#[cfg(cfail1)]
348+
pub trait AddArgumentTrait {
349+
fn method_name(&self);
350+
}
351+
352+
#[cfg(cfail1)]
353+
impl AddArgumentTrait for Foo {
354+
fn method_name(&self) { }
355+
}
356+
357+
#[cfg(not(cfail1))]
358+
pub trait AddArgumentTrait {
359+
fn method_name(&self, x: u32);
360+
}
361+
362+
#[cfg(not(cfail1))]
363+
#[rustc_clean(label="Hir", cfg="cfail2")]
364+
#[rustc_clean(label="Hir", cfg="cfail3")]
365+
#[rustc_metadata_dirty(cfg="cfail2")]
366+
#[rustc_metadata_clean(cfg="cfail3")]
367+
impl AddArgumentTrait for Foo {
368+
#[rustc_dirty(label="Hir", cfg="cfail2")]
369+
#[rustc_clean(label="Hir", cfg="cfail3")]
370+
#[rustc_metadata_dirty(cfg="cfail2")]
371+
#[rustc_metadata_clean(cfg="cfail3")]
372+
fn method_name(&self, _x: u32) { }
373+
}
374+
375+
// Change argument type
376+
377+
#[cfg(cfail1)]
378+
pub trait ChangeArgumentTypeTrait {
379+
fn method_name(&self, x: u32);
380+
}
381+
382+
#[cfg(cfail1)]
383+
impl ChangeArgumentTypeTrait for Foo {
384+
fn method_name(&self, _x: u32) { }
385+
}
386+
387+
#[cfg(not(cfail1))]
388+
pub trait ChangeArgumentTypeTrait {
389+
fn method_name(&self, x: char);
390+
}
391+
392+
#[cfg(not(cfail1))]
393+
#[rustc_clean(label="Hir", cfg="cfail2")]
394+
#[rustc_clean(label="Hir", cfg="cfail3")]
395+
#[rustc_metadata_dirty(cfg="cfail2")]
396+
#[rustc_metadata_clean(cfg="cfail3")]
397+
impl ChangeArgumentTypeTrait for Foo {
398+
#[rustc_dirty(label="Hir", cfg="cfail2")]
399+
#[rustc_clean(label="Hir", cfg="cfail3")]
400+
#[rustc_metadata_dirty(cfg="cfail2")]
401+
#[rustc_metadata_clean(cfg="cfail3")]
402+
fn method_name(&self, _x: char) { }
403+
}
404+

0 commit comments

Comments
 (0)
Please sign in to comment.