fix: Fix inline_const_as_literal error when the number >= 10

This commit is contained in:
coekjan 2024-09-05 13:50:44 +08:00
parent 50882fbfa2
commit 0b9d2725ae
No known key found for this signature in database
GPG key ID: E2B19491B838BB2B
2 changed files with 14 additions and 4 deletions

View file

@ -2553,6 +2553,17 @@ impl Const {
Type::from_value_def(db, self.id)
}
/// Evaluate the constant and return the result as a string.
///
/// This function is intended for IDE assistance, different from [`Const::render_eval`].
pub fn eval(self, db: &dyn HirDatabase, edition: Edition) -> Result<String, ConstEvalError> {
let c = db.const_eval(self.id.into(), Substitution::empty(Interner), None)?;
Ok(format!("{}", c.display(db, edition)))
}
/// Evaluate the constant and return the result as a string, with more detailed information.
///
/// This function is intended for user-facing display.
pub fn render_eval(
self,
db: &dyn HirDatabase,