Skip to content
New issue

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

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

Already on GitHub? # to your account

Adding #[must_use] on an item #159

Closed
Tracked by #5
obi1kenobi opened this issue Oct 23, 2022 · 1 comment · Fixed by #278, #279, #282 or #283
Closed
Tracked by #5

Adding #[must_use] on an item #159

obi1kenobi opened this issue Oct 23, 2022 · 1 comment · Fixed by #278, #279, #282 or #283
Assignees
Labels
A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.

Comments

@obi1kenobi
Copy link
Owner

obi1kenobi commented Oct 23, 2022

When #[must_use] is added, code in downstream crates that did not use a value of that type will get a compiler lint.

New lints for existing code requires a minor version: https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md#minor-change-introducing-new-lint-warningserrors

We want to support both "bare" #[must_use] and the form with a reason: #[must_use = "foo bar"]

@obi1kenobi obi1kenobi added A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue. labels Oct 23, 2022
@obi1kenobi obi1kenobi changed the title Adding on an item Adding #[must_use] on an item Oct 30, 2022
@SmolSir SmolSir self-assigned this Dec 29, 2022
@SmolSir SmolSir linked a pull request Jan 6, 2023 that will close this issue
6 tasks
@SmolSir
Copy link
Collaborator

SmolSir commented Jan 6, 2023

According to Rust Reference about #[must_use] attribute, the following lints have to be added:

  • enum_must_use_added
  • struct_must_use_added
  • function_must_use_added
  • trait_must_use_added
  • union_must_use_added
  • inherent_method_must_use_added
  • trait_method_must_use_added

The following schema additions should be implemented to enable all of the lints (or are closely related to them):

  • new schema for Union
  • missing implementation for implemented_trait edge for Impl

The union_must_use_added lint requires schema addition before it can be implemented.
The trait_method_must_use_added and inherent_method_moved_must_use_added lints may require schema addition of implemented_trait edge for Impl before they can be implemented.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lint Area: new or existing lint E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.
Projects
None yet
2 participants