aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/visibility.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/visibility.rs')
-rw-r--r--crates/ra_hir_def/src/visibility.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs
index b11e9bc52..e4c25ab7d 100644
--- a/crates/ra_hir_def/src/visibility.rs
+++ b/crates/ra_hir_def/src/visibility.rs
@@ -109,26 +109,26 @@ impl RawVisibility {
109 &self, 109 &self,
110 db: &impl DefDatabase, 110 db: &impl DefDatabase,
111 resolver: &crate::resolver::Resolver, 111 resolver: &crate::resolver::Resolver,
112 ) -> ResolvedVisibility { 112 ) -> Visibility {
113 // we fall back to public visibility (i.e. fail open) if the path can't be resolved 113 // we fall back to public visibility (i.e. fail open) if the path can't be resolved
114 resolver.resolve_visibility(db, self).unwrap_or(ResolvedVisibility::Public) 114 resolver.resolve_visibility(db, self).unwrap_or(Visibility::Public)
115 } 115 }
116} 116}
117 117
118/// Visibility of an item, with the path resolved. 118/// Visibility of an item, with the path resolved.
119#[derive(Debug, Copy, Clone, PartialEq, Eq)] 119#[derive(Debug, Copy, Clone, PartialEq, Eq)]
120pub enum ResolvedVisibility { 120pub enum Visibility {
121 /// Visibility is restricted to a certain module. 121 /// Visibility is restricted to a certain module.
122 Module(ModuleId), 122 Module(ModuleId),
123 /// Visibility is unrestricted. 123 /// Visibility is unrestricted.
124 Public, 124 Public,
125} 125}
126 126
127impl ResolvedVisibility { 127impl Visibility {
128 pub fn visible_from(self, db: &impl DefDatabase, from_module: ModuleId) -> bool { 128 pub fn visible_from(self, db: &impl DefDatabase, from_module: ModuleId) -> bool {
129 let to_module = match self { 129 let to_module = match self {
130 ResolvedVisibility::Module(m) => m, 130 Visibility::Module(m) => m,
131 ResolvedVisibility::Public => return true, 131 Visibility::Public => return true,
132 }; 132 };
133 // if they're not in the same crate, it can't be visible 133 // if they're not in the same crate, it can't be visible
134 if from_module.krate != to_module.krate { 134 if from_module.krate != to_module.krate {
@@ -144,8 +144,8 @@ impl ResolvedVisibility {
144 from_module: crate::LocalModuleId, 144 from_module: crate::LocalModuleId,
145 ) -> bool { 145 ) -> bool {
146 let to_module = match self { 146 let to_module = match self {
147 ResolvedVisibility::Module(m) => m, 147 Visibility::Module(m) => m,
148 ResolvedVisibility::Public => return true, 148 Visibility::Public => return true,
149 }; 149 };
150 // from_module needs to be a descendant of to_module 150 // from_module needs to be a descendant of to_module
151 let mut ancestors = std::iter::successors(Some(from_module), |m| { 151 let mut ancestors = std::iter::successors(Some(from_module), |m| {