Skip to content

RFC: Cargo feature deprecation #3486

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Sep 9, 2023

Rendered

RFC for feature-deprecation
RFC goals: add a way to deprecate Cargo features

This was split from #3416

[features]
foo = { enables = [], deprecated = true }
foo = { enables = [], deprecated = "this works as a note" }
bar = { enables = [], deprecated = { since = "1.2.3", note = "don't use this!" } }

This would resolve rust-lang/cargo#7130

@tgross35 tgross35 force-pushed the feature-deprecation branch from 0c803c3 to 6c3d1f4 Compare September 9, 2023 23:20
@compiler-errors compiler-errors added the T-cargo Relevant to the Cargo team, which will review and decide on the RFC. label Sep 9, 2023
The hope with these changes is to clarify what is there and not to
change what the author intended.
Comment on lines +113 to +115
[rationale-and-alternatives]: #rationale-and-alternatives

WIP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to close this out

Comment on lines +119 to +121
[prior-art]: #prior-art

WIP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to close this out

Comment on lines +142 to +144
- A `rust-version` field that could indicate e.g. `rust-version = "nightly"` or
`rust-version = "1.65"` to specify a MSRV for that feature. See:
<https://github.com/rust-lang/rfcs/pull/3416#discussion_r1174478461>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to deprecation?

@tgross35 tgross35 marked this pull request as draft September 10, 2023 01:48
Comment on lines +138 to +141
- A `stable` field can be set false to indicate API-unstable or nightly-only
features (something such as `stable = 3.2` could be used to indicate when a
feature was stabilized). See also:
<https://github.com/rust-lang/cargo/issues/10882>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this connected to this RFC?

```toml
[features]
foo = { enables = [], deprecated = true }
foo = { enables = [], deprecated = "this works as a note" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres two foo features, is that intentional?

@epage epage added the S-waiting-on-author Status: This is awaiting some action from the author. label May 21, 2024
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought is the (current) inability to squelch the warning. Let's say I update a dependency and start getting the warning, but I can't change it right now. That can be frustrating since you'll get spammed with a warning you can't do anything about every time you run cargo. For normal deprecations, you have the ability to #[allow] it, but without the ability to control cargo's warnings in cargo (cargo#12235), there's nothing you can do.


[index changes]: #index-changes

The infromation provided by `deprecated` needs to be stored in the index, and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section contradicts the sentence above that says the information will not be in the index. It's not clear why this is suggesting it should be in the index. Offhand I don't know why this would be added, since I don't think the resolver needs to know this.

attribute in Rust source. The value can be a boolean, string, or an object with
`since` or `note` keys. Schema rules are as follows:

- If a boolean value, `false` indicates not deprecated and `true` indicates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what the benefit is of having a boolean form. deprecated=true provides little information to the user, and it seems relatively little effort to at least provide a string explaining why it is deprecated or what to use instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume its to be consistent with the attribute but I see little lost in being inconsistent on this part.

string was specified in the `note` field (e.g. `foo = { deprecated = { note = "my msg" } }`)
- If not specified, the default is `false`

If a downstream crate attempts to use a feature marked `deprecated`, Cargo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see some clarity around the transitive behavior. I would expect transitive warnings to be hidden (like #[deprecated] due to cap-lints), and only show usage of deprecated features from dependency declarations in the local package, or the command-line (x/y style).

And a related thing, if I do --features foo where foo is deprecated in the local package, does that show a warning?

@epage
Copy link
Contributor

epage commented Mar 9, 2025

Another thought is the (current) inability to squelch the warning. Let's say I update a dependency and start getting the warning, but I can't change it right now. That can be frustrating since you'll get spammed with a warning you can't do anything about every time you run cargo. For normal deprecations, you have the ability to #[allow] it, but without the ability to control cargo's warnings in cargo (cargo#12235), there's nothing you can do.

This problem and anoth'r possible solution is hinted at in the since section. The idea i had was to make deprecated smarter by looking at version requirements and whether their minimum is at least at since, see #3416 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. T-cargo Relevant to the Cargo team, which will review and decide on the RFC.
Projects
Status: RFC needs review
Status: Unreviewed
Development

Successfully merging this pull request may close these issues.

Feature Request: A way to deprecate features
5 participants