Skip to content

Fully generic sysvar implementations #5

Description

@tgross35

I think I actually came up with a way to make sysvar implementations fully generic using struct update syntax. Proof:

struct St {
    x: *mut i32,
    y: i32
}

unsafe impl Sync for St {}

trait Foo {
    const DEFAULT_ST: St = St{x: std::ptr::null_mut(), y: 0};
}

struct Bar;

impl Foo for Bar {}

static TEST: St = St {x: 0x123 as *mut i32, ..Bar::DEFAULT_ST};

The proc macro would create something like TEST. Just needs to detect string literals and convert them to c strings, and keep a map of field mappings.

To keep safety, 1. this trait needs to be marked unsafe and 2. our proc macro should check and reject raw pointer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions