diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-21 17:46:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-21 17:46:48 +0100 |
| commit | 8d1262118128b0d235f0b0c26f063082f4fc6916 (patch) | |
| tree | 88e51f7b95293579e13fec63ba313ec9c1db0fbe /compiler/rustc_pattern_analysis/src/rustc.rs | |
| parent | 2e41425de635480bac45c554d5fbdddc34a62bd1 (diff) | |
| parent | d697dd44d18fbab9a28032d7b1ceba829600637e (diff) | |
| download | rust-8d1262118128b0d235f0b0c26f063082f4fc6916.tar.gz rust-8d1262118128b0d235f0b0c26f063082f4fc6916.zip | |
Rollup merge of #122644 - Nadrieril:complexity-tests, r=compiler-errors
pattern analysis: add a custom test harness There are two features of the pattern analysis code that are hard to test: the newly-added pattern complexity limit, and the computation of arm intersections. This PR adds some crate-specific tests for that, including an unmaintainable but pretty macro to help construct patterns. r? `````@compiler-errors`````
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/rustc.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 4cb306b1950..ae3eabe1745 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -880,13 +880,14 @@ impl<'p, 'tcx: 'p> PatCx for RustcPatCtxt<'p, 'tcx> { fn write_variant_name( f: &mut fmt::Formatter<'_>, - pat: &crate::pat::DeconstructedPat<Self>, + ctor: &crate::constructor::Constructor<Self>, + ty: &Self::Ty, ) -> fmt::Result { - if let ty::Adt(adt, _) = pat.ty().kind() { + if let ty::Adt(adt, _) = ty.kind() { if adt.is_box() { write!(f, "Box")? } else { - let variant = adt.variant(Self::variant_index_for_adt(pat.ctor(), *adt)); + let variant = adt.variant(Self::variant_index_for_adt(ctor, *adt)); write!(f, "{}", variant.name)?; } } |
