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.
This commit is contained in:
parent
883f5e5e65
commit
4fb57e0796
3 changed files with 109 additions and 10 deletions
|
|
@ -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() {}
|
||||
|
|
@ -9,19 +9,19 @@
|
|||
// except according to those terms.
|
||||
|
||||
mod m1 {
|
||||
pub use ::E::V; //~ ERROR variant `V` is private, and cannot be reexported
|
||||
pub use ::E::V; //~ ERROR variant `V` is private and cannot be reexported
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
pub use ::E::{V}; //~ ERROR variant `V` is private, and cannot be reexported
|
||||
pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be reexported
|
||||
}
|
||||
|
||||
mod m3 {
|
||||
pub use ::E::V::{self}; //~ ERROR variant `V` is private, and cannot be reexported
|
||||
pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be reexported
|
||||
}
|
||||
|
||||
mod m4 {
|
||||
pub use ::E::*; //~ ERROR variant `V` is private, and cannot be reexported
|
||||
pub use ::E::*; //~ ERROR enum is private and its variants cannot be reexported
|
||||
}
|
||||
|
||||
enum E { V }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue