]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/ich_method_call_trait_scope.rs
Rollup merge of #35558 - lukehinds:master, r=nikomatsakis
[rust.git] / src / test / incremental / ich_method_call_trait_scope.rs
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.
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 // Check that the hash for a method call is sensitive to the traits in
12 // scope.
13
14 // revisions: rpass1 rpass2
15
16 #![feature(rustc_attrs)]
17
18 fn test<T>() { }
19
20 trait Trait1 {
21     fn method(&self) { }
22 }
23
24 impl Trait1 for () { }
25
26 trait Trait2 {
27     fn method(&self) { }
28 }
29
30 impl Trait2 for () { }
31
32 #[cfg(rpass1)]
33 mod mod3 {
34     use Trait1;
35
36     fn bar() {
37         ().method();
38     }
39
40     fn baz() {
41         22; // no method call, traits in scope don't matter
42     }
43 }
44
45 #[cfg(rpass2)]
46 mod mod3 {
47     use Trait2;
48
49     #[rustc_dirty(label="Hir", cfg="rpass2")]
50     fn bar() {
51         ().method();
52     }
53
54     #[rustc_clean(label="Hir", cfg="rpass2")]
55     fn baz() {
56         22; // no method call, traits in scope don't matter
57     }
58 }
59
60 fn main() { }