aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/raw.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-22 09:27:13 +0000
committerGitHub <[email protected]>2019-11-22 09:27:13 +0000
commitf24aa7a45ad6ffbbae56d5bca50afd6aefa1a4c7 (patch)
tree286d7f91a45aa132691729a98302b687f677b643 /crates/ra_hir_def/src/nameres/raw.rs
parentd59bf33b9e1c20d6ef3fd9b72f3cf4730172b5a8 (diff)
parenta87e9145a67634a5ea8a893ab8b52b3c07108a13 (diff)
Merge #2351
2351: Rename Atts trait r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres/raw.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 7c68fd638..55a9634f8 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -16,7 +16,12 @@ use ra_syntax::{
16}; 16};
17use test_utils::tested_by; 17use test_utils::tested_by;
18 18
19use crate::{attr::Attr, db::DefDatabase2, path::Path, FileAstId, HirFileId, ModuleSource, Source}; 19use crate::{
20 attr::{Attr, Attrs},
21 db::DefDatabase2,
22 path::Path,
23 FileAstId, HirFileId, ModuleSource, Source,
24};
20 25
21/// `RawItems` is a set of top-level items in a file (except for impls). 26/// `RawItems` is a set of top-level items in a file (except for impls).
22/// 27///
@@ -129,21 +134,12 @@ impl Index<Impl> for RawItems {
129 } 134 }
130} 135}
131 136
132// Avoid heap allocation on items without attributes.
133type Attrs = Option<Arc<[Attr]>>;
134
135#[derive(Debug, PartialEq, Eq, Clone)] 137#[derive(Debug, PartialEq, Eq, Clone)]
136pub(super) struct RawItem { 138pub(super) struct RawItem {
137 attrs: Attrs, 139 pub(super) attrs: Attrs,
138 pub(super) kind: RawItemKind, 140 pub(super) kind: RawItemKind,
139} 141}
140 142
141impl RawItem {
142 pub(super) fn attrs(&self) -> &[Attr] {
143 self.attrs.as_ref().map_or(&[], |it| &*it)
144 }
145}
146
147#[derive(Debug, PartialEq, Eq, Clone, Copy)] 143#[derive(Debug, PartialEq, Eq, Clone, Copy)]
148pub(super) enum RawItemKind { 144pub(super) enum RawItemKind {
149 Module(Module), 145 Module(Module),