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.
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.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for closure expression.
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.
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
24 #![feature(rustc_attrs)]
28 // Change closure body ---------------------------------------------------------
30 pub fn change_closure_body() {
35 #[rustc_clean(cfg="cfail2", except="HirBody")]
36 #[rustc_clean(cfg="cfail3")]
37 pub fn change_closure_body() {
43 // Add parameter ---------------------------------------------------------------
45 pub fn add_parameter() {
51 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
52 #[rustc_clean(cfg="cfail3")]
53 pub fn add_parameter() {
55 let _ = |x: u32| x + 1;
60 // Change parameter pattern ----------------------------------------------------
62 pub fn change_parameter_pattern() {
67 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")]
68 #[rustc_clean(cfg="cfail3")]
69 pub fn change_parameter_pattern() {
75 // Add `move` to closure -------------------------------------------------------
82 #[rustc_clean(cfg="cfail2", except="HirBody")]
83 #[rustc_clean(cfg="cfail3")]
90 // Add type ascription to parameter --------------------------------------------
92 pub fn add_type_ascription_to_parameter() {
93 let closure = |x| x + 1u32;
94 let _: u32 = closure(1);
98 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")]
99 #[rustc_clean(cfg="cfail3")]
100 pub fn add_type_ascription_to_parameter() {
101 let closure = |x: u32| x + 1u32;
102 let _: u32 = closure(1);
107 // Change parameter type -------------------------------------------------------
109 pub fn change_parameter_type() {
110 let closure = |x: u32| (x as u64) + 1;
115 #[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, MirOptimized, TypeckTables")]
116 #[rustc_clean(cfg="cfail3")]
117 pub fn change_parameter_type() {
118 let closure = |x: u16| (x as u64) + 1;