diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/ast_transform.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/utils.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/lower.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/file_structure.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 2 |
9 files changed, 12 insertions, 16 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 0a7be87a0..28f3f3546 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -81,7 +81,7 @@ impl<'a> SubstituteTypeParams<'a> { | |||
81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the | 81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the |
82 | // trait ref, and then go from the types in the substs back to the syntax). | 82 | // trait ref, and then go from the types in the substs back to the syntax). |
83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { | 83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { |
84 | let target_trait = impl_def.target_trait()?; | 84 | let target_trait = impl_def.trait_()?; |
85 | let path_type = match target_trait { | 85 | let path_type = match target_trait { |
86 | ast::Type::PathType(path) => path, | 86 | ast::Type::PathType(path) => path, |
87 | _ => return None, | 87 | _ => return None, |
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index bb16ebd4e..373de273c 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -111,11 +111,8 @@ pub(crate) fn resolve_target_trait( | |||
111 | sema: &Semantics<RootDatabase>, | 111 | sema: &Semantics<RootDatabase>, |
112 | impl_def: &ast::Impl, | 112 | impl_def: &ast::Impl, |
113 | ) -> Option<hir::Trait> { | 113 | ) -> Option<hir::Trait> { |
114 | let ast_path = impl_def | 114 | let ast_path = |
115 | .target_trait() | 115 | impl_def.trait_().map(|it| it.syntax().clone()).and_then(ast::PathType::cast)?.path()?; |
116 | .map(|it| it.syntax().clone()) | ||
117 | .and_then(ast::PathType::cast)? | ||
118 | .path()?; | ||
119 | 116 | ||
120 | match sema.resolve_path(&ast_path) { | 117 | match sema.resolve_path(&ast_path) { |
121 | Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), | 118 | Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), |
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index b5d416acb..450ef8798 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs | |||
@@ -448,8 +448,8 @@ impl Ctx { | |||
448 | fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> { | 448 | fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> { |
449 | let generic_params = | 449 | let generic_params = |
450 | self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); | 450 | self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); |
451 | 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)); |
452 | let target_type = self.lower_type_ref(&impl_def.target_type()?); | 452 | let target_type = self.lower_type_ref(&impl_def.self_ty()?); |
453 | let is_negative = impl_def.excl_token().is_some(); | 453 | let is_negative = impl_def.excl_token().is_some(); |
454 | 454 | ||
455 | // 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. |
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index d70e33e72..fdbf75abd 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -253,7 +253,7 @@ impl ToNav for hir::ImplDef { | |||
253 | let focus_range = if derive_attr.is_some() { | 253 | let focus_range = if derive_attr.is_some() { |
254 | None | 254 | None |
255 | } else { | 255 | } else { |
256 | src.value.target_type().map(|ty| original_range(db, src.with_value(ty.syntax())).range) | 256 | src.value.self_ty().map(|ty| original_range(db, src.with_value(ty.syntax())).range) |
257 | }; | 257 | }; |
258 | 258 | ||
259 | NavigationTarget::from_syntax( | 259 | NavigationTarget::from_syntax( |
diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index ef368651a..87cab4503 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs | |||
@@ -130,8 +130,8 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
130 | ast::Const(it) => decl_with_type_ref(&it, it.ty()), | 130 | ast::Const(it) => decl_with_type_ref(&it, it.ty()), |
131 | ast::Static(it) => decl_with_type_ref(&it, it.ty()), | 131 | ast::Static(it) => decl_with_type_ref(&it, it.ty()), |
132 | ast::Impl(it) => { | 132 | ast::Impl(it) => { |
133 | let target_type = it.target_type()?; | 133 | let target_type = it.self_ty()?; |
134 | let target_trait = it.target_trait(); | 134 | let target_trait = it.trait_(); |
135 | let label = match target_trait { | 135 | let label = match target_trait { |
136 | None => format!("impl {}", target_type.syntax().text()), | 136 | None => format!("impl {}", target_type.syntax().text()), |
137 | Some(t) => { | 137 | Some(t) => { |
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 96aed7cc7..3cd6c815b 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -194,7 +194,7 @@ fn text_edit_from_self_param( | |||
194 | new_name: &str, | 194 | new_name: &str, |
195 | ) -> Option<TextEdit> { | 195 | ) -> Option<TextEdit> { |
196 | fn target_type_name(impl_def: &ast::Impl) -> Option<String> { | 196 | fn target_type_name(impl_def: &ast::Impl) -> Option<String> { |
197 | if let Some(ast::Type::PathType(p)) = impl_def.target_type() { | 197 | if let Some(ast::Type::PathType(p)) = impl_def.self_ty() { |
198 | return Some(p.path()?.segment()?.name_ref()?.text().to_string()); | 198 | return Some(p.path()?.segment()?.name_ref()?.text().to_string()); |
199 | } | 199 | } |
200 | None | 200 | None |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 231a0f727..01aefb60d 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -267,7 +267,6 @@ impl Impl { | |||
267 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 267 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
268 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | 268 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } |
269 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 269 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
270 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
271 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | 270 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } |
272 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 271 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
273 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 272 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 4b4a72375..af5a93d1d 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -136,14 +136,14 @@ impl ast::UseTreeList { | |||
136 | } | 136 | } |
137 | 137 | ||
138 | impl ast::Impl { | 138 | impl ast::Impl { |
139 | pub fn target_type(&self) -> Option<ast::Type> { | 139 | pub fn self_ty(&self) -> Option<ast::Type> { |
140 | match self.target() { | 140 | match self.target() { |
141 | (Some(t), None) | (_, Some(t)) => Some(t), | 141 | (Some(t), None) | (_, Some(t)) => Some(t), |
142 | _ => None, | 142 | _ => None, |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | pub fn target_trait(&self) -> Option<ast::Type> { | 146 | pub fn trait_(&self) -> Option<ast::Type> { |
147 | match self.target() { | 147 | match self.target() { |
148 | (Some(t), Some(_)) => Some(t), | 148 | (Some(t), Some(_)) => Some(t), |
149 | _ => None, | 149 | _ => None, |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 0325ab0b4..2dddaf09a 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -208,7 +208,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) { | |||
208 | Some(it) => it, | 208 | Some(it) => it, |
209 | None => return, | 209 | None => return, |
210 | }; | 210 | }; |
211 | if impl_def.target_trait().is_some() { | 211 | if impl_def.trait_().is_some() { |
212 | errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); | 212 | errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); |
213 | } | 213 | } |
214 | } | 214 | } |