Skip to content
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

Private enum variant reexport error emits an error per each variant #46209

Closed
estebank opened this issue Nov 23, 2017 · 1 comment
Closed

Private enum variant reexport error emits an error per each variant #46209

estebank opened this issue Nov 23, 2017 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics

Comments

@estebank
Copy link
Contributor

When trying to reexport the variants of a private enum, a diagnostic is emitted for each variant pointing always at the same reexport span, making it too verbose:

error: variant `Variant1` is private, and cannot be reexported, consider declaring its enum as `pub`
  --> file.rs:12:9
   |
12 | pub use self::Enum::*;
   |         ^^^^^^^^^^^^^
(...)
error: variant `VariantN` is private, and cannot be reexported, consider declaring its enum as `pub`
  --> file.rs:12:9
   |
12 | pub use self::Enum::*;
   |         ^^^^^^^^^^^^^

Ideally there would be only one diagnostic emitted, with an extra span pointing at the definition of Enum to suggest making it public.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics labels Nov 23, 2017
@zackmdavis
Copy link
Member

I have a vision for this.

zackmdavis added a commit to zackmdavis/rust that referenced this issue Nov 26, 2017
We issue just one message for an erroneous glob private variant reëxport
(using the Session's one-time-diagnostics capability), but individual
(non-glob) such erroneous reëxports still get their own messages. The
suggestion to make the enum public is also one-time.

The enum variant reëxport error didn't have an associated error code
(and remedying this here is deemed out of the scope of this commit), so
we resort to the expediency of using 0 as the `DiagnosticMessageId`
value.

Adding Debug to NameResolution was helpful in development.

This resolves rust-lang#46209.
@bors bors closed this as completed in 4fb57e0 Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

2 participants