From 30bcf2a6b5b77de43b7bcb98dde3d5b6feb0c3f6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 7 Feb 2025 10:57:14 +1100 Subject: [PATCH 1/2] Add `pattern_complexity_limit` to `Limits`. It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`. --- crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs index 2b854310a1..3312da470c 100644 --- a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs +++ b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs @@ -95,7 +95,7 @@ impl<'db> MatchCheckCtx<'db> { let place_validity = PlaceValidity::from_bool(known_valid_scrutinee.unwrap_or(true)); // Measured to take ~100ms on modern hardware. - let complexity_limit = Some(500000); + let complexity_limit = 500000; compute_match_usefulness(self, arms, scrut_ty, place_validity, complexity_limit) } From 610f4c4046a6d6c7a3fe09ad5d13c00aba146ef7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 7 Feb 2025 15:58:00 +1100 Subject: [PATCH 2/2] Rename `pattern_complexity` attr as `pattern_complexity_limit`. For consistency with `recursion_limit`, `move_size_limit`, and `type_length_limit`. --- crates/ide-db/src/generated/lints.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ide-db/src/generated/lints.rs b/crates/ide-db/src/generated/lints.rs index 14af22c319..ed9d6c6750 100644 --- a/crates/ide-db/src/generated/lints.rs +++ b/crates/ide-db/src/generated/lints.rs @@ -9107,8 +9107,8 @@ The tracking issue for this feature is: [#27721] deny_since: None, }, Lint { - label: "pattern_complexity", - description: r##"# `pattern_complexity` + label: "pattern_complexity_limit", + description: r##"# `pattern_complexity_limit` This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use.