Skip to content

Conversation

@0xPoe
Copy link
Member

@0xPoe 0xPoe commented May 15, 2021

Try to close #8827

@0xPoe
Copy link
Member Author

0xPoe commented May 15, 2021

@Veykril Do you have any suggestions on how to get strukt right here? Thanks!

@Veykril
Copy link
Member

Veykril commented May 15, 2021

Right this is a bit more annoying to do here. I think what we actually want here is another function generate_trait_impl_text_from_impl(impl_: &ast::Impl, trait_text: &str, code: &str) -> String instead which copies the generics and all from another impl instead.

As for the following example:

struct Foo<T> { t: T }

impl<T: From<i32>> Foo<T> {
    fn new() -> Self {
        Foo { t: 0.into() }
    }
}

Here we want the T: From<i32> bounds of the impl, not just the T from the struct def. So we don't actually need the struct def here, only the impl node.

It's fine to copy the generate_impl_text_inner impl for that for now so that there is also a version working for an ast::Impl, or edit it so that it works for both if you can.

@0xPoe 0xPoe force-pushed the rustin-fix-default_fn_node_for_new branch 3 times, most recently from c988fbc to 24838e8 Compare May 15, 2021 12:20
@0xPoe
Copy link
Member Author

0xPoe commented May 15, 2021

@Veykril Added. Thanks for your help!

@0xPoe 0xPoe changed the title Generate the impl block via generate_trait_impl_text Generate the impl block via generate_trait_impl_text_from_impl May 15, 2021
@0xPoe 0xPoe force-pushed the rustin-fix-default_fn_node_for_new branch from 0b002ed to 696a8bf Compare May 15, 2021 12:44
@Veykril
Copy link
Member

Veykril commented May 16, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented May 16, 2021

@bors bors bot merged commit b824588 into rust-lang:master May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing type parameters in creation of Default impl

2 participants