mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
parent
c2d3f90886
commit
1b5c60f549
1 changed files with 6 additions and 4 deletions
|
@ -229,15 +229,17 @@ fn self_type(ast_func: &ast::Fn) -> Option<ast::Type> {
|
|||
|
||||
/// Output the real name of `Self` like `MyType<T>`, without the lifetimes.
|
||||
fn self_type_without_lifetimes(ast_func: &ast::Fn) -> Option<String> {
|
||||
let path_segment =
|
||||
ast::PathType::cast(self_type(ast_func)?.syntax().clone())?.path()?.segment()?;
|
||||
let path_segment = match self_type(ast_func)? {
|
||||
ast::Type::PathType(path_type) => path_type.path()?.segment()?,
|
||||
_ => return None,
|
||||
};
|
||||
let mut name = path_segment.name_ref()?.to_string();
|
||||
let generics = path_segment
|
||||
.generic_arg_list()?
|
||||
.generic_args()
|
||||
.filter(|generic| matches!(generic, ast::GenericArg::TypeArg(_)))
|
||||
.map(|generic| generic.to_string());
|
||||
let generics: String = Itertools::intersperse(generics, ", ".to_string()).collect();
|
||||
let generics: String = generics.format(", ").to_string();
|
||||
if !generics.is_empty() {
|
||||
name.push('<');
|
||||
name.push_str(&generics);
|
||||
|
@ -325,7 +327,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
|
|||
},
|
||||
_ => "_".to_string(),
|
||||
});
|
||||
Itertools::intersperse(args_iter, ", ".to_string()).collect()
|
||||
args_iter.format(", ").to_string()
|
||||
}
|
||||
|
||||
/// Helper function to build a function call. `None` if expected `self_name` was not provided
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue