Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/goto_definition.rs')
-rw-r--r--crates/ide/src/goto_definition.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index ebd68983ed..b894e85752 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -3476,4 +3476,74 @@ fn main() {
"#,
);
}
+
+ #[test]
+ fn offset_of() {
+ check(
+ r#"
+//- minicore: offset_of
+struct Foo {
+ field: i32,
+ // ^^^^^
+}
+
+fn foo() {
+ let _ = core::mem::offset_of!(Foo, fiel$0d);
+}
+ "#,
+ );
+
+ check(
+ r#"
+//- minicore: offset_of
+struct Bar(Foo);
+struct Foo {
+ field: i32,
+ // ^^^^^
+}
+
+fn foo() {
+ let _ = core::mem::offset_of!(Bar, 0.fiel$0d);
+}
+ "#,
+ );
+
+ check(
+ r#"
+//- minicore: offset_of
+struct Bar(Baz);
+enum Baz {
+ Abc(Foo),
+ None,
+}
+struct Foo {
+ field: i32,
+ // ^^^^^
+}
+
+fn foo() {
+ let _ = core::mem::offset_of!(Bar, 0.Abc.0.fiel$0d);
+}
+ "#,
+ );
+
+ check(
+ r#"
+//- minicore: offset_of
+struct Bar(Baz);
+enum Baz {
+ Abc(Foo),
+ // ^^^
+ None,
+}
+struct Foo {
+ field: i32,
+}
+
+fn foo() {
+ let _ = core::mem::offset_of!(Bar, 0.Ab$0c.0.field);
+}
+ "#,
+ );
+ }
}