Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert #[must_use] on generate_new #11738

Closed
wants to merge 1 commit into from
Closed

Insert #[must_use] on generate_new #11738

wants to merge 1 commit into from

Conversation

Walther
Copy link
Contributor

@Walther Walther commented Mar 17, 2022

Fixes #11736

@lnicola
Copy link
Member

lnicola commented Mar 17, 2022

Umm #11737

@Walther
Copy link
Contributor Author

Walther commented Mar 17, 2022

😆 you're fast!

@Walther Walther closed this Mar 17, 2022
@lnicola
Copy link
Member

lnicola commented Mar 17, 2022

Oof, sorry 😞.

We should probably check the other code generation assists, there might be other cases like this.

@Walther
Copy link
Contributor Author

Walther commented Mar 17, 2022

<3 all good, thanks for making rust-analyzer better!

@lnicola
Copy link
Member

lnicola commented Mar 17, 2022

Yeah, so generate_enum_is_method, generate_getter and generate_is_empty_from_len are similar. Do you want to take some of those?

@Walther
Copy link
Contributor Author

Walther commented Mar 17, 2022

Happy to help! Maybe you pick the first one and I'll do the other two?

@lnicola
Copy link
Member

lnicola commented Mar 17, 2022

Sure :-)

bors bot added a commit that referenced this pull request Mar 17, 2022
11737: Emit `#[must_use]` in `Generate new` assist r=lnicola a=lnicola

Closes #11736

11739: Insert #[must_use] in generate_getter r=lnicola a=Walther

Inserts `#[must_use]` for the generated getter methods.

From discussion in #11736 and #11738

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Walther <veeti.haapsamo@gmail.com>
bors bot added a commit that referenced this pull request Mar 17, 2022
11740: Insert #[must_use] in generate_is_empty_from_len r=lnicola a=Walther

Inserts `#[must_use]` for the generated `is_empty` methods. I also added the `#[must_use]` for the `len()` methods in the documentation examples and tests for this generator while at it, to make sure they too encourage the use of the annotation.

From discussion in #11736 and #11738

Co-authored-by: Walther <veeti.haapsamo@gmail.com>
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.

Feature Request / Discussion: should Generate new insert #[must_use]?
2 participants