Skip to content

Continue reporting remaining errors instead of silently dropping them #121032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
});

// 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());
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/typeck/cyclic_type_ice.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 31 additions & 0 deletions tests/ui/typeck/cyclic_type_ice.stderr
Original file line number Diff line number Diff line change
@@ -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`.