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

let...else statements are unstable in solana-frozen-abi-macro-1.16.0 #32133

Closed
D0bhareach opened this issue Jun 14, 2023 · 18 comments · Fixed by #32232
Closed

let...else statements are unstable in solana-frozen-abi-macro-1.16.0 #32133

D0bhareach opened this issue Jun 14, 2023 · 18 comments · Fixed by #32232
Labels
community Community contribution

Comments

@D0bhareach
Copy link

Problem

While compiling anchor-lang = "0.28.0" project have got this error:
.cargo/registry/src/github.com-1ecc6299db9ec823/solana-frozen-abi-macro-1.16.0/src/lib.rs:422:5

422 let Some(expected_digest) = expected_digest else {
423 return Error::new_spanned(
424 TokenStream2::from(item),
425 "the required "digest" = ... attribute is missing.",
...
428 .into()
429 };

= note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
= help: add `#![feature(let_else)]` to the crate attributes to enable

For more information about this error, try rustc --explain E0658.
error: could not compile solana-frozen-abi-macro due to previous error
My rustc -V: rustc 1.70.0 (90c541806 2023-05-31)

@D0bhareach D0bhareach added the community Community contribution label Jun 14, 2023
@Twist96
Copy link

Twist96 commented Jun 15, 2023

I'm having this error too

@PratikBodawala
Copy link

PratikBodawala commented Jun 19, 2023

I had the same issue, for now, I have downgraded the Rust version to 1.69.0,
additionally, change Solana version to 1.16.1

@sausage-dog
Copy link

I get this error with either Solana 1.16.1 or 1.16.0 at rustc 1.69.0.

@smart-tech-master
Copy link

me too

@mvines
Copy link
Member

mvines commented Jun 21, 2023

@dmakarov - not sure if you have any idea as to what's going on here? The bug reports so far are super low quality here but seems like there's something not right. Unclear if this is an anchor issue or something with the platform tooling

@D0bhareach
Copy link
Author

D0bhareach commented Jun 21, 2023

This is issue with Rust version used by libraries I believe it is 1.61 for Solana, honestly don't remember where remember it was in dependencies for workspace. So, I guess, newer syntax is used to compile with older version. So if code above is changed to to if let Some(val) {bla-bla} else {bla-bla } error should disappear.
In order to compile I downgrade versions of dependencies like this:
mpl-token-metadata = {version = "1.12.0", features = ["no-entrypoint"]} solana-program = "=1.14.17"

@dmakarov
Copy link
Contributor

@dmakarov - not sure if you have any idea as to what's going on here? The bug reports so far are super low quality here but seems like there's something not right. Unclear if this is an anchor issue or something with the platform tooling

We'll update platform-tools to latest rust version soon. Until then we could patch frozen-abi-macro/src/lib.rs and add #![feature(let_else)] to enable

let Some(expected_digest) = expected_digest else {
I haven't check that it would work with the platform-tools rust compiler, though.

@sausage-dog
Copy link

sausage-dog commented Jun 21, 2023

Works for me with this:

[dependencies]
         anchor-lang = "0.26.0"
         anchor-spl = "0.26.0"
         metaplex-token-metadata = { version = "0.0.1", features = ["no-entrypoint"] }
         solana-program = "=1.14.13"
         getrandom = { version = "0.2.9", features = ["custom"] }
         switchboard-v2 = "0.1.15"
         mpl-bubblegum = { version = "0.8.0", features = [ "no-entrypoint" ]}
         spl-account-compression = { version = "0.1.10", features = [ "no-entrypoint" ]}  

at rustc 1.69.0 (84c898d65 2023-04-16)

@marshallr12
Copy link

marshallr12 commented Jun 21, 2023

This isn't an anchor specific issue. I can reproduce it attempting to build using rust 1.70 and dependency solana-program 1.16.1:

cargo new test-solana --lib
cd test-solana
cargo add solana-program
cargo build-sbf

Compiling solana-frozen-abi-macro v1.16.1
error[E0658]: let...else statements are unstable
--> /home/marshall/.cargo/registry/src/github.com-1ecc6299db9ec823/solana-frozen-abi-macro-1.16.1/src/lib.rs:422:5
|
422 | / let Some(expected_digest) = expected_digest else {
423 | | return Error::new_spanned(
424 | | TokenStream2::from(item),
425 | | "the required "digest" = ... attribute is missing.",
... |
428 | | .into()
429 | | };
| |______^
|
= note: see issue #87335 rust-lang/rust#87335 for more information
= help: add #![feature(let_else)] to the crate attributes to enable

@mvines
Copy link
Member

mvines commented Jun 21, 2023

cargo new test-solana --lib
cd test-solana
cargo add solana-program
cargo build-sbf

These STR worked fine for me.

$ cargo build-sbf --version
solana-cargo-build-sbf 1.16.1
platform-tools v1.37

@dmakarov
Copy link
Contributor

platform-tools 1.37 is based on rust 1.68. let_else feature is stable since rust 1.65, so, indeed, platform-tools v1.37 should work.

@mvines
Copy link
Member

mvines commented Jun 21, 2023

I can also confirm the issue reproduces with:

$ cargo build-sbf --version
solana-cargo-build-sbf 1.14.17
sbf-tools v1.29

But this is also expected. One cannot expect to build solana-program 1.16.1 with the platform tools in 1.14

@mvines
Copy link
Member

mvines commented Jun 21, 2023

We could try adding https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field to crates like solana-program to make this error more explicit

@marshallr12
Copy link

As of now, if I run solana-install update, I will get solana-cargo-build-sbf 1.14.20 and sbf v1.29, which still reproduces the issue if you follow the Rust Quickstart.

@mvines
Copy link
Member

mvines commented Jun 22, 2023

solana-install update will (intentionally) not bump your minor solana version, so if you are currently on a v1.14 release then you won't get v1.16. Use solana-install init v1.16.1 to jump to a v1.16 release.

@marshallr12
Copy link

solana-install update will (intentionally) not bump your minor solana version, so if you are currently on a v1.14 release then you won't get v1.16. Use solana-install init v1.16.1 to jump to a v1.16 release.

Thank you, that worked for me. I think it would be very useful to have a --latest or similar option for solana-install update.

@mvines
Copy link
Member

mvines commented Jun 22, 2023

Great. Hopefully starting with 1.16.2, we'll have a more explicit error when this condition occurs so it'll be more obvious that a newer version of the platform-tools needs to be installed.

@Twist96
Copy link

Twist96 commented Jul 3, 2023

@dmakarov - not sure if you have any idea as to what's going on here? The bug reports so far are super low quality here but seems like there's something not right. Unclear if this is an anchor issue or something with the platform tooling

We'll update platform-tools to latest rust version soon. Until then we could patch frozen-abi-macro/src/lib.rs and add #![feature(let_else)] to enable

let Some(expected_digest) = expected_digest else {

I haven't check that it would work with the platform-tools rust compiler, though.

This worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
8 participants