Skip to content

Commit 546da15

Browse files
Rename Attrs index field to id
1 parent 3fcdd1b commit 546da15

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/hir_def/src/attr.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl RawAttrs {
103103
match attr {
104104
Either::Left(attr) => Attr::from_src(attr, hygiene, index),
105105
Either::Right(comment) => comment.doc_comment().map(|doc| Attr {
106-
index,
106+
id: index,
107107
input: Some(AttrInput::Literal(SmolStr::new(doc))),
108108
path: Interned::new(ModPath::from(hir_expand::name!(doc))),
109109
}),
@@ -164,7 +164,7 @@ impl RawAttrs {
164164
let cfg = parts.next().unwrap();
165165
let cfg = Subtree { delimiter: subtree.delimiter, token_trees: cfg.to_vec() };
166166
let cfg = CfgExpr::parse(&cfg);
167-
let index = attr.index;
167+
let index = attr.id;
168168
let attrs = parts.filter(|a| !a.is_empty()).filter_map(|attr| {
169169
let tree = Subtree { delimiter: None, token_trees: attr.to_vec() };
170170
let attr = ast::Attr::parse(&format!("#[{}]", tree)).ok()?;
@@ -471,7 +471,7 @@ impl AttrsWithOwner {
471471
) -> Option<(Documentation, DocsRangeMap)> {
472472
// FIXME: code duplication in `docs` above
473473
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)),
475475
AttrInput::TokenTree(_) => None,
476476
});
477477
let indent = docs
@@ -563,8 +563,8 @@ impl AttrSourceMap {
563563
/// the attribute represented by `Attr`.
564564
pub fn source_of(&self, attr: &Attr) -> InFile<&Either<ast::Attr, ast::Comment>> {
565565
self.attrs
566-
.get(attr.index.0 as usize)
567-
.unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", attr.index))
566+
.get(attr.id.0 as usize)
567+
.unwrap_or_else(|| panic!("cannot find `Attr` at index {:?}", attr.id))
568568
.as_ref()
569569
}
570570
}
@@ -609,7 +609,7 @@ impl DocsRangeMap {
609609

610610
#[derive(Debug, Clone, PartialEq, Eq)]
611611
pub struct Attr {
612-
pub(crate) index: AttrId,
612+
pub(crate) id: AttrId,
613613
pub(crate) path: Interned<ModPath>,
614614
pub(crate) input: Option<AttrInput>,
615615
}
@@ -623,7 +623,7 @@ pub enum AttrInput {
623623
}
624624

625625
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> {
627627
let path = Interned::new(ModPath::from_src(ast.path()?, hygiene)?);
628628
let input = if let Some(ast::Expr::Literal(lit)) = ast.expr() {
629629
let value = match lit.kind() {
@@ -636,7 +636,7 @@ impl Attr {
636636
} else {
637637
None
638638
};
639-
Some(Attr { index, path, input })
639+
Some(Attr { id, path, input })
640640
}
641641

642642
/// Parses this attribute as a `#[derive]`, returns an iterator that yields all contained paths

0 commit comments

Comments
 (0)