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.rs250
1 files changed, 239 insertions, 11 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 7b7eef9d57..a281a49152 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -12,6 +12,7 @@ const HOVER_BASE_CONFIG: HoverConfig = HoverConfig {
size: Some(MemoryLayoutHoverRenderKind::Both),
offset: Some(MemoryLayoutHoverRenderKind::Both),
alignment: Some(MemoryLayoutHoverRenderKind::Both),
+ padding: Some(MemoryLayoutHoverRenderKind::Both),
niches: true,
}),
documentation: true,
@@ -933,7 +934,7 @@ struct Foo$0(pub u32) where u32: Copy;
---
- size = 4, align = 4, no Drop
+ size = 4, align = 4, largest padding = 0, no Drop
"#]],
);
}
@@ -959,7 +960,7 @@ struct Foo$0 { field: u32 }
---
- size = 4, align = 4, no Drop
+ size = 4, align = 4, largest padding = 0, no Drop
"#]],
);
check(
@@ -984,7 +985,7 @@ struct Foo$0 where u32: Copy { field: u32 }
---
- size = 4, align = 4, no Drop
+ size = 4, align = 4, largest padding = 0, no Drop
"#]],
);
}
@@ -1013,7 +1014,7 @@ fn hover_record_struct_limit() {
---
- size = 12 (0xC), align = 4, no Drop
+ size = 12 (0xC), align = 4, largest padding = 0, no Drop
"#]],
);
check_hover_fields_limit(
@@ -1036,7 +1037,7 @@ fn hover_record_struct_limit() {
---
- size = 4, align = 4, no Drop
+ size = 4, align = 4, largest padding = 0, no Drop
"#]],
);
check_hover_fields_limit(
@@ -1062,7 +1063,7 @@ fn hover_record_struct_limit() {
---
- size = 16 (0x10), align = 4, no Drop
+ size = 16 (0x10), align = 4, largest padding = 0, no Drop
"#]],
);
check_hover_fields_limit(
@@ -1083,7 +1084,7 @@ fn hover_record_struct_limit() {
---
- size = 12 (0xC), align = 4, no Drop
+ size = 12 (0xC), align = 4, largest padding = 0, no Drop
"#]],
);
check_hover_fields_limit(
@@ -1104,7 +1105,7 @@ fn hover_record_struct_limit() {
---
- size = 12 (0xC), align = 4, no Drop
+ size = 12 (0xC), align = 4, largest padding = 0, no Drop
"#]],
);
@@ -3114,7 +3115,7 @@ struct S$0<T>(core::marker::PhantomData<T>);
---
- size = 0, align = 1, no Drop
+ size = 0, align = 1, largest padding = 0, no Drop
"#]],
);
}
@@ -3148,6 +3149,111 @@ fn test_hover_layout_of_enum() {
}
#[test]
+fn test_hover_layout_padding_info() {
+ check(
+ r#"struct $0Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }"#,
+ expect![[r#"
+ *Foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ struct Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }
+ ```
+
+ ---
+
+ size = 16 (0x10), align = 8, largest padding = 3, niches = 254, no Drop
+ "#]],
+ );
+
+ check(
+ r#"#[repr(align(32))]
+ struct $0Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }"#,
+ expect![[r#"
+ *Foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ struct Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }
+ ```
+
+ ---
+
+ size = 32 (0x20), align = 32 (0x20), largest padding = 19 (0x13), niches = 254, no Drop
+ "#]],
+ );
+
+ check(
+ r#"#[repr(C)]
+ struct $0Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }"#,
+ expect![[r#"
+ *Foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ struct Foo {
+ x: bool,
+ y: i64,
+ z: u32,
+ }
+ ```
+
+ ---
+
+ size = 24 (0x18), align = 8, tail padding = 4, niches = 254, no Drop
+ "#]],
+ );
+
+ check(
+ r#"struct $0Foo(i16, u128, u64)"#,
+ expect![[r#"
+ *Foo*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ struct Foo(i16, u128, u64)
+ ```
+
+ ---
+
+ size = 32 (0x20), align = 8, largest padding = 6, no Drop
+ "#]],
+ );
+}
+
+#[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 }"#,
@@ -7375,6 +7481,128 @@ pub struct Foo(i32);
}
#[test]
+fn hover_intra_inner_attr() {
+ check(
+ r#"
+/// outer comment for [`Foo`]
+#[doc = "Doc outer comment for [`Foo`]"]
+pub fn Foo {
+ //! inner comment for [`Foo$0`]
+ #![doc = "Doc inner comment for [`Foo`]"]
+}
+"#,
+ expect![[r#"
+ *[`Foo`]*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ pub fn Foo()
+ ```
+
+ ---
+
+ outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ Doc outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ inner comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ Doc inner comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ "#]],
+ );
+
+ check(
+ r#"
+/// outer comment for [`Foo`]
+#[doc = "Doc outer comment for [`Foo`]"]
+pub mod Foo {
+ //! inner comment for [`super::Foo$0`]
+ #![doc = "Doc inner comment for [`super::Foo`]"]
+}
+"#,
+ expect![[r#"
+ *[`super::Foo`]*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ pub mod Foo
+ ```
+
+ ---
+
+ outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ Doc outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ inner comment for [`super::Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ Doc inner comment for [`super::Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ "#]],
+ );
+}
+
+#[test]
+fn hover_intra_outer_attr() {
+ check(
+ r#"
+/// outer comment for [`Foo$0`]
+#[doc = "Doc outer comment for [`Foo`]"]
+pub fn Foo() {
+ //! inner comment for [`Foo`]
+ #![doc = "Doc inner comment for [`Foo`]"]
+}
+"#,
+ expect![[r#"
+ *[`Foo`]*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ pub fn Foo()
+ ```
+
+ ---
+
+ outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ Doc outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ inner comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ Doc inner comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/fn.Foo.html)
+ "#]],
+ );
+
+ check(
+ r#"
+/// outer comment for [`Foo$0`]
+#[doc = "Doc outer comment for [`Foo`]"]
+pub mod Foo {
+ //! inner comment for [`super::Foo`]
+ #![doc = "Doc inner comment for [`super::Foo`]"]
+}
+"#,
+ expect![[r#"
+ *[`Foo`]*
+
+ ```rust
+ ra_test_fixture
+ ```
+
+ ```rust
+ pub mod Foo
+ ```
+
+ ---
+
+ outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ Doc outer comment for [`Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ inner comment for [`super::Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ Doc inner comment for [`super::Foo`](https://docs.rs/ra_test_fixture/*/ra_test_fixture/Foo/index.html)
+ "#]],
+ );
+}
+
+#[test]
fn hover_intra_generics() {
check(
r#"
@@ -9076,7 +9304,7 @@ struct Pedro$0<'a> {
---
- size = 16 (0x10), align = 8, niches = 1, no Drop
+ size = 16 (0x10), align = 8, largest padding = 0, niches = 1, no Drop
"#]],
)
}
@@ -10437,7 +10665,7 @@ struct DropField$0 {
---
- size = 4, align = 4, needs Drop
+ size = 4, align = 4, largest padding = 0, needs Drop
"#]],
);
check(