forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#38202 - michaelwoerister:closure-ich-test, …
…r=nikomatsakis Some incr. comp. hash tests r? @nikomatsakis
- Loading branch information
Showing
5 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
Oops, something went wrong.