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

Make #[MustUseResult] work with inheritance #40

Open
ZebulanStanphill opened this issue Feb 6, 2025 · 1 comment
Open

Make #[MustUseResult] work with inheritance #40

ZebulanStanphill opened this issue Feb 6, 2025 · 1 comment
Assignees

Comments

@ZebulanStanphill
Copy link
Contributor

I have repeatedly run into situations where I want to declare an interface method as requiring the result to be used, but currently, the #[MustUseResult] attribute is not inherited, so I have to place the attribute on every implementation of the method.

Use-cases include nearly every method where the attribute would normally be used, where such method is originally defined on an interface, abstract class, or parent class.

Perhaps, for the rare case where an overriding method differs from its parent in that its return value is probably ignorable, it might make sense to add an optional parameter to the attribute to flip the behavior e.g. #[MustUseResult(false)]. I would not consider this essential, however.

See also #29, which is basically this issue but for the #[Friend] attribute instead.

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

No branches or pull requests

2 participants