limit and delimit available fields in note
Also, don't show the note if no fields are available (usually due to privacy).
This commit is contained in:
parent
bf7e91f61d
commit
2dbfa3995e
11 changed files with 46 additions and 29 deletions
|
|
@ -4,7 +4,7 @@ error[E0609]: no field `zz` on type `Foo`
|
|||
17 | f.zz;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: bar
|
||||
= note: available fields are: `bar`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@ mod submodule {
|
|||
pub struct Demo {
|
||||
pub favorite_integer: isize,
|
||||
secret_integer: isize,
|
||||
pub innocently_misspellable: ()
|
||||
pub innocently_misspellable: (),
|
||||
another_field: bool,
|
||||
yet_another_field: bool,
|
||||
always_more_fields: bool,
|
||||
and_ever: bool,
|
||||
}
|
||||
|
||||
impl Demo {
|
||||
|
|
@ -34,6 +38,6 @@ fn main() {
|
|||
|
||||
let demo = Demo::default();
|
||||
let innocent_field_misaccess = demo.inocently_mispellable;
|
||||
// note shouldn't suggest private `secret_integer` field
|
||||
// note shouldn't suggest private fields
|
||||
let egregious_field_misaccess = demo.egregiously_nonexistent_field;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
error[E0560]: struct `submodule::Demo` has no field named `inocently_mispellable`
|
||||
--> $DIR/issue-42599_available_fields_note.rs:22:39
|
||||
--> $DIR/issue-42599_available_fields_note.rs:26:39
|
||||
|
|
||||
22 | Self { secret_integer: 2, inocently_mispellable: () }
|
||||
26 | Self { secret_integer: 2, inocently_mispellable: () }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ field does not exist - did you mean `innocently_misspellable`?
|
||||
|
||||
error[E0560]: struct `submodule::Demo` has no field named `egregiously_nonexistent_field`
|
||||
--> $DIR/issue-42599_available_fields_note.rs:26:39
|
||||
--> $DIR/issue-42599_available_fields_note.rs:30:39
|
||||
|
|
||||
26 | Self { secret_integer: 3, egregiously_nonexistent_field: () }
|
||||
30 | Self { secret_integer: 3, egregiously_nonexistent_field: () }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `submodule::Demo` does not have this field
|
||||
|
|
||||
= note: available fields are: favorite_integer, secret_integer, innocently_misspellable
|
||||
= note: available fields are: `favorite_integer`, `secret_integer`, `innocently_misspellable`, `another_field`, `yet_another_field` ... and 2 others
|
||||
|
||||
error[E0609]: no field `inocently_mispellable` on type `submodule::Demo`
|
||||
--> $DIR/issue-42599_available_fields_note.rs:36:41
|
||||
--> $DIR/issue-42599_available_fields_note.rs:40:41
|
||||
|
|
||||
36 | let innocent_field_misaccess = demo.inocently_mispellable;
|
||||
40 | let innocent_field_misaccess = demo.inocently_mispellable;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ did you mean `innocently_misspellable`?
|
||||
|
||||
error[E0609]: no field `egregiously_nonexistent_field` on type `submodule::Demo`
|
||||
--> $DIR/issue-42599_available_fields_note.rs:38:42
|
||||
--> $DIR/issue-42599_available_fields_note.rs:42:42
|
||||
|
|
||||
38 | let egregious_field_misaccess = demo.egregiously_nonexistent_field;
|
||||
42 | let egregious_field_misaccess = demo.egregiously_nonexistent_field;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown field
|
||||
|
|
||||
= note: available fields are: favorite_integer, innocently_misspellable
|
||||
= note: available fields are: `favorite_integer`, `innocently_misspellable`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue