Skip to content

librustc: hint close matches on accessing nonexisting fields - #19267

Closed
oli-obk wants to merge 1 commit into
rust-lang:masterfrom
oli-obk:feature/hint_struct_field_access
Closed

librustc: hint close matches on accessing nonexisting fields#19267
oli-obk wants to merge 1 commit into
rust-lang:masterfrom
oli-obk:feature/hint_struct_field_access

Conversation

@oli-obk

Copy link
Copy Markdown
Contributor
structA{foo:int,car:int,barr:int}fnmain(){let a = A{foo:5,car:9,bar:42};}

now shows

main.rs:7:39:7:42 error: structure `A` has no field named `bar`
main.rs:7let a = A{foo:5,car:9,bar:42};
^~~
main.rs:7:39:7:42 help: did you mean `car`?
main.rs:7let a = A{foo:5,car:9,bar:42};
^~~
main.rs:7:39:7:42 help: did you mean `barr`?
main.rs:7let a = A{foo:5,car:9,bar:42};
^~~

same help message for accessing fields.

can't do it for functions, as they aren't iteratable. Only exact lookups are possible there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our style is to not add any whitespace for alignment.

@emberian

Copy link
Copy Markdown
Contributor

Could you add some tests for this? Just a few cases in compile-fail that the messages get emitted.

@oli-obk
oli-obkforce-pushed the feature/hint_struct_field_access branch from d179dc0 to 5d1b223CompareDecember 6, 2014 12:47
barosl added a commit to barosl/rust that referenced this pull request Dec 22, 2014
barosl added a commit to barosl/rust that referenced this pull request Dec 22, 2014
@baroslbarosl mentioned this pull request Dec 22, 2014
@Gankra

Copy link
Copy Markdown
Contributor

@oli-obk have you made all your changes? (github doesn't notify us when you just add commits, you need to ping someone when you're ready).

Regardless, needs a rebase.

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

not yet, as i need to rewrite some of the error reporting code, to prevent hinting field names of fields that are actually set

@flaper87

Copy link
Copy Markdown
Contributor

closing for inactivity. @oli-obk let us know when you get back to this. It needs rebase so probably a new PR would be just fine.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@oli-obk@emberian@Gankra@flaper87