mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-18 03:13:31 +00:00
Allow static initializers to be const evaluated
This commit is contained in:
parent
d1fbfc676b
commit
94c35f6138
7 changed files with 87 additions and 28 deletions
|
|
@ -486,13 +486,19 @@ pub(super) fn definition(
|
|||
}
|
||||
}
|
||||
Definition::Static(it) => {
|
||||
let source = it.source(db)?;
|
||||
let mut body = source.value.body()?.syntax().clone();
|
||||
if let Some(macro_file) = source.file_id.macro_file() {
|
||||
let span_map = db.expansion_span_map(macro_file);
|
||||
body = prettify_macro_expansion(db, body, &span_map, it.krate(db).into());
|
||||
let body = it.render_eval(db, edition);
|
||||
match body {
|
||||
Ok(it) => Some(it),
|
||||
Err(_) => {
|
||||
let source = it.source(db)?;
|
||||
let mut body = source.value.body()?.syntax().clone();
|
||||
if let Some(macro_file) = source.file_id.macro_file() {
|
||||
let span_map = db.expansion_span_map(macro_file);
|
||||
body = prettify_macro_expansion(db, body, &span_map, it.krate(db).into());
|
||||
}
|
||||
Some(body.to_string())
|
||||
}
|
||||
}
|
||||
Some(body.to_string())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue