rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.58k stars 2.39k forks source link

Next step for deprecations in Cargo #13629

Open weihanglo opened 5 months ago

weihanglo commented 5 months ago

2024 Deprecations

Problem

Cargo has been emitting a bunch deprecation message for a (long?) while. Since edition 2024 is approaching (1.82.0 anticipated), and a Cargo linting system is on the way (https://github.com/rust-lang/cargo/pull/13621), we might want to take advantage of this timing to evaluate whether this deprecations could be turned into a hard error.

The main risk here is CI automation might fail. Unlike rustc and clippy lints, people hardly noticed Cargo warnings becuase because there was no way to set -D on them.

Deprecations

2024 Edition

These are being tracked in rust-lang/rust#123754

### `dev_dependencies`/`build_dependencies`/`default_features`/`crate_types`/`proc_macro` https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/util/toml/mod.rs#L198-L199 * Warn since: 1.61 (2022-05-19) but only when conflicting with dash ones * may become a hard error? NO * Risk: Old crates fail to compile. Might need an edition boundary. * * Next step: * Error on 2024 edition ### good old `[project]` (replaced with `[package]`) https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/util/toml/mod.rs#L497-L498 * Warn since: 1.66 (2022-12-15) * may become a hard error? ✅ * Risk: Old crates fail to compile. Require an edition boundary. * * Next step: * Error on 2024 edition ### `default-features` in inherited dependencies https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/util/toml/mod.rs#L1801-L1803 * Warn since: 1.69.0 (2023-04-29) * may become a hard error? ✅ * Risk: Build failures. Easy to fix. * * Next step: * Error in 2024 Edition

Independent of Edition

Approved changes

Proposed changes

plugin support

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/util/toml/targets.rs#L211-L216

dependency without path, version, git, workspace specified

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/cargo/util/toml/mod.rs#L1914-L1918

Note:

license-file and readme pointing to a non-existent file

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/ops/cargo_package.rs#L416-L418

--release is ignored when paired with --profile

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/cargo/util/command_prelude.rs#L570-L573

cargo read-manifest

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/bin/cargo/commands/read_manifest.rs#L9

[replace] is deprecated

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/doc/src/reference/overriding-dependencies.md?plain=1#L300-L301

old cargo tree flags: --all, no-dev-dependencies, --no-indent, --prefix-depth, --all-targets

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/bin/cargo/commands/tree.rs#L144-L146

path override modifying dependency graph

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/core/registry.rs#L535-L538

rustc-cdylib-link-arg used in non-cdylib target

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/core/compiler/custom_build.rs#L850-L856

user-defined alias is shadowing an external subcommand found

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/bin/cargo/cli.rs#L321-L323

output artifact name collisions

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/core/compiler/build_runner/mod.rs#L472-L474

Bail out when trying to link to a library that is not linkable

https://github.com/rust-lang/cargo/blob/f0ae76519127d16d87362c6d88416d92cba86c6a/src/cargo/core/compiler/mod.rs#L1427-L1430

Ambiguous package name in git dependency

https://github.com/rust-lang/cargo/blob/bd1cf584af2c356eeb3980c3c9bb0fea190ed633/src/cargo/ops/cargo_read_manifest.rs#L225-L234

No further steps

deprecate --all (alias to --workspace)

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/cargo/util/command_prelude.rs#L54

Deprecate .cargo/config

https://github.com/rust-lang/cargo/blob/8bcecfeed464c990733ff680e0b4546a73fbed44/src/cargo/util/context/mod.rs#L1563-L1567

epage commented 5 months ago

dependency without path, version, git, workspace specified

While it says it may transition to a hard error, the fact that issues seemed to exist where we broke people previously for this makes me cautious about doing it.

I'm at least for making this an error on the next Edition.

cargo read-manifest

As this is a command, I don't think there are further next steps.

At most, we could check the Edition and hard error but that seems unnecessary.

We could hide it in cargo --list but its good for people to know what built-ins exist because of how conflicts work with commands.

path override modifying dependency graph

I don't have a good feel for this for turning

Bail out when trying to link to a library that is not linkable

I feel like this is blocked on issues like #7825

output artifact name collisions

Is this blocked on #8794?

deprecate --all (alias to --workspace)

We should remove this from -h.

Otherwise, as a CLI, there isn't much more we should do.

[replace] is deprecated

Being config, I'm not sure there is much we should do.

license-file and readme pointing to a non-existent file

At one point, this was an error. I wonder if we were too aggressive in making this a warning.

Maybe if the fields are empty, we allow it but otherwise go ahead and error?

old cargo tree flags: --all, no-dev-dependencies, --no-indent, --prefix-depth, --all-targets

Being a CLI, is there much we should do?

rustc-cdylib-link-arg used in non-cdylib target

I'm for a hard error. The message says this wasn't originally allowed and that it was a bug that it was allowed.

--release is ignored when paired with --profile

Despite being in the CLI, I'm somewhat tempted to allow this to error.

user-defined alias is shadowing an external subcommand found:

Despite being a mixture of CLI and config, I'm game for this. Generally aliases are for users and not automation. xtasks are an exception but a well structured pattern of it.

dev_dependencies/build_dependencies/default_features/crate_types/proc_macro

Error on next edition

good old [project] (replaced with [package])

Without more historical context for why it should unconditionally error, I'd say error on next edition

default-features in inherited dependencies

Error on next edition

plugin support

Remove

Deprecate .cargo/config

Keep as-is (deprecated). Being config, we can't use Editions. Its also likely something tied to automation, so we can't remove either.

epage commented 5 months ago

We discussed some of these in today's team meeting and updated the next steps for those items. For things that weren't discussed I noted that the "Next Steps" are "proposed".