diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-01-17 17:19:23 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-01-17 18:01:17 -0500 |
| commit | 072c3daa4cb6e1a8958ad9d61ebc7e062d570eac (patch) | |
| tree | 47756b686d36eba04192cefe99f232165a6a5b00 /src/test | |
| parent | 0f9c784751434c70ddd6719ccda6817c819126f9 (diff) | |
track recursion limit when expanding existential impl trait
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs b/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs new file mode 100644 index 00000000000..abde9689bd6 --- /dev/null +++ b/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempts to construct infinite types via impl trait fail +// in a graceful way. +// +// Regression test for #38064. + +// error-pattern:overflow evaluating the requirement `impl Quux` + +#![feature(conservative_impl_trait)] + +trait Quux {} + +fn foo() -> impl Quux { + struct Foo<T>(T); + impl<T> Quux for Foo<T> {} + Foo(bar()) +} + +fn bar() -> impl Quux { + struct Bar<T>(T); + impl<T> Quux for Bar<T> {} + Bar(foo()) +} + +// effectively: +// struct Foo(Bar); +// struct Bar(Foo); +// should produce an error about infinite size + +fn main() { foo(); } |
