diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-24 10:41:34 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-24 10:41:34 +0100 |
| commit | 56ea366763b5fbac9ded4e0bdab7bd0fe1cb75b2 (patch) | |
| tree | 2c99565e6ddac8d988b8595b543d0c3f1f68d31b | |
| parent | 5e0d8c3b6261db13d64d5f6aa43c7088876fbb20 (diff) | |
| download | rust-56ea366763b5fbac9ded4e0bdab7bd0fe1cb75b2.tar.gz rust-56ea366763b5fbac9ded4e0bdab7bd0fe1cb75b2.zip | |
add test for Failed to normalize closure with TAIT #109020
Fixes #109020
| -rw-r--r-- | tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs new file mode 100644 index 00000000000..c5ee46024f9 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs @@ -0,0 +1,41 @@ +// ICE Failed to normalize closure with TAIT +// issue: rust-lang/rust#109020 +//@ check-pass + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + +type WithEmplacableForFn<'a> = impl EmplacableFn + 'a; + +fn with_emplacable_for<'a, F, R>(mut f: F) -> R +where + F: for<'b> FnMut(Emplacable<WithEmplacableForFn<'b>>) -> R, +{ + fn with_emplacable_for_inner<'a, R>( + _: &'a (), + _: &mut dyn FnMut(Emplacable<WithEmplacableForFn<'a>>) -> R, + ) -> R { + fn _constrain(_: &mut ()) -> WithEmplacableForFn<'_> { + () + } + loop {} + } + + with_emplacable_for_inner(&(), &mut f) +} + +trait EmplacableFn {} + +impl EmplacableFn for () {} + +struct Emplacable<F> +where + F: EmplacableFn, +{ + phantom: PhantomData<F>, +} + +fn main() { + with_emplacable_for(|_| {}); +} |
