Skip to content

Commit 7556f74

Browse files
committed
Remove hack
1 parent 78977cd commit 7556f74

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

crates/hir-ty/src/tests/regression.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,6 @@ fn regression_11688_4() {
14881488

14891489
#[test]
14901490
fn gat_crash_1() {
1491-
cov_mark::check!(ignore_gats);
14921491
check_no_mismatches(
14931492
r#"
14941493
trait ATrait {}
@@ -1527,30 +1526,22 @@ unsafe impl Storage for InlineStorage {
15271526

15281527
#[test]
15291528
fn gat_crash_3() {
1530-
// FIXME: This test currently crashes rust analyzer in a debug build but not in a
1531-
// release build (i.e. for the user). With the assumption that tests will always be run
1532-
// in debug mode, we catch the unwind and expect that it panicked. See the
1533-
// [`crate::utils::generics`] function for more information.
1534-
cov_mark::check!(ignore_gats);
1535-
std::panic::catch_unwind(|| {
1536-
check_no_mismatches(
1537-
r#"
1529+
check_no_mismatches(
1530+
r#"
15381531
trait Collection {
1539-
type Item;
1540-
type Member<T>: Collection<Item = T>;
1541-
fn add(&mut self, value: Self::Item) -> Result<(), Self::Error>;
1532+
type Item;
1533+
type Member<T>: Collection<Item = T>;
1534+
fn add(&mut self, value: Self::Item) -> Result<(), Self::Error>;
15421535
}
15431536
struct ConstGen<T, const N: usize> {
1544-
data: [T; N],
1537+
data: [T; N],
15451538
}
15461539
impl<T, const N: usize> Collection for ConstGen<T, N> {
1547-
type Item = T;
1548-
type Member<U> = ConstGen<U, N>;
1540+
type Item = T;
1541+
type Member<U> = ConstGen<U, N>;
15491542
}
1550-
"#,
1551-
);
1552-
})
1553-
.expect_err("must panic");
1543+
"#,
1544+
);
15541545
}
15551546

15561547
#[test]

crates/hir-ty/src/utils.rs

-25
Original file line numberDiff line numberDiff line change
@@ -173,31 +173,6 @@ pub(super) fn associated_type_by_name_including_super_traits(
173173

174174
pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics {
175175
let parent_generics = parent_generic_def(db, def).map(|def| Box::new(generics(db, def)));
176-
if parent_generics.is_some() && matches!(def, GenericDefId::TypeAliasId(_)) {
177-
let params = db.generic_params(def);
178-
let parent_params = &parent_generics.as_ref().unwrap().params;
179-
let has_consts =
180-
params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_)));
181-
let parent_has_consts =
182-
parent_params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_)));
183-
return if has_consts || parent_has_consts {
184-
// XXX: treat const generic associated types as not existing to avoid crashes
185-
// (#11769)
186-
//
187-
// Note: Also crashes when the parent has const generics (also even if the GAT
188-
// doesn't use them), see `tests::regression::gat_crash_3` for an example.
189-
// Avoids that by disabling GATs when the parent (i.e. `impl` block) has
190-
// const generics (#12193).
191-
//
192-
// Chalk expects the inner associated type's parameters to come
193-
// *before*, not after the trait's generics as we've always done it.
194-
// Adapting to this requires a larger refactoring
195-
cov_mark::hit!(ignore_gats);
196-
Generics { def, params: Interned::new(Default::default()), parent_generics }
197-
} else {
198-
Generics { def, params, parent_generics }
199-
};
200-
}
201176
Generics { def, params: db.generic_params(def), parent_generics }
202177
}
203178

0 commit comments

Comments
 (0)