Closed
Description
When specifying a an enum variant where a type is expected, rustc gives a list of all possible variants with that name. (and suggests to use the enum type instead)
In projects with a lot of dependencies and a very common variant name, this list can quickly become overwhelming. This is e.g. the case on the Rust Playground on the 2018 edition, since all whitelisted crates get linked into the playground code.
fn foo() -> None {}
gives the following error on the playground:
error[E0573]: expected type, found variant `None`
--> src/lib.rs:1:13
|
1 | fn foo() -> None {}
| ^^^^ not a type
|
= help: there is an enum variant `bitflags::_core::prelude::v1::None`, try using `bitflags::_core::prelude::v1`?
= help: there is an enum variant `bitflags::_core::prelude::v1::Option::None`, try using `bitflags::_core::prelude::v1::Option`?
= help: there is an enum variant `chrono::LocalResult::None`, try using `chrono::LocalResult`?
= help: there is an enum variant `chrono::format::Pad::None`, try using `chrono::format::Pad`?
= help: there is an enum variant `clap::Format::None`, try using `clap::Format`?
= help: there is an enum variant `core::prelude::v1::None`, try using `core::prelude::v1`?
= help: there is an enum variant `core::prelude::v1::Option::None`, try using `core::prelude::v1::Option`?
= help: there is an enum variant `csv::Trim::None`, try using `csv::Trim`?
= help: there is an enum variant `flate2::FlushCompress::None`, try using `flate2::FlushCompress`?
= help: there is an enum variant `flate2::FlushDecompress::None`, try using `flate2::FlushDecompress`?
= help: there is an enum variant `libflate::lz77::CompressionLevel::None`, try using `libflate::lz77::CompressionLevel`?
= help: there is an enum variant `lzw::Bits::None`, try using `lzw::Bits`?
= help: there is an enum variant `miniz_oxide::MZFlush::None`, try using `miniz_oxide::MZFlush`?
= help: there is an enum variant `miniz_oxide::deflate::core::TDEFLFlush::None`, try using `miniz_oxide::deflate::core::TDEFLFlush`?
= help: there is an enum variant `proc_macro2::Delimiter::None`, try using `proc_macro2::Delimiter`?
= help: there is an enum variant `quote::__rt::Delimiter::None`, try using `quote::__rt::Delimiter`?
= help: there is an enum variant `serde::export::None`, try using `serde::export`?
= help: there is an enum variant `serde::export::Option::None`, try using `serde::export::Option`?
= help: there is an enum variant `serde::private::de::Content::None`, try using `serde::private::de::Content`?
= help: there is an enum variant `serde_derive_internals::attr::Default::None`, try using `serde_derive_internals::attr::Default`?
= help: there is an enum variant `serde_derive_internals::attr::EnumTag::None`, try using `serde_derive_internals::attr::EnumTag`?
= help: there is an enum variant `serde_derive_internals::attr::RenameRule::None`, try using `serde_derive_internals::attr::RenameRule`?
= help: there is an enum variant `std::prelude::v1::None`, try using `std::prelude::v1`?
= help: there is an enum variant `std::prelude::v1::Option::None`, try using `std::prelude::v1::Option`?
= help: there is an enum variant `syn::FloatSuffix::None`, try using `syn::FloatSuffix`?
= help: there is an enum variant `syn::IntSuffix::None`, try using `syn::IntSuffix`?
= help: there is an enum variant `syn::PathArguments::None`, try using `syn::PathArguments`?
= help: there is an enum variant `syn::TraitBoundModifier::None`, try using `syn::TraitBoundModifier`?
= help: there is an enum variant `syn::export::None`, try using `syn::export`?
= help: there is an enum variant `syn::export::quote::__rt::Delimiter::None`, try using `syn::export::quote::__rt::Delimiter`?
= help: there is an enum variant `syntex_syntax::ast::TraitBoundModifier::None`, try using `syntex_syntax::ast::TraitBoundModifier`?
= help: there is an enum variant `syntex_syntax::attr::InlineAttr::None`, try using `syntex_syntax::attr::InlineAttr`?
= help: there is an enum variant `syntex_syntax::entry::EntryPointType::None`, try using `syntex_syntax::entry::EntryPointType`?
= help: there is an enum variant `syntex_syntax::util::parser::Fixity::None`, try using `syntex_syntax::util::parser::Fixity`?
= help: there is an enum variant `tiff::decoder::CompressionMethod::None`, try using `tiff::decoder::CompressionMethod`?
Maybe a better approach is to only give N
suggestions by default, and show the full list when --verbose
is passed.
Rust version is 1.31.0-beta.13, edition is 2018.