diff options
author | Aleksey Kladov <[email protected]> | 2020-04-09 17:40:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-09 17:48:13 +0100 |
commit | 2bfb65db93e48d8f9e8ecac0b2ea837c081a4db5 (patch) | |
tree | 8a518f7fadab6918dea225122a69c8fd040e0fc1 /crates/ra_hir_def/src | |
parent | e6d22187a67e762bb950de244a6ca15f3a0b0731 (diff) |
Be consistent about token accesors
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/generics.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/type_ref.rs | 4 |
5 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index b02de5d67..c4a5ec59c 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -572,7 +572,10 @@ impl ExprCollector<'_> { | |||
572 | let pattern = match &pat { | 572 | let pattern = match &pat { |
573 | ast::Pat::BindPat(bp) => { | 573 | ast::Pat::BindPat(bp) => { |
574 | let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); | 574 | let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); |
575 | let annotation = BindingAnnotation::new(bp.is_mutable(), bp.is_ref()); | 575 | let annotation = BindingAnnotation::new( |
576 | bp.mut_kw_token().is_some(), | ||
577 | bp.ref_kw_token().is_some(), | ||
578 | ); | ||
576 | let subpat = bp.pat().map(|subpat| self.collect_pat(subpat)); | 579 | let subpat = bp.pat().map(|subpat| self.collect_pat(subpat)); |
577 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { | 580 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { |
578 | // This could also be a single-segment path pattern. To | 581 | // This could also be a single-segment path pattern. To |
@@ -613,7 +616,7 @@ impl ExprCollector<'_> { | |||
613 | } | 616 | } |
614 | ast::Pat::RefPat(p) => { | 617 | ast::Pat::RefPat(p) => { |
615 | let pat = self.collect_pat_opt(p.pat()); | 618 | let pat = self.collect_pat_opt(p.pat()); |
616 | let mutability = Mutability::from_mutable(p.is_mut()); | 619 | let mutability = Mutability::from_mutable(p.mut_kw_token().is_some()); |
617 | Pat::Ref { pat, mutability } | 620 | Pat::Ref { pat, mutability } |
618 | } | 621 | } |
619 | ast::Pat::PathPat(p) => { | 622 | ast::Pat::PathPat(p) => { |
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 606ec48b0..689bb6c5c 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -75,7 +75,7 @@ impl FunctionData { | |||
75 | TypeRef::unit() | 75 | TypeRef::unit() |
76 | }; | 76 | }; |
77 | 77 | ||
78 | let ret_type = if src.value.is_async() { | 78 | let ret_type = if src.value.async_kw_token().is_some() { |
79 | let future_impl = desugar_future_path(ret_type); | 79 | let future_impl = desugar_future_path(ret_type); |
80 | let ty_bound = TypeBound::Path(future_impl); | 80 | let ty_bound = TypeBound::Path(future_impl); |
81 | TypeRef::ImplTrait(vec![ty_bound]) | 81 | TypeRef::ImplTrait(vec![ty_bound]) |
@@ -136,7 +136,7 @@ impl TraitData { | |||
136 | pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> { | 136 | pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> { |
137 | let src = tr.lookup(db).source(db); | 137 | let src = tr.lookup(db).source(db); |
138 | let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); | 138 | let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); |
139 | let auto = src.value.is_auto(); | 139 | let auto = src.value.auto_kw_token().is_some(); |
140 | let ast_id_map = db.ast_id_map(src.file_id); | 140 | let ast_id_map = db.ast_id_map(src.file_id); |
141 | 141 | ||
142 | let container = AssocContainerId::TraitId(tr); | 142 | let container = AssocContainerId::TraitId(tr); |
@@ -213,7 +213,7 @@ impl ImplData { | |||
213 | 213 | ||
214 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); | 214 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); |
215 | let target_type = TypeRef::from_ast_opt(src.value.target_type()); | 215 | let target_type = TypeRef::from_ast_opt(src.value.target_type()); |
216 | let is_negative = src.value.is_negative(); | 216 | let is_negative = src.value.excl_token().is_some(); |
217 | let module_id = impl_loc.container.module(db); | 217 | let module_id = impl_loc.container.module(db); |
218 | 218 | ||
219 | let mut items = Vec::new(); | 219 | let mut items = Vec::new(); |
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index b687ce2b2..d850244c4 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -194,7 +194,7 @@ impl GenericParams { | |||
194 | } | 194 | } |
195 | 195 | ||
196 | fn add_where_predicate_from_bound(&mut self, bound: ast::TypeBound, type_ref: TypeRef) { | 196 | fn add_where_predicate_from_bound(&mut self, bound: ast::TypeBound, type_ref: TypeRef) { |
197 | if bound.has_question_mark() { | 197 | if bound.question_token().is_some() { |
198 | // FIXME: remove this bound | 198 | // FIXME: remove this bound |
199 | return; | 199 | return; |
200 | } | 200 | } |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index a9dff3a5d..e72ba52cf 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -287,7 +287,7 @@ impl RawItemsCollector { | |||
287 | let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene); | 287 | let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene); |
288 | 288 | ||
289 | let ast_id = self.source_ast_id_map.ast_id(&module); | 289 | let ast_id = self.source_ast_id_map.ast_id(&module); |
290 | if module.has_semi() { | 290 | if module.semi_token().is_some() { |
291 | let item = | 291 | let item = |
292 | self.raw_items.modules.alloc(ModuleData::Declaration { name, visibility, ast_id }); | 292 | self.raw_items.modules.alloc(ModuleData::Declaration { name, visibility, ast_id }); |
293 | self.push_item(current_module, attrs, RawItemKind::Module(item)); | 293 | self.push_item(current_module, attrs, RawItemKind::Module(item)); |
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs index 01cc392db..7a8338937 100644 --- a/crates/ra_hir_def/src/type_ref.rs +++ b/crates/ra_hir_def/src/type_ref.rs | |||
@@ -77,7 +77,7 @@ impl TypeRef { | |||
77 | } | 77 | } |
78 | ast::TypeRef::PointerType(inner) => { | 78 | ast::TypeRef::PointerType(inner) => { |
79 | let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); | 79 | let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); |
80 | let mutability = Mutability::from_mutable(inner.is_mut()); | 80 | let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some()); |
81 | TypeRef::RawPtr(Box::new(inner_ty), mutability) | 81 | TypeRef::RawPtr(Box::new(inner_ty), mutability) |
82 | } | 82 | } |
83 | ast::TypeRef::ArrayType(inner) => { | 83 | ast::TypeRef::ArrayType(inner) => { |
@@ -88,7 +88,7 @@ impl TypeRef { | |||
88 | } | 88 | } |
89 | ast::TypeRef::ReferenceType(inner) => { | 89 | ast::TypeRef::ReferenceType(inner) => { |
90 | let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); | 90 | let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); |
91 | let mutability = Mutability::from_mutable(inner.is_mut()); | 91 | let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some()); |
92 | TypeRef::Reference(Box::new(inner_ty), mutability) | 92 | TypeRef::Reference(Box::new(inner_ty), mutability) |
93 | } | 93 | } |
94 | ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder, | 94 | ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder, |