diff options
author | Jonas Schievink <[email protected]> | 2021-04-09 12:36:22 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-04-09 12:36:22 +0100 |
commit | 546da15972312f62be8a64a409d39a8d96ed53a6 (patch) | |
tree | 9c41d31b7396d9137f3436ba6084bee293ee0a69 /crates | |
parent | 3fcdd1bcdf8a93769f74b7b4ca5ba043ad316e46 (diff) |
Rename `Attr`s `index` field to `id`
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/attr.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 1549024c1..dd99c8d15 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -103,7 +103,7 @@ impl RawAttrs { | |||
103 | match attr { | 103 | match attr { |
104 | Either::Left(attr) => Attr::from_src(attr, hygiene, index), | 104 | Either::Left(attr) => Attr::from_src(attr, hygiene, index), |
105 | Either::Right(comment) => comment.doc_comment().map(|doc| Attr { | 105 | Either::Right(comment) => comment.doc_comment().map(|doc| Attr { |
106 | index, | 106 | id: index, |
107 | input: Some(AttrInput::Literal(SmolStr::new(doc))), | 107 | input: Some(AttrInput::Literal(SmolStr::new(doc))), |
108 | path: Interned::new(ModPath::from(hir_expand::name!(doc))), | 108 | path: Interned::new(ModPath::from(hir_expand::name!(doc))), |
109 | }), | 109 | }), |
@@ -164,7 +164,7 @@ impl RawAttrs { | |||
164 | let cfg = parts.next().unwrap(); | 164 | let cfg = parts.next().unwrap(); |
165 | let cfg = Subtree { delimiter: subtree.delimiter, token_trees: cfg.to_vec() }; | 165 | let cfg = Subtree { delimiter: subtree.delimiter, token_trees: cfg.to_vec() }; |
166 | let cfg = CfgExpr::parse(&cfg); | 166 | let cfg = CfgExpr::parse(&cfg); |
167 | let index = attr.index; | 167 | let index = attr.id; |
168 | let attrs = parts.filter(|a| !a.is_empty()).filter_map(|attr| { | 168 | let attrs = parts.filter(|a| !a.is_empty()).filter_map(|attr| { |
169 | let tree = Subtree { delimiter: None, token_trees: attr.to_vec() }; | 169 | let tree = Subtree { delimiter: None, token_trees: attr.to_vec() }; |
170 | let attr = ast::Attr::parse(&format!("#[{}]", tree)).ok()?; | 170 | let attr = ast::Attr::parse(&format!("#[{}]", tree)).ok()?; |
@@ -471,7 +471,7 @@ impl AttrsWithOwner { | |||
471 | ) -> Option<(Documentation, DocsRangeMap)> { | 471 | ) -> Option<(Documentation, DocsRangeMap)> { |
472 | // FIXME: code duplication in `docs` above | 472 | // FIXME: code duplication in `docs` above |
473 | let docs = self.by_key("doc").attrs().flat_map(|attr| match attr.input.as_ref()? { | 473 | let docs = self.by_key("doc").attrs().flat_map(|attr| match attr.input.as_ref()? { |
474 | AttrInput::Literal(s) => Some((s, attr.index)), | 474 | AttrInput::Literal(s) => Some((s, attr.id)), |
475 | AttrInput::TokenTree(_) => None, | 475 | AttrInput::TokenTree(_) => None, |
476 | }); | 476 | }); |
477 | let indent = docs | 477 | let indent = docs |
@@ -563,8 +563,8 @@ impl AttrSourceMap { | |||
563 | /// the attribute represented by `Attr`. | 563 | /// the attribute represented by `Attr`. |
564 | pub fn source_of(&self, attr: &Attr) -> InFile<&Either<ast::Attr, ast::Comment>> { | 564 | pub fn source_of(&self, attr: &Attr) -> InFile<&Either<ast::Attr, ast::Comment>> { |
565 | self.attrs | 565 | self.attrs |
566 | .get(attr.index.0 as usize) | 566 | .get(attr.id.0 as usize) |
567 | .unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", attr.index)) | 567 | .unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", attr.id)) |
568 | .as_ref() | 568 | .as_ref() |
569 | } | 569 | } |
570 | } | 570 | } |
@@ -609,7 +609,7 @@ impl DocsRangeMap { | |||
609 | 609 | ||
610 | #[derive(Debug, Clone, PartialEq, Eq)] | 610 | #[derive(Debug, Clone, PartialEq, Eq)] |
611 | pub struct Attr { | 611 | pub struct Attr { |
612 | pub(crate) index: AttrId, | 612 | pub(crate) id: AttrId, |
613 | pub(crate) path: Interned<ModPath>, | 613 | pub(crate) path: Interned<ModPath>, |
614 | pub(crate) input: Option<AttrInput>, | 614 | pub(crate) input: Option<AttrInput>, |
615 | } | 615 | } |
@@ -623,7 +623,7 @@ pub enum AttrInput { | |||
623 | } | 623 | } |
624 | 624 | ||
625 | impl Attr { | 625 | impl Attr { |
626 | fn from_src(ast: ast::Attr, hygiene: &Hygiene, index: AttrId) -> Option<Attr> { | 626 | fn from_src(ast: ast::Attr, hygiene: &Hygiene, id: AttrId) -> Option<Attr> { |
627 | let path = Interned::new(ModPath::from_src(ast.path()?, hygiene)?); | 627 | let path = Interned::new(ModPath::from_src(ast.path()?, hygiene)?); |
628 | let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() { | 628 | let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() { |
629 | let value = match lit.kind() { | 629 | let value = match lit.kind() { |
@@ -636,7 +636,7 @@ impl Attr { | |||
636 | } else { | 636 | } else { |
637 | None | 637 | None |
638 | }; | 638 | }; |
639 | Some(Attr { index, path, input }) | 639 | Some(Attr { id, path, input }) |
640 | } | 640 | } |
641 | 641 | ||
642 | /// Parses this attribute as a `#[derive]`, returns an iterator that yields all contained paths | 642 | /// Parses this attribute as a `#[derive]`, returns an iterator that yields all contained paths |