mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Rename
This commit is contained in:
parent
81359af733
commit
af53d5f4b0
8 changed files with 12 additions and 15 deletions
|
@ -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
|
// 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).
|
// trait ref, and then go from the types in the substs back to the syntax).
|
||||||
fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> {
|
fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> {
|
||||||
let target_trait = impl_def.target_trait()?;
|
let target_trait = impl_def.trait_()?;
|
||||||
let path_type = match target_trait {
|
let path_type = match target_trait {
|
||||||
ast::Type::PathType(path) => path,
|
ast::Type::PathType(path) => path,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
|
|
@ -111,11 +111,8 @@ pub(crate) fn resolve_target_trait(
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
impl_def: &ast::Impl,
|
impl_def: &ast::Impl,
|
||||||
) -> Option<hir::Trait> {
|
) -> Option<hir::Trait> {
|
||||||
let ast_path = impl_def
|
let ast_path =
|
||||||
.target_trait()
|
impl_def.trait_().map(|it| it.syntax().clone()).and_then(ast::PathType::cast)?.path()?;
|
||||||
.map(|it| it.syntax().clone())
|
|
||||||
.and_then(ast::PathType::cast)?
|
|
||||||
.path()?;
|
|
||||||
|
|
||||||
match sema.resolve_path(&ast_path) {
|
match sema.resolve_path(&ast_path) {
|
||||||
Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def),
|
Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def),
|
||||||
|
|
|
@ -448,8 +448,8 @@ impl Ctx {
|
||||||
fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> {
|
fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> {
|
||||||
let generic_params =
|
let generic_params =
|
||||||
self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def);
|
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_trait = impl_def.trait_().map(|tr| self.lower_type_ref(&tr));
|
||||||
let target_type = self.lower_type_ref(&impl_def.target_type()?);
|
let target_type = self.lower_type_ref(&impl_def.self_ty()?);
|
||||||
let is_negative = impl_def.excl_token().is_some();
|
let is_negative = impl_def.excl_token().is_some();
|
||||||
|
|
||||||
// We cannot use `assoc_items()` here as that does not include macro calls.
|
// We cannot use `assoc_items()` here as that does not include macro calls.
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl ToNav for hir::ImplDef {
|
||||||
let focus_range = if derive_attr.is_some() {
|
let focus_range = if derive_attr.is_some() {
|
||||||
None
|
None
|
||||||
} else {
|
} 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(
|
NavigationTarget::from_syntax(
|
||||||
|
|
|
@ -130,8 +130,8 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
||||||
ast::Const(it) => decl_with_type_ref(&it, it.ty()),
|
ast::Const(it) => decl_with_type_ref(&it, it.ty()),
|
||||||
ast::Static(it) => decl_with_type_ref(&it, it.ty()),
|
ast::Static(it) => decl_with_type_ref(&it, it.ty()),
|
||||||
ast::Impl(it) => {
|
ast::Impl(it) => {
|
||||||
let target_type = it.target_type()?;
|
let target_type = it.self_ty()?;
|
||||||
let target_trait = it.target_trait();
|
let target_trait = it.trait_();
|
||||||
let label = match target_trait {
|
let label = match target_trait {
|
||||||
None => format!("impl {}", target_type.syntax().text()),
|
None => format!("impl {}", target_type.syntax().text()),
|
||||||
Some(t) => {
|
Some(t) => {
|
||||||
|
|
|
@ -194,7 +194,7 @@ fn text_edit_from_self_param(
|
||||||
new_name: &str,
|
new_name: &str,
|
||||||
) -> Option<TextEdit> {
|
) -> Option<TextEdit> {
|
||||||
fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
|
fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
|
||||||
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());
|
return Some(p.path()?.segment()?.name_ref()?.text().to_string());
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
@ -136,14 +136,14 @@ impl ast::UseTreeList {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::Impl {
|
impl ast::Impl {
|
||||||
pub fn target_type(&self) -> Option<ast::Type> {
|
pub fn self_ty(&self) -> Option<ast::Type> {
|
||||||
match self.target() {
|
match self.target() {
|
||||||
(Some(t), None) | (_, Some(t)) => Some(t),
|
(Some(t), None) | (_, Some(t)) => Some(t),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_trait(&self) -> Option<ast::Type> {
|
pub fn trait_(&self) -> Option<ast::Type> {
|
||||||
match self.target() {
|
match self.target() {
|
||||||
(Some(t), Some(_)) => Some(t),
|
(Some(t), Some(_)) => Some(t),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -208,7 +208,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return,
|
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()));
|
errors.push(SyntaxError::new("Unnecessary visibility qualifier", vis.syntax.text_range()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue