diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 0a7be87a0c..28f3f3546c 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> { // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the // trait ref, and then go from the types in the substs back to the syntax). fn get_syntactic_substs(impl_def: ast::Impl) -> Option> { - let target_trait = impl_def.target_trait()?; + let target_trait = impl_def.trait_()?; let path_type = match target_trait { ast::Type::PathType(path) => path, _ => return None, diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index bb16ebd4e8..373de273ca 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( sema: &Semantics, impl_def: &ast::Impl, ) -> Option { - let ast_path = impl_def - .target_trait() - .map(|it| it.syntax().clone()) - .and_then(ast::PathType::cast)? - .path()?; + let ast_path = + impl_def.trait_().map(|it| it.syntax().clone()).and_then(ast::PathType::cast)?.path()?; match sema.resolve_path(&ast_path) { 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 b5d416acbc..450ef87981 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 { fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option> { let generic_params = self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); - let target_trait = impl_def.target_trait().map(|tr| self.lower_type_ref(&tr)); - let target_type = self.lower_type_ref(&impl_def.target_type()?); + let target_trait = impl_def.trait_().map(|tr| self.lower_type_ref(&tr)); + let target_type = self.lower_type_ref(&impl_def.self_ty()?); let is_negative = impl_def.excl_token().is_some(); // 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 d70e33e72e..fdbf75abd9 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 { let focus_range = if derive_attr.is_some() { None } else { - src.value.target_type().map(|ty| original_range(db, src.with_value(ty.syntax())).range) + src.value.self_ty().map(|ty| original_range(db, src.with_value(ty.syntax())).range) }; NavigationTarget::from_syntax( diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index ef368651ae..87cab45037 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 { ast::Const(it) => decl_with_type_ref(&it, it.ty()), ast::Static(it) => decl_with_type_ref(&it, it.ty()), ast::Impl(it) => { - let target_type = it.target_type()?; - let target_trait = it.target_trait(); + let target_type = it.self_ty()?; + let target_trait = it.trait_(); let label = match target_trait { None => format!("impl {}", target_type.syntax().text()), Some(t) => { diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 96aed7cc73..3cd6c815b1 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( new_name: &str, ) -> Option { fn target_type_name(impl_def: &ast::Impl) -> Option { - if let Some(ast::Type::PathType(p)) = impl_def.target_type() { + if let Some(ast::Type::PathType(p)) = impl_def.self_ty() { return Some(p.path()?.segment()?.name_ref()?.text().to_string()); } None diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 4b4a72375b..af5a93d1d0 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 { } impl ast::Impl { - pub fn target_type(&self) -> Option { + pub fn self_ty(&self) -> Option { match self.target() { (Some(t), None) | (_, Some(t)) => Some(t), _ => None, } } - pub fn target_trait(&self) -> Option { + pub fn trait_(&self) -> Option { match self.target() { (Some(t), Some(_)) => Some(t), _ => None, diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 0325ab0b42..2dddaf09a4 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) { Some(it) => it, None => return, }; - if impl_def.target_trait().is_some() { + if impl_def.trait_().is_some() { errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range())); } }