Rollup merge of #121032 - oli-obk:cyclic_type_ice, r=cjgillot
Continue reporting remaining errors instead of silently dropping them I was too eager to add assertions in https://github.com/rust-lang/rust/pull/120342/files#diff-593003090e0fb5c21f31413ce5feb506e235ec33c4775da88b853980429b9ff1R741 fixes #120864
This commit is contained in:
commit
25bba60e9d
@ -740,8 +740,9 @@ fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool {
|
||||
});
|
||||
|
||||
// We're done if we found errors, but we already emitted them.
|
||||
if let Some(reported) = reported {
|
||||
assert!(errors.is_empty());
|
||||
if let Some(reported) = reported
|
||||
&& errors.is_empty()
|
||||
{
|
||||
return reported;
|
||||
}
|
||||
assert!(!errors.is_empty());
|
||||
|
7
tests/ui/typeck/cyclic_type_ice.rs
Normal file
7
tests/ui/typeck/cyclic_type_ice.rs
Normal file
@ -0,0 +1,7 @@
|
||||
fn thing() {
|
||||
let f = |_, _| ();
|
||||
f(f); //~ ERROR: closure/coroutine type that references itself
|
||||
//~^ ERROR: this function takes 2 arguments but 1 argument was supplied
|
||||
}
|
||||
|
||||
fn main() {}
|
31
tests/ui/typeck/cyclic_type_ice.stderr
Normal file
31
tests/ui/typeck/cyclic_type_ice.stderr
Normal file
@ -0,0 +1,31 @@
|
||||
error[E0644]: closure/coroutine type that references itself
|
||||
--> $DIR/cyclic_type_ice.rs:3:7
|
||||
|
|
||||
LL | f(f);
|
||||
| ^ 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 issue #46062 <https://github.com/rust-lang/rust/issues/46062>
|
||||
for more information
|
||||
|
||||
error[E0057]: this function takes 2 arguments but 1 argument was supplied
|
||||
--> $DIR/cyclic_type_ice.rs:3:5
|
||||
|
|
||||
LL | f(f);
|
||||
| ^--- an argument is missing
|
||||
|
|
||||
note: closure defined here
|
||||
--> $DIR/cyclic_type_ice.rs:2:13
|
||||
|
|
||||
LL | let f = |_, _| ();
|
||||
| ^^^^^^
|
||||
help: provide the argument
|
||||
|
|
||||
LL | f(/* */, /* */);
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0057, E0644.
|
||||
For more information about an error, try `rustc --explain E0057`.
|
Loading…
Reference in New Issue
Block a user