]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_error_codes/src/error_codes/E0211.md
New upstream version 1.66.0+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0211.md
CommitLineData
60c5eb7d
XL
1#### Note: this error code is no longer emitted by the compiler.
2
3You used a function or type which doesn't fit the requirements for where it was
4used. Erroneous code examples:
5
6```compile_fail
7#![feature(intrinsics)]
8
9extern "rust-intrinsic" {
2b03887a 10 #[rustc_safe_intrinsic]
60c5eb7d
XL
11 fn size_of<T>(); // error: intrinsic has wrong type
12}
13
14// or:
15
16fn main() -> i32 { 0 }
17// error: main function expects type: `fn() {main}`: expected (), found i32
18
19// or:
20
21let x = 1u8;
22match x {
23 0u8..=3i8 => (),
24 // error: mismatched types in range: expected u8, found i8
25 _ => ()
26}
27
28// or:
29
30use std::rc::Rc;
31struct Foo;
32
33impl Foo {
34 fn x(self: Rc<Foo>) {}
35 // error: mismatched self type: expected `Foo`: expected struct
36 // `Foo`, found struct `alloc::rc::Rc`
37}
38```
39
40For the first code example, please check the function definition. Example:
41
42```
43#![feature(intrinsics)]
44
45extern "rust-intrinsic" {
2b03887a 46 #[rustc_safe_intrinsic]
60c5eb7d
XL
47 fn size_of<T>() -> usize; // ok!
48}
49```
50
51The second case example is a bit particular: the main function must always
52have this definition:
53
54```compile_fail
55fn main();
56```
57
58They never take parameters and never return types.
59
60For the third example, when you match, all patterns must have the same type
61as the type you're matching on. Example:
62
63```
64let x = 1u8;
65
66match x {
67 0u8..=3u8 => (), // ok!
68 _ => ()
69}
70```
71
72And finally, for the last example, only `Box<Self>`, `&Self`, `Self`,
73or `&mut Self` work as explicit self parameters. Example:
74
75```
76struct Foo;
77
78impl Foo {
79 fn x(self: Box<Foo>) {} // ok!
80}
81```