aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-19 01:52:51 +0000
committerGitHub <[email protected]>2020-12-19 01:52:51 +0000
commitbd270cbc024f56596c315061d10732ebbe16eef9 (patch)
treeeeb2a2dd4fc58f608ce7260eee1a372c03d31923
parente47e7a0143a537ef76b0f946dfc3ec56ed2e0507 (diff)
parenta2062d18926f15e330c873eab97aed4d5d308ea1 (diff)
Merge #6944
6944: Make attribute API more private r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r--crates/hir_def/src/attr.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index d1ed23947..73b17da10 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -42,7 +42,7 @@ impl From<Documentation> for String {
42 42
43/// Syntactical attributes, without filtering of `cfg_attr`s. 43/// Syntactical attributes, without filtering of `cfg_attr`s.
44#[derive(Default, Debug, Clone, PartialEq, Eq)] 44#[derive(Default, Debug, Clone, PartialEq, Eq)]
45pub struct RawAttrs { 45pub(crate) struct RawAttrs {
46 entries: Option<Arc<[Attr]>>, 46 entries: Option<Arc<[Attr]>>,
47} 47}
48 48
@@ -72,7 +72,7 @@ impl ops::Deref for Attrs {
72} 72}
73 73
74impl RawAttrs { 74impl RawAttrs {
75 pub const EMPTY: Self = Self { entries: None }; 75 pub(crate) const EMPTY: Self = Self { entries: None };
76 76
77 pub(crate) fn new(owner: &dyn AttrsOwner, hygiene: &Hygiene) -> Self { 77 pub(crate) fn new(owner: &dyn AttrsOwner, hygiene: &Hygiene) -> Self {
78 let (inner_attrs, inner_docs) = inner_attributes(owner.syntax()) 78 let (inner_attrs, inner_docs) = inner_attributes(owner.syntax())
@@ -241,18 +241,6 @@ impl Attrs {
241 raw_attrs.filter(db, def.krate(db)) 241 raw_attrs.filter(db, def.krate(db))
242 } 242 }
243 243
244 pub fn merge(&self, other: Attrs) -> Attrs {
245 match (&self.0.entries, &other.0.entries) {
246 (None, None) => Attrs::EMPTY,
247 (Some(entries), None) | (None, Some(entries)) => {
248 Attrs(RawAttrs { entries: Some(entries.clone()) })
249 }
250 (Some(a), Some(b)) => {
251 Attrs(RawAttrs { entries: Some(a.iter().chain(b.iter()).cloned().collect()) })
252 }
253 }
254 }
255
256 pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> { 244 pub fn by_key(&self, key: &'static str) -> AttrQuery<'_> {
257 AttrQuery { attrs: self, key } 245 AttrQuery { attrs: self, key }
258 } 246 }