mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Added consteval tests
This commit is contained in:
parent
2f84b6e2e5
commit
ad0a6bf1a3
6 changed files with 46 additions and 11 deletions
|
@ -348,12 +348,15 @@ pub(super) fn definition(
|
|||
Definition::Module(it) => label_and_docs(db, it),
|
||||
Definition::Function(it) => label_and_docs(db, it),
|
||||
Definition::Adt(it) => label_and_docs(db, it),
|
||||
Definition::Variant(it) => label_value_and_docs(db, it, |&it| match it.kind(db) {
|
||||
StructKind::Unit => match it.eval(db) {
|
||||
Ok(x) => Some(format!("{}", x.enum_value().unwrap_or(x))),
|
||||
Err(_) => it.value(db).map(|x| format!("{:?}", x)),
|
||||
},
|
||||
_ => None,
|
||||
Definition::Variant(it) => label_value_and_docs(db, it, |&it| {
|
||||
if it.parent.is_data_carrying(db) {
|
||||
match it.eval(db) {
|
||||
Ok(x) => Some(format!("{}", x.enum_value().unwrap_or(x))),
|
||||
Err(_) => it.value(db).map(|x| format!("{:?}", x)),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}),
|
||||
Definition::Const(it) => label_value_and_docs(db, it, |it| {
|
||||
let body = it.eval(db);
|
||||
|
|
|
@ -698,6 +698,7 @@ fn hover_enum_variant() {
|
|||
check(
|
||||
r#"
|
||||
enum Option<T> {
|
||||
Some(T)
|
||||
/// The None variant
|
||||
Non$0e
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue