]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs/struct-fn-in-definition.rs
Add basic test
[rust.git] / src / test / ui / structs / struct-fn-in-definition.rs
1 // It might be intuitive for a user coming from languages like Java
2 // to declare a method directly in a struct's definition. Make sure
3 // rustc can give a helpful suggestion.
4 // Suggested in issue #76421
5
6 struct S {
7     field: usize,
8     fn do_something() {}
9     //~^ ERROR functions are not allowed in struct definitions
10     //~| HELP unlike in C++, Java, and C#, functions are declared in `impl` blocks
11     //~| HELP see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information
12 }
13
14 fn main() {}