diff options
| author | Ryo Yoshida <low.ryoshida@gmail.com> | 2022-10-02 21:13:30 +0900 |
|---|---|---|
| committer | Ryo Yoshida <low.ryoshida@gmail.com> | 2022-10-03 02:40:12 +0900 |
| commit | 7556f74b1691276d12e4cf96eb2df8f74836cdc1 (patch) | |
| tree | 42ae494194288eb5a1132f571c3ad0c142d1005b | |
| parent | 78977cd86cd17e008f94f8579d6a5aaebe46e69b (diff) | |
| download | rust-7556f74b1691276d12e4cf96eb2df8f74836cdc1.tar.gz rust-7556f74b1691276d12e4cf96eb2df8f74836cdc1.zip | |
Remove hack
| -rw-r--r-- | crates/hir-ty/src/tests/regression.rs | 29 | ||||
| -rw-r--r-- | crates/hir-ty/src/utils.rs | 25 |
2 files changed, 10 insertions, 44 deletions
diff --git a/crates/hir-ty/src/tests/regression.rs b/crates/hir-ty/src/tests/regression.rs index 47cc3341e70..16ba3dd6e3c 100644 --- a/crates/hir-ty/src/tests/regression.rs +++ b/crates/hir-ty/src/tests/regression.rs @@ -1488,7 +1488,6 @@ fn regression_11688_4() { #[test] fn gat_crash_1() { - cov_mark::check!(ignore_gats); check_no_mismatches( r#" trait ATrait {} @@ -1527,30 +1526,22 @@ 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); - std::panic::catch_unwind(|| { - check_no_mismatches( - r#" + check_no_mismatches( + r#" trait Collection { - type Item; - type Member<T>: Collection<Item = T>; - fn add(&mut self, value: Self::Item) -> Result<(), Self::Error>; +type Item; +type Member<T>: Collection<Item = T>; +fn add(&mut self, value: Self::Item) -> Result<(), Self::Error>; } struct ConstGen<T, const N: usize> { - data: [T; N], +data: [T; N], } impl<T, const N: usize> Collection for ConstGen<T, N> { - type Item = T; - type Member<U> = ConstGen<U, N>; +type Item = T; +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 adcf142bc35..e54bcb421a2 100644 --- a/crates/hir-ty/src/utils.rs +++ b/crates/hir-ty/src/utils.rs @@ -173,31 +173,6 @@ pub(super) fn associated_type_by_name_including_super_traits( pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics { let parent_generics = parent_generic_def(db, def).map(|def| Box::new(generics(db, def))); - if parent_generics.is_some() && matches!(def, GenericDefId::TypeAliasId(_)) { - let params = db.generic_params(def); - let parent_params = &parent_generics.as_ref().unwrap().params; - let has_consts = - params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_))); - let parent_has_consts = - 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) - // - // 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. - // Adapting to this requires a larger refactoring - cov_mark::hit!(ignore_gats); - Generics { def, params: Interned::new(Default::default()), parent_generics } - } else { - Generics { def, params, parent_generics } - }; - } Generics { def, params: db.generic_params(def), parent_generics } } |
