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

Unnecessary error for weak dependency features #10540

Closed
CryZe opened this issue Apr 7, 2022 · 5 comments
Closed

Unnecessary error for weak dependency features #10540

CryZe opened this issue Apr 7, 2022 · 5 comments
Labels
C-bug Category: bug

Comments

@CryZe
Copy link

CryZe commented Apr 7, 2022

Problem

I just tried out the weak dependency features support in Rust 1.60. And I'm getting the following error:

error: failed to parse manifest at `[...]\Cargo.toml`

Caused by:
  feature `std` includes `serde?/std` with a `?`, but `serde` is not an optional dependency
  A non-optional dependency of the same name is defined; consider removing the `?` or changing the dependency to be optional

This error is unnecessary and should probably be removed. The whole point of the weak dependency features is to fix the old system where you accidentally bring in dependencies. Ideally the default would be changed, but can't due to backwards compatibility, so ?/ is the alternative that was chosen. Now in order to not accidentally bring in dependencies I don't want, I want to use ?/ everywhere, but apparently this error prevents me from doing so.

Steps

  1. Use ?/ with a dependency that is not optional.

Possible Solution(s)

Don't show the error.

Notes

No response

Version

cargo 1.60.0 (d1fd9fe2c 2022-03-01)
release: 1.60.0
commit-hash: d1fd9fe2c40a1a56af9132b5c92ab963ac7ae422
commit-date: 2022-03-01
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.19042 (Windows 10 Education) [64-bit]
@CryZe CryZe added the C-bug Category: bug label Apr 7, 2022
@ehuss
Copy link
Contributor

ehuss commented Apr 12, 2022

We discussed this issue, and we decided it is best to stay with the current syntax. The ? was intentionally chosen to mean "optional" (with some similarity with Rust's use of ? and options). We'd also like to avoid further churn in changing syntax.

We understand that the current syntax is not ideal, and was forced by need of backwards compatibility. I opened #10556 with a possible option for the future.

@ehuss ehuss closed this as completed Apr 12, 2022
@CryZe
Copy link
Author

CryZe commented Apr 12, 2022

This is not what this issue is about. The syntax is fine, the error is not. The error is there for people who might accidentally use this feature (which is probably close to no one), but I think it's counter productive in the way it works... and is entirely optional anyway. Cargo would work just fine without emitting this error in the first place.

@CryZe
Copy link
Author

CryZe commented Apr 21, 2022

Can this be reopened considering it has been misunderstood entirely?

@epage
Copy link
Contributor

epage commented Apr 21, 2022

When discussing syntax, we are also referring to the semantics of that syntax. We are not wanting to allow ? when something is optional. As ehuss said, #10556 is the path forward for improving the behavior here.

@CryZe
Copy link
Author

CryZe commented Apr 21, 2022

When the long term goal are the semantics I'm proposing here anyway (independent of syntax), then why artificially cripple ? now with no advantages? Why not adopt the proper semantics already for ? (with no backwards compatibility concerns or syntax changes) There's literally close to no reason to not do it.

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

3 participants