fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71868 - Mark-Simulacrum:stable-1.43.1, r=pietroalbini8d69840ab92

1.43.1
11.6 KiB420 linesraw
1{
2  "message": "cannot find type `Iter` in this scope",
3  "code": {
4    "code": "E0412",
5    "explanation": "The type name used is not in scope.
6
7Erroneous code examples:
8
9```compile_fail,E0412
10impl Something {} // error: type name `Something` is not in scope
11
12// or:
13
14trait Foo {
15    fn bar(N); // error: type name `N` is not in scope
16}
17
18// or:
19
20fn foo(x: T) {} // type name `T` is not in scope
21```
22
23To fix this error, please verify you didn't misspell the type name, you did
24declare it or imported it into the scope. Examples:
25
26```
27struct Something;
28
29impl Something {} // ok!
30
31// or:
32
33trait Foo {
34    type N;
35
36    fn bar(_: Self::N); // ok!
37}
38
39// or:
40
41fn foo<T>(x: T) {} // ok!
42```
43
44Another case that causes this error is when a type is imported into a parent
45module. To fix this, you can follow the suggestion and use File directly or
46`use super::File;` which will import the types from the parent namespace. An
47example that causes this error is below:
48
49```compile_fail,E0412
50use std::fs::File;
51
52mod foo {
53    fn some_function(f: File) {}
54}
55```
56
57```
58use std::fs::File;
59
60mod foo {
61    // either
62    use super::File;
63    // or
64    // use std::fs::File;
65    fn foo(f: File) {}
66}
67# fn main() {} // don't insert it for us; that'll break imports
68```
69"
70  },
71  "level": "error",
72  "spans": [
73    {
74      "file_name": "$DIR/use_suggestion_json.rs",
75      "byte_start": 471,
76      "byte_end": 475,
77      "line_start": 12,
78      "line_end": 12,
79      "column_start": 12,
80      "column_end": 16,
81      "is_primary": true,
82      "text": [
83        {
84          "text": "    let x: Iter;",
85          "highlight_start": 12,
86          "highlight_end": 16
87        }
88      ],
89      "label": "not found in this scope",
90      "suggested_replacement": null,
91      "suggestion_applicability": null,
92      "expansion": null
93    }
94  ],
95  "children": [
96    {
97      "message": "possible candidates are found in other modules, you can import them into scope",
98      "code": null,
99      "level": "help",
100      "spans": [
101        {
102          "file_name": "$DIR/use_suggestion_json.rs",
103          "byte_start": 448,
104          "byte_end": 448,
105          "line_start": 11,
106          "line_end": 11,
107          "column_start": 1,
108          "column_end": 1,
109          "is_primary": true,
110          "text": [
111            {
112              "text": "fn main() {",
113              "highlight_start": 1,
114              "highlight_end": 1
115            }
116          ],
117          "label": null,
118          "suggested_replacement": "use std::collections::binary_heap::Iter;
119
120",
121          "suggestion_applicability": "Unspecified",
122          "expansion": null
123        },
124        {
125          "file_name": "$DIR/use_suggestion_json.rs",
126          "byte_start": 448,
127          "byte_end": 448,
128          "line_start": 11,
129          "line_end": 11,
130          "column_start": 1,
131          "column_end": 1,
132          "is_primary": true,
133          "text": [
134            {
135              "text": "fn main() {",
136              "highlight_start": 1,
137              "highlight_end": 1
138            }
139          ],
140          "label": null,
141          "suggested_replacement": "use std::collections::btree_map::Iter;
142
143",
144          "suggestion_applicability": "Unspecified",
145          "expansion": null
146        },
147        {
148          "file_name": "$DIR/use_suggestion_json.rs",
149          "byte_start": 448,
150          "byte_end": 448,
151          "line_start": 11,
152          "line_end": 11,
153          "column_start": 1,
154          "column_end": 1,
155          "is_primary": true,
156          "text": [
157            {
158              "text": "fn main() {",
159              "highlight_start": 1,
160              "highlight_end": 1
161            }
162          ],
163          "label": null,
164          "suggested_replacement": "use std::collections::btree_set::Iter;
165
166",
167          "suggestion_applicability": "Unspecified",
168          "expansion": null
169        },
170        {
171          "file_name": "$DIR/use_suggestion_json.rs",
172          "byte_start": 448,
173          "byte_end": 448,
174          "line_start": 11,
175          "line_end": 11,
176          "column_start": 1,
177          "column_end": 1,
178          "is_primary": true,
179          "text": [
180            {
181              "text": "fn main() {",
182              "highlight_start": 1,
183              "highlight_end": 1
184            }
185          ],
186          "label": null,
187          "suggested_replacement": "use std::collections::hash_map::Iter;
188
189",
190          "suggestion_applicability": "Unspecified",
191          "expansion": null
192        },
193        {
194          "file_name": "$DIR/use_suggestion_json.rs",
195          "byte_start": 448,
196          "byte_end": 448,
197          "line_start": 11,
198          "line_end": 11,
199          "column_start": 1,
200          "column_end": 1,
201          "is_primary": true,
202          "text": [
203            {
204              "text": "fn main() {",
205              "highlight_start": 1,
206              "highlight_end": 1
207            }
208          ],
209          "label": null,
210          "suggested_replacement": "use std::collections::hash_set::Iter;
211
212",
213          "suggestion_applicability": "Unspecified",
214          "expansion": null
215        },
216        {
217          "file_name": "$DIR/use_suggestion_json.rs",
218          "byte_start": 448,
219          "byte_end": 448,
220          "line_start": 11,
221          "line_end": 11,
222          "column_start": 1,
223          "column_end": 1,
224          "is_primary": true,
225          "text": [
226            {
227              "text": "fn main() {",
228              "highlight_start": 1,
229              "highlight_end": 1
230            }
231          ],
232          "label": null,
233          "suggested_replacement": "use std::collections::linked_list::Iter;
234
235",
236          "suggestion_applicability": "Unspecified",
237          "expansion": null
238        },
239        {
240          "file_name": "$DIR/use_suggestion_json.rs",
241          "byte_start": 448,
242          "byte_end": 448,
243          "line_start": 11,
244          "line_end": 11,
245          "column_start": 1,
246          "column_end": 1,
247          "is_primary": true,
248          "text": [
249            {
250              "text": "fn main() {",
251              "highlight_start": 1,
252              "highlight_end": 1
253            }
254          ],
255          "label": null,
256          "suggested_replacement": "use std::collections::vec_deque::Iter;
257
258",
259          "suggestion_applicability": "Unspecified",
260          "expansion": null
261        },
262        {
263          "file_name": "$DIR/use_suggestion_json.rs",
264          "byte_start": 448,
265          "byte_end": 448,
266          "line_start": 11,
267          "line_end": 11,
268          "column_start": 1,
269          "column_end": 1,
270          "is_primary": true,
271          "text": [
272            {
273              "text": "fn main() {",
274              "highlight_start": 1,
275              "highlight_end": 1
276            }
277          ],
278          "label": null,
279          "suggested_replacement": "use std::option::Iter;
280
281",
282          "suggestion_applicability": "Unspecified",
283          "expansion": null
284        },
285        {
286          "file_name": "$DIR/use_suggestion_json.rs",
287          "byte_start": 448,
288          "byte_end": 448,
289          "line_start": 11,
290          "line_end": 11,
291          "column_start": 1,
292          "column_end": 1,
293          "is_primary": true,
294          "text": [
295            {
296              "text": "fn main() {",
297              "highlight_start": 1,
298              "highlight_end": 1
299            }
300          ],
301          "label": null,
302          "suggested_replacement": "use std::path::Iter;
303
304",
305          "suggestion_applicability": "Unspecified",
306          "expansion": null
307        },
308        {
309          "file_name": "$DIR/use_suggestion_json.rs",
310          "byte_start": 448,
311          "byte_end": 448,
312          "line_start": 11,
313          "line_end": 11,
314          "column_start": 1,
315          "column_end": 1,
316          "is_primary": true,
317          "text": [
318            {
319              "text": "fn main() {",
320              "highlight_start": 1,
321              "highlight_end": 1
322            }
323          ],
324          "label": null,
325          "suggested_replacement": "use std::result::Iter;
326
327",
328          "suggestion_applicability": "Unspecified",
329          "expansion": null
330        },
331        {
332          "file_name": "$DIR/use_suggestion_json.rs",
333          "byte_start": 448,
334          "byte_end": 448,
335          "line_start": 11,
336          "line_end": 11,
337          "column_start": 1,
338          "column_end": 1,
339          "is_primary": true,
340          "text": [
341            {
342              "text": "fn main() {",
343              "highlight_start": 1,
344              "highlight_end": 1
345            }
346          ],
347          "label": null,
348          "suggested_replacement": "use std::slice::Iter;
349
350",
351          "suggestion_applicability": "Unspecified",
352          "expansion": null
353        },
354        {
355          "file_name": "$DIR/use_suggestion_json.rs",
356          "byte_start": 448,
357          "byte_end": 448,
358          "line_start": 11,
359          "line_end": 11,
360          "column_start": 1,
361          "column_end": 1,
362          "is_primary": true,
363          "text": [
364            {
365              "text": "fn main() {",
366              "highlight_start": 1,
367              "highlight_end": 1
368            }
369          ],
370          "label": null,
371          "suggested_replacement": "use std::sync::mpsc::Iter;
372
373",
374          "suggestion_applicability": "Unspecified",
375          "expansion": null
376        }
377      ],
378      "children": [],
379      "rendered": null
380    }
381  ],
382  "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0412]\u001b[0m\u001b[0m\u001b[1m: cannot find type `Iter` in this scope\u001b[0m
383\u001b[0m  \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m$DIR/use_suggestion_json.rs:12:12\u001b[0m
384\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
385\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m    let x: Iter;\u001b[0m
386\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m           \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m
387\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
388\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: possible candidates are found in other modules, you can import them into scope\u001b[0m
389\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
390\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::binary_heap::Iter;\u001b[0m
391\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
392\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::btree_map::Iter;\u001b[0m
393\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
394\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::btree_set::Iter;\u001b[0m
395\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
396\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0muse std::collections::hash_map::Iter;\u001b[0m
397\u001b[0m   \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
398\u001b[0m     and 8 other candidates\u001b[0m
399
400"
401}
402{
403  "message": "aborting due to previous error",
404  "code": null,
405  "level": "error",
406  "spans": [],
407  "children": [],
408  "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m
409
410"
411}
412{
413  "message": "For more information about this error, try `rustc --explain E0412`.",
414  "code": null,
415  "level": "failure-note",
416  "spans": [],
417  "children": [],
418  "rendered": "\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0412`.\u001b[0m
419"
420}