2. Save the file.
3. You'll be shown the following diagnostics:
![image](https://github.com/rust-lang/rust-enhanced/assets/38900226/b11c5246-d99f-4a9e-a135-7878ccc359de)
As pointed out by the white arrow I drew, there's a message that says "in this macro invocation", but there are no explicit macros.
Cargo's output:
error[E0277]: expected a Fn<()> closure, found ()
--> src/main.rs:1:11
1
fn f() -> impl Fn() {}
^^^^^^^^^ expected an Fn<()> closure, found ()
= help: the trait Fn<()> is not implemented for ()
= note: wrap the () in a closure with no arguments: || { /* code */ }
Output of `cargo check --message-format json`:
<details>
<summary>Expand me</summary>
```json
{"reason":"compiler-artifact","package_id":"memchr 2.6.2 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/memchr-2.6.2/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"memchr","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/memchr-2.6.2/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["alloc","default","std"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libmemchr-8693cb7cad6ee538.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"aho-corasick 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aho-corasick-1.0.5/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"aho_corasick","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aho-corasick-1.0.5/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","perf-literal","std"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libaho_corasick-6106a3715930b32a.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"regex-syntax 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-syntax-0.7.5/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"regex-syntax","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-syntax-0.7.5/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","std","unicode","unicode-age","unicode-bool","unicode-case","unicode-gencat","unicode-perl","unicode-script","unicode-segment"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libregex_syntax-4b51dc2ea8d1dac9.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"regex-automata 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-automata-0.3.7/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"regex-automata","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-automata-0.3.7/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["alloc","dfa-onepass","hybrid","meta","nfa-backtrack","nfa-pikevm","nfa-thompson","perf-inline","perf-literal","perf-literal-multisubstring","perf-literal-substring","std","syntax","unicode","unicode-age","unicode-bool","unicode-case","unicode-gencat","unicode-perl","unicode-script","unicode-segment","unicode-word-boundary"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libregex_automata-5428088d8e41f6fb.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"regex 1.9.4 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-1.9.4/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"regex","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-1.9.4/src/lib.rs","edition":"2021","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default","perf","perf-backtrack","perf-cache","perf-dfa","perf-inline","perf-literal","perf-onepass","std","unicode","unicode-age","unicode-bool","unicode-case","unicode-gencat","unicode-perl","unicode-script","unicode-segment"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libregex-9b330358452c3423.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytecount-0.5.1/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"bytecount","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytecount-0.5.1/src/lib.rs","edition":"2015","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libbytecount-21af24debbd45e15.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"unicode-segmentation 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/unicode-segmentation-1.10.1/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"unicode-segmentation","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/unicode-segmentation-1.10.1/src/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libunicode_segmentation-3834957449bebce6.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-artifact","package_id":"xi-rope 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)","manifest_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xi-rope-0.3.0/Cargo.toml","target":{"kind":["lib"],"crate_types":["lib"],"name":"xi-rope","src_path":"/home/marcospb19/.cargo/registry/src/index.crates.io-6f17d22bba15001f/xi-rope-0.3.0/src/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":["default"],"filenames":["/home/marcospb19/play/rust/target/debug/deps/libxi_rope-46ff7d7f931609cf.rmeta"],"executable":null,"fresh":true}
{"reason":"compiler-message","package_id":"rust 0.1.0 (path+file:///home/marcospb19/play/rust)","manifest_path":"/home/marcospb19/play/rust/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"rust","src_path":"/home/marcospb19/play/rust/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error[E0277]: expected a `Fn<()>` closure, found `()`\n --> src/main.rs:1:11\n |\n1 | fn f() -> impl Fn() {}\n | ^^^^^^^^^ expected an `Fn<()>` closure, found `()`\n |\n = help: the trait `Fn<()>` is not implemented for `()`\n = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`\n\n","children":[{"children":[],"code":null,"level":"help","message":"the trait `Fn<()>` is not implemented for `()`","rendered":null,"spans":[]},{"children":[],"code":null,"level":"note","message":"wrap the `()` in a closure with no arguments: `|| { /* code */ }`","rendered":null,"spans":[]}],"code":{"code":"E0277","explanation":"You tried to use a type which doesn't implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n foo.bar();\n}\n\nfn main() {\n // we now call the method with the i32 type, which doesn't implement\n // the Foo trait\n some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n foo.bar(); // we can now use this method since i32 implements the\n // Foo trait\n}\n\nfn main() {\n some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n // implemented for the type `T`\n}\n\nfn main() {\n // We now call the method with the i32 type,\n // which *does* implement the Debug trait.\n some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n println!(\"{:?}\", foo);\n}\n\nfn main() {\n // Calling the method is still fine, as i32 implements Debug.\n some_func(5i32);\n\n // This would fail to compile now:\n // struct WithoutDebug;\n // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","message":"expected a `Fn<()>` closure, found `()`","spans":[{"byte_end":19,"byte_start":10,"column_end":20,"column_start":11,"expansion":{"def_site_span":{"byte_end":0,"byte_start":0,"column_end":1,"column_start":1,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":1,"line_start":1,"suggested_replacement":null,"suggestion_applicability":null,"text":[]},"macro_decl_name":"desugaring of `impl Trait`","span":{"byte_end":19,"byte_start":10,"column_end":20,"column_start":11,"expansion":null,"file_name":"src/main.rs","is_primary":false,"label":null,"line_end":1,"line_start":1,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":20,"highlight_start":11,"text":"fn f() -> impl Fn() {}"}]}},"file_name":"src/main.rs","is_primary":true,"label":"expected an `Fn<()>` closure, found `()`","line_end":1,"line_start":1,"suggested_replacement":null,"suggestion_applicability":null,"text":[{"highlight_end":20,"highlight_start":11,"text":"fn f() -> impl Fn() {}"}]}]}}
{"reason":"compiler-message","package_id":"rust 0.1.0 (path+file:///home/marcospb19/play/rust)","manifest_path":"/home/marcospb19/play/rust/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"rust","src_path":"/home/marcospb19/play/rust/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"error: aborting due to previous error\n\n","children":[],"code":null,"level":"error","message":"aborting due to previous error","spans":[]}}
{"reason":"compiler-message","package_id":"rust 0.1.0 (path+file:///home/marcospb19/play/rust)","manifest_path":"/home/marcospb19/play/rust/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"rust","src_path":"/home/marcospb19/play/rust/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"message":{"rendered":"For more information about this error, try `rustc --explain E0277`.\n","children":[],"code":null,"level":"failure-note","message":"For more information about this error, try `rustc --explain E0277`.","spans":[]}}
{"reason":"build-finished","success":false}
Sublime Text Version
Build 4155
Rust Enhanced Version
2.25.0
Operating system
Arch Linux
Steps to reproduce
fn main() {}
Fn<()>
closure, found()
--> src/main.rs:1:11Fn<()>
closure, found()
= help: the trait
Fn<()>
is not implemented for()
= note: wrap the()
in a closure with no arguments:|| { /* code */ }