Merge commit '9b3d03408c' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2023-08-21 12:44:09 +03:00
parent 883f16d805
commit 30d8aa1bec
136 changed files with 3865 additions and 1451 deletions

View file

@ -52,12 +52,14 @@ use hir_expand::name;
use la_arena::{Arena, Idx};
use mir::{MirEvalError, VTableMap};
use rustc_hash::FxHashSet;
use syntax::ast::{make, ConstArg};
use traits::FnTrait;
use triomphe::Arc;
use utils::Generics;
use crate::{
consteval::unknown_const, db::HirDatabase, infer::unify::InferenceTable, utils::generics,
consteval::unknown_const, db::HirDatabase, display::HirDisplay, infer::unify::InferenceTable,
utils::generics,
};
pub use autoderef::autoderef;
@ -719,3 +721,16 @@ where
value.visit_with(&mut collector, DebruijnIndex::INNERMOST);
collector.placeholders.into_iter().collect()
}
pub fn known_const_to_ast(konst: &Const, db: &dyn HirDatabase) -> Option<ConstArg> {
if let ConstValue::Concrete(c) = &konst.interned().value {
match c.interned {
ConstScalar::UnevaluatedConst(GeneralConstId::InTypeConstId(cid), _) => {
return Some(cid.source(db.upcast()));
}
ConstScalar::Unknown => return None,
_ => (),
}
}
Some(make::expr_const_value(konst.display(db).to_string().as_str()))
}