about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-01-25 13:45:57 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-03-08 08:34:09 +0100
commit4f6c557c9d9c7cfade41cf473935a26ad54351d4 (patch)
tree65cc740e7769538d17c14d64ca392f564cb2fa3b
parent3d8c4d4fe9358d23d9edd6ac016477f91f1de997 (diff)
downloadrust-4f6c557c9d9c7cfade41cf473935a26ad54351d4.tar.gz
rust-4f6c557c9d9c7cfade41cf473935a26ad54351d4.zip
Wrap the miri ErrorKind in an Rc to reduce work in queries
-rw-r--r--src/librustc/ich/impls_ty.rs4
-rw-r--r--src/librustc/mir/interpret/error.rs9
-rw-r--r--src/librustc/ty/structural_impls.rs4
3 files changed, 9 insertions, 8 deletions
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs
index 54297a1fc39..74441d46945 100644
--- a/src/librustc/ich/impls_ty.rs
+++ b/src/librustc/ich/impls_ty.rs
@@ -489,9 +489,9 @@ for ::mir::interpret::EvalError<'gcx> {
                                           hasher: &mut StableHasher<W>) {
         use mir::interpret::EvalErrorKind::*;
 
-        mem::discriminant(&self.kind).hash_stable(hcx, hasher);
+        mem::discriminant(&*self.kind).hash_stable(hcx, hasher);
 
-        match self.kind {
+        match *self.kind {
             DanglingPointerDeref |
             DoubleFree |
             InvalidMemoryAccess |
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 977e617968a..702fd85794f 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -1,5 +1,6 @@
 use std::error::Error;
 use std::{fmt, env};
+use std::rc::Rc;
 
 use mir;
 use ty::{FnSig, Ty, layout};
@@ -14,7 +15,7 @@ use backtrace::Backtrace;
 
 #[derive(Debug, Clone)]
 pub struct EvalError<'tcx> {
-    pub kind: EvalErrorKind<'tcx>,
+    pub kind: Rc<EvalErrorKind<'tcx>>,
     pub backtrace: Option<Backtrace>,
 }
 
@@ -25,7 +26,7 @@ impl<'tcx> From<EvalErrorKind<'tcx>> for EvalError<'tcx> {
             _ => None
         };
         EvalError {
-            kind,
+            kind: Rc::new(kind),
             backtrace,
         }
     }
@@ -131,7 +132,7 @@ pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
 impl<'tcx> Error for EvalError<'tcx> {
     fn description(&self) -> &str {
         use self::EvalErrorKind::*;
-        match self.kind {
+        match *self.kind {
             MachineError(ref inner) => inner,
             FunctionPointerTyMismatch(..) =>
                 "tried to call a function through a function pointer of a different type",
@@ -252,7 +253,7 @@ impl<'tcx> Error for EvalError<'tcx> {
 impl<'tcx> fmt::Display for EvalError<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         use self::EvalErrorKind::*;
-        match self.kind {
+        match *self.kind {
             PointerOutOfBounds { ptr, access, allocation_size } => {
                 write!(f, "{} at offset {}, outside bounds of allocation {} which has size {}",
                        if access { "memory access" } else { "pointer computed" },
diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs
index 7cc509f6914..9394a853920 100644
--- a/src/librustc/ty/structural_impls.rs
+++ b/src/librustc/ty/structural_impls.rs
@@ -591,7 +591,7 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::EvalError<'a> {
     type Lifted = interpret::EvalError<'tcx>;
     fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
         use ::mir::interpret::EvalErrorKind::*;
-        let kind = match self.kind {
+        let kind = match *self.kind {
             MachineError(ref err) => MachineError(err.clone()),
             FunctionPointerTyMismatch(a, b) => FunctionPointerTyMismatch(
                 tcx.lift(&a)?,
@@ -691,7 +691,7 @@ impl<'a, 'tcx> Lift<'tcx> for interpret::EvalError<'a> {
             TypeckError => TypeckError,
         };
         Some(interpret::EvalError {
-            kind,
+            kind: Rc::new(kind),
             backtrace: self.backtrace.clone(),
         })
     }