Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/hover/tests.rs')
-rw-r--r--crates/ide/src/hover/tests.rs85
1 files changed, 85 insertions, 0 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 96cd83b924..987e5d1556 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -3399,6 +3399,7 @@ impl<const LEN: usize> Foo<LEN$0> {}
);
}
+// FIXME: move these tests to consteval module
#[test]
fn hover_const_eval() {
check(
@@ -3577,6 +3578,90 @@ const FOO$0: &str = "bar";
This is a doc
"#]],
);
+ check(
+ r#"
+const F1: i32 = 1;
+const F$03: i32 = 3 * F2;
+const F2: i32 = 2 * F1;
+"#,
+ expect![[r#"
+ *F3*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ const F3: i32 = 6
+ ```
+ "#]],
+ );
+ check(
+ r#"
+const F1: i32 = 1 * F3;
+const F2: i32 = 2 * F1;
+const F$03: i32 = 3 * F2;
+"#,
+ expect![[r#"
+ *F3*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ const F3: i32 = 3 * F2
+ ```
+ "#]],
+ );
+ check(
+ r#"
+struct U5;
+impl U5 {
+ const VAL: usize = 5;
+}
+const X$0X: usize = U5::VAL;
+"#,
+ expect![[r#"
+ *XX*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ const XX: usize = 5
+ ```
+ "#]],
+ );
+}
+
+// FIXME: this should evaluate to zero
+#[test]
+fn hover_const_eval_broken() {
+ check(
+ r#"
+struct U0;
+trait ToConst {
+ const VAL: usize;
+}
+impl ToConst for U0 {
+ const VAL: usize = 0;
+}
+const X$0X: usize = U0::VAL;
+"#,
+ expect![[r#"
+ *XX*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ const XX: usize = U0::VAL
+ ```
+ "#]],
+ );
}
#[test]