Rahix / avr-hal

embedded-hal abstractions for AVR microcontrollers
Apache License 2.0
1.23k stars 216 forks source link

cargo build - error[E0658] - proc_macro::Literal::byte_character(byte) #537

Open Rahix opened 2 months ago

Rahix commented 2 months ago

Originally reported in #535.

Due to a change in proc-macro2 version v1.0.80, the toolchain version we use is no longer supported (see https://github.com/dtolnay/proc-macro2/issues/451). To reproduce:

cargo generate --git https://github.com/rahix/avr-hal-template -r bb141bd00f6b9687e986db8aeb66a3f3f50cca12 -n proc-macro-regression
cd proc-macro-regression/
cargo build

which end with the following build error:

   Compiling proc-macro2 v1.0.81
error[E0658]: use of unstable library feature 'proc_macro_byte_character'
   --> /home/rahix/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.81/src/wrapper.rs:871:21
    |
871 |                     proc_macro::Literal::byte_character(byte)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information
    = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'proc_macro_c_str_literals'
   --> /home/rahix/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.81/src/wrapper.rs:898:21
    |
898 |                     proc_macro::Literal::c_string(string)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information
    = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-21; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` (lib) due to 2 previous errors

The solution to this issue comes in two parts:

Rahix commented 2 months ago

The avr-hal-template is updated to pin the dependency version. New projects generated from the template will no longer run into this problem. Unclear whether this is enough or whether we should do more...

avr-hal itself also needs fixing for the examples.

For documentation, the dependency can be pinned using these lines in Cargo.toml:

# The latest releases of `proc-macro2` do not support the rust toolchain that
# we use.  Thus, we must fix this dependency to an older version where our
# toolchain is still supported.  See https://github.com/Rahix/avr-hal/issues/537
[build-dependencies.proc-macro2]
version = "=1.0.79"
Rahix commented 1 month ago

Examples in this repository now also have the dependency pin (#544).

Rahix commented 1 month ago

So avr-device will need to deal with this for its own CI, too. So maybe the solution is to simply pin proc-macro2 in avr-device-macros so it will solve the problem for each and every downstream crate (See https://github.com/Rahix/avr-device/pull/156).

What does everyone else think about this? Are there any problems with doing this?

Rahix commented 1 month ago

From #546: The CI of this project (avr-hal) does not fail on this... Needs to be investigated.