rust-embedded / embedded-hal

A Hardware Abstraction Layer (HAL) for embedded systems
Apache License 2.0
1.95k stars 197 forks source link

Use rust-version field #490

Closed Sh3Rm4n closed 10 months ago

Sh3Rm4n commented 1 year ago

I've noticed that this project does not use the rust-version field yet, while maintaining a MSRV policy. Add this field to make this policy machine-readable and leverage nicer cargo feedback in case of an older rust version.

Dirbaio commented 1 year ago

rust-version actively forbids using the crate in lower version. I'm not sure if this is something we want to do.

The 1.60 MSRV is due to the use of dep: in Cargo.toml. Only embedded-hal-bus and embedded-io-adapters actually use it, so in theory other crates like embedded-hal could work on 1.59 or older. So, adding rust-version is overly strict.

Options:

I'm not sure what's the best solution here.

Sh3Rm4n commented 1 year ago

rust-version actively forbids using the crate in lower version. I'm not sure if this is something we want to do.

Yeah, that is a valid concern. However, --ignore-rust-verison exist to be able to opt out of this behavior.

The 1.60 MSRV is due to the use of dep: in Cargo.toml. Only embedded-hal-bus and embedded-io-adapters actually use it, so in theory other crates like embedded-hal could work on 1.59 or older. So, adding rust-version is overly strict.

I'm fine with making it more granular per crate.

Options:

  • [...]
  • Track MSRV for each crate individually, set rust-version to that.

Well, I'm unsurprisingly in favor of this approach. It is machine-readable, generates clear error messages instead of some issues, which seem totally unrelated for the user, if they did not check their installed version yet, and it can be better checked by CI. The README approach is not as visible to most users and has to be verified manually if the MSRV needs changing. IMO rust-version makes maintaining the MSRV guarantees easier.

But this is not up to me, as I'm not a maintainer of embedded-hal, so I'm fine if you close this PR and keep using the current approach. :)

rursprung commented 1 year ago

FYI: if you want to identify the MSRV for each crate (to set it now initially) you can use cargo-msrv to do that. i think with that it's then also no hassle to update it for the individual crates when needed

Sh3Rm4n commented 11 months ago

I've reduced the MSRV for all crates, which do not use dep: to 1.56, which is the 2021 edition release.

rursprung commented 10 months ago

i think this should land before v1.0 is released - it'd help with cleaner error messages in the future when the MSRV for a crate is increased. the rust/crates teams also encourages setting this field (see various posts in their forums & issues)

Dirbaio commented 10 months ago

Doing option 2 ("Track MSRV for each crate individually, set rust-version to that.") sounds good to me then. We can discuss it next weekly meeting and merge if there's no objections.