mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Expect the test to panic by catching the unwind
This commit is contained in:
parent
ad7a1ed8cc
commit
ac8cb8ce3b
2 changed files with 15 additions and 5 deletions
|
@ -1528,7 +1528,12 @@ unsafe impl Storage for InlineStorage {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn gat_crash_3() {
|
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);
|
cov_mark::check!(ignore_gats);
|
||||||
|
std::panic::catch_unwind(|| {
|
||||||
check_no_mismatches(
|
check_no_mismatches(
|
||||||
r#"
|
r#"
|
||||||
trait Collection {
|
trait Collection {
|
||||||
|
@ -1545,6 +1550,8 @@ impl<T, const N: usize> Collection for ConstGen<T, N> {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
})
|
||||||
|
.expect_err("must panic");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -183,9 +183,12 @@ pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics {
|
||||||
parent_params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_)));
|
parent_params.iter().any(|(_, x)| matches!(x, TypeOrConstParamData::ConstParamData(_)));
|
||||||
return if has_consts || parent_has_consts {
|
return if has_consts || parent_has_consts {
|
||||||
// XXX: treat const generic associated types as not existing to avoid crashes
|
// XXX: treat const generic associated types as not existing to avoid crashes
|
||||||
// (#11769, #12193)
|
// (#11769)
|
||||||
// Note: also crashes when the parent has const generics (also even if the GAT
|
//
|
||||||
|
// 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.
|
// 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
|
// Chalk expects the inner associated type's parameters to come
|
||||||
// *before*, not after the trait's generics as we've always done it.
|
// *before*, not after the trait's generics as we've always done it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue