Skip to content

offset_of! ecosystem testing #111839

@est31

Description

@est31
Member

I'm filing this issue to get some testing of the offset_of macro, whose implementation has recently been merged in #106934 .

There is already widespread use of the offset_of macro in the ecosystem through an implementation supporting stable via the memoffset crate, whose version 0.9.0 supports the unstable_offset_of feature due to Gilnaa/memoffset#72. So for a lot of the users, testing out is as simple as updating memoffset and running the tests with the unstable_offset_of feature enabled. Thankfully, for testing one doesn't have to add that feature to Cargo.toml, creating a requirement on nightly, one can just add --features memoffset/unstable_offset_of and it will work.

The biggest reverse dependencies of memoffset are:

  • crossbeam-epoch: PR
    nix: PR
    rustix: PR
    pyo3: PR comment
    wayland-sys: PR
    wasmtime-runtime: PR comment
    wasmer-types/wasmer-vm
    field-offset: PR comment
    rowan: PR
    glium: PR comment
    intrusive-collections: PR
    imgui: PR
    egui-glow: PR
    virtio-queue: comment
    arcstr: PR
    ggez

It would be good to go through this list, and:

  1. update the memoffset crate to 0.9.0, ideally filing a PR (but not enabling unstable_offset_of in Cargo.toml unless the project already requires nightly!)
  2. run cargo +nightly test --features memoffset/unstable_offset_of or cargo +nightly run --features memoffset/unstable_offset_of etc, trying out the feature and seeing if something is broken, ideally also the --all parameter if it's a workspace
  3. tell here about the experience

In addition of that, it is useful to get feedback from any project that uses the memoffset crate indirectly as a transitive dependency. For that, one also has to wait for the upgrade to 0.9.0 to go through the dependency chain and then one can add a direct (unused) dependency on memoffset to enable the feature, and test it out.

For example, field-offset has a large number of reverse dependencies that one could go through also. I have made a PR for rustc in #112298.

cc #106655 tracking issue

Activity

changed the title [-]offset_of ecosystem testing[/-] [+]`offset_of!` ecosystem testing[/+] on May 22, 2023
est31

est31 commented on May 22, 2023

@est31
MemberAuthor

@rustbot label F-offset_of

est31

est31 commented on May 22, 2023

@est31
MemberAuthor

@rustbot label E-help-wanted

added
E-help-wantedCall for participation: Help is requested to fix this issue.
on May 22, 2023
added a commit that references this issue on May 30, 2023

29 remaining items

joshlf

joshlf commented on Oct 24, 2023

@joshlf
Contributor

Confirmed for field-offset. Confirmed for pyo3 (there were trybuild failures, but I believe they're related to compiler version, not behavior changes).

Some of the remaining crates are difficult to test locally for one reason or another. I've put up do-not-merge PRs that enable memoffset's unstable_offset_of feature so that CI can run on those PRs as a replacement for running the test suites locally.

rust-vmm/vm-virtio#268 (CI only tests on stable; I've requested a maintainer to run for us: rust-vmm/vm-virtio#269)
ggez/ggez#1260

joshlf

joshlf commented on Oct 24, 2023

@joshlf
Contributor

Confirmed for virtio-queue.

joshlf

joshlf commented on Oct 25, 2023

@joshlf
Contributor

@est31 Are we hoping to get to 100% coverage here, or is 14/16 good enough? (For the remaining 2, we haven't found issues, we've just run into unrelated problems running the test or getting the feature merged.)

est31

est31 commented on Oct 28, 2023

@est31
MemberAuthor

It's not a precise science, my main goal for the list was to give a starting point. I think we can close this particular issue which was mostly to get things started, as projects often use stable only and are afraid to use nightly features (and indeed there is discussions to maybe change the syntax of offset_of). Of course, even if this issue is closed, further testing will always be encouraged.

Thanks ❤️ @joshlf for your help, and thanks @ojeda and everyone else for confirming that it works for their use cases.

ojeda

ojeda commented on Oct 28, 2023

@ojeda
Contributor

My pleasure!

added 2 commits that reference this issue on Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue.F-offset_of`#![feature(offset_of)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @joshlf@ojeda@sunfishcode@est31@sanbox-irl

        Issue actions

          `offset_of!` ecosystem testing · Issue #111839 · rust-lang/rust