about summary refs log tree commit diff
path: root/src/test/compile-fail
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-08 11:36:52 +0000
committerbors <bors@rust-lang.org>2017-01-08 11:36:52 +0000
commitcbf88730e755d099c854f84dd0f1990490bf0088 (patch)
treed963b89f70bd039ba13fb0ef7f5393a30e315226 /src/test/compile-fail
parent7ac9d337dcc544b4b1959997cdd36f1ba0c8d3e1 (diff)
parentcde0a7e7e01f64caed45e97ff958821d9247959e (diff)
downloadrust-cbf88730e755d099c854f84dd0f1990490bf0088.tar.gz
rust-cbf88730e755d099c854f84dd0f1990490bf0088.zip
Auto merge of #38813 - eddyb:lazy-11, r=nikomatsakis
[11/n] Separate ty::Tables into one per each body.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/38449) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

In order to track the results of type-checking and inference for incremental recompilation, they must be stored separately for each function or constant value, instead of lumped together.

These side-`Tables` also have to be tracked by various passes, as they visit through bodies (all of which have `Tables`, even if closures share the ones from their parent functions). This is usually done by switching a `tables` field in an override of `visit_nested_body` before recursing through `visit_body`, to the relevant one and then restoring it - however, in many cases the nesting is unnecessary and creating the visitor for each body in the crate and then visiting that body, would be a much cleaner solution.

To simplify handling of inlined HIR & its side-tables, their `NodeId` remapping and entries HIR map were fully stripped out, which means that `NodeId`s from inlined HIR must not be used where a local `NodeId` is expected. It might be possible to make the nodes (`Expr`, `Block`, `Pat`, etc.) that only show up within a `Body` have IDs that are scoped to that `Body`, which would also allow `Tables` to use `Vec`s.

That last part also fixes #38790 which was accidentally introduced in a previous refactor.
Diffstat (limited to 'src/test/compile-fail')
-rw-r--r--src/test/compile-fail/const-eval-overflow.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/test/compile-fail/const-eval-overflow.rs b/src/test/compile-fail/const-eval-overflow.rs
index b8f3f714a84..3c688d58fd1 100644
--- a/src/test/compile-fail/const-eval-overflow.rs
+++ b/src/test/compile-fail/const-eval-overflow.rs
@@ -15,6 +15,8 @@
 // change this warn to a deny, then the compiler will exit before
 // those errors are detected.
 
+#![warn(const_err)]
+
 use std::fmt;
 use std::{i8, i16, i32, i64, isize};
 use std::{u8, u16, u32, u64, usize};
@@ -80,7 +82,8 @@ const VALS_I64: (i64, i64, i64, i64) =
      );
 
 const VALS_U8: (u8, u8, u8, u8) =
-    (-(u8::MIN as i8) as u8,
+    ( //~ WARN constant evaluation error: attempt to subtract with overflow.
+     -(u8::MIN as i8) as u8,
      u8::MIN - 1,
      //~^ ERROR constant evaluation error
      //~| attempt to subtract with overflow
@@ -93,7 +96,8 @@ const VALS_U8: (u8, u8, u8, u8) =
      );
 
 const VALS_U16: (u16, u16, u16, u16) =
-    (-(u16::MIN as i16) as u16,
+    ( //~ WARN constant evaluation error: attempt to subtract with overflow.
+     -(u16::MIN as i16) as u16,
      u16::MIN - 1,
      //~^ ERROR constant evaluation error
      //~| attempt to subtract with overflow
@@ -106,7 +110,8 @@ const VALS_U16: (u16, u16, u16, u16) =
      );
 
 const VALS_U32: (u32, u32, u32, u32) =
-    (-(u32::MIN as i32) as u32,
+    ( //~ WARN constant evaluation error: attempt to subtract with overflow.
+     -(u32::MIN as i32) as u32,
      u32::MIN - 1,
      //~^ ERROR constant evaluation error
      //~| attempt to subtract with overflow
@@ -119,7 +124,8 @@ const VALS_U32: (u32, u32, u32, u32) =
      );
 
 const VALS_U64: (u64, u64, u64, u64) =
-    (-(u64::MIN as i64) as u64,
+    ( //~ WARN constant evaluation error: attempt to subtract with overflow.
+     -(u64::MIN as i64) as u64,
      u64::MIN - 1,
      //~^ ERROR constant evaluation error
      //~| attempt to subtract with overflow