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

Very bad diagnostics when using a crate with the new dep: syntax on older compiler versions #10700

Closed
diondokter opened this issue May 25, 2022 · 1 comment
Labels
C-bug Category: bug

Comments

@diondokter
Copy link

Problem

I released a new crate version with the following line: https://github.com/tweedegolf/nrf-modem-nal/blob/55730488496b2df99e42c4e34aa840c543951529/Cargo.toml#L24
This uses the new dep: syntax.

We use this crate in a project with a rust-toolchain.toml that was set at 1.59.
When updating the crate version in our project by changing the version from "0.1.0" to "0.1.1", the following error would be displayed:

    Updating crates.io index
error: failed to select a version for the requirement `nrf-modem-nal = "^0.1.1"`
candidate versions found which didn't match: 0.1.0
location searched: crates.io index
required by package `firmware v2.0.0 (/src/firmware)`

It makes it look like the entire crate version doesn't exist.

Steps

  1. Have a crate that uses the dep: syntax
  2. Use a compiler from before that feature was added
  3. Add the crate as a dependency of a project
  4. Build the project
  5. See the bad diagnostics

Possible Solution(s)

I don't know if it's ever done to distribute a new cargo with an old compiler. If not, then there's not much that can be done probably.

There are two things that can be done to prevent this in the future:

  1. Make cargo not bail when it encounters new features like this.
    Here's the crate index: https://github.com/rust-lang/crates.io-index/blob/master/nr/f-/nrf-modem-nal
    As you can see, cargo should probably be able to parse that the version is there, but that it is likely that a newer version has to be used to use that version.
  2. Let cargo detect the new syntax/features and add an implicit rust-version to cargo.toml when publishing a crate

Notes

This happens on Windows and Linux, but probably on every platform

Version

cargo 1.59.0 (49d8809dc 2022-02-10)
release: 1.59.0
commit-hash: 49d8809dc2d3e6e0d5ec634fcf26d8e2aab67130
commit-date: 2022-02-10
host: x86_64-pc-windows-msvc
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:Schannel)
os: Windows 10.0.22000 (Windows 10 Pro) [64-bit]
@diondokter diondokter added the C-bug Category: bug label May 25, 2022
@epage
Copy link
Contributor

epage commented May 25, 2022

We are tracking this in #10623

@epage epage closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants