You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a user-defined type to make intent and usage clearer:
typeBasicBlock = Vec<Statement>;
I do need/want the type to be a Vec. Unfortunately, the ptr_arg warning is issued on the resolved type, rather than taking the user-defined type into account. E.g., I have a function signature like the following:
Since this method doesn't really require a Vec and could get away using a slice, clippy issues the following warning:
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/canon.rs:123:20
|
123 | block: &BasicBlock,
| ^^^^^^^^^^^
|
= note: #[warn(clippy::ptr_arg)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
In this case, however, I really do want to specify the argument type as a BasicBlock, which means it is essentially a Vec. I could define it as &[Statement] to pacify the warning, but I would lose some of the clarity that the user-defined type provides. Perhaps the real answer is to rework the type entirely, but there are other contexts where I need it to work like a Vec so I'd be trading off something else.
Generally, the warning is quite is useful so I don't want to disable it as it may apply to other arguments in the function. If possible, though, I think it should silence itself when encountering a user-defined type.
The text was updated successfully, but these errors were encountered:
I have a user-defined type to make intent and usage clearer:
I do need/want the type to be a
Vec
. Unfortunately, theptr_arg
warning is issued on the resolved type, rather than taking the user-defined type into account. E.g., I have a function signature like the following:Since this method doesn't really require a
Vec
and could get away using a slice, clippy issues the following warning:In this case, however, I really do want to specify the argument type as a
BasicBlock
, which means it is essentially aVec
. I could define it as&[Statement]
to pacify the warning, but I would lose some of the clarity that the user-defined type provides. Perhaps the real answer is to rework the type entirely, but there are other contexts where I need it to work like aVec
so I'd be trading off something else.Generally, the warning is quite is useful so I don't want to disable it as it may apply to other arguments in the function. If possible, though, I think it should silence itself when encountering a user-defined type.
The text was updated successfully, but these errors were encountered: