From a1364cd0db6a533dfe9c693827ef20fe6118af11 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 7 Nov 2017 15:49:51 +0100 Subject: incr.comp.: Acknowledge the fact that shift operations can panic at runtime. --- src/test/incremental/hashes/panic_exprs.rs | 39 ++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/incremental/hashes/panic_exprs.rs b/src/test/incremental/hashes/panic_exprs.rs index 5d4d434fd63..4a3e4bc49ce 100644 --- a/src/test/incremental/hashes/panic_exprs.rs +++ b/src/test/incremental/hashes/panic_exprs.rs @@ -152,13 +152,48 @@ pub fn mod_by_zero(val: i32) -> i32 { } +// shift left ------------------------------------------------------------------ +#[cfg(cfail1)] +pub fn shift_left(val: i32, shift: usize) -> i32 { + val << shift +} + +#[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 shift_left(val: i32, shift: usize) -> i32 { + val << shift +} + + +// shift right ------------------------------------------------------------------ +#[cfg(cfail1)] +pub fn shift_right(val: i32, shift: usize) -> i32 { + val >> shift +} + +#[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 shift_right(val: i32, shift: usize) -> i32 { + val >> shift +} + // THE FOLLOWING ITEMS SHOULD NOT BE INFLUENCED BY THEIR SOURCE LOCATION // bitwise --------------------------------------------------------------------- #[cfg(cfail1)] pub fn bitwise(val: i32) -> i32 { - !val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1 + !val & 0x101010101 | 0x45689 ^ 0x2372382 } #[cfg(not(cfail1))] @@ -169,7 +204,7 @@ pub fn bitwise(val: i32) -> i32 { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] pub fn bitwise(val: i32) -> i32 { - !val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1 + !val & 0x101010101 | 0x45689 ^ 0x2372382 } -- cgit 1.4.1-3-g733a5 From 616b45542bc42cf7a3f3639a4832d84babd6a505 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 8 Nov 2017 11:30:14 +0100 Subject: incr.comp.: Make DefSpan an input dep-node so it is not affected by the existing Span/HIR hashing hack. --- src/librustc/dep_graph/dep_node.rs | 8 +++++++- src/librustc/dep_graph/graph.rs | 3 +++ src/test/incremental/remove_source_file/main.rs | 15 +++++++++------ src/test/incremental/spans_in_type_debuginfo.rs | 1 - 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 3ecaa1d66a7..d05445e44dd 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -568,7 +568,13 @@ define_dep_nodes!( <'tcx> [] ParamEnv(DefId), [] DescribeDef(DefId), - [] DefSpan(DefId), + + // FIXME(mw): DefSpans are not really inputs since they are derived from + // HIR. But at the moment HIR hashing still contains some hacks that allow + // to make type debuginfo to be source location independent. Declaring + // DefSpan an input makes sure that changes to these are always detected + // regardless of HIR hashing. + [input] DefSpan(DefId), [] LookupStability(DefId), [] LookupDeprecationEntry(DefId), [] ItemBodyNestedBodies(DefId), diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 465984479f8..a586424d196 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -789,6 +789,9 @@ impl CurrentDepGraph { // node. if cfg!(debug_assertions) { if node.kind.is_input() && reads.len() > 0 && + // FIXME(mw): Special case for DefSpan until Spans are handled + // better in general. + node.kind != DepKind::DefSpan && reads.iter().any(|&i| { !(self.nodes[i].kind == DepKind::CrateMetadata || self.nodes[i].kind == DepKind::Krate) diff --git a/src/test/incremental/remove_source_file/main.rs b/src/test/incremental/remove_source_file/main.rs index 4ba33f3bb3d..3ae26c6aa45 100644 --- a/src/test/incremental/remove_source_file/main.rs +++ b/src/test/incremental/remove_source_file/main.rs @@ -11,21 +11,24 @@ // This test case makes sure that the compiler doesn't crash due to a failing // table lookup when a source file is removed. -// revisions:rpass1 rpass2 +// revisions:cfail1 cfail2 // Note that we specify -g so that the FileMaps actually get referenced by the // incr. comp. cache: // compile-flags: -Z query-dep-graph -g +// must-compile-successfully -#[cfg(rpass1)] +#![crate_type= "rlib"] + +#[cfg(cfail1)] mod auxiliary; -#[cfg(rpass1)] -fn main() { +#[cfg(cfail1)] +pub fn foo() { auxiliary::print_hello(); } -#[cfg(rpass2)] -fn main() { +#[cfg(cfail2)] +pub fn foo() { println!("hello"); } diff --git a/src/test/incremental/spans_in_type_debuginfo.rs b/src/test/incremental/spans_in_type_debuginfo.rs index 7d8e6c9d9d7..e1369d92c5c 100644 --- a/src/test/incremental/spans_in_type_debuginfo.rs +++ b/src/test/incremental/spans_in_type_debuginfo.rs @@ -14,7 +14,6 @@ // revisions:rpass1 rpass2 // compile-flags: -Z query-dep-graph -g -#![rustc_partition_reused(module="spans_in_type_debuginfo", cfg="rpass2")] #![rustc_partition_reused(module="spans_in_type_debuginfo-structs", cfg="rpass2")] #![rustc_partition_reused(module="spans_in_type_debuginfo-enums", cfg="rpass2")] -- cgit 1.4.1-3-g733a5 From 95b0849715de67c8929f3b6cd0f8f63b457e1982 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 8 Nov 2017 11:32:16 +0100 Subject: incr.comp.: Adapt nested_items test to new HIR hashing rules. --- src/test/incremental/ich_nested_items.rs | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/test') diff --git a/src/test/incremental/ich_nested_items.rs b/src/test/incremental/ich_nested_items.rs index e8e40d57b1e..2e0f0ba0837 100644 --- a/src/test/incremental/ich_nested_items.rs +++ b/src/test/incremental/ich_nested_items.rs @@ -11,29 +11,29 @@ // Check that the hash of `foo` doesn't change just because we ordered // the nested items (or even added new ones). -// revisions: rpass1 rpass2 +// revisions: cfail1 cfail2 +// must-compile-successfully +#![crate_type = "rlib"] #![feature(rustc_attrs)] -#[cfg(rpass1)] -fn foo() { - fn bar() { } - fn baz() { } +#[cfg(cfail1)] +pub fn foo() { + pub fn bar() { } + pub fn baz() { } } -#[cfg(rpass2)] -#[rustc_clean(label="Hir", cfg="rpass2")] -#[rustc_clean(label="HirBody", cfg="rpass2")] -fn foo() { - #[rustc_clean(label="Hir", cfg="rpass2")] - #[rustc_clean(label="HirBody", cfg="rpass2")] - fn baz() { } // order is different... +#[cfg(cfail2)] +#[rustc_clean(label="Hir", cfg="cfail2")] +#[rustc_dirty(label="HirBody", cfg="cfail2")] +pub fn foo() { + #[rustc_clean(label="Hir", cfg="cfail2")] + #[rustc_clean(label="HirBody", cfg="cfail2")] + pub fn baz() { } // order is different... - #[rustc_clean(label="Hir", cfg="rpass2")] - #[rustc_clean(label="HirBody", cfg="rpass2")] - fn bar() { } // but that doesn't matter. + #[rustc_clean(label="Hir", cfg="cfail2")] + #[rustc_clean(label="HirBody", cfg="cfail2")] + pub fn bar() { } // but that doesn't matter. - fn bap() { } // neither does adding a new item + pub fn bap() { } // neither does adding a new item } - -fn main() { } -- cgit 1.4.1-3-g733a5