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.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 04d239d255..a79e47dd67 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -6,6 +6,7 @@ use crate::{fixture, HoverConfig, HoverDocFormat};
const HOVER_BASE_CONFIG: HoverConfig = HoverConfig {
links_in_hover: false,
+ memory_layout: true,
documentation: true,
format: HoverDocFormat::Markdown,
keywords: true,
@@ -57,6 +58,23 @@ fn check_hover_no_links(ra_fixture: &str, expect: Expect) {
expect.assert_eq(&actual)
}
+fn check_hover_no_memory_layout(ra_fixture: &str, expect: Expect) {
+ let (analysis, position) = fixture::position(ra_fixture);
+ let hover = analysis
+ .hover(
+ &HoverConfig { memory_layout: false, ..HOVER_BASE_CONFIG },
+ FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
+ )
+ .unwrap()
+ .unwrap();
+
+ let content = analysis.db.file_text(position.file_id);
+ let hovered_element = &content[hover.range];
+
+ let actual = format!("*{hovered_element}*\n{}\n", hover.info.markup);
+ expect.assert_eq(&actual)
+}
+
fn check_hover_no_markdown(ra_fixture: &str, expect: Expect) {
let (analysis, position) = fixture::position(ra_fixture);
let hover = analysis
@@ -1746,6 +1764,44 @@ pub fn fo$0o() {}
}
#[test]
+fn test_hover_no_memory_layout() {
+ check_hover_no_memory_layout(
+ r#"struct Foo { fiel$0d_a: u8, field_b: i32, field_c: i16 }"#,
+ expect![[r#"
+ *field_a*
+
+ ```rust
+ test::Foo
+ ```
+
+ ```rust
+ field_a: u8
+ ```
+ "#]],
+ );
+
+ check_hover_no_memory_layout(
+ r#"
+//- minicore: copy
+fn main() {
+ let x = 2;
+ let y = $0|z| x + z;
+}
+"#,
+ expect![[r#"
+ *|*
+ ```rust
+ {closure#0}
+ impl Fn(i32) -> i32
+ ```
+
+ ## Captures
+ * `x` by immutable borrow
+ "#]],
+ );
+}
+
+#[test]
fn test_hover_macro_generated_struct_fn_doc_comment() {
cov_mark::check!(hover_macro_generated_struct_fn_doc_comment);