Add new pattern_complexity
attribute to add possibility to limit and check recursion in pattern matching
This commit is contained in:
parent
5257aee7dd
commit
be31b6b6cd
8 changed files with 56 additions and 6 deletions
|
@ -895,6 +895,11 @@ impl<'p, 'tcx: 'p> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
|
|||
errors::OverlappingRangeEndpoints { overlap: overlaps, range: pat_span },
|
||||
);
|
||||
}
|
||||
|
||||
fn complexity_exceeded(&self) -> Result<(), Self::Error> {
|
||||
let span = self.whole_match_span.unwrap_or(self.scrut_span);
|
||||
Err(self.tcx.dcx().span_err(span, "reached pattern complexity limit"))
|
||||
}
|
||||
}
|
||||
|
||||
/// Recursively expand this pattern into its subpatterns. Only useful for or-patterns.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue