fork/rust

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

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

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