mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
fix: Fix inline_const_as_literal
error when the number >= 10
This commit is contained in:
parent
50882fbfa2
commit
0b9d2725ae
2 changed files with 14 additions and 4 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue