give better error messages when a cycle arises

This commit is contained in:
Niko Matsakis 2017-11-17 11:13:13 -05:00
parent 5e0e8ae291
commit 27bedfa36b
9 changed files with 134 additions and 29 deletions

View file

@ -43,9 +43,6 @@ error[E0308]: mismatched types
|
41 | f = box f;
| ^^^^^ cyclic type of infinite size
|
= note: expected type `_`
found type `std::boxed::Box<_>`
error[E0308]: mismatched types
--> $DIR/coerce-suggestions.rs:48:9

View file

@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that unboxed closures cannot capture their own type.
//
// Also regression test for issue #21410.
fn g<F>(_: F) where F: FnOnce(Option<F>) {}
fn main() {
g(|_| { }); //~ ERROR mismatched types
g(|_| { });
}

View file

@ -0,0 +1,12 @@
error[E0644]: closure/generator type that references itself
--> $DIR/unboxed-closure-no-cyclic-sig.rs:18:7
|
18 | g(|_| { });
| ^^^^^^^^ cyclic type of infinite size
|
= note: closures cannot capture themselves or take themselves as argument;
this error may be the result of a recent compiler bug-fix,
see https://github.com/rust-lang/rust/issues/46062 for more details
error: aborting due to previous error