Skip to content

Commit

Permalink
Duplicate tests for incremental spans mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 10, 2021
1 parent 2e37ed8 commit 11a999e
Show file tree
Hide file tree
Showing 30 changed files with 2,532 additions and 1,096 deletions.
14 changes: 10 additions & 4 deletions src/test/incremental/change_symbol_export_status.rs
@@ -1,9 +1,15 @@
// revisions: rpass1 rpass2
// revisions: rpass1 rpass2 rpass3 rpass4
// compile-flags: -Zquery-dep-graph
// [rpass1]compile-flags: -Zincremental-ignore-spans
// [rpass2]compile-flags: -Zincremental-ignore-spans
// [rpass3]compile-flags: -Zincremental-relative-spans
// [rpass4]compile-flags: -Zincremental-relative-spans

#![feature(rustc_attrs)]
#![rustc_partition_codegened(module = "change_symbol_export_status-mod1", cfg = "rpass2")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod1", cfg = "rpass2")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod2", cfg = "rpass2")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod1", cfg = "rpass4")]
#![rustc_partition_reused(module = "change_symbol_export_status-mod2", cfg = "rpass4")]

// This test case makes sure that a change in symbol visibility is detected by
// our dependency tracking. We do this by changing a module's visibility to
Expand All @@ -13,13 +19,13 @@
// even from an executable. Plain Rust functions are only exported from Rust
// libraries, which our test infrastructure does not support.

#[cfg(rpass1)]
#[cfg(any(rpass1,rpass3))]
pub mod mod1 {
#[no_mangle]
pub fn foo() {}
}

#[cfg(rpass2)]
#[cfg(any(rpass2,rpass4))]
mod mod1 {
#[no_mangle]
pub fn foo() {}
Expand Down
70 changes: 46 additions & 24 deletions src/test/incremental/hashes/call_expressions.rs
Expand Up @@ -6,8 +6,14 @@
// rev3 and make sure that the hash has not changed.

// build-pass (FIXME(62277): could be check-pass?)
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
// compile-flags: -Z query-dep-graph
// [cfail1]compile-flags: -Zincremental-ignore-spans
// [cfail2]compile-flags: -Zincremental-ignore-spans
// [cfail3]compile-flags: -Zincremental-ignore-spans
// [cfail4]compile-flags: -Zincremental-relative-spans
// [cfail5]compile-flags: -Zincremental-relative-spans
// [cfail6]compile-flags: -Zincremental-relative-spans


#![allow(warnings)]
Expand All @@ -19,29 +25,33 @@ fn callee2(_x: u32, _y: i64) {}


// Change Callee (Function)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_callee_function() {
callee1(1, 2)
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn change_callee_function() {
callee2(1, 2)
}



// Change Argument (Function)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_argument_function() {
callee1(1, 2)
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_argument_function() {
callee1(1, 3)
}
Expand All @@ -50,13 +60,15 @@ pub fn change_argument_function() {

// Change Callee Indirectly (Function)
mod change_callee_indirectly_function {
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
use super::callee1 as callee;
#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
use super::callee2 as callee;

#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
pub fn change_callee_indirectly_function() {
callee(1, 2)
}
Expand All @@ -70,15 +82,17 @@ impl Struct {
}

// Change Callee (Method)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_callee_method() {
let s = Struct;
s.method1('x', true);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn change_callee_method() {
let s = Struct;
s.method2('x', true);
Expand All @@ -87,15 +101,17 @@ pub fn change_callee_method() {


// Change Argument (Method)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_argument_method() {
let s = Struct;
s.method1('x', true);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_argument_method() {
let s = Struct;
s.method1('y', true);
Expand All @@ -104,15 +120,17 @@ pub fn change_argument_method() {


// Change Callee (Method, UFCS)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_ufcs_callee_method() {
let s = Struct;
Struct::method1(&s, 'x', true);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn change_ufcs_callee_method() {
let s = Struct;
Struct::method2(&s, 'x', true);
Expand All @@ -121,32 +139,36 @@ pub fn change_ufcs_callee_method() {


// Change Argument (Method, UFCS)
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_argument_method_ufcs() {
let s = Struct;
Struct::method1(&s, 'x', true);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_argument_method_ufcs() {
let s = Struct;
Struct::method1(&s, 'x', false);
Struct::method1(&s, 'x',false);
}



// Change To UFCS
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_to_ufcs() {
let s = Struct;
s.method1('x', true);
s.method1('x', true); // ------
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail6")]
// One might think this would be expanded in the hir_owner_nodes/Mir, but it actually
// results in slightly different hir_owner/Mir.
pub fn change_to_ufcs() {
Expand All @@ -162,15 +184,15 @@ impl Struct2 {

// Change UFCS Callee Indirectly
pub mod change_ufcs_callee_indirectly {
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
use super::Struct as Struct;
#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
use super::Struct2 as Struct;

#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail3")]


#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn change_ufcs_callee_indirectly() {
let s = Struct;
Struct::method1(&s, 'q', false)
Expand Down
54 changes: 36 additions & 18 deletions src/test/incremental/hashes/closure_expressions.rs
Expand Up @@ -6,39 +6,49 @@
// rev3 and make sure that the hash has not changed.

// build-pass (FIXME(62277): could be check-pass?)
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans -Zmir-opt-level=0
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
// compile-flags: -Z query-dep-graph -Zmir-opt-level=0
// [cfail1]compile-flags: -Zincremental-ignore-spans
// [cfail2]compile-flags: -Zincremental-ignore-spans
// [cfail3]compile-flags: -Zincremental-ignore-spans
// [cfail4]compile-flags: -Zincremental-relative-spans
// [cfail5]compile-flags: -Zincremental-relative-spans
// [cfail6]compile-flags: -Zincremental-relative-spans

#![allow(warnings)]
#![feature(rustc_attrs)]
#![crate_type="rlib"]


// Change closure body
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_closure_body() {
let _ = || 1u32;
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail6")]
pub fn change_closure_body() {
let _ = || 3u32;
}



// Add parameter
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn add_parameter() {
let x = 0u32;
let _ = || x + 1;
let _ = | | x + 1;
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn add_parameter() {
let x = 0u32;
let _ = |x: u32| x + 1;
Expand All @@ -47,45 +57,51 @@ pub fn add_parameter() {


// Change parameter pattern
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_parameter_pattern() {
let _ = |x: (u32,)| x;
let _ = | x : (u32,)| x;
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck, optimized_mir")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn change_parameter_pattern() {
let _ = |(x,): (u32,)| x;
}



// Add `move` to closure
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn add_move() {
let _ = || 1;
let _ = || 1;
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn add_move() {
let _ = move || 1;
}



// Add type ascription to parameter
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn add_type_ascription_to_parameter() {
let closure = |x| x + 1u32;
let closure = |x | x + 1u32;
let _: u32 = closure(1);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner_nodes, typeck")]
#[rustc_clean(cfg = "cfail6")]
pub fn add_type_ascription_to_parameter() {
let closure = |x: u32| x + 1u32;
let _: u32 = closure(1);
Expand All @@ -94,15 +110,17 @@ pub fn add_type_ascription_to_parameter() {


// Change parameter type
#[cfg(cfail1)]
#[cfg(any(cfail1,cfail4))]
pub fn change_parameter_type() {
let closure = |x: u32| (x as u64) + 1;
let _ = closure(1);
}

#[cfg(not(cfail1))]
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
#[rustc_clean(cfg="cfail6")]
pub fn change_parameter_type() {
let closure = |x: u16| (x as u64) + 1;
let _ = closure(1);
Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/hashes/consts.rs
Expand Up @@ -7,7 +7,7 @@

// build-pass (FIXME(62277): could be check-pass?)
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
// compile-flags: -Z query-dep-graph

#![allow(warnings)]
#![feature(rustc_attrs)]
Expand Down

0 comments on commit 11a999e

Please sign in to comment.