about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-12-12 14:10:33 -0500
committerGitHub <noreply@github.com>2016-12-12 14:10:33 -0500
commita9dcfd0936afb24fd3b4127e9e0af5da10f0dc96 (patch)
treea7ac63ba8a274bf83046c5bbafa2025250e80511
parent5e425b7b4ba77655032249027f3b2f969d154c48 (diff)
parent9ccd5c5739e3b188a6c82b709fbb4adbd73ba331 (diff)
downloadrust-a9dcfd0936afb24fd3b4127e9e0af5da10f0dc96.tar.gz
rust-a9dcfd0936afb24fd3b4127e9e0af5da10f0dc96.zip
Rollup merge of #38202 - michaelwoerister:closure-ich-test, r=nikomatsakis
Some incr. comp. hash tests

r? @nikomatsakis
-rw-r--r--src/test/incremental/hashes/closure_expressions.rs144
-rw-r--r--src/test/incremental/hashes/enum_constructors.rs387
-rw-r--r--src/test/incremental/hashes/exported_vs_not.rs86
-rw-r--r--src/test/incremental/hashes/indexing_expressions.rs157
-rw-r--r--src/test/incremental/hashes/struct_constructors.rs12
5 files changed, 786 insertions, 0 deletions
diff --git a/src/test/incremental/hashes/closure_expressions.rs b/src/test/incremental/hashes/closure_expressions.rs
new file mode 100644
index 00000000000..38fe5cdffeb
--- /dev/null
+++ b/src/test/incremental/hashes/closure_expressions.rs
@@ -0,0 +1,144 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+// This test case tests the incremental compilation hash (ICH) implementation
+// for closure expression.
+
+// The general pattern followed here is: Change one thing between rev1 and rev2
+// and make sure that the hash has changed, then change nothing between rev2 and
+// rev3 and make sure that the hash has not changed.
+
+// must-compile-successfully
+// revisions: cfail1 cfail2 cfail3
+// compile-flags: -Z query-dep-graph
+
+#![allow(warnings)]
+#![feature(rustc_attrs)]
+#![crate_type="rlib"]
+
+
+// Change closure body ---------------------------------------------------------
+#[cfg(cfail1)]
+fn change_closure_body() {
+    let _ = || 1u32;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_closure_body() {
+    let _ = || 3u32;
+}
+
+
+
+// Add parameter ---------------------------------------------------------------
+#[cfg(cfail1)]
+fn add_parameter() {
+    let x = 0u32;
+    let _ = || x + 1;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn add_parameter() {
+    let x = 0u32;
+    let _ = |x: u32| x + 1;
+}
+
+
+
+// Change parameter pattern ----------------------------------------------------
+#[cfg(cfail1)]
+fn change_parameter_pattern() {
+    let _ = |x: &u32| x;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_parameter_pattern() {
+    let _ = |&x: &u32| x;
+}
+
+
+
+// Add `move` to closure -------------------------------------------------------
+#[cfg(cfail1)]
+fn add_move() {
+    let _ = || 1;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn add_move() {
+    let _ = move || 1;
+}
+
+
+
+// Add type ascription to parameter --------------------------------------------
+#[cfg(cfail1)]
+fn add_type_ascription_to_parameter() {
+    let closure = |x| x + 1u32;
+    let _: u32 = closure(1);
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn add_type_ascription_to_parameter() {
+    let closure = |x: u32| x + 1u32;
+    let _: u32 = closure(1);
+}
+
+
+
+// Change parameter type -------------------------------------------------------
+#[cfg(cfail1)]
+fn change_parameter_type() {
+    let closure = |x: u32| (x as u64) + 1;
+    let _ = closure(1);
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_parameter_type() {
+    let closure = |x: u16| (x as u64) + 1;
+    let _ = closure(1);
+}
diff --git a/src/test/incremental/hashes/enum_constructors.rs b/src/test/incremental/hashes/enum_constructors.rs
new file mode 100644
index 00000000000..7f991b30fc4
--- /dev/null
+++ b/src/test/incremental/hashes/enum_constructors.rs
@@ -0,0 +1,387 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+// This test case tests the incremental compilation hash (ICH) implementation
+// for struct constructor expressions.
+
+// The general pattern followed here is: Change one thing between rev1 and rev2
+// and make sure that the hash has changed, then change nothing between rev2 and
+// rev3 and make sure that the hash has not changed.
+
+// must-compile-successfully
+// revisions: cfail1 cfail2 cfail3
+// compile-flags: -Z query-dep-graph
+
+#![allow(warnings)]
+#![feature(rustc_attrs)]
+#![crate_type="rlib"]
+
+
+enum Enum {
+    Struct {
+        x: i32,
+        y: i64,
+        z: i16,
+    },
+    Tuple(i32, i64, i16)
+}
+
+// Change field value (struct-like) -----------------------------------------
+#[cfg(cfail1)]
+fn change_field_value_struct_like() -> Enum {
+    Enum::Struct {
+        x: 0,
+        y: 1,
+        z: 2,
+    }
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_field_value_struct_like() -> Enum {
+    Enum::Struct {
+        x: 0,
+        y: 2,
+        z: 2,
+    }
+}
+
+
+
+// Change field order (struct-like) -----------------------------------------
+#[cfg(cfail1)]
+fn change_field_order_struct_like() -> Enum {
+    Enum::Struct {
+        x: 3,
+        y: 4,
+        z: 5,
+    }
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_field_order_struct_like() -> Enum {
+    Enum::Struct {
+        y: 4,
+        x: 3,
+        z: 5,
+    }
+}
+
+
+enum Enum2 {
+    Struct {
+        x: i8,
+        y: i8,
+        z: i8,
+    },
+    Struct2 {
+        x: i8,
+        y: i8,
+        z: i8,
+    },
+    Tuple(u16, u16, u16),
+    Tuple2(u64, u64, u64),
+}
+
+// Change constructor path (struct-like) ------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_path_struct_like() {
+    let _ = Enum::Struct {
+        x: 0,
+        y: 1,
+        z: 2,
+    };
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_path_struct_like() {
+    let _ = Enum2::Struct {
+        x: 0,
+        y: 1,
+        z: 2,
+    };
+}
+
+
+
+// Change variant (regular struct) ------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_variant_struct_like() {
+    let _ = Enum2::Struct {
+        x: 0,
+        y: 1,
+        z: 2,
+    };
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_variant_struct_like() {
+    let _ = Enum2::Struct2 {
+        x: 0,
+        y: 1,
+        z: 2,
+    };
+}
+
+
+// Change constructor path indirectly (struct-like) -------------------------
+mod change_constructor_path_indirectly_struct_like {
+    #[cfg(cfail1)]
+    use super::Enum as TheEnum;
+    #[cfg(not(cfail1))]
+    use super::Enum2 as TheEnum;
+
+    #[rustc_dirty(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_dirty(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> TheEnum {
+        TheEnum::Struct {
+            x: 0,
+            y: 1,
+            z: 2,
+        }
+    }
+}
+
+
+// Change constructor variant indirectly (struct-like) ---------------------------
+mod change_constructor_variant_indirectly_struct_like {
+    use super::Enum2;
+    #[cfg(cfail1)]
+    use super::Enum2::Struct as Variant;
+    #[cfg(not(cfail1))]
+    use super::Enum2::Struct2 as Variant;
+
+    #[rustc_clean(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_clean(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> Enum2 {
+        Variant {
+            x: 0,
+            y: 1,
+            z: 2,
+        }
+    }
+}
+
+
+// Change field value (tuple-like) -------------------------------------------
+#[cfg(cfail1)]
+fn change_field_value_tuple_like() -> Enum {
+    Enum::Tuple(0, 1, 2)
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_field_value_tuple_like() -> Enum {
+    Enum::Tuple(0, 1, 3)
+}
+
+
+
+// Change constructor path (tuple-like) --------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_path_tuple_like() {
+    let _ = Enum::Tuple(0, 1, 2);
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_path_tuple_like() {
+    let _ = Enum2::Tuple(0, 1, 2);
+}
+
+
+
+// Change constructor variant (tuple-like) --------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_variant_tuple_like() {
+    let _ = Enum2::Tuple(0, 1, 2);
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_variant_tuple_like() {
+    let _ = Enum2::Tuple2(0, 1, 2);
+}
+
+
+// Change constructor path indirectly (tuple-like) ---------------------------
+mod change_constructor_path_indirectly_tuple_like {
+    #[cfg(cfail1)]
+    use super::Enum as TheEnum;
+    #[cfg(not(cfail1))]
+    use super::Enum2 as TheEnum;
+
+    #[rustc_dirty(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_dirty(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> TheEnum {
+        TheEnum::Tuple(0, 1, 2)
+    }
+}
+
+
+
+// Change constructor variant indirectly (tuple-like) ---------------------------
+mod change_constructor_variant_indirectly_tuple_like {
+    use super::Enum2;
+    #[cfg(cfail1)]
+    use super::Enum2::Tuple as Variant;
+    #[cfg(not(cfail1))]
+    use super::Enum2::Tuple2 as Variant;
+
+    #[rustc_clean(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_clean(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> Enum2 {
+        Variant(0, 1, 2)
+    }
+}
+
+
+enum Clike {
+    A,
+    B,
+    C
+}
+
+enum Clike2 {
+    B,
+    C,
+    D
+}
+
+// Change constructor path (C-like) --------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_path_c_like() {
+    let _ = Clike::B;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_path_c_like() {
+    let _ = Clike2::B;
+}
+
+
+
+// Change constructor variant (C-like) --------------------------------------
+#[cfg(cfail1)]
+fn change_constructor_variant_c_like() {
+    let _ = Clike::A;
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_constructor_variant_c_like() {
+    let _ = Clike::C;
+}
+
+
+// Change constructor path indirectly (C-like) ---------------------------
+mod change_constructor_path_indirectly_c_like {
+    #[cfg(cfail1)]
+    use super::Clike as TheEnum;
+    #[cfg(not(cfail1))]
+    use super::Clike2 as TheEnum;
+
+    #[rustc_dirty(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_dirty(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> TheEnum {
+        TheEnum::B
+    }
+}
+
+
+
+// Change constructor variant indirectly (C-like) ---------------------------
+mod change_constructor_variant_indirectly_c_like {
+    use super::Clike;
+    #[cfg(cfail1)]
+    use super::Clike::A as Variant;
+    #[cfg(not(cfail1))]
+    use super::Clike::B as Variant;
+
+    #[rustc_clean(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_clean(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
+    fn function() -> Clike {
+        Variant
+    }
+}
diff --git a/src/test/incremental/hashes/exported_vs_not.rs b/src/test/incremental/hashes/exported_vs_not.rs
new file mode 100644
index 00000000000..082badacc6c
--- /dev/null
+++ b/src/test/incremental/hashes/exported_vs_not.rs
@@ -0,0 +1,86 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// must-compile-successfully
+// revisions: cfail1 cfail2 cfail3
+// compile-flags: -Z query-dep-graph
+
+#![allow(warnings)]
+#![feature(rustc_attrs)]
+#![crate_type="rlib"]
+
+// Case 1: The function body is not exported to metadata. If the body changes,
+//         the hash of the HirBody node should change, but not the hash of
+//         either the Hir or the Metadata node.
+
+#[cfg(cfail1)]
+pub fn body_not_exported_to_metadata() -> u32 {
+    1
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+pub fn body_not_exported_to_metadata() -> u32 {
+    2
+}
+
+
+
+// Case 2: The function body *is* exported to metadata because the function is
+//         marked as #[inline]. Only the hash of the Hir depnode should be
+//         unaffected by a change to the body.
+
+#[cfg(cfail1)]
+#[inline]
+pub fn body_exported_to_metadata_because_of_inline() -> u32 {
+    1
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_dirty(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+#[inline]
+pub fn body_exported_to_metadata_because_of_inline() -> u32 {
+    2
+}
+
+
+
+// Case 2: The function body *is* exported to metadata because the function is
+//         generic. Only the hash of the Hir depnode should be
+//         unaffected by a change to the body.
+
+#[cfg(cfail1)]
+#[inline]
+pub fn body_exported_to_metadata_because_of_generic() -> u32 {
+    1
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_dirty(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+#[inline]
+pub fn body_exported_to_metadata_because_of_generic() -> u32 {
+    2
+}
+
diff --git a/src/test/incremental/hashes/indexing_expressions.rs b/src/test/incremental/hashes/indexing_expressions.rs
new file mode 100644
index 00000000000..bb31982d93f
--- /dev/null
+++ b/src/test/incremental/hashes/indexing_expressions.rs
@@ -0,0 +1,157 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+// This test case tests the incremental compilation hash (ICH) implementation
+// for closure expression.
+
+// The general pattern followed here is: Change one thing between rev1 and rev2
+// and make sure that the hash has changed, then change nothing between rev2 and
+// rev3 and make sure that the hash has not changed.
+
+// must-compile-successfully
+// revisions: cfail1 cfail2 cfail3
+// compile-flags: -Z query-dep-graph
+
+#![allow(warnings)]
+#![feature(rustc_attrs)]
+#![crate_type="rlib"]
+#![feature(inclusive_range_syntax)]
+
+// Change simple index ---------------------------------------------------------
+#[cfg(cfail1)]
+fn change_simple_index(slice: &[u32]) -> u32 {
+    slice[3]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_simple_index(slice: &[u32]) -> u32 {
+    slice[4]
+}
+
+
+
+// Change lower bound ----------------------------------------------------------
+#[cfg(cfail1)]
+fn change_lower_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..5]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_lower_bound(slice: &[u32]) -> &[u32] {
+    &slice[2..5]
+}
+
+
+
+// Change upper bound ----------------------------------------------------------
+#[cfg(cfail1)]
+fn change_upper_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..5]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_upper_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..7]
+}
+
+
+
+// Add lower bound -------------------------------------------------------------
+#[cfg(cfail1)]
+fn add_lower_bound(slice: &[u32]) -> &[u32] {
+    &slice[..4]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn add_lower_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..4]
+}
+
+
+
+// Add upper bound -------------------------------------------------------------
+#[cfg(cfail1)]
+fn add_upper_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn add_upper_bound(slice: &[u32]) -> &[u32] {
+    &slice[3..7]
+}
+
+
+
+// Change mutability -----------------------------------------------------------
+#[cfg(cfail1)]
+fn change_mutability(slice: &mut [u32]) -> u32 {
+    (&mut slice[3..5])[0]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn change_mutability(slice: &mut [u32]) -> u32 {
+    (&slice[3..5])[0]
+}
+
+
+
+// Exclusive to inclusive range ------------------------------------------------
+#[cfg(cfail1)]
+fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
+    &slice[3..7]
+}
+
+#[cfg(not(cfail1))]
+#[rustc_clean(label="Hir", cfg="cfail2")]
+#[rustc_clean(label="Hir", cfg="cfail3")]
+#[rustc_dirty(label="HirBody", cfg="cfail2")]
+#[rustc_clean(label="HirBody", cfg="cfail3")]
+#[rustc_metadata_clean(cfg="cfail2")]
+#[rustc_metadata_clean(cfg="cfail3")]
+fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] {
+    &slice[3...7]
+}
diff --git a/src/test/incremental/hashes/struct_constructors.rs b/src/test/incremental/hashes/struct_constructors.rs
index 6a9f4698bf8..0e23d953baf 100644
--- a/src/test/incremental/hashes/struct_constructors.rs
+++ b/src/test/incremental/hashes/struct_constructors.rs
@@ -202,6 +202,12 @@ mod change_constructor_path_indirectly_regular_struct {
     #[cfg(not(cfail1))]
     use super::RegularStruct2 as Struct;
 
+    #[rustc_dirty(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_dirty(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
     fn function() -> Struct {
         Struct {
             x: 0,
@@ -262,6 +268,12 @@ mod change_constructor_path_indirectly_tuple_struct {
     #[cfg(not(cfail1))]
     use super::TupleStruct2 as Struct;
 
+    #[rustc_dirty(label="Hir", cfg="cfail2")]
+    #[rustc_clean(label="Hir", cfg="cfail3")]
+    #[rustc_dirty(label="HirBody", cfg="cfail2")]
+    #[rustc_clean(label="HirBody", cfg="cfail3")]
+    #[rustc_metadata_dirty(cfg="cfail2")]
+    #[rustc_metadata_clean(cfg="cfail3")]
     fn function() -> Struct {
         Struct(0, 1, 2)
     }