How to check crate compatibility with edition 2018?

Hello.
I sometimes have problems with the rust edition:

Caused by:
  feature `edition2021` is required

  this Cargo does not support nightly features, but if you
  switch to nightly channel you can add
  `cargo-features = ["edition2021"]` to enable this feature

How to check crate compatibility with edition 2018?
Is exist any tool for this?

It sounds like you're using an old compiler. The thing to look for is the MSRV of the crate, which means "minimum supported rust version". If the compiler version you are using is not older than the MSRV of a crate, then you shouldn't run into edition issues either.

1 Like

I using rustc-1.54.0. It's required by yocto honister.
https://layers.openembedded.org/layerindex/recipe/190301/
I was using 1.49 before.

The 2021 edition was introduced with rust 1.56. If you really can't use a newer rustc version, you can try changing edition = "2021" to edition = "2018" in Cargo.toml and see if it compiles.

1 Like

I have edition = "2018" in my project. Some dependencies changed edition (2018->2021).

https://lib.rs has a "secret" compatibility page which might be helpful for checking dependency crates.

E.g. for tokio

https://lib.rs/compat/tokio

2 Likes

You probably need to lock them down, then. MSRV increase is not considered a breaking change by most developers thus to avoid the problem the only somewhat reliable solutions is Cargo.lock.

Most Rust developers would consider that a trouble caused by yocto and would ask them to decide what they plan to do about it.

1 Like

It's a cool tool but it not working now. ;(

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.