mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-18 03:13:31 +00:00
Resolve offset_of!() in IDE
This commit is contained in:
parent
db6db2aacc
commit
8d824c7828
5 changed files with 169 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue