Skip to content

Warn about explicit import of TryInto, TryFrom, and FromIterator when migrating to 2021 edition. #117448

Closed
@cyqsimon

Description

@cyqsimon

Problem

One of the changes made in 2021 edition is that TryInto, TryFrom, and FromIterator are now in scope by default (link). So an explicit use statement is now redundant.

However, it seems like neither cargo fix --edition nor cargo fix --edition-idioms (and not even clippy!) catches this. I'm not sure which one of the these should be responsible, but it seems like one of them should at least emit a warning for this.

Steps

  1. Checkout a Rust project on 2018 edition that uses TryInto, TryFrom, and FromIterator. An example would be bat before 4b33093.
  2. Perform the normal edition upgrade procedure.
  3. Notice that the explicit use statements are not caught (no warnings).

Possible Solution(s)

Make cargo fix --edition or cargo fix --edition-idioms catch this and warn about it. Or maybe have clippy do this. Which one is more appropriate I'm not sure.

Notes

No response

Version

cargo 1.73.0 (9c4383fb5 2023-08-26)
release: 1.73.0
commit-hash: 9c4383fb55986096b414d98125421ab87b5fd642
commit-date: 2023-08-26
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.2.1-DEV (sys:0.4.65+curl-8.2.1 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: EndeavourOS Rolling Release (rolling) [64-bit]

Metadata

Metadata

Assignees

Labels

A-edition-2021Area: The 2021 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions