]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0599.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0599.md
1 This error occurs when a method is used on a type which doesn't implement it:
2
3 Erroneous code example:
4
5 ```compile_fail,E0599
6 struct Mouth;
7
8 let x = Mouth;
9 x.chocolate(); // error: no method named `chocolate` found for type `Mouth`
10                //        in the current scope
11 ```
12
13 In this case, you need to implement the `chocolate` method to fix the error:
14
15 ```
16 struct Mouth;
17
18 impl Mouth {
19     fn chocolate(&self) { // We implement the `chocolate` method here.
20         println!("Hmmm! I love chocolate!");
21     }
22 }
23
24 let x = Mouth;
25 x.chocolate(); // ok!
26 ```