-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rustc suggests both std and core imports at times #83564
Comments
cc @estebank feels like we should at least show |
This is quite useful in situations like the rust playground because there sometimes there are many different sources for a function, and sometimes the std one (that's most times the one you really want) gets elided in the "others" sources. |
We already have a couple of hacks for these kind of suggestions, so I'd be fine with just modifying the code here to push any rust/compiler/rustc_resolve/src/diagnostics.rs Line 1640 in ee0357a
As pointed above it might make sense to bias the sort to always put |
Add regression test for issue rust-lang#83564 cc rust-lang#83564 r? `@davidtwco`
Add regression test for issue rust-lang#83564 cc rust-lang#83564 r? ``@davidtwco``
…laumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#87260 (Libgccjit codegen) - rust-lang#89212 (x.py: run `rustup toolchain link` in setup) - rust-lang#89233 (Hide `<...> defined here` note if the source is not available) - rust-lang#89235 (make junit output more consistent with default format) - rust-lang#89255 (Fix incorrect disambiguation suggestion for associated items) - rust-lang#89276 (Fix the population of the `union.impls` field) - rust-lang#89283 (Add regression test for issue rust-lang#83564) - rust-lang#89318 (rustc_session: Remove lint store from `Session`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The regression test (#89283), when run on the playground, does seem to have regressed between beta 1.57.0 and nightly 1.58.0, which is weird because it's a test, so it shouldn't have changed. Maybe it only regressed when there are external dependencies? |
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
Tweak output of import suggestions When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
Rollup merge of rust-lang#126371 - estebank:suggest-core, r=fmease Tweak output of import suggestions When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix rust-lang#83564.
rustc often offers a help to import something from std and core:
Perhaps in such situations rustc could use an heuristic to suggest only one of the two imports.
The text was updated successfully, but these errors were encountered: