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

add must use annotation to functions that have no mutable args or statics #145

Closed
wants to merge 1 commit into from
Closed

add must use annotation to functions that have no mutable args or statics #145

wants to merge 1 commit into from

Conversation

lillianzhang331
Copy link
Contributor

Copy link
Member

@Malax Malax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing this PR with @edmorley, I remove my approve. Adding must_use makes sense, but we need to go further than just slapping annotations on anything where static analysis can figure out the value needs to be used.

We most likely want to add messages to most of them too.

pub fn build(self) -> BuildResult {
BuildResult(InnerBuildResult::Pass {
launch: self.launch,
store: self.store,
})
}

#[must_use]
Copy link
Member

@edmorley edmorley Nov 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think #[must_use] should be used on this function and the one below given they do mutate the original struct - seems like false positives. (Unless we want to enforce the chaining function style of using these builders - which may actually be what we want, but worth discussing.)

Fixing this lint is definitely one where we need to vet each case and not just add the annotations where clippy suggested without checking :-)

@edmorley
Copy link
Member

I found some guidelines on when to use must_use, here:
rust-lang/rust#48926 (comment)

@Malax
Copy link
Member

Malax commented Nov 17, 2021

Should we close this PR and continue discussion in the issue itself, or create a new one? This PR will not be merged anytime soon and with a very different changeset, correct?

@edmorley
Copy link
Member

I think we should close this for now, and discuss in the issue what strategy we wish to use here before opening a new PR.

@Malax Malax closed this Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix clippy::must-use-candidate warnings
3 participants