rust-embedded / embedded-hal

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

Use `feature()` on nightly toolchains only. #534

Closed Dirbaio closed 10 months ago

Dirbaio commented 10 months ago

feature() is only allowed on Nightly, it's completely disallowed on stable and beta even for already-stabilized features. So, we autodetect whether the user is using nightly and conditionally use feature(). This allows the crates to Just Work on current 1.75 beta and will also Just Work when 1.75 stable is out.

Keeping feature() is desirable to keep support for:

Once xtensa rust 1.75 is out, we can remove this (upstream nightlies that require feature() will be quite old by then, so dropping support for them should be OK).

I decided to not use already-made crates like rustversion to do this because they're quite big and do way more than what we need, so I felt badd adding another dep. The code is inspired from rustversion's build.rs.