Closed
Description
This code on the playground
pub enum Option<T> {
/// No value
None,
/// Some value `T`
Some(T),
}
pub use Option::*;
produces the following error
error[E0659]: `Option` is ambiguous
--> src/lib.rs:8:9
|
8 | pub use Option::*;
| ^^^^^^ ambiguous name
|
= note: ambiguous because of multiple potential import sources
note: `Option` could refer to the enum defined here
--> src/lib.rs:1:1
|
1 | / pub enum Option<T> {
2 | | /// No value
3 | | None,
4 | | /// Some value `T`
5 | | Some(T),
6 | | }
| |_^
= help: use `crate::Option` to refer to this enum unambiguously
note: `Option` could also refer to the enum defined here
Note how the 2nd note is dangling: no span is shown after it says 'could also refer to the enum defined here'.
I was not able to reproduce this locally, so this might also have to do with something special the playground is doing -- Cc @shepmaster
Activity
shepmaster commentedon Nov 19, 2021
I’d guess it has something to do with the number of crates and their types available by default.
For example, just typing
Option
by itself says:camelid commentedon Nov 19, 2021
I think the standard library is not always distributed with sources, which sometimes causes weird diagnostics. That could be what's happening here.
shepmaster commentedon Nov 19, 2021
Yes, the playground uses the
minimal
profile, which doesn't include therust-src
component.As an example:
[-]"X is ambiguous" error looks odd when one of the spans is missing[/-][+]"X is ambiguous" error is missing a span when the standard library source is not available[/+]E0659
if the source is not available #91298Rollup merge of rust-lang#91298 - FabianWolff:issue-91028-source-avai…
Rollup merge of rust-lang#91298 - FabianWolff:issue-91028-source-avai…
Rollup merge of rust-lang#91298 - FabianWolff:issue-91028-source-avai…