X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=compiler%2Frustc_middle%2Fsrc%2Fty%2Fconsts%2Fkind.rs;h=d9721863a58c801fa49c21594cfc26309a2dc47d;hb=2cd2070af7643ad88d280a4933bc4fb60451e521;hp=de63dae8a3df6455eb311d18c3eef5b717535591;hpb=9178bc059f3e932d94a52efba7a9e010f1bc6d37;p=rust.git diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index de63dae8a3d..d9721863a58 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use super::Const; use crate::mir; use crate::mir::interpret::{AllocId, ConstValue, Scalar}; @@ -49,6 +47,7 @@ pub fn new( /// Represents a constant in Rust. #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)] #[derive(Hash, HashStable, TypeFoldable, TypeVisitable)] +#[derive(derive_more::From)] pub enum ConstKind<'tcx> { /// A const generic parameter. Param(ty::ParamConst), @@ -71,12 +70,19 @@ pub enum ConstKind<'tcx> { /// A placeholder for a const which could not be computed; this is /// propagated to avoid useless error messages. + #[from(ignore)] Error(ErrorGuaranteed), /// Expr which contains an expression which has partially evaluated items. Expr(Expr<'tcx>), } +impl<'tcx> From> for ConstKind<'tcx> { + fn from(const_vid: ty::ConstVid<'tcx>) -> Self { + InferConst::Var(const_vid).into() + } +} + #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] #[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)] pub enum Expr<'tcx> {