diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs new file mode 100644 index 0000000000000..7ebc348996f5e --- /dev/null +++ b/src/test/ui/impl-trait/issue-55608-captures-empty-region.rs @@ -0,0 +1,22 @@ +// This used to ICE because it creates an `impl Trait` that captures a +// hidden empty region. + +#![feature(conservative_impl_trait)] + +fn server() -> impl FilterBase2 { //~ ERROR [E0700] + segment2(|| { loop { } }).map2(|| "") +} + +trait FilterBase2 { + fn map2(self, _fn: F) -> Map2 where Self: Sized { loop { } } +} + +struct Map2 { _func: F } + +impl FilterBase2 for Map2 { } + +fn segment2(_fn: F) -> Map2 where F: Fn() -> Result<(), ()> { + loop { } +} + +fn main() { server(); } diff --git a/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr b/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr new file mode 100644 index 0000000000000..d1f147834d2ef --- /dev/null +++ b/src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr @@ -0,0 +1,11 @@ +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/issue-55608-captures-empty-region.rs:6:16 + | +LL | fn server() -> impl FilterBase2 { //~ ERROR [E0700] + | ^^^^^^^^^^^^^^^^ + | + = note: hidden type `Map2<[closure@$DIR/issue-55608-captures-empty-region.rs:7:36: 7:41]>` captures an empty lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`.