Skip to content

Commit 9a5f3b6

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#120864
2 parents 1157dc5 + e9cda9b commit 9a5f3b6

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
740740
});
741741

742742
// We're done if we found errors, but we already emitted them.
743-
if let Some(reported) = reported {
744-
assert!(errors.is_empty());
743+
if let Some(reported) = reported
744+
&& errors.is_empty()
745+
{
745746
return reported;
746747
}
747748
assert!(!errors.is_empty());

tests/ui/typeck/cyclic_type_ice.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn thing() {
2+
let f = |_, _| ();
3+
f(f); //~ ERROR: closure/coroutine type that references itself
4+
//~^ ERROR: this function takes 2 arguments but 1 argument was supplied
5+
}
6+
7+
fn main() {}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0644]: closure/coroutine type that references itself
2+
--> $DIR/cyclic_type_ice.rs:3:7
3+
|
4+
LL | f(f);
5+
| ^ cyclic type of infinite size
6+
|
7+
= note: closures cannot capture themselves or take themselves as argument;
8+
this error may be the result of a recent compiler bug-fix,
9+
see issue #46062 <https://github.com/rust-lang/rust/issues/46062>
10+
for more information
11+
12+
error[E0057]: this function takes 2 arguments but 1 argument was supplied
13+
--> $DIR/cyclic_type_ice.rs:3:5
14+
|
15+
LL | f(f);
16+
| ^--- an argument is missing
17+
|
18+
note: closure defined here
19+
--> $DIR/cyclic_type_ice.rs:2:13
20+
|
21+
LL | let f = |_, _| ();
22+
| ^^^^^^
23+
help: provide the argument
24+
|
25+
LL | f(/* */, /* */);
26+
| ~~~~~~~~~~~~~~~~
27+
28+
error: aborting due to 2 previous errors
29+
30+
Some errors have detailed explanations: E0057, E0644.
31+
For more information about an error, try `rustc --explain E0057`.

0 commit comments

Comments
 (0)