I recently tried to migrate a rust crate from rust edition 2018 to 2021. The easy part was migrating the code for my current target:

  • leave the edition as it currently is (2018)
  • run cargo fix --edition
  • then change the edition to the new one (2021)

This worked fine but failed on CI due to problems with the netbsd code:

--> src/fsevent.rs:437:14 `*mut c_void` cannot be sent between threads safely

This was essentially a borrow/lifetime change where the field instead of the wrapping struct was now moved.

I could have added the fix manually, but there is an easier fix: You can perform the cargo edition migrations for other compilation targets, without having to actually run them or correctly cross compiling to them:

rustup target add x86_64-unknown-netbsd
#if you want to build and not only check for this target
#cargo build --target=x86_64-unknown-netbsd
cargo fix --edition --allow-dirty --target=x86_64-unknown-netbsd

So just run the cargo fix for all other targets you support, then increase the edition value.