Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error message on invalid field names for a struct variant #20084

Merged
merged 1 commit into from
Dec 23, 2014

Conversation

barosl
Copy link
Contributor

@barosl barosl commented Dec 20, 2014

Fixes #19922.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@barosl barosl force-pushed the struct-variant-field-err branch from ffd612e to 4e1bba0 Compare December 20, 2014 20:46
None =>
format!("structure `{}` has no field named `{}`",
actual,
token::get_ident(field.ident.node))
Copy link
Member

Choose a reason for hiding this comment

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

Could you put a block around this format! invocation if you're going to stagger it like that?

@barosl barosl force-pushed the struct-variant-field-err branch 2 times, most recently from 53e0a53 to b220925 Compare December 21, 2014 00:08
@barosl barosl force-pushed the struct-variant-field-err branch from b220925 to c9010bf Compare December 21, 2014 01:21
actual, variant_type.name.as_str(),
token::get_ident(field.ident.node))
}
None => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it'd have been nice to have a test for this case as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh... it's true. I'll add it soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the case is already provided by the existing test cases(struct-fields-too-many.rs and issue-4736.rs), so I think it would not be necessary to add another one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's provided, but it's still nice to have it in the same issue-19922.rs file as a quick proof that this works for the other cases. Sorry, I should have phrased my previous comment better :)

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 22, 2014
@bors bors merged commit c9010bf into rust-lang:master Dec 23, 2014
Sign up for free to 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.

Confusing error message for incorrect struct variant field
5 participants