Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit af3b6a0

Browse files
committed
Auto merge of rust-lang#14621 - alibektas:make_impl_trait_fix, r=Veykril
Simple fix for make::impl_trait This is my first PR in this project. I made this PR because I needed this function to work properly for the main PR I am working on (rust-lang#14386). This is a small amendment to what it was before. We still need to improve this in order for it to fully comply with its syntactic definition as stated [here](https://doc.rust-lang.org/reference/items/implementations.html).
2 parents 3a08713 + 4601331 commit af3b6a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/syntax/src/ast/make.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ pub fn impl_trait(
184184
ty: ast::Path,
185185
ty_params: Option<ast::GenericParamList>,
186186
) -> ast::Impl {
187-
let ty_params = ty_params.map_or_else(String::new, |params| params.to_string());
188-
ast_from_text(&format!("impl{ty_params} {trait_} for {ty}{ty_params} {{}}"))
187+
// TODO : If this function is now correct we can also change `impl_` accordingly`
188+
let ty_params_str = ty_params.as_ref().map_or_else(String::new, |params| params.to_string());
189+
let ty_genargs_str =
190+
ty_params.map_or_else(String::new, |params| params.to_generic_args().to_string());
191+
ast_from_text(&format!("impl{ty_params_str} {trait_} for {ty}{ty_genargs_str} {{}}"))
189192
}
190193

191194
pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {

0 commit comments

Comments
 (0)