Skip to content

Commit

Permalink
Added newline, deleted unnecessary try_eval functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hayashi-stl committed Aug 30, 2020
1 parent 3389719 commit bce9291
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
23 changes: 0 additions & 23 deletions chalk-ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,12 +934,6 @@ impl<I: Interner> Const<I> {
ConstValue::Unevaluated(_) => false,
}
}

/// Tries to evaluate the constant.
/// This is guaranteed to return a concrete constant or an error.
pub fn try_eval(&self, interner: &I) -> Result<Const<I>, ConstEvalError> {
Ok(Self::new(interner, self.data(interner).try_eval(interner)?))
}
}

/// Constant data, containing the constant's type and value.
Expand All @@ -951,23 +945,6 @@ pub struct ConstData<I: Interner> {
pub value: ConstValue<I>,
}

impl<I: Interner> ConstData<I> {
/// Tries to evaluate the constant.
/// This is guaranteed to return a concrete constant or an error.
pub fn try_eval(&self, interner: &I) -> Result<ConstData<I>, ConstEvalError> {
match &self.value {
ConstValue::BoundVar(_) | ConstValue::InferenceVar(_) | ConstValue::Placeholder(_) => {
Err(ConstEvalError::TooGeneric)
}
ConstValue::Concrete(_) => Ok(self.clone()),
ConstValue::Unevaluated(expr) => Ok(ConstData {
ty: self.ty.clone(),
value: ConstValue::Concrete(expr.try_eval(&self.ty, interner)?),
}),
}
}
}

/// A constant value, not necessarily concrete.
#[derive(Clone, PartialEq, Eq, Hash, HasInterner)]
pub enum ConstValue<I: Interner> {
Expand Down
2 changes: 1 addition & 1 deletion chalk-parse/src/parser.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,4 @@ ConstValue: u32 = <s:r"[0-9]+"> => u32::from_str_radix(s, 10).unwrap();
UnevaluatedConst: Option<u32> = {
"?" => None,
<s:ConstValue> "?" => Some(<>),
}
}

0 comments on commit bce9291

Please sign in to comment.