diff options
Diffstat (limited to 'src/librustc_mir/const_eval/error.rs')
| -rw-r--r-- | src/librustc_mir/const_eval/error.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/librustc_mir/const_eval/error.rs b/src/librustc_mir/const_eval/error.rs new file mode 100644 index 00000000000..8948cc0fc3e --- /dev/null +++ b/src/librustc_mir/const_eval/error.rs @@ -0,0 +1,30 @@ +use std::error::Error; +use std::fmt; + +use crate::interpret::InterpErrorInfo; + +#[derive(Clone, Debug)] +pub enum ConstEvalError { + NeedsRfc(String), + ConstAccessesStatic, +} + +impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalError { + fn into(self) -> InterpErrorInfo<'tcx> { + err_unsup!(Unsupported(self.to_string())).into() + } +} + +impl fmt::Display for ConstEvalError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use self::ConstEvalError::*; + match *self { + NeedsRfc(ref msg) => { + write!(f, "\"{}\" needs an rfc before being allowed inside constants", msg) + } + ConstAccessesStatic => write!(f, "constant accesses static"), + } + } +} + +impl Error for ConstEvalError {} |
