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.
This commit is contained in:
Florian Diebold 2019-12-26 16:42:57 +01:00
parent 04cf98f8a6
commit dfe95d735b

View file

@ -1,7 +1,5 @@
//! Defines hir-level representation of visibility (e.g. `pub` and `pub(crate)`). //! Defines hir-level representation of visibility (e.g. `pub` and `pub(crate)`).
use std::sync::Arc;
use hir_expand::{hygiene::Hygiene, InFile}; use hir_expand::{hygiene::Hygiene, InFile};
use ra_syntax::ast; use ra_syntax::ast;
@ -14,20 +12,17 @@ use crate::{
/// Visibility of an item, not yet resolved. /// Visibility of an item, not yet resolved.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum RawVisibility { pub enum RawVisibility {
// FIXME: We could avoid the allocation in many cases by special-casing
// pub(crate), pub(super) and private. Alternatively, `ModPath` could be
// made to contain an Arc<[Segment]> instead of a Vec?
/// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is /// `pub(in module)`, `pub(crate)` or `pub(super)`. Also private, which is
/// equivalent to `pub(self)`. /// equivalent to `pub(self)`.
Module(Arc<ModPath>), Module(ModPath),
/// `pub`. /// `pub`.
Public, Public,
} }
impl RawVisibility { impl RawVisibility {
fn private() -> RawVisibility { const fn private() -> RawVisibility {
let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() }; let path = ModPath { kind: PathKind::Super(0), segments: Vec::new() };
RawVisibility::Module(Arc::new(path)) RawVisibility::Module(path)
} }
pub(crate) fn from_ast( pub(crate) fn from_ast(
@ -52,15 +47,15 @@ impl RawVisibility {
None => return RawVisibility::private(), None => return RawVisibility::private(),
Some(path) => path, Some(path) => path,
}; };
RawVisibility::Module(Arc::new(path)) RawVisibility::Module(path)
} }
ast::VisibilityKind::PubCrate => { ast::VisibilityKind::PubCrate => {
let path = ModPath { kind: PathKind::Crate, segments: Vec::new() }; let path = ModPath { kind: PathKind::Crate, segments: Vec::new() };
RawVisibility::Module(Arc::new(path)) RawVisibility::Module(path)
} }
ast::VisibilityKind::PubSuper => { ast::VisibilityKind::PubSuper => {
let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() };
RawVisibility::Module(Arc::new(path)) RawVisibility::Module(path)
} }
ast::VisibilityKind::Pub => RawVisibility::Public, ast::VisibilityKind::Pub => RawVisibility::Public,
} }