aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-12-26 15:42:57 +0000
committerFlorian Diebold <[email protected]>2019-12-26 15:42:57 +0000
commitdfe95d735bf9bb0d49d2ab90438577089207c8a0 (patch)
tree443773efb235615480781e56b199d6f4b94b9654 /crates/ra_hir_def
parent04cf98f8a6a67c899dd290d4b66c37794b24a568 (diff)
Remove Arc from RawVisibility
Now that it's not used as a direct query return value anymore, it doesn't need to be cheaply cloneable anymore.
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/visibility.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs
index a90ba7376..ad3f09981 100644
--- a/crates/ra_hir_def/src/visibility.rs
+++ b/crates/ra_hir_def/src/visibility.rs
@@ -1,7 +1,5 @@
1//! Defines hir-level representation of visibility (e.g. `pub` and `pub(crate)`). 1//! Defines hir-level representation of visibility (e.g. `pub` and `pub(crate)`).
2 2
3use std::sync::Arc;
4
5use hir_expand::{hygiene::Hygiene, InFile}; 3use hir_expand::{hygiene::Hygiene, InFile};
6use ra_syntax::ast; 4use ra_syntax::ast;
7 5
@@ -14,20 +12,17 @@ use crate::{
14/// Visibility of an item, not yet resolved. 12/// Visibility of an item, not yet resolved.
15#[derive(Debug, Clone, PartialEq, Eq)] 13#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum RawVisibility { 14pub enum RawVisibility {
17 // FIXME: We could avoid the allocation in many cases by special-casing
18 // pub(crate), pub(super) and private. Alternatively, `ModPath` could be
19 // made to contain an Arc<[Segment]> instead of a Vec?
20 /// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is 15 /// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is
21 /// equivalent to `pub(self)`. 16 /// equivalent to `pub(self)`.
22 Module(Arc<ModPath>), 17 Module(ModPath),
23 /// `pub`. 18 /// `pub`.
24 Public, 19 Public,
25} 20}
26 21
27impl RawVisibility { 22impl RawVisibility {
28 fn private() -> RawVisibility { 23 const fn private() -> RawVisibility {
29 let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() }; 24 let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() };
30 RawVisibility::Module(Arc::new(path)) 25 RawVisibility::Module(path)
31 } 26 }
32 27
33 pub(crate) fn from_ast( 28 pub(crate) fn from_ast(
@@ -52,15 +47,15 @@ impl RawVisibility {
52 None => return RawVisibility::private(), 47 None => return RawVisibility::private(),
53 Some(path) => path, 48 Some(path) => path,
54 }; 49 };
55 RawVisibility::Module(Arc::new(path)) 50 RawVisibility::Module(path)
56 } 51 }
57 ast::VisibilityKind::PubCrate => { 52 ast::VisibilityKind::PubCrate => {
58 let path = ModPath { kind: PathKind::Crate, segments: Vec::new() }; 53 let path = ModPath { kind: PathKind::Crate, segments: Vec::new() };
59 RawVisibility::Module(Arc::new(path)) 54 RawVisibility::Module(path)
60 } 55 }
61 ast::VisibilityKind::PubSuper => { 56 ast::VisibilityKind::PubSuper => {
62 let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; 57 let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() };
63 RawVisibility::Module(Arc::new(path)) 58 RawVisibility::Module(path)
64 } 59 }
65 ast::VisibilityKind::Pub => RawVisibility::Public, 60 ast::VisibilityKind::Pub => RawVisibility::Public,
66 } 61 }