]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0412.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0412.md
1 The type name used is not in scope.
2
3 Erroneous code examples:
4
5 ```compile_fail,E0412
6 impl Something {} // error: type name `Something` is not in scope
7
8 // or:
9
10 trait Foo {
11     fn bar(N); // error: type name `N` is not in scope
12 }
13
14 // or:
15
16 fn foo(x: T) {} // type name `T` is not in scope
17 ```
18
19 To fix this error, please verify you didn't misspell the type name, you did
20 declare it or imported it into the scope. Examples:
21
22 ```
23 struct Something;
24
25 impl Something {} // ok!
26
27 // or:
28
29 trait Foo {
30     type N;
31
32     fn bar(_: Self::N); // ok!
33 }
34
35 // or:
36
37 fn foo<T>(x: T) {} // ok!
38 ```
39
40 Another case that causes this error is when a type is imported into a parent
41 module. To fix this, you can follow the suggestion and use File directly or
42 `use super::File;` which will import the types from the parent namespace. An
43 example that causes this error is below:
44
45 ```compile_fail,E0412
46 use std::fs::File;
47
48 mod foo {
49     fn some_function(f: File) {}
50 }
51 ```
52
53 ```
54 use std::fs::File;
55
56 mod foo {
57     // either
58     use super::File;
59     // or
60     // use std::fs::File;
61     fn foo(f: File) {}
62 }
63 # fn main() {} // don't insert it for us; that'll break imports
64 ```