-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Warn about explicit import of TryInto
, TryFrom
, and FromIterator
when migrating to 2021 edition.
#117448
Labels
A-edition-2021
Area: The 2021 edition
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
rustbot
added
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Oct 31, 2023
@rustbot label A-edition-2021 A-lint A-suggestion-diagnostics C-enhancement -C-bug |
rustbot
added
A-edition-2021
Area: The 2021 edition
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
and removed
C-bug
Category: This is a bug.
labels
Oct 31, 2023
saethlin
removed
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Oct 31, 2023
Seems like this doesn't need to be edition 2021 or these traits specific, there could just be a warning for shadowing a prelude import with the exact same item (when that shadowing is not itself shadowing a glob import of a different item). |
@rustbot claim |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 20, 2023
Enhance lint unused_imports to check unnecessary imports in std::prelude fixes rust-lang#117448 detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` detect : `Option::{self, Some}` `mem::drop`
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 22, 2023
Enhance lint unused_imports to check unnecessary imports in std::prelude fixes rust-lang#117448 detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` detect : `Option::{self, Some}` `mem::drop`
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 23, 2023
Enhance lint unused_imports to check unnecessary imports in std::prelude fixes rust-lang#117448 detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` detect : `Option::{self, Some}` `mem::drop`
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 23, 2023
Enhance lint unused_imports to check unnecessary imports in std::prelude fixes rust-lang#117448 detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` detect : `Option::{self, Some}` `mem::drop`
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 23, 2023
Enhance lint unused_imports to check unnecessary imports in std::prelude fixes rust-lang#117448 detects unnecessary imports in std::prelude that can be eliminated. For example import: ```rust use std::{option::{Iter, IterMut, IntoIter, Option::{self, Some}}, convert::{TryFrom, TryInto}, mem::drop}; ``` detect : `Option::{self, Some}` `mem::drop`
surechen
added a commit
to surechen/rust
that referenced
this issue
Feb 12, 2024
… other situations like module-relative uses, we can do more accurate redundant import checking. fixes rust-lang#117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
surechen
added a commit
to surechen/rust
that referenced
this issue
Feb 12, 2024
… other situations like module-relative uses, we can do more accurate redundant import checking. fixes rust-lang#117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
surechen
added a commit
to surechen/rust
that referenced
this issue
Feb 13, 2024
… other situations like module-relative uses, we can do more accurate redundant import checking. fixes rust-lang#117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Feb 13, 2024
Tracking import use types for more accurate redundant import checking fixes rust-lang#117448 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Feb 18, 2024
Tracking import use types for more accurate redundant import checking fixes rust-lang#117448 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Feb 26, 2024
… other situations like module-relative uses, we can do more accurate redundant import checking. fixes rust-lang#117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
bors
pushed a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 17, 2024
… other situations like module-relative uses, we can do more accurate redundant import checking. fixes rust-lang#117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 17, 2024
Tracking import use types for more accurate redundant import checking fixes rust-lang#117448 By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking. For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-edition-2021
Area: The 2021 edition
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Problem
One of the changes made in 2021 edition is that
TryInto
,TryFrom
, andFromIterator
are now in scope by default (link). So an explicituse
statement is now redundant.However, it seems like neither
cargo fix --edition
norcargo 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
TryInto
,TryFrom
, andFromIterator
. An example would be bat before 4b33093.use
statements are not caught (no warnings).Possible Solution(s)
Make
cargo fix --edition
orcargo 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
The text was updated successfully, but these errors were encountered: