mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Merge pull request #19657 from ChayimFriedman2/better-offset-of
feat: Better support `offset_of!()`
This commit is contained in:
commit
1c68d83569
9 changed files with 230 additions and 3 deletions
|
|
@ -70,6 +70,7 @@
|
|||
//! unimplemented: panic
|
||||
//! column:
|
||||
//! addr_of:
|
||||
//! offset_of:
|
||||
|
||||
#![rustc_coherence_is_core]
|
||||
|
||||
|
|
@ -414,6 +415,13 @@ pub mod mem {
|
|||
use crate::marker::DiscriminantKind;
|
||||
pub struct Discriminant<T>(<T as DiscriminantKind>::Discriminant);
|
||||
// endregion:discriminant
|
||||
|
||||
// region:offset_of
|
||||
pub macro offset_of($Container:ty, $($fields:expr)+ $(,)?) {
|
||||
// The `{}` is for better error messages
|
||||
{builtin # offset_of($Container, $($fields)+)}
|
||||
}
|
||||
// endregion:offset_of
|
||||
}
|
||||
|
||||
pub mod ptr {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue