Skip to content

Dropping unused and unreferenced external crate should not trigger recompile #52365

Open
@mqudsi

Description

@mqudsi

After compiling a project that has a reference to an external crate in Cargo.toml but that is not imported (no extern crate foo;), a subsequent cargo build after dropping the unused dependency from Cargo.toml triggers a full rebuild.

Unless the removal triggers a change in the version of a different dependency in the lock file (which I don't think can currently happen in this scenario), a recompile should be skipped.

(I'd even go further and say that a remote crate imported with extern crate foo or even #[macro_use] extern crate foo; that is not actually used and does not introduce build scripts, etc. should also not trigger a rebuild, but that is at least understandable as it can affect type negotiations, etc. in which case it should be more of an "early abort" once the AST has been formed and it becomes possible to determine that no types have changed.)

Metadata

Metadata

Assignees

Labels

A-incr-compArea: Incremental compilationC-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-incr-compWorking group: Incremental compilation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions