Avoid invoking ignored_unit_patterns in macro definition

This commit is contained in:
koka 2023-10-03 20:36:35 +09:00
parent 81400e2db8
commit e465264d47
No known key found for this signature in database
GPG key ID: A5917A40697774CD
5 changed files with 68 additions and 6 deletions

View file

@ -37,6 +37,10 @@ declare_lint_pass!(IgnoredUnitPatterns => [IGNORED_UNIT_PATTERNS]);
impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns {
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx hir::Pat<'tcx>) {
if pat.span.from_expansion() {
return;
}
match cx.tcx.hir().get_parent(pat.hir_id) {
Node::Param(param) if matches!(cx.tcx.hir().get_parent(param.hir_id), Node::Item(_)) => {
// Ignore function parameters