Skip to content

Make #[MustUseResult] work with inheritance #40

Open
@ZebulanStanphill

Description

@ZebulanStanphill

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions