call it hir::VisibilityKind
instead of hir::Visibility_:*
It was pointed out in review that the glob-exported underscore-suffixed convention for `Spanned` HIR nodes is no longer preferred: see February 2016's #31487 for AST's migration away from this style towards properly namespaced NodeKind enums. This concerns #51968.
This commit is contained in:
parent
c2d44b2286
commit
43a0a65fa2
15 changed files with 74 additions and 71 deletions
|
@ -1104,7 +1104,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
|
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
|
||||||
if let VisibilityRestricted { ref path, id } = vis.node {
|
if let VisibilityKind::Restricted { ref path, id } = vis.node {
|
||||||
visitor.visit_id(id);
|
visitor.visit_id(id);
|
||||||
visitor.visit_path(path, id)
|
visitor.visit_path(path, id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1285,7 +1285,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
name: keywords::Invalid.name(),
|
name: keywords::Invalid.name(),
|
||||||
attrs: Default::default(),
|
attrs: Default::default(),
|
||||||
node: exist_ty_item_kind,
|
node: exist_ty_item_kind,
|
||||||
vis: respan(span.shrink_to_lo(), hir::VisibilityInherited),
|
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
|
||||||
span: exist_ty_span,
|
span: exist_ty_span,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2771,11 +2771,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit);
|
let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit);
|
||||||
let item = hir::ItemUse(P(path), hir::UseKind::Single);
|
let item = hir::ItemUse(P(path), hir::UseKind::Single);
|
||||||
let vis_kind = match vis.node {
|
let vis_kind = match vis.node {
|
||||||
hir::VisibilityPublic => hir::VisibilityPublic,
|
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
|
||||||
hir::VisibilityCrate(sugar) => hir::VisibilityCrate(sugar),
|
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
|
||||||
hir::VisibilityInherited => hir::VisibilityInherited,
|
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||||
hir::VisibilityRestricted { ref path, id: _ } => {
|
hir::VisibilityKind::Restricted { ref path, id: _ } => {
|
||||||
hir::VisibilityRestricted {
|
hir::VisibilityKind::Restricted {
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
// We are allocating a new NodeId here
|
// We are allocating a new NodeId here
|
||||||
id: this.next_id().node_id,
|
id: this.next_id().node_id,
|
||||||
|
@ -2844,11 +2844,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
|
|
||||||
self.with_hir_id_owner(new_id, |this| {
|
self.with_hir_id_owner(new_id, |this| {
|
||||||
let vis_kind = match vis.node {
|
let vis_kind = match vis.node {
|
||||||
hir::VisibilityPublic => hir::VisibilityPublic,
|
hir::VisibilityKind::Public => hir::VisibilityKind::Public,
|
||||||
hir::VisibilityCrate(sugar) => hir::VisibilityCrate(sugar),
|
hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
|
||||||
hir::VisibilityInherited => hir::VisibilityInherited,
|
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||||
hir::VisibilityRestricted { ref path, id: _ } => {
|
hir::VisibilityKind::Restricted { ref path, id: _ } => {
|
||||||
hir::VisibilityRestricted {
|
hir::VisibilityKind::Restricted {
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
// We are allocating a new NodeId here
|
// We are allocating a new NodeId here
|
||||||
id: this.next_id().node_id,
|
id: this.next_id().node_id,
|
||||||
|
@ -2876,7 +2876,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
// the stability of `use a::{};`, to avoid it showing up as
|
// the stability of `use a::{};`, to avoid it showing up as
|
||||||
// a re-export by accident when `pub`, e.g. in documentation.
|
// a re-export by accident when `pub`, e.g. in documentation.
|
||||||
let path = P(self.lower_path(id, &prefix, ParamMode::Explicit));
|
let path = P(self.lower_path(id, &prefix, ParamMode::Explicit));
|
||||||
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityInherited);
|
*vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
|
||||||
hir::ItemUse(path, hir::UseKind::ListStem)
|
hir::ItemUse(path, hir::UseKind::ListStem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4277,9 +4277,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
explicit_owner: Option<NodeId>,
|
explicit_owner: Option<NodeId>,
|
||||||
) -> hir::Visibility {
|
) -> hir::Visibility {
|
||||||
let node = match v.node {
|
let node = match v.node {
|
||||||
VisibilityKind::Public => hir::VisibilityPublic,
|
VisibilityKind::Public => hir::VisibilityKind::Public,
|
||||||
VisibilityKind::Crate(sugar) => hir::VisibilityCrate(sugar),
|
VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
|
||||||
VisibilityKind::Restricted { ref path, id } => hir::VisibilityRestricted {
|
VisibilityKind::Restricted { ref path, id } => hir::VisibilityKind::Restricted {
|
||||||
path: P(self.lower_path(id, path, ParamMode::Explicit)),
|
path: P(self.lower_path(id, path, ParamMode::Explicit)),
|
||||||
id: if let Some(owner) = explicit_owner {
|
id: if let Some(owner) = explicit_owner {
|
||||||
self.lower_node_id_with_owner(id, owner).node_id
|
self.lower_node_id_with_owner(id, owner).node_id
|
||||||
|
@ -4287,7 +4287,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
self.lower_node_id(id).node_id
|
self.lower_node_id(id).node_id
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
VisibilityKind::Inherited => hir::VisibilityInherited,
|
VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||||
};
|
};
|
||||||
respan(v.span, node)
|
respan(v.span, node)
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,10 +459,10 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||||
|
|
||||||
fn visit_vis(&mut self, visibility: &'hir Visibility) {
|
fn visit_vis(&mut self, visibility: &'hir Visibility) {
|
||||||
match visibility.node {
|
match visibility.node {
|
||||||
VisibilityPublic |
|
VisibilityKind::Public |
|
||||||
VisibilityCrate(_) |
|
VisibilityKind::Crate(_) |
|
||||||
VisibilityInherited => {}
|
VisibilityKind::Inherited => {}
|
||||||
VisibilityRestricted { id, .. } => {
|
VisibilityKind::Restricted { id, .. } => {
|
||||||
self.insert(id, NodeVisibility(visibility));
|
self.insert(id, NodeVisibility(visibility));
|
||||||
self.with_parent(id, |this| {
|
self.with_parent(id, |this| {
|
||||||
intravisit::walk_vis(this, visibility);
|
intravisit::walk_vis(this, visibility);
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ impl<'hir> Map<'hir> {
|
||||||
Some(EntryLifetime(_, _, lifetime)) => lifetime.span,
|
Some(EntryLifetime(_, _, lifetime)) => lifetime.span,
|
||||||
Some(EntryGenericParam(_, _, param)) => param.span,
|
Some(EntryGenericParam(_, _, param)) => param.span,
|
||||||
Some(EntryVisibility(_, _, &Spanned {
|
Some(EntryVisibility(_, _, &Spanned {
|
||||||
node: VisibilityRestricted { ref path, .. }, ..
|
node: VisibilityKind::Restricted { ref path, .. }, ..
|
||||||
})) => path.span,
|
})) => path.span,
|
||||||
Some(EntryVisibility(_, _, v)) => bug!("unexpected Visibility {:?}", v),
|
Some(EntryVisibility(_, _, v)) => bug!("unexpected Visibility {:?}", v),
|
||||||
Some(EntryLocal(_, _, local)) => local.span,
|
Some(EntryLocal(_, _, local)) => local.span,
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub use self::Stmt_::*;
|
||||||
pub use self::Ty_::*;
|
pub use self::Ty_::*;
|
||||||
pub use self::UnOp::*;
|
pub use self::UnOp::*;
|
||||||
pub use self::UnsafeSource::*;
|
pub use self::UnsafeSource::*;
|
||||||
pub use self::Visibility_::*;
|
|
||||||
|
|
||||||
use hir::def::Def;
|
use hir::def::Def;
|
||||||
use hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX};
|
use hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX};
|
||||||
|
@ -1929,30 +1928,30 @@ pub struct PolyTraitRef {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Visibility = Spanned<Visibility_>;
|
pub type Visibility = Spanned<VisibilityKind>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum Visibility_ {
|
pub enum VisibilityKind {
|
||||||
VisibilityPublic,
|
Public,
|
||||||
VisibilityCrate(CrateSugar),
|
Crate(CrateSugar),
|
||||||
VisibilityRestricted { path: P<Path>, id: NodeId },
|
Restricted { path: P<Path>, id: NodeId },
|
||||||
VisibilityInherited,
|
Inherited,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visibility_ {
|
impl VisibilityKind {
|
||||||
pub fn is_pub(&self) -> bool {
|
pub fn is_pub(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
VisibilityPublic => true,
|
VisibilityKind::Public => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_pub_restricted(&self) -> bool {
|
pub fn is_pub_restricted(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
VisibilityPublic |
|
VisibilityKind::Public |
|
||||||
VisibilityInherited => false,
|
VisibilityKind::Inherited => false,
|
||||||
VisibilityCrate(..) |
|
VisibilityKind::Crate(..) |
|
||||||
VisibilityRestricted { .. } => true,
|
VisibilityKind::Restricted { .. } => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -840,10 +840,10 @@ impl<'a> State<'a> {
|
||||||
|
|
||||||
pub fn print_visibility(&mut self, vis: &hir::Visibility) -> io::Result<()> {
|
pub fn print_visibility(&mut self, vis: &hir::Visibility) -> io::Result<()> {
|
||||||
match vis.node {
|
match vis.node {
|
||||||
hir::VisibilityPublic => self.word_nbsp("pub")?,
|
hir::VisibilityKind::Public => self.word_nbsp("pub")?,
|
||||||
hir::VisibilityCrate(ast::CrateSugar::JustCrate) => self.word_nbsp("crate")?,
|
hir::VisibilityKind::Crate(ast::CrateSugar::JustCrate) => self.word_nbsp("crate")?,
|
||||||
hir::VisibilityCrate(ast::CrateSugar::PubCrate) => self.word_nbsp("pub(crate)")?,
|
hir::VisibilityKind::Crate(ast::CrateSugar::PubCrate) => self.word_nbsp("pub(crate)")?,
|
||||||
hir::VisibilityRestricted { ref path, .. } => {
|
hir::VisibilityKind::Restricted { ref path, .. } => {
|
||||||
self.s.word("pub(")?;
|
self.s.word("pub(")?;
|
||||||
if path.segments.len() == 1 &&
|
if path.segments.len() == 1 &&
|
||||||
path.segments[0].ident.name == keywords::Super.name() {
|
path.segments[0].ident.name == keywords::Super.name() {
|
||||||
|
@ -856,7 +856,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
self.word_nbsp(")")?;
|
self.word_nbsp(")")?;
|
||||||
}
|
}
|
||||||
hir::VisibilityInherited => ()
|
hir::VisibilityKind::Inherited => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -952,16 +952,19 @@ impl<'a> State<'a> {
|
||||||
self.print_outer_attributes(&ti.attrs)?;
|
self.print_outer_attributes(&ti.attrs)?;
|
||||||
match ti.node {
|
match ti.node {
|
||||||
hir::TraitItemKind::Const(ref ty, default) => {
|
hir::TraitItemKind::Const(ref ty, default) => {
|
||||||
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityInherited };
|
let vis = Spanned { span: syntax_pos::DUMMY_SP,
|
||||||
|
node: hir::VisibilityKind::Inherited };
|
||||||
self.print_associated_const(ti.ident, &ty, default, &vis)?;
|
self.print_associated_const(ti.ident, &ty, default, &vis)?;
|
||||||
}
|
}
|
||||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
|
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
|
||||||
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityInherited };
|
let vis = Spanned { span: syntax_pos::DUMMY_SP,
|
||||||
|
node: hir::VisibilityKind::Inherited };
|
||||||
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None)?;
|
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None)?;
|
||||||
self.s.word(";")?;
|
self.s.word(";")?;
|
||||||
}
|
}
|
||||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
|
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
|
||||||
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityInherited };
|
let vis = Spanned { span: syntax_pos::DUMMY_SP,
|
||||||
|
node: hir::VisibilityKind::Inherited };
|
||||||
self.head("")?;
|
self.head("")?;
|
||||||
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, &[], Some(body))?;
|
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, &[], Some(body))?;
|
||||||
self.nbsp()?;
|
self.nbsp()?;
|
||||||
|
@ -2267,7 +2270,8 @@ impl<'a> State<'a> {
|
||||||
},
|
},
|
||||||
name,
|
name,
|
||||||
&generics,
|
&generics,
|
||||||
&Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityInherited },
|
&Spanned { span: syntax_pos::DUMMY_SP,
|
||||||
|
node: hir::VisibilityKind::Inherited },
|
||||||
arg_names,
|
arg_names,
|
||||||
None)?;
|
None)?;
|
||||||
self.end()
|
self.end()
|
||||||
|
|
|
@ -710,20 +710,20 @@ impl_stable_hash_for!(enum ::syntax::ast::CrateSugar {
|
||||||
PubCrate,
|
PubCrate,
|
||||||
});
|
});
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Visibility_ {
|
impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind {
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
hcx: &mut StableHashingContext<'a>,
|
hcx: &mut StableHashingContext<'a>,
|
||||||
hasher: &mut StableHasher<W>) {
|
hasher: &mut StableHasher<W>) {
|
||||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||||
match *self {
|
match *self {
|
||||||
hir::VisibilityPublic |
|
hir::VisibilityKind::Public |
|
||||||
hir::VisibilityInherited => {
|
hir::VisibilityKind::Inherited => {
|
||||||
// No fields to hash.
|
// No fields to hash.
|
||||||
}
|
}
|
||||||
hir::VisibilityCrate(sugar) => {
|
hir::VisibilityKind::Crate(sugar) => {
|
||||||
sugar.hash_stable(hcx, hasher);
|
sugar.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
hir::VisibilityRestricted { ref path, id } => {
|
hir::VisibilityKind::Restricted { ref path, id } => {
|
||||||
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
|
||||||
id.hash_stable(hcx, hasher);
|
id.hash_stable(hcx, hasher);
|
||||||
});
|
});
|
||||||
|
@ -733,7 +733,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Visibility_ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_stable_hash_for_spanned!(hir::Visibility_);
|
impl_stable_hash_for_spanned!(hir::VisibilityKind);
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Defaultness {
|
impl<'a> HashStable<StableHashingContext<'a>> for hir::Defaultness {
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
|
|
|
@ -269,15 +269,15 @@ impl<'a, 'gcx, 'tcx> DefIdTree for TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
impl Visibility {
|
impl Visibility {
|
||||||
pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt) -> Self {
|
pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt) -> Self {
|
||||||
match visibility.node {
|
match visibility.node {
|
||||||
hir::VisibilityPublic => Visibility::Public,
|
hir::VisibilityKind::Public => Visibility::Public,
|
||||||
hir::VisibilityCrate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)),
|
hir::VisibilityKind::Crate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)),
|
||||||
hir::VisibilityRestricted { ref path, .. } => match path.def {
|
hir::VisibilityKind::Restricted { ref path, .. } => match path.def {
|
||||||
// If there is no resolution, `resolve` will have already reported an error, so
|
// If there is no resolution, `resolve` will have already reported an error, so
|
||||||
// assume that the visibility is public to avoid reporting more privacy errors.
|
// assume that the visibility is public to avoid reporting more privacy errors.
|
||||||
Def::Err => Visibility::Public,
|
Def::Err => Visibility::Public,
|
||||||
def => Visibility::Restricted(def.def_id()),
|
def => Visibility::Restricted(def.def_id()),
|
||||||
},
|
},
|
||||||
hir::VisibilityInherited => {
|
hir::VisibilityKind::Inherited => {
|
||||||
Visibility::Restricted(tcx.hir.get_module_parent(id))
|
Visibility::Restricted(tcx.hir.get_module_parent(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||||
hir::ItemUnion(..) => "a union",
|
hir::ItemUnion(..) => "a union",
|
||||||
hir::ItemTrait(.., ref trait_item_refs) => {
|
hir::ItemTrait(.., ref trait_item_refs) => {
|
||||||
// Issue #11592, traits are always considered exported, even when private.
|
// Issue #11592, traits are always considered exported, even when private.
|
||||||
if it.vis.node == hir::VisibilityInherited {
|
if it.vis.node == hir::VisibilityKind::Inherited {
|
||||||
self.private_traits.insert(it.id);
|
self.private_traits.insert(it.id);
|
||||||
for trait_item_ref in trait_item_refs {
|
for trait_item_ref in trait_item_refs {
|
||||||
self.private_traits.insert(trait_item_ref.id.node_id);
|
self.private_traits.insert(trait_item_ref.id.node_id);
|
||||||
|
@ -414,7 +414,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||||
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
|
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
|
||||||
match cx.tcx.hir.find(node_id) {
|
match cx.tcx.hir.find(node_id) {
|
||||||
Some(hir_map::NodeItem(item)) => {
|
Some(hir_map::NodeItem(item)) => {
|
||||||
if item.vis.node == hir::VisibilityInherited {
|
if item.vis.node == hir::VisibilityKind::Inherited {
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
self.private_traits.insert(impl_item_ref.id.node_id);
|
self.private_traits.insert(impl_item_ref.id.node_id);
|
||||||
}
|
}
|
||||||
|
@ -1179,15 +1179,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
|
||||||
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
||||||
let suggest_export = |vis: &hir::Visibility, err: &mut DiagnosticBuilder| {
|
let suggest_export = |vis: &hir::Visibility, err: &mut DiagnosticBuilder| {
|
||||||
let suggestion = match vis.node {
|
let suggestion = match vis.node {
|
||||||
hir::VisibilityInherited => {
|
hir::VisibilityKind::Inherited => {
|
||||||
// inherited visibility is empty span at item start; need an extra space
|
// inherited visibility is empty span at item start; need an extra space
|
||||||
Some("pub ".to_owned())
|
Some("pub ".to_owned())
|
||||||
},
|
},
|
||||||
hir::VisibilityRestricted { .. } |
|
hir::VisibilityKind::Restricted { .. } |
|
||||||
hir::VisibilityCrate(_) => {
|
hir::VisibilityKind::Crate(_) => {
|
||||||
Some("pub".to_owned())
|
Some("pub".to_owned())
|
||||||
},
|
},
|
||||||
hir::VisibilityPublic => {
|
hir::VisibilityKind::Public => {
|
||||||
err.help("try exporting the item with a `pub use` statement");
|
err.help("try exporting the item with a `pub use` statement");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1399,7 @@ impl UnreachablePub {
|
||||||
vis: &hir::Visibility, span: Span, exportable: bool) {
|
vis: &hir::Visibility, span: Span, exportable: bool) {
|
||||||
let mut applicability = Applicability::MachineApplicable;
|
let mut applicability = Applicability::MachineApplicable;
|
||||||
match vis.node {
|
match vis.node {
|
||||||
hir::VisibilityPublic if !cx.access_levels.is_reachable(id) => {
|
hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => {
|
||||||
if span.ctxt().outer().expn_info().is_some() {
|
if span.ctxt().outer().expn_info().is_some() {
|
||||||
applicability = Applicability::MaybeIncorrect;
|
applicability = Applicability::MaybeIncorrect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
fn encode_info_for_items(&mut self) -> Index {
|
fn encode_info_for_items(&mut self) -> Index {
|
||||||
let krate = self.tcx.hir.krate();
|
let krate = self.tcx.hir.krate();
|
||||||
let mut index = IndexBuilder::new(self);
|
let mut index = IndexBuilder::new(self);
|
||||||
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityPublic };
|
let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public };
|
||||||
index.record(DefId::local(CRATE_DEF_INDEX),
|
index.record(DefId::local(CRATE_DEF_INDEX),
|
||||||
IsolatedEncoder::encode_info_for_mod,
|
IsolatedEncoder::encode_info_for_mod,
|
||||||
FromId(CRATE_NODE_ID, (&krate.module, &krate.attrs, &vis)));
|
FromId(CRATE_NODE_ID, (&krate.module, &krate.attrs, &vis)));
|
||||||
|
|
|
@ -1469,8 +1469,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
|
||||||
}
|
}
|
||||||
if !vis.is_at_least(self.required_visibility, self.tcx) {
|
if !vis.is_at_least(self.required_visibility, self.tcx) {
|
||||||
let vis_adj = match hir_vis.node {
|
let vis_adj = match hir_vis.node {
|
||||||
hir::VisibilityCrate(_) => "crate-visible",
|
hir::VisibilityKind::Crate(_) => "crate-visible",
|
||||||
hir::VisibilityRestricted { .. } => "restricted",
|
hir::VisibilityKind::Restricted { .. } => "restricted",
|
||||||
_ => "private"
|
_ => "private"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -633,7 +633,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
..
|
..
|
||||||
}) |
|
}) |
|
||||||
Node::NodeVisibility(&Spanned {
|
Node::NodeVisibility(&Spanned {
|
||||||
node: hir::VisibilityRestricted { ref path, .. }, .. }) => path.def,
|
node: hir::VisibilityKind::Restricted { ref path, .. }, .. }) => path.def,
|
||||||
|
|
||||||
Node::NodeExpr(&hir::Expr {
|
Node::NodeExpr(&hir::Expr {
|
||||||
node: hir::ExprStruct(ref qpath, ..),
|
node: hir::ExprStruct(ref qpath, ..),
|
||||||
|
|
|
@ -3226,10 +3226,10 @@ pub enum Visibility {
|
||||||
impl Clean<Option<Visibility>> for hir::Visibility {
|
impl Clean<Option<Visibility>> for hir::Visibility {
|
||||||
fn clean(&self, cx: &DocContext) -> Option<Visibility> {
|
fn clean(&self, cx: &DocContext) -> Option<Visibility> {
|
||||||
Some(match self.node {
|
Some(match self.node {
|
||||||
hir::VisibilityPublic => Visibility::Public,
|
hir::VisibilityKind::Public => Visibility::Public,
|
||||||
hir::VisibilityInherited => Visibility::Inherited,
|
hir::VisibilityKind::Inherited => Visibility::Inherited,
|
||||||
hir::VisibilityCrate(_) => Visibility::Crate,
|
hir::VisibilityKind::Crate(_) => Visibility::Crate,
|
||||||
hir::VisibilityRestricted { ref path, .. } => {
|
hir::VisibilityKind::Restricted { ref path, .. } => {
|
||||||
let path = path.clean(cx);
|
let path = path.clean(cx);
|
||||||
let did = register_def(cx, path.def);
|
let did = register_def(cx, path.def);
|
||||||
Visibility::Restricted(did, path)
|
Visibility::Restricted(did, path)
|
||||||
|
|
|
@ -54,7 +54,7 @@ impl Module {
|
||||||
Module {
|
Module {
|
||||||
name : name,
|
name : name,
|
||||||
id: ast::CRATE_NODE_ID,
|
id: ast::CRATE_NODE_ID,
|
||||||
vis: Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityInherited },
|
vis: Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Inherited },
|
||||||
stab: None,
|
stab: None,
|
||||||
depr: None,
|
depr: None,
|
||||||
where_outer: syntax_pos::DUMMY_SP,
|
where_outer: syntax_pos::DUMMY_SP,
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||||
self.module = self.visit_mod_contents(krate.span,
|
self.module = self.visit_mod_contents(krate.span,
|
||||||
krate.attrs.clone(),
|
krate.attrs.clone(),
|
||||||
Spanned { span: syntax_pos::DUMMY_SP,
|
Spanned { span: syntax_pos::DUMMY_SP,
|
||||||
node: hir::VisibilityPublic },
|
node: hir::VisibilityKind::Public },
|
||||||
ast::CRATE_NODE_ID,
|
ast::CRATE_NODE_ID,
|
||||||
&krate.module,
|
&krate.module,
|
||||||
None);
|
None);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue