-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one-time diagnostic and suggestion for reëxporting private variant error
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 #46209.
- Loading branch information
1 parent
883f5e5
commit 4fb57e0
Showing
3 changed files
with
109 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(crate_visibility_modifier)] | ||
|
||
mod rank { | ||
pub use self::Professor::*; | ||
//~^ ERROR enum is private and its variants cannot be reexported | ||
pub use self::Lieutenant::{JuniorGrade, Full}; | ||
//~^ ERROR variant `JuniorGrade` is private and cannot be reexported | ||
//~| ERROR variant `Full` is private and cannot be reexported | ||
pub use self::PettyOfficer::*; | ||
//~^ ERROR enum is private and its variants cannot be reexported | ||
pub use self::Crewman::*; | ||
//~^ ERROR enum is private and its variants cannot be reexported | ||
|
||
enum Professor { | ||
Adjunct, | ||
Assistant, | ||
Associate, | ||
Full | ||
} | ||
|
||
enum Lieutenant { | ||
JuniorGrade, | ||
Full, | ||
} | ||
|
||
pub(in rank) enum PettyOfficer { | ||
SecondClass, | ||
FirstClass, | ||
Chief, | ||
MasterChief | ||
} | ||
|
||
crate enum Crewman { | ||
Recruit, | ||
Apprentice, | ||
Full | ||
} | ||
|
||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters