Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
Rahix opened this issue Apr 18, 2024 · 4 comments
Open
2 tasks
Labels
bug Something isn't working

Comments

@Rahix
Copy link
Owner

Rahix commented Apr 18, 2024

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 dtolnay/proc-macro2#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:

  • We need to upgrade to a newer rust toolchain version again.
  • We need to pin proc-macro2 to v1.0.79 somewhere to ensure this won't hit us again. I am unsure where the right place for this is:
    • avr-device? Pulled in by everyone who might care about this, but feels like the wrong level for such a fix.
    • avr-hal-template? Gives users control over the fix, if it ever needs changing. Downside is that it does not reach existing users, only new ones...
    • avr-hal/arduino-hal/atmega-hal? Should allow reaching existing users more easily, but still not really the right level for the fix...
@Rahix Rahix added the bug Something isn't working label Apr 18, 2024
@Rahix Rahix pinned this issue Apr 18, 2024
Rahix added a commit to Rahix/avr-hal-template that referenced this issue Apr 18, 2024
The latest releases of `proc-macro2` do not support the rust toolchain
that we use [1].  Thus, we must fix this dependency to an older version
where our toolchain is still supported.

As a first step, add this pinning here in the avr-hal-template so people
who create new projects from now on are no longer affected.  In the long
run, we should look at finding a solution that can be rolled out to
existing users as well.

[1]: Rahix/avr-hal#537
@Rahix
Copy link
Owner Author

Rahix commented Apr 18, 2024

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 added a commit that referenced this issue May 4, 2024
The latest releases of `proc-macro2` do not support the rust toolchain
that we use [1].  Thus, we must fix this dependency to an older version
where our toolchain is still supported.

[1]: #537
Rahix added a commit that referenced this issue May 4, 2024
The latest releases of `proc-macro2` do not support the rust toolchain
that we use [1].  Thus, we must fix this dependency to an older version
where our toolchain is still supported.

[1]: #537
@Rahix
Copy link
Owner Author

Rahix commented May 4, 2024

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

Rahix added a commit to Rahix/avr-device that referenced this issue May 4, 2024
Rahix added a commit to Rahix/avr-device that referenced this issue May 4, 2024
@Rahix
Copy link
Owner Author

Rahix commented May 4, 2024

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 Rahix/avr-device#156).

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

@Rahix
Copy link
Owner Author

Rahix commented May 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant