Closed
Description
Code
type Foo = Bar;
fn check(f: impl FnOnce(Foo), val: Foo) {
f(val);
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0412]: cannot find type `Bar` in this scope
--> src/lib.rs:1:12
|
1 | type Foo = Bar;
| ^^^ not found in this scope
error[E0618]: expected function, found `impl FnOnce(Foo)`
--> src/lib.rs:4:5
|
3 | fn check(f: impl FnOnce(Foo), val: Foo) {
| - `f` has type `impl FnOnce(Foo)`
4 | f(val);
| ^-----
| |
| call expression requires function
Some errors have detailed explanations: E0412, E0618.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `playground` (lib) due to 2 previous errors
Desired output
Compiling playground v0.0.1 (/playground)
error[E0412]: cannot find type `Bar` in this scope
--> src/lib.rs:1:12
|
1 | type Foo = Bar;
| ^^^ not found in this scope
Some errors have detailed explanations: E0412, E0618.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `playground` (lib) due to 2 previous errors
Rationale and extra context
Saying that impl FnOnce()
is not a function is confusing and distracts from the real issue. I think compiler should either report nothing on the line with the call or say something about unknown types in function signature.
Other cases
type Foo = Bar;
// Doesn’t exhibit this issue
fn check(f: impl FnOnce() -> Foo) {
f();
}
Anything else?
No response