Auto merge of #14947 - HKalbasi:render-const, r=HKalbasi

Add enum, reference, array and slice to `render_const_scalar`
This commit is contained in:
bors 2023-06-02 10:18:36 +00:00
commit 0677c204ca
9 changed files with 561 additions and 115 deletions

View file

@ -2106,14 +2106,6 @@ impl Const {
pub fn render_eval(self, db: &dyn HirDatabase) -> Result<String, ConstEvalError> {
let c = db.const_eval(self.id.into(), Substitution::empty(Interner))?;
let r = format!("{}", HexifiedConst(c).display(db));
// We want to see things like `<utf8-error>` and `<layout-error>` as they are probably bug in our
// implementation, but there is no need to show things like `<enum-not-supported>` or `<ref-not-supported>` to
// the user.
if r.contains("not-supported>") {
return Err(ConstEvalError::MirEvalError(MirEvalError::NotSupported(
"rendering complex constants".to_string(),
)));
}
return Ok(r);
}
}