Skip to content

simplify processing of ConstVal objects when not all variants are legal #26935

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

Merged
merged 1 commit into from
Jul 21, 2015

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 10, 2015

r? @eddyb

Adding new variants is annoying as one needs to modify all these places that don't handle the new variant.

I chose not to use Display as I don't think it is appropriate.

@eddyb
Copy link
Member

eddyb commented Jul 10, 2015

Why not add another enum instead of using strings?

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 10, 2015

No reason in particular...

I'd love to have a repr C discriminant enum for every enum and an easy way to convert to it... (oh + subset-enums xD ) but since we don't have that, I'll just hand-code them

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 10, 2015

hmm actually there is a reason... another enum will require touching all those places again and only save us from modifying the hand-flattened ErrorKind enum... What I could do is dump the actual ConstVal into the variant instead of a string

ConstVal::Binary(_) => "binary array",
ConstVal::Struct(..) => "struct",
ConstVal::Tuple(_) => "tuple"
const_val => const_val.description(),
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to keep around the special-case for ConstVal::Int? The fact that the integer is negative is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll just change the description method to emit that information, too

@oli-obk oli-obk force-pushed the const_val_description branch from a41225f to 441b994 Compare July 13, 2015 08:53
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 13, 2015

updated to pass around the actual ConstVal object instead of a string and to print "negative integer" for negative signed integers

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 21, 2015

ping @eddyb

@eddyb
Copy link
Member

eddyb commented Jul 21, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 21, 2015

📌 Commit 441b994 has been approved by eddyb

@bors
Copy link
Collaborator

bors commented Jul 21, 2015

⌛ Testing commit 441b994 with merge 5dbddfb...

bors added a commit that referenced this pull request Jul 21, 2015
r? @eddyb 

Adding new variants is annoying as one needs to modify all these places that **don't** handle the new variant.

I chose not to use `Display` as I don't think it is appropriate.
@bors bors merged commit 441b994 into rust-lang:master Jul 21, 2015
@oli-obk oli-obk deleted the const_val_description branch July 22, 2015 06:23
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.

4 participants