mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix generic type substitution in impl trait with assoc type
This commit is contained in:
parent
0add6e95e5
commit
d9b3242bcd
3 changed files with 411 additions and 11 deletions
|
@ -166,6 +166,14 @@ pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {
|
|||
ast_from_text(&format!("use {};", name_ref))
|
||||
}
|
||||
|
||||
pub fn path_segment_ty(type_ref: ast::Type, trait_ref: Option<ast::PathType>) -> ast::PathSegment {
|
||||
let text = match trait_ref {
|
||||
Some(trait_ref) => format!("fn f(x: <{} as {}>) {{}}", type_ref, trait_ref),
|
||||
None => format!("fn f(x: <{}>) {{}}", type_ref),
|
||||
};
|
||||
ast_from_text(&text)
|
||||
}
|
||||
|
||||
pub fn path_segment_self() -> ast::PathSegment {
|
||||
ast_from_text("use self;")
|
||||
}
|
||||
|
@ -196,9 +204,9 @@ pub fn path_from_segments(
|
|||
) -> ast::Path {
|
||||
let segments = segments.into_iter().map(|it| it.syntax().clone()).join("::");
|
||||
ast_from_text(&if is_abs {
|
||||
format!("use ::{};", segments)
|
||||
format!("fn f(x: ::{}) {{}}", segments)
|
||||
} else {
|
||||
format!("use {};", segments)
|
||||
format!("fn f(x: {}) {{}}", segments)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue