diff options
| author | Dominik Gschwind <dominik.gschwind99@gmail.com> | 2022-08-21 22:48:53 +0200 |
|---|---|---|
| committer | Dominik Gschwind <dominik.gschwind99@gmail.com> | 2022-08-21 22:48:53 +0200 |
| commit | ac8cb8ce3b81b4f4559809a3aec50cb0799c126f (patch) | |
| tree | 9ae12d629dbd49378c2c40cac91ca1154d3e7b81 | |
| parent | ad7a1ed8cc9ba44c6a294317a2289a0b6fd75219 (diff) | |
| download | rust-ac8cb8ce3b81b4f4559809a3aec50cb0799c126f.tar.gz rust-ac8cb8ce3b81b4f4559809a3aec50cb0799c126f.zip | |
Expect the test to panic by catching the unwind
| -rw-r--r-- | crates/hir-ty/src/tests/regression.rs | 13 | ||||
| -rw-r--r-- | crates/hir-ty/src/utils.rs | 7 |
2 files changed, 15 insertions, 5 deletions
diff --git a/crates/hir-ty/src/tests/regression.rs b/crates/hir-ty/src/tests/regression.rs index 9b64fccccd2..582e2338efe 100644 --- a/crates/hir-ty/src/tests/regression.rs +++ b/crates/hir-ty/src/tests/regression.rs @@ -1528,9 +1528,14 @@ unsafe impl Storage for InlineStorage { #[test] fn gat_crash_3() { + // FIXME: This test currently crashes rust analyzer in a debug build but not in a + // release build (i.e. for the user). With the assumption that tests will always be run + // in debug mode, we catch the unwind and expect that it panicked. See the + // [`crate::utils::generics`] function for more information. cov_mark::check!(ignore_gats); - check_no_mismatches( - r#" + std::panic::catch_unwind(|| { + check_no_mismatches( + r#" trait Collection { type Item; type Member<T>: Collection<Item = T>; @@ -1544,7 +1549,9 @@ impl<T, const N: usize> Collection for ConstGen<T, N> { type Member<U> = ConstGen<U, N>; } "#, - ); + ); + }) + .expect_err("must panic"); } #[test] diff --git a/crates/hir-ty/src/utils.rs b/crates/hir-ty/src/utils.rs index bdb9ade9c85..d6638db0285 100644 --- a/crates/hir-ty/src/utils.rs +++ b/crates/hir-ty/src/utils.rs @@ -183,9 +183,12 @@ pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics { parent_params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_))); return if has_consts || parent_has_consts { // XXX: treat const generic associated types as not existing to avoid crashes - // (#11769, #12193) - // Note: also crashes when the parent has const generics (also even if the GAT + // (#11769) + // + // Note: Also crashes when the parent has const generics (also even if the GAT // doesn't use them), see `tests::regression::gat_crash_3` for an example. + // Avoids that by disabling GATs when the parent (i.e. `impl` block) has + // const generics (#12193). // // Chalk expects the inner associated type's parameters to come // *before*, not after the trait's generics as we've always done it. |
