Skip to content

Minor cleanups to custom discriminator code. #1544

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
Jan 17, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/tutorial/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ equivalent to a C enum:
This will define `north`, `east`, `south`, and `west` as constants,
all of which have type `direction`.

When the enum is is C like, that is none of the variants have
parameters, it is possible to explicit set the discriminator values to
an integer value:
When the enum is C like, that is none of the variants have parameters,
it is possible to explicitly set the discriminator values to an integer
value:

enum color {
red = 0xff0000;
Expand Down
4 changes: 2 additions & 2 deletions src/comp/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2636,8 +2636,8 @@ fn tag_variants(cx: ctxt, id: ast::def_id) -> @[variant_info] {
@csearch::get_tag_variants(cx, id)
} else {
// FIXME: Now that the variants are run through the type checker (to
// check the disr_expr if one exists), this code should likely be
// moved there to avoid having to call eval_const_expr twice
// check the disr_expr if it exists), this code should likely be
// moved there to avoid having to call eval_const_expr twice.
alt cx.items.get(id.node) {
ast_map::node_item(@{node: ast::item_tag(variants, _), _}) {
let disr_val = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/comp/middle/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2488,8 +2488,8 @@ fn check_tag_variants(ccx: @crate_ctxt, _sp: span, vs: [ast::variant],
demand::simple(fcx, e.span, declty, cty);
// FIXME: issue #1417
// Also, check_expr (from check_const pass) doesn't guarantee that
// the expression in an form that eval_const_expr, so we may still
// get an internal compiler error
// the expression in an form that eval_const_expr can handle, so
// we may still get an internal compiler error.
alt syntax::ast_util::eval_const_expr(e) {
syntax::ast_util::const_int(val) {
disr_val = val as int;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/enum-disr-val-pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() {
test_color(imaginary, -1, "imaginary");
}

fn test_color(color: color, val: int, name: str) unsafe{
fn test_color(color: color, val: int, name: str) {
assert (color as int == val);
assert (color as float == val as float);
}
Expand Down