2016-11-10 10:55:31 -06:00
|
|
|
// This test case tests the incremental compilation hash (ICH) implementation
|
|
|
|
// for function and method call 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.
|
|
|
|
|
2019-07-02 16:30:28 -05:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2021-04-22 14:33:16 -05:00
|
|
|
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
|
2022-05-27 20:17:39 -05:00
|
|
|
// compile-flags: -Z query-dep-graph -O
|
2021-04-22 14:33:16 -05:00
|
|
|
// [cfail1]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail2]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail3]compile-flags: -Zincremental-ignore-spans
|
2016-11-10 10:55:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
fn callee1(_x: u32, _y: i64) {}
|
|
|
|
fn callee2(_x: u32, _y: i64) {}
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Callee (Function)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_callee_function() {
|
|
|
|
callee1(1, 2)
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_callee_function() {
|
|
|
|
callee2(1, 2)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Argument (Function)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_function() {
|
|
|
|
callee1(1, 2)
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_function() {
|
|
|
|
callee1(1, 3)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Callee Indirectly (Function)
|
2016-11-10 10:55:31 -06:00
|
|
|
mod change_callee_indirectly_function {
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
use super::callee1 as callee;
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2016-11-10 10:55:31 -06:00
|
|
|
use super::callee2 as callee;
|
|
|
|
|
2021-05-15 06:20:42 -05:00
|
|
|
#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
|
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_callee_indirectly_function() {
|
|
|
|
callee(1, 2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Struct;
|
|
|
|
impl Struct {
|
|
|
|
fn method1(&self, _x: char, _y: bool) {}
|
|
|
|
fn method2(&self, _x: char, _y: bool) {}
|
|
|
|
}
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Callee (Method)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_callee_method() {
|
|
|
|
let s = Struct;
|
|
|
|
s.method1('x', true);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_callee_method() {
|
|
|
|
let s = Struct;
|
|
|
|
s.method2('x', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Argument (Method)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_method() {
|
|
|
|
let s = Struct;
|
|
|
|
s.method1('x', true);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_method() {
|
|
|
|
let s = Struct;
|
|
|
|
s.method1('y', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Callee (Method, UFCS)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_ufcs_callee_method() {
|
|
|
|
let s = Struct;
|
|
|
|
Struct::method1(&s, 'x', true);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_ufcs_callee_method() {
|
|
|
|
let s = Struct;
|
|
|
|
Struct::method2(&s, 'x', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change Argument (Method, UFCS)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_method_ufcs() {
|
|
|
|
let s = Struct;
|
|
|
|
Struct::method1(&s, 'x', true);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_argument_method_ufcs() {
|
|
|
|
let s = Struct;
|
2021-04-22 14:33:16 -05:00
|
|
|
Struct::method1(&s, 'x',false);
|
2016-11-10 10:55:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change To UFCS
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_to_ufcs() {
|
|
|
|
let s = Struct;
|
2021-04-22 14:33:16 -05:00
|
|
|
s.method1('x', true); // ------
|
2016-11-10 10:55:31 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2023-05-07 12:35:26 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2020-03-17 20:48:17 -05:00
|
|
|
// One might think this would be expanded in the hir_owner_nodes/Mir, but it actually
|
2020-02-12 09:00:15 -06:00
|
|
|
// results in slightly different hir_owner/Mir.
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_to_ufcs() {
|
|
|
|
let s = Struct;
|
|
|
|
Struct::method1(&s, 'x', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct Struct2;
|
|
|
|
impl Struct2 {
|
|
|
|
fn method1(&self, _x: char, _y: bool) {}
|
|
|
|
}
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change UFCS Callee Indirectly
|
2017-10-27 11:57:15 -05:00
|
|
|
pub mod change_ufcs_callee_indirectly {
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 10:55:31 -06:00
|
|
|
use super::Struct as Struct;
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2016-11-10 10:55:31 -06:00
|
|
|
use super::Struct2 as Struct;
|
|
|
|
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")]
|
2017-10-06 17:15:29 -05:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 10:55:31 -06:00
|
|
|
pub fn change_ufcs_callee_indirectly() {
|
|
|
|
let s = Struct;
|
|
|
|
Struct::method1(&s, 'q', false)
|
|
|
|
}
|
|
|
|
}
|