substrate icon indicating copy to clipboard operation
substrate copied to clipboard

pallet::call macro does not preserve lint attributes

Open branan opened this issue 3 years ago • 1 comments

Is there an existing issue?

  • [X] I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • [X] This is not a support question.

Description of bug

The pallet procedural macro does not preserve any attributes on fns in a #[pallet::call] impl. This means that it is impossible to add a #[allow(lint)] or #[deny(lint)] attribute to a given call and have it be known/respected by the compiler.

It may make sense to filter unknown attributes from call fns in most cases, since they could be other procedural macros which could change things in ways that would break the expected contract of a call. However, I think that for developer ergonomics the lint macros should still be passed on to the compiler.

I believe that preserving allow, deny, and warn attributes is a fairly straightforward addition to the proc macro.

The workaround is to just use a global #![allow(lint)] for the entire crate, but that is less than ideal as it can mask new instances of a warning that a developer may care about.

Steps to reproduce

No response

branan avatar Sep 19 '22 21:09 branan

@sam0x17

kianenigma avatar Sep 20 '22 13:09 kianenigma