1
Fork 0

Don't gate the feature twice

This commit is contained in:
Nadrieril 2023-12-12 14:52:05 +01:00
parent e274372689
commit 19e0c984d3
4 changed files with 31 additions and 51 deletions

View file

@ -676,6 +676,19 @@ impl Pat {
});
could_be_never_pattern
}
/// Whether this contains a `!` pattern. This in particular means that a feature gate error will
/// be raised if the feature is off. Used to avoid gating the feature twice.
pub fn contains_never_pattern(&self) -> bool {
let mut contains_never_pattern = false;
self.walk(&mut |pat| {
if matches!(pat.kind, PatKind::Never) {
contains_never_pattern = true;
}
true
});
contains_never_pattern
}
}
/// A single field in a struct pattern.