diff options
| author | bors <bors@rust-lang.org> | 2023-04-21 18:25:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-21 18:25:42 +0000 |
| commit | af3b6a0893cc3a05b5ddc1e9d31b2c454b480426 (patch) | |
| tree | 682d7c143fc9160021cdc5dbb5c7d2381731b45d | |
| parent | 3a08713caa55718fafbf9483bec40379fbafd1de (diff) | |
| parent | 4601331ceb07ff8669b4089a18be676ae614009f (diff) | |
| download | rust-af3b6a0893cc3a05b5ddc1e9d31b2c454b480426.tar.gz rust-af3b6a0893cc3a05b5ddc1e9d31b2c454b480426.zip | |
Auto merge of #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 (#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).
| -rw-r--r-- | crates/syntax/src/ast/make.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 5aebe4cd9f5..c56ddb51609 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -184,8 +184,11 @@ pub fn impl_trait( ty: ast::Path, ty_params: Option<ast::GenericParamList>, ) -> ast::Impl { - let ty_params = ty_params.map_or_else(String::new, |params| params.to_string()); - ast_from_text(&format!("impl{ty_params} {trait_} for {ty}{ty_params} {{}}")) + // TODO : If this function is now correct we can also change `impl_` accordingly` + let ty_params_str = ty_params.as_ref().map_or_else(String::new, |params| params.to_string()); + let ty_genargs_str = + ty_params.map_or_else(String::new, |params| params.to_generic_args().to_string()); + ast_from_text(&format!("impl{ty_params_str} {trait_} for {ty}{ty_genargs_str} {{}}")) } pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { |
