diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-08-13 13:48:47 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-08-22 18:28:57 +0200 |
| commit | bb78426ca8f12f467e4d3bb38e82c0d3b6209e61 (patch) | |
| tree | 80627d1053b6bb1cdcaea8f50789786613026f04 /src/librustc/mir/interpret | |
| parent | 674ef668f13c52a1fadbf01b24d8da1e12d15e70 (diff) | |
| download | rust-bb78426ca8f12f467e4d3bb38e82c0d3b6209e61.tar.gz rust-bb78426ca8f12f467e4d3bb38e82c0d3b6209e61.zip | |
Allow panicking with string literal messages inside constants
Diffstat (limited to 'src/librustc/mir/interpret')
| -rw-r--r-- | src/librustc/mir/interpret/error.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 1e9584bc55b..436478b8416 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -17,6 +17,7 @@ use errors::DiagnosticBuilder; use syntax_pos::Span; use syntax::ast; +use syntax::symbol::Symbol; pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, Lrc<ConstEvalErr<'tcx>>>; @@ -250,7 +251,12 @@ pub enum EvalErrorKind<'tcx, O> { HeapAllocZeroBytes, HeapAllocNonPowerOfTwoAlignment(u64), Unreachable, - Panic, + Panic { + msg: Symbol, + line: u32, + col: u32, + file: Symbol, + }, ReadFromReturnPointer, PathNotFound(Vec<String>), UnimplementedTraitSelection, @@ -370,7 +376,7 @@ impl<'tcx, O> EvalErrorKind<'tcx, O> { "tried to re-, de-, or allocate heap memory with alignment that is not a power of two", Unreachable => "entered unreachable code", - Panic => + Panic { .. } => "the evaluated program panicked", ReadFromReturnPointer => "tried to read from the return pointer", @@ -465,6 +471,8 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> { write!(f, "{}", inner), IncorrectAllocationInformation(size, size2, align, align2) => write!(f, "incorrect alloc info: expected size {} and align {}, got size {} and align {}", size.bytes(), align.abi(), size2.bytes(), align2.abi()), + Panic { ref msg, line, col, ref file } => + write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col), _ => write!(f, "{}", self.description()), } } |
