diff options
author | Dmitry <[email protected]> | 2020-08-09 14:35:51 +0100 |
---|---|---|
committer | Dmitry <[email protected]> | 2020-08-09 14:39:32 +0100 |
commit | 8068302fefc75440b823f4bf1731a5f347d7c767 (patch) | |
tree | 251b967182e79bc82a58c2fb208c688f6152df1f /crates/ra_hir_def/src/item_tree | |
parent | 1a43a0f63e0008787225abb6fb2baef97b6a39e0 (diff) | |
parent | 8a57afe5a4bfab40072a83f7dc4ca560bf860919 (diff) |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'crates/ra_hir_def/src/item_tree')
-rw-r--r-- | crates/ra_hir_def/src/item_tree/lower.rs | 175 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/tests.rs | 62 |
2 files changed, 117 insertions, 120 deletions
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index f79b8fca3..450ef8798 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs | |||
@@ -1,10 +1,7 @@ | |||
1 | //! AST -> `ItemTree` lowering code. | 1 | //! AST -> `ItemTree` lowering code. |
2 | 2 | ||
3 | use super::*; | 3 | use std::{collections::hash_map::Entry, mem, sync::Arc}; |
4 | use crate::{ | 4 | |
5 | attr::Attrs, | ||
6 | generics::{GenericParams, TypeParamData, TypeParamProvenance}, | ||
7 | }; | ||
8 | use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; | 5 | use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; |
9 | use ra_arena::map::ArenaMap; | 6 | use ra_arena::map::ArenaMap; |
10 | use ra_syntax::{ | 7 | use ra_syntax::{ |
@@ -12,7 +9,13 @@ use ra_syntax::{ | |||
12 | SyntaxNode, | 9 | SyntaxNode, |
13 | }; | 10 | }; |
14 | use smallvec::SmallVec; | 11 | use smallvec::SmallVec; |
15 | use std::{collections::hash_map::Entry, mem, sync::Arc}; | 12 | |
13 | use crate::{ | ||
14 | attr::Attrs, | ||
15 | generics::{GenericParams, TypeParamData, TypeParamProvenance}, | ||
16 | }; | ||
17 | |||
18 | use super::*; | ||
16 | 19 | ||
17 | fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { | 20 | fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { |
18 | FileItemTreeId { index, _p: PhantomData } | 21 | FileItemTreeId { index, _p: PhantomData } |
@@ -70,19 +73,19 @@ impl Ctx { | |||
70 | self.tree.data_mut() | 73 | self.tree.data_mut() |
71 | } | 74 | } |
72 | 75 | ||
73 | fn lower_mod_item(&mut self, item: &ast::ModuleItem, inner: bool) -> Option<ModItems> { | 76 | fn lower_mod_item(&mut self, item: &ast::Item, inner: bool) -> Option<ModItems> { |
74 | assert!(inner || self.inner_items.is_empty()); | 77 | assert!(inner || self.inner_items.is_empty()); |
75 | 78 | ||
76 | // Collect inner items for 1-to-1-lowered items. | 79 | // Collect inner items for 1-to-1-lowered items. |
77 | match item { | 80 | match item { |
78 | ast::ModuleItem::StructDef(_) | 81 | ast::Item::Struct(_) |
79 | | ast::ModuleItem::UnionDef(_) | 82 | | ast::Item::Union(_) |
80 | | ast::ModuleItem::EnumDef(_) | 83 | | ast::Item::Enum(_) |
81 | | ast::ModuleItem::FnDef(_) | 84 | | ast::Item::Fn(_) |
82 | | ast::ModuleItem::TypeAliasDef(_) | 85 | | ast::Item::TypeAlias(_) |
83 | | ast::ModuleItem::ConstDef(_) | 86 | | ast::Item::Const(_) |
84 | | ast::ModuleItem::StaticDef(_) | 87 | | ast::Item::Static(_) |
85 | | ast::ModuleItem::MacroCall(_) => { | 88 | | ast::Item::MacroCall(_) => { |
86 | // Skip this if we're already collecting inner items. We'll descend into all nodes | 89 | // Skip this if we're already collecting inner items. We'll descend into all nodes |
87 | // already. | 90 | // already. |
88 | if !inner { | 91 | if !inner { |
@@ -92,34 +95,30 @@ impl Ctx { | |||
92 | 95 | ||
93 | // These are handled in their respective `lower_X` method (since we can't just blindly | 96 | // These are handled in their respective `lower_X` method (since we can't just blindly |
94 | // walk them). | 97 | // walk them). |
95 | ast::ModuleItem::TraitDef(_) | 98 | ast::Item::Trait(_) | ast::Item::Impl(_) | ast::Item::ExternBlock(_) => {} |
96 | | ast::ModuleItem::ImplDef(_) | ||
97 | | ast::ModuleItem::ExternBlock(_) => {} | ||
98 | 99 | ||
99 | // These don't have inner items. | 100 | // These don't have inner items. |
100 | ast::ModuleItem::Module(_) | 101 | ast::Item::Module(_) | ast::Item::ExternCrate(_) | ast::Item::Use(_) => {} |
101 | | ast::ModuleItem::ExternCrateItem(_) | ||
102 | | ast::ModuleItem::UseItem(_) => {} | ||
103 | }; | 102 | }; |
104 | 103 | ||
105 | let attrs = Attrs::new(item, &self.hygiene); | 104 | let attrs = Attrs::new(item, &self.hygiene); |
106 | let items = match item { | 105 | let items = match item { |
107 | ast::ModuleItem::StructDef(ast) => self.lower_struct(ast).map(Into::into), | 106 | ast::Item::Struct(ast) => self.lower_struct(ast).map(Into::into), |
108 | ast::ModuleItem::UnionDef(ast) => self.lower_union(ast).map(Into::into), | 107 | ast::Item::Union(ast) => self.lower_union(ast).map(Into::into), |
109 | ast::ModuleItem::EnumDef(ast) => self.lower_enum(ast).map(Into::into), | 108 | ast::Item::Enum(ast) => self.lower_enum(ast).map(Into::into), |
110 | ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), | 109 | ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into), |
111 | ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), | 110 | ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into), |
112 | ast::ModuleItem::StaticDef(ast) => self.lower_static(ast).map(Into::into), | 111 | ast::Item::Static(ast) => self.lower_static(ast).map(Into::into), |
113 | ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), | 112 | ast::Item::Const(ast) => Some(self.lower_const(ast).into()), |
114 | ast::ModuleItem::Module(ast) => self.lower_module(ast).map(Into::into), | 113 | ast::Item::Module(ast) => self.lower_module(ast).map(Into::into), |
115 | ast::ModuleItem::TraitDef(ast) => self.lower_trait(ast).map(Into::into), | 114 | ast::Item::Trait(ast) => self.lower_trait(ast).map(Into::into), |
116 | ast::ModuleItem::ImplDef(ast) => self.lower_impl(ast).map(Into::into), | 115 | ast::Item::Impl(ast) => self.lower_impl(ast).map(Into::into), |
117 | ast::ModuleItem::UseItem(ast) => Some(ModItems( | 116 | ast::Item::Use(ast) => Some(ModItems( |
118 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), | 117 | self.lower_use(ast).into_iter().map(Into::into).collect::<SmallVec<_>>(), |
119 | )), | 118 | )), |
120 | ast::ModuleItem::ExternCrateItem(ast) => self.lower_extern_crate(ast).map(Into::into), | 119 | ast::Item::ExternCrate(ast) => self.lower_extern_crate(ast).map(Into::into), |
121 | ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), | 120 | ast::Item::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), |
122 | ast::ModuleItem::ExternBlock(ast) => { | 121 | ast::Item::ExternBlock(ast) => { |
123 | Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>())) | 122 | Some(ModItems(self.lower_extern_block(ast).into_iter().collect::<SmallVec<_>>())) |
124 | } | 123 | } |
125 | }; | 124 | }; |
@@ -147,27 +146,26 @@ impl Ctx { | |||
147 | fn collect_inner_items(&mut self, container: &SyntaxNode) { | 146 | fn collect_inner_items(&mut self, container: &SyntaxNode) { |
148 | let forced_vis = self.forced_visibility.take(); | 147 | let forced_vis = self.forced_visibility.take(); |
149 | let mut inner_items = mem::take(&mut self.tree.inner_items); | 148 | let mut inner_items = mem::take(&mut self.tree.inner_items); |
150 | inner_items.extend( | 149 | inner_items.extend(container.descendants().skip(1).filter_map(ast::Item::cast).filter_map( |
151 | container.descendants().skip(1).filter_map(ast::ModuleItem::cast).filter_map(|item| { | 150 | |item| { |
152 | let ast_id = self.source_ast_id_map.ast_id(&item); | 151 | let ast_id = self.source_ast_id_map.ast_id(&item); |
153 | Some((ast_id, self.lower_mod_item(&item, true)?.0)) | 152 | Some((ast_id, self.lower_mod_item(&item, true)?.0)) |
154 | }), | 153 | }, |
155 | ); | 154 | )); |
156 | self.tree.inner_items = inner_items; | 155 | self.tree.inner_items = inner_items; |
157 | self.forced_visibility = forced_vis; | 156 | self.forced_visibility = forced_vis; |
158 | } | 157 | } |
159 | 158 | ||
160 | fn lower_assoc_item(&mut self, item: &ast::ModuleItem) -> Option<AssocItem> { | 159 | fn lower_assoc_item(&mut self, item: &ast::AssocItem) -> Option<AssocItem> { |
161 | match item { | 160 | match item { |
162 | ast::ModuleItem::FnDef(ast) => self.lower_function(ast).map(Into::into), | 161 | ast::AssocItem::Fn(ast) => self.lower_function(ast).map(Into::into), |
163 | ast::ModuleItem::TypeAliasDef(ast) => self.lower_type_alias(ast).map(Into::into), | 162 | ast::AssocItem::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into), |
164 | ast::ModuleItem::ConstDef(ast) => Some(self.lower_const(ast).into()), | 163 | ast::AssocItem::Const(ast) => Some(self.lower_const(ast).into()), |
165 | ast::ModuleItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), | 164 | ast::AssocItem::MacroCall(ast) => self.lower_macro_call(ast).map(Into::into), |
166 | _ => None, | ||
167 | } | 165 | } |
168 | } | 166 | } |
169 | 167 | ||
170 | fn lower_struct(&mut self, strukt: &ast::StructDef) -> Option<FileItemTreeId<Struct>> { | 168 | fn lower_struct(&mut self, strukt: &ast::Struct) -> Option<FileItemTreeId<Struct>> { |
171 | let visibility = self.lower_visibility(strukt); | 169 | let visibility = self.lower_visibility(strukt); |
172 | let name = strukt.name()?.as_name(); | 170 | let name = strukt.name()?.as_name(); |
173 | let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt); | 171 | let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt); |
@@ -196,7 +194,7 @@ impl Ctx { | |||
196 | } | 194 | } |
197 | } | 195 | } |
198 | 196 | ||
199 | fn lower_record_fields(&mut self, fields: &ast::RecordFieldDefList) -> IdRange<Field> { | 197 | fn lower_record_fields(&mut self, fields: &ast::RecordFieldList) -> IdRange<Field> { |
200 | let start = self.next_field_idx(); | 198 | let start = self.next_field_idx(); |
201 | for field in fields.fields() { | 199 | for field in fields.fields() { |
202 | if let Some(data) = self.lower_record_field(&field) { | 200 | if let Some(data) = self.lower_record_field(&field) { |
@@ -208,15 +206,15 @@ impl Ctx { | |||
208 | IdRange::new(start..end) | 206 | IdRange::new(start..end) |
209 | } | 207 | } |
210 | 208 | ||
211 | fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> { | 209 | fn lower_record_field(&mut self, field: &ast::RecordField) -> Option<Field> { |
212 | let name = field.name()?.as_name(); | 210 | let name = field.name()?.as_name(); |
213 | let visibility = self.lower_visibility(field); | 211 | let visibility = self.lower_visibility(field); |
214 | let type_ref = self.lower_type_ref_opt(field.ascribed_type()); | 212 | let type_ref = self.lower_type_ref_opt(field.ty()); |
215 | let res = Field { name, type_ref, visibility }; | 213 | let res = Field { name, type_ref, visibility }; |
216 | Some(res) | 214 | Some(res) |
217 | } | 215 | } |
218 | 216 | ||
219 | fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> { | 217 | fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldList) -> IdRange<Field> { |
220 | let start = self.next_field_idx(); | 218 | let start = self.next_field_idx(); |
221 | for (i, field) in fields.fields().enumerate() { | 219 | for (i, field) in fields.fields().enumerate() { |
222 | let data = self.lower_tuple_field(i, &field); | 220 | let data = self.lower_tuple_field(i, &field); |
@@ -227,22 +225,20 @@ impl Ctx { | |||
227 | IdRange::new(start..end) | 225 | IdRange::new(start..end) |
228 | } | 226 | } |
229 | 227 | ||
230 | fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Field { | 228 | fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleField) -> Field { |
231 | let name = Name::new_tuple_field(idx); | 229 | let name = Name::new_tuple_field(idx); |
232 | let visibility = self.lower_visibility(field); | 230 | let visibility = self.lower_visibility(field); |
233 | let type_ref = self.lower_type_ref_opt(field.type_ref()); | 231 | let type_ref = self.lower_type_ref_opt(field.ty()); |
234 | let res = Field { name, type_ref, visibility }; | 232 | let res = Field { name, type_ref, visibility }; |
235 | res | 233 | res |
236 | } | 234 | } |
237 | 235 | ||
238 | fn lower_union(&mut self, union: &ast::UnionDef) -> Option<FileItemTreeId<Union>> { | 236 | fn lower_union(&mut self, union: &ast::Union) -> Option<FileItemTreeId<Union>> { |
239 | let visibility = self.lower_visibility(union); | 237 | let visibility = self.lower_visibility(union); |
240 | let name = union.name()?.as_name(); | 238 | let name = union.name()?.as_name(); |
241 | let generic_params = self.lower_generic_params(GenericsOwner::Union, union); | 239 | let generic_params = self.lower_generic_params(GenericsOwner::Union, union); |
242 | let fields = match union.record_field_def_list() { | 240 | let fields = match union.record_field_list() { |
243 | Some(record_field_def_list) => { | 241 | Some(record_field_list) => self.lower_fields(&StructKind::Record(record_field_list)), |
244 | self.lower_fields(&StructKind::Record(record_field_def_list)) | ||
245 | } | ||
246 | None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())), | 242 | None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())), |
247 | }; | 243 | }; |
248 | let ast_id = self.source_ast_id_map.ast_id(union); | 244 | let ast_id = self.source_ast_id_map.ast_id(union); |
@@ -250,7 +246,7 @@ impl Ctx { | |||
250 | Some(id(self.data().unions.alloc(res))) | 246 | Some(id(self.data().unions.alloc(res))) |
251 | } | 247 | } |
252 | 248 | ||
253 | fn lower_enum(&mut self, enum_: &ast::EnumDef) -> Option<FileItemTreeId<Enum>> { | 249 | fn lower_enum(&mut self, enum_: &ast::Enum) -> Option<FileItemTreeId<Enum>> { |
254 | let visibility = self.lower_visibility(enum_); | 250 | let visibility = self.lower_visibility(enum_); |
255 | let name = enum_.name()?.as_name(); | 251 | let name = enum_.name()?.as_name(); |
256 | let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); | 252 | let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); |
@@ -263,7 +259,7 @@ impl Ctx { | |||
263 | Some(id(self.data().enums.alloc(res))) | 259 | Some(id(self.data().enums.alloc(res))) |
264 | } | 260 | } |
265 | 261 | ||
266 | fn lower_variants(&mut self, variants: &ast::EnumVariantList) -> IdRange<Variant> { | 262 | fn lower_variants(&mut self, variants: &ast::VariantList) -> IdRange<Variant> { |
267 | let start = self.next_variant_idx(); | 263 | let start = self.next_variant_idx(); |
268 | for variant in variants.variants() { | 264 | for variant in variants.variants() { |
269 | if let Some(data) = self.lower_variant(&variant) { | 265 | if let Some(data) = self.lower_variant(&variant) { |
@@ -275,14 +271,14 @@ impl Ctx { | |||
275 | IdRange::new(start..end) | 271 | IdRange::new(start..end) |
276 | } | 272 | } |
277 | 273 | ||
278 | fn lower_variant(&mut self, variant: &ast::EnumVariant) -> Option<Variant> { | 274 | fn lower_variant(&mut self, variant: &ast::Variant) -> Option<Variant> { |
279 | let name = variant.name()?.as_name(); | 275 | let name = variant.name()?.as_name(); |
280 | let fields = self.lower_fields(&variant.kind()); | 276 | let fields = self.lower_fields(&variant.kind()); |
281 | let res = Variant { name, fields }; | 277 | let res = Variant { name, fields }; |
282 | Some(res) | 278 | Some(res) |
283 | } | 279 | } |
284 | 280 | ||
285 | fn lower_function(&mut self, func: &ast::FnDef) -> Option<FileItemTreeId<Function>> { | 281 | fn lower_function(&mut self, func: &ast::Fn) -> Option<FileItemTreeId<Function>> { |
286 | let visibility = self.lower_visibility(func); | 282 | let visibility = self.lower_visibility(func); |
287 | let name = func.name()?.as_name(); | 283 | let name = func.name()?.as_name(); |
288 | 284 | ||
@@ -290,7 +286,7 @@ impl Ctx { | |||
290 | let mut has_self_param = false; | 286 | let mut has_self_param = false; |
291 | if let Some(param_list) = func.param_list() { | 287 | if let Some(param_list) = func.param_list() { |
292 | if let Some(self_param) = param_list.self_param() { | 288 | if let Some(self_param) = param_list.self_param() { |
293 | let self_type = match self_param.ascribed_type() { | 289 | let self_type = match self_param.ty() { |
294 | Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), | 290 | Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), |
295 | None => { | 291 | None => { |
296 | let self_type = TypeRef::Path(name![Self].into()); | 292 | let self_type = TypeRef::Path(name![Self].into()); |
@@ -309,7 +305,7 @@ impl Ctx { | |||
309 | has_self_param = true; | 305 | has_self_param = true; |
310 | } | 306 | } |
311 | for param in param_list.params() { | 307 | for param in param_list.params() { |
312 | let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ascribed_type()); | 308 | let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); |
313 | params.push(type_ref); | 309 | params.push(type_ref); |
314 | } | 310 | } |
315 | } | 311 | } |
@@ -321,7 +317,7 @@ impl Ctx { | |||
321 | } | 317 | } |
322 | } | 318 | } |
323 | 319 | ||
324 | let ret_type = match func.ret_type().and_then(|rt| rt.type_ref()) { | 320 | let ret_type = match func.ret_type().and_then(|rt| rt.ty()) { |
325 | Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), | 321 | Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref), |
326 | _ => TypeRef::unit(), | 322 | _ => TypeRef::unit(), |
327 | }; | 323 | }; |
@@ -353,10 +349,10 @@ impl Ctx { | |||
353 | 349 | ||
354 | fn lower_type_alias( | 350 | fn lower_type_alias( |
355 | &mut self, | 351 | &mut self, |
356 | type_alias: &ast::TypeAliasDef, | 352 | type_alias: &ast::TypeAlias, |
357 | ) -> Option<FileItemTreeId<TypeAlias>> { | 353 | ) -> Option<FileItemTreeId<TypeAlias>> { |
358 | let name = type_alias.name()?.as_name(); | 354 | let name = type_alias.name()?.as_name(); |
359 | let type_ref = type_alias.type_ref().map(|it| self.lower_type_ref(&it)); | 355 | let type_ref = type_alias.ty().map(|it| self.lower_type_ref(&it)); |
360 | let visibility = self.lower_visibility(type_alias); | 356 | let visibility = self.lower_visibility(type_alias); |
361 | let bounds = self.lower_type_bounds(type_alias); | 357 | let bounds = self.lower_type_bounds(type_alias); |
362 | let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias); | 358 | let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias); |
@@ -372,9 +368,9 @@ impl Ctx { | |||
372 | Some(id(self.data().type_aliases.alloc(res))) | 368 | Some(id(self.data().type_aliases.alloc(res))) |
373 | } | 369 | } |
374 | 370 | ||
375 | fn lower_static(&mut self, static_: &ast::StaticDef) -> Option<FileItemTreeId<Static>> { | 371 | fn lower_static(&mut self, static_: &ast::Static) -> Option<FileItemTreeId<Static>> { |
376 | let name = static_.name()?.as_name(); | 372 | let name = static_.name()?.as_name(); |
377 | let type_ref = self.lower_type_ref_opt(static_.ascribed_type()); | 373 | let type_ref = self.lower_type_ref_opt(static_.ty()); |
378 | let visibility = self.lower_visibility(static_); | 374 | let visibility = self.lower_visibility(static_); |
379 | let mutable = static_.mut_token().is_some(); | 375 | let mutable = static_.mut_token().is_some(); |
380 | let ast_id = self.source_ast_id_map.ast_id(static_); | 376 | let ast_id = self.source_ast_id_map.ast_id(static_); |
@@ -382,9 +378,9 @@ impl Ctx { | |||
382 | Some(id(self.data().statics.alloc(res))) | 378 | Some(id(self.data().statics.alloc(res))) |
383 | } | 379 | } |
384 | 380 | ||
385 | fn lower_const(&mut self, konst: &ast::ConstDef) -> FileItemTreeId<Const> { | 381 | fn lower_const(&mut self, konst: &ast::Const) -> FileItemTreeId<Const> { |
386 | let name = konst.name().map(|it| it.as_name()); | 382 | let name = konst.name().map(|it| it.as_name()); |
387 | let type_ref = self.lower_type_ref_opt(konst.ascribed_type()); | 383 | let type_ref = self.lower_type_ref_opt(konst.ty()); |
388 | let visibility = self.lower_visibility(konst); | 384 | let visibility = self.lower_visibility(konst); |
389 | let ast_id = self.source_ast_id_map.ast_id(konst); | 385 | let ast_id = self.source_ast_id_map.ast_id(konst); |
390 | let res = Const { name, visibility, type_ref, ast_id }; | 386 | let res = Const { name, visibility, type_ref, ast_id }; |
@@ -417,15 +413,15 @@ impl Ctx { | |||
417 | Some(id(self.data().mods.alloc(res))) | 413 | Some(id(self.data().mods.alloc(res))) |
418 | } | 414 | } |
419 | 415 | ||
420 | fn lower_trait(&mut self, trait_def: &ast::TraitDef) -> Option<FileItemTreeId<Trait>> { | 416 | fn lower_trait(&mut self, trait_def: &ast::Trait) -> Option<FileItemTreeId<Trait>> { |
421 | let name = trait_def.name()?.as_name(); | 417 | let name = trait_def.name()?.as_name(); |
422 | let visibility = self.lower_visibility(trait_def); | 418 | let visibility = self.lower_visibility(trait_def); |
423 | let generic_params = | 419 | let generic_params = |
424 | self.lower_generic_params_and_inner_items(GenericsOwner::Trait(trait_def), trait_def); | 420 | self.lower_generic_params_and_inner_items(GenericsOwner::Trait(trait_def), trait_def); |
425 | let auto = trait_def.auto_token().is_some(); | 421 | let auto = trait_def.auto_token().is_some(); |
426 | let items = trait_def.item_list().map(|list| { | 422 | let items = trait_def.assoc_item_list().map(|list| { |
427 | self.with_inherited_visibility(visibility, |this| { | 423 | self.with_inherited_visibility(visibility, |this| { |
428 | list.items() | 424 | list.assoc_items() |
429 | .filter_map(|item| { | 425 | .filter_map(|item| { |
430 | let attrs = Attrs::new(&item, &this.hygiene); | 426 | let attrs = Attrs::new(&item, &this.hygiene); |
431 | this.collect_inner_items(item.syntax()); | 427 | this.collect_inner_items(item.syntax()); |
@@ -449,18 +445,18 @@ impl Ctx { | |||
449 | Some(id(self.data().traits.alloc(res))) | 445 | Some(id(self.data().traits.alloc(res))) |
450 | } | 446 | } |
451 | 447 | ||
452 | fn lower_impl(&mut self, impl_def: &ast::ImplDef) -> Option<FileItemTreeId<Impl>> { | 448 | fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> { |
453 | let generic_params = | 449 | let generic_params = |
454 | self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); | 450 | self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); |
455 | let target_trait = impl_def.target_trait().map(|tr| self.lower_type_ref(&tr)); | 451 | let target_trait = impl_def.trait_().map(|tr| self.lower_type_ref(&tr)); |
456 | let target_type = self.lower_type_ref(&impl_def.target_type()?); | 452 | let target_type = self.lower_type_ref(&impl_def.self_ty()?); |
457 | let is_negative = impl_def.excl_token().is_some(); | 453 | let is_negative = impl_def.excl_token().is_some(); |
458 | 454 | ||
459 | // We cannot use `assoc_items()` here as that does not include macro calls. | 455 | // We cannot use `assoc_items()` here as that does not include macro calls. |
460 | let items = impl_def | 456 | let items = impl_def |
461 | .item_list() | 457 | .assoc_item_list() |
462 | .into_iter() | 458 | .into_iter() |
463 | .flat_map(|it| it.items()) | 459 | .flat_map(|it| it.assoc_items()) |
464 | .filter_map(|item| { | 460 | .filter_map(|item| { |
465 | self.collect_inner_items(item.syntax()); | 461 | self.collect_inner_items(item.syntax()); |
466 | let assoc = self.lower_assoc_item(&item)?; | 462 | let assoc = self.lower_assoc_item(&item)?; |
@@ -474,7 +470,7 @@ impl Ctx { | |||
474 | Some(id(self.data().impls.alloc(res))) | 470 | Some(id(self.data().impls.alloc(res))) |
475 | } | 471 | } |
476 | 472 | ||
477 | fn lower_use(&mut self, use_item: &ast::UseItem) -> Vec<FileItemTreeId<Import>> { | 473 | fn lower_use(&mut self, use_item: &ast::Use) -> Vec<FileItemTreeId<Import>> { |
478 | // FIXME: cfg_attr | 474 | // FIXME: cfg_attr |
479 | let is_prelude = use_item.has_atom_attr("prelude_import"); | 475 | let is_prelude = use_item.has_atom_attr("prelude_import"); |
480 | let visibility = self.lower_visibility(use_item); | 476 | let visibility = self.lower_visibility(use_item); |
@@ -503,10 +499,10 @@ impl Ctx { | |||
503 | 499 | ||
504 | fn lower_extern_crate( | 500 | fn lower_extern_crate( |
505 | &mut self, | 501 | &mut self, |
506 | extern_crate: &ast::ExternCrateItem, | 502 | extern_crate: &ast::ExternCrate, |
507 | ) -> Option<FileItemTreeId<ExternCrate>> { | 503 | ) -> Option<FileItemTreeId<ExternCrate>> { |
508 | let path = ModPath::from_name_ref(&extern_crate.name_ref()?); | 504 | let path = ModPath::from_name_ref(&extern_crate.name_ref()?); |
509 | let alias = extern_crate.alias().map(|a| { | 505 | let alias = extern_crate.rename().map(|a| { |
510 | a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) | 506 | a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) |
511 | }); | 507 | }); |
512 | let visibility = self.lower_visibility(extern_crate); | 508 | let visibility = self.lower_visibility(extern_crate); |
@@ -552,15 +548,16 @@ impl Ctx { | |||
552 | self.collect_inner_items(item.syntax()); | 548 | self.collect_inner_items(item.syntax()); |
553 | let attrs = Attrs::new(&item, &self.hygiene); | 549 | let attrs = Attrs::new(&item, &self.hygiene); |
554 | let id: ModItem = match item { | 550 | let id: ModItem = match item { |
555 | ast::ExternItem::FnDef(ast) => { | 551 | ast::ExternItem::Fn(ast) => { |
556 | let func = self.lower_function(&ast)?; | 552 | let func = self.lower_function(&ast)?; |
557 | self.data().functions[func.index].is_unsafe = true; | 553 | self.data().functions[func.index].is_unsafe = true; |
558 | func.into() | 554 | func.into() |
559 | } | 555 | } |
560 | ast::ExternItem::StaticDef(ast) => { | 556 | ast::ExternItem::Static(ast) => { |
561 | let statik = self.lower_static(&ast)?; | 557 | let statik = self.lower_static(&ast)?; |
562 | statik.into() | 558 | statik.into() |
563 | } | 559 | } |
560 | ast::ExternItem::MacroCall(_) => return None, | ||
564 | }; | 561 | }; |
565 | self.add_attrs(id.into(), attrs); | 562 | self.add_attrs(id.into(), attrs); |
566 | Some(id) | 563 | Some(id) |
@@ -573,10 +570,10 @@ impl Ctx { | |||
573 | fn lower_generic_params_and_inner_items( | 570 | fn lower_generic_params_and_inner_items( |
574 | &mut self, | 571 | &mut self, |
575 | owner: GenericsOwner<'_>, | 572 | owner: GenericsOwner<'_>, |
576 | node: &impl ast::TypeParamsOwner, | 573 | node: &impl ast::GenericParamsOwner, |
577 | ) -> GenericParamsId { | 574 | ) -> GenericParamsId { |
578 | // Generics are part of item headers and may contain inner items we need to collect. | 575 | // Generics are part of item headers and may contain inner items we need to collect. |
579 | if let Some(params) = node.type_param_list() { | 576 | if let Some(params) = node.generic_param_list() { |
580 | self.collect_inner_items(params.syntax()); | 577 | self.collect_inner_items(params.syntax()); |
581 | } | 578 | } |
582 | if let Some(clause) = node.where_clause() { | 579 | if let Some(clause) = node.where_clause() { |
@@ -589,7 +586,7 @@ impl Ctx { | |||
589 | fn lower_generic_params( | 586 | fn lower_generic_params( |
590 | &mut self, | 587 | &mut self, |
591 | owner: GenericsOwner<'_>, | 588 | owner: GenericsOwner<'_>, |
592 | node: &impl ast::TypeParamsOwner, | 589 | node: &impl ast::GenericParamsOwner, |
593 | ) -> GenericParamsId { | 590 | ) -> GenericParamsId { |
594 | let mut sm = &mut ArenaMap::default(); | 591 | let mut sm = &mut ArenaMap::default(); |
595 | let mut generics = GenericParams::default(); | 592 | let mut generics = GenericParams::default(); |
@@ -651,10 +648,10 @@ impl Ctx { | |||
651 | self.data().vis.alloc(vis) | 648 | self.data().vis.alloc(vis) |
652 | } | 649 | } |
653 | 650 | ||
654 | fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { | 651 | fn lower_type_ref(&self, type_ref: &ast::Type) -> TypeRef { |
655 | TypeRef::from_ast(&self.body_ctx, type_ref.clone()) | 652 | TypeRef::from_ast(&self.body_ctx, type_ref.clone()) |
656 | } | 653 | } |
657 | fn lower_type_ref_opt(&self, type_ref: Option<ast::TypeRef>) -> TypeRef { | 654 | fn lower_type_ref_opt(&self, type_ref: Option<ast::Type>) -> TypeRef { |
658 | type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error) | 655 | type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error) |
659 | } | 656 | } |
660 | 657 | ||
@@ -702,7 +699,7 @@ enum GenericsOwner<'a> { | |||
702 | Enum, | 699 | Enum, |
703 | Union, | 700 | Union, |
704 | /// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter. | 701 | /// The `TraitDef` is needed to fill the source map for the implicit `Self` parameter. |
705 | Trait(&'a ast::TraitDef), | 702 | Trait(&'a ast::Trait), |
706 | TypeAlias, | 703 | TypeAlias, |
707 | Impl, | 704 | Impl, |
708 | } | 705 | } |
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index f26982985..a81497fa8 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs | |||
@@ -21,7 +21,7 @@ fn test_inner_items(ra_fixture: &str) { | |||
21 | let mut outer_items = FxHashSet::default(); | 21 | let mut outer_items = FxHashSet::default(); |
22 | let mut worklist = tree.top_level_items().to_vec(); | 22 | let mut worklist = tree.top_level_items().to_vec(); |
23 | while let Some(item) = worklist.pop() { | 23 | while let Some(item) = worklist.pop() { |
24 | let node: ast::ModuleItem = match item { | 24 | let node: ast::Item = match item { |
25 | ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 25 | ModItem::Import(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
26 | ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 26 | ModItem::ExternCrate(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
27 | ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(), | 27 | ModItem::Function(it) => tree.source(&db, InFile::new(file_id, it)).into(), |
@@ -53,7 +53,7 @@ fn test_inner_items(ra_fixture: &str) { | |||
53 | 53 | ||
54 | // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or | 54 | // Now descend the root node and check that all `ast::ModuleItem`s are either recorded above, or |
55 | // registered as inner items. | 55 | // registered as inner items. |
56 | for item in root.descendants().skip(1).filter_map(ast::ModuleItem::cast) { | 56 | for item in root.descendants().skip(1).filter_map(ast::Item::cast) { |
57 | if outer_items.contains(&item) { | 57 | if outer_items.contains(&item) { |
58 | continue; | 58 | continue; |
59 | } | 59 | } |
@@ -228,31 +228,31 @@ fn smoke() { | |||
228 | 228 | ||
229 | top-level items: | 229 | top-level items: |
230 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] | 230 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] |
231 | Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } | 231 | Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) } |
232 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] | 232 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] |
233 | Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } | 233 | Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Use>(0) } |
234 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] | 234 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] |
235 | ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrateItem>(1) } | 235 | ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrate>(1) } |
236 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] | 236 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] |
237 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(2) } | 237 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(2) } |
238 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] | 238 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] |
239 | > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAliasDef>(8) } | 239 | > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAlias>(8) } |
240 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] | 240 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] |
241 | > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) } | 241 | > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Const>(9) } |
242 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] | 242 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] |
243 | > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(10) } | 243 | > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(10) } |
244 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] | 244 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] |
245 | > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(11) } | 245 | > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(11) } |
246 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] | 246 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] |
247 | Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit } | 247 | Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(3), kind: Unit } |
248 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] | 248 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] |
249 | Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple } | 249 | Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::<ra_hir_def::item_tree::Field>(0..1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(4), kind: Tuple } |
250 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] | 250 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] |
251 | Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(5), kind: Record } | 251 | Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(1..2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Struct>(5), kind: Record } |
252 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] | 252 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] |
253 | Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) } | 253 | Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::<ra_hir_def::item_tree::Variant>(0..1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Enum>(6) } |
254 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] | 254 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] |
255 | Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UnionDef>(7) } | 255 | Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::<ra_hir_def::item_tree::Field>(3..4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Union>(7) } |
256 | "##]], | 256 | "##]], |
257 | ); | 257 | ); |
258 | } | 258 | } |
@@ -274,13 +274,13 @@ fn simple_inner_items() { | |||
274 | inner attrs: Attrs { entries: None } | 274 | inner attrs: Attrs { entries: None } |
275 | 275 | ||
276 | top-level items: | 276 | top-level items: |
277 | Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 277 | Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) } |
278 | > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 278 | > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) } |
279 | 279 | ||
280 | inner items: | 280 | inner items: |
281 | 281 | ||
282 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2): | 282 | for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(2): |
283 | Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 283 | Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) } |
284 | 284 | ||
285 | "#]], | 285 | "#]], |
286 | ); | 286 | ); |
@@ -303,9 +303,9 @@ fn extern_attrs() { | |||
303 | 303 | ||
304 | top-level items: | 304 | top-level items: |
305 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] | 305 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] |
306 | Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 306 | Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) } |
307 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] | 307 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] |
308 | Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 308 | Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) } |
309 | "##]], | 309 | "##]], |
310 | ); | 310 | ); |
311 | } | 311 | } |
@@ -327,11 +327,11 @@ fn trait_attrs() { | |||
327 | 327 | ||
328 | top-level items: | 328 | top-level items: |
329 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] | 329 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] |
330 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) } | 330 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Trait>(0) } |
331 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] | 331 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] |
332 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 332 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) } |
333 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] | 333 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] |
334 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 334 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) } |
335 | "##]], | 335 | "##]], |
336 | ); | 336 | ); |
337 | } | 337 | } |
@@ -353,11 +353,11 @@ fn impl_attrs() { | |||
353 | 353 | ||
354 | top-level items: | 354 | top-level items: |
355 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] | 355 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] |
356 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 356 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) } |
357 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] | 357 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] |
358 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 358 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) } |
359 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] | 359 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] |
360 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 360 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(2) } |
361 | "##]], | 361 | "##]], |
362 | ); | 362 | ); |
363 | } | 363 | } |
@@ -408,13 +408,13 @@ fn inner_item_attrs() { | |||
408 | inner attrs: Attrs { entries: None } | 408 | inner attrs: Attrs { entries: None } |
409 | 409 | ||
410 | top-level items: | 410 | top-level items: |
411 | Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(0) } | 411 | Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(0) } |
412 | 412 | ||
413 | inner items: | 413 | inner items: |
414 | 414 | ||
415 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1): | 415 | for AST FileAstId::<ra_syntax::ast::generated::nodes::Item>(1): |
416 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] | 416 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] |
417 | Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 417 | Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Fn>(1) } |
418 | 418 | ||
419 | "##]], | 419 | "##]], |
420 | ); | 420 | ); |
@@ -432,7 +432,7 @@ fn assoc_item_macros() { | |||
432 | inner attrs: Attrs { entries: None } | 432 | inner attrs: Attrs { entries: None } |
433 | 433 | ||
434 | top-level items: | 434 | top-level items: |
435 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 435 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::Impl>(0) } |
436 | > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) } | 436 | > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) } |
437 | "#]], | 437 | "#]], |
438 | ); | 438 | ); |