5 matches across 1 files for func main lang:Markdown path:compiler/rustc_error_codes/src/error_codes/E0562.md lang:Markdown
snippet_mode: auto · sorted by relevance
compiler/rustc_error_codes/src/error_codes/E0562.md MARKDOWN 5 matches view file →
1`impl Trait` is only allowed as a function return and argument type.
2
3Erroneous code example:
· · ·
4
5```compile_fail,E0562
6fn main() {
7 let count_to_ten: impl Iterator<Item=usize> = 0..10;
8 // error: `impl Trait` not allowed outside of function and inherent method
· · ·
8 // error: `impl Trait` not allowed outside of function and inherent method
9 // return types
10 for i in count_to_ten {
· · ·
14```
15
16Make sure `impl Trait` appears in a function signature.
17
18```
· · ·
21}
22
23fn main() {
24 for i in count_to_n(10) { // ok!
25 println!("{}", i);
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.