]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/issue-42602.rs
Rollup merge of #56476 - GuillaumeGomez:invalid-line-number-match, r=QuietMisdreavus
[rust.git] / src / test / incremental / issue-42602.rs
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 // Regression test for #42602. It used to be that we had
12 // a dep-graph like
13 //
14 //     typeck(foo) -> FnOnce -> typeck(bar)
15 //
16 // This was fixed by improving the resolution of the `FnOnce` trait
17 // selection node.
18
19 // revisions:cfail1 cfail2 cfail3
20 // compile-flags:-Zquery-dep-graph
21 // compile-pass
22
23 #![feature(rustc_attrs)]
24
25 fn main() {
26     a::foo();
27     b::bar();
28 }
29
30 mod a {
31     #[cfg(cfail1)]
32     pub fn foo() {
33         let x = vec![1, 2, 3];
34         let v = || ::std::mem::drop(x);
35         v();
36     }
37
38     #[cfg(not(cfail1))]
39     pub fn foo() {
40         let x = vec![1, 2, 3, 4];
41         let v = || ::std::mem::drop(x);
42         v();
43     }
44 }
45
46 mod b {
47     #[rustc_clean(cfg="cfail2")]
48     #[rustc_clean(cfg="cfail3")]
49     pub fn bar() {
50         let x = vec![1, 2, 3];
51         let v = || ::std::mem::drop(x);
52         v();
53     }
54 }