mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Merge commit '9b3d03408c
' into sync-from-ra
This commit is contained in:
parent
883f16d805
commit
30d8aa1bec
136 changed files with 3865 additions and 1451 deletions
|
@ -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()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue