]> git.lizzy.rs Git - rust.git/blob - src/test/ui/did_you_mean/issue-42599_available_fields_note.rs
Auto merge of #43488 - Florob:repeat-opt, r=arielb1
[rust.git] / src / test / ui / did_you_mean / issue-42599_available_fields_note.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 mod submodule {
12
13     #[derive(Default)]
14     pub struct Demo {
15         pub favorite_integer: isize,
16         secret_integer: isize,
17         pub innocently_misspellable: (),
18         another_field: bool,
19         yet_another_field: bool,
20         always_more_fields: bool,
21         and_ever: bool,
22     }
23
24     impl Demo {
25         fn new_with_secret_two() -> Self {
26             Self { secret_integer: 2, inocently_mispellable: () }
27         }
28
29         fn new_with_secret_three() -> Self {
30             Self { secret_integer: 3, egregiously_nonexistent_field: () }
31         }
32     }
33
34 }
35
36 fn main() {
37     use submodule::Demo;
38
39     let demo = Demo::default();
40     let innocent_field_misaccess = demo.inocently_mispellable;
41     // note shouldn't suggest private fields
42     let egregious_field_misaccess = demo.egregiously_nonexistent_field;
43 }