rustc: Make the pretty printer output commas after enum variants. Update all tests accordingly.

This commit is contained in:
Patrick Walton 2012-01-19 18:31:08 -08:00
parent c6278e53dc
commit 59ebe6af18
94 changed files with 135 additions and 135 deletions

View File

@ -451,7 +451,7 @@ fn print_item(s: ps, &&item: @ast::item) {
}
_ {}
}
word(s.s, ";");
word(s.s, ",");
end(s);
maybe_print_trailing_comment(s, v.span, none::<uint>);
}

View File

@ -8,7 +8,7 @@ use std;
import int;
import str;
enum bottle { none; dual; single; multiple(int); }
enum bottle { none, dual, single, multiple(int), }
fn show(b: bottle) {
alt b {

View File

@ -1,7 +1,7 @@
use std;
import int;
enum tree { nil; node(~tree, ~tree, int); }
enum tree { nil, node(~tree, ~tree, int), }
fn item_check(t: ~tree) -> int {
alt *t {

View File

@ -25,7 +25,7 @@ export grid_t, read_grid, solve_grid, write_grid;
type grid = [[mutable u8]];
// exported type of sudoku grids
enum grid_t { grid_ctor(grid); }
enum grid_t { grid_ctor(grid), }
// read a sudoku problem from file f
fn read_grid(f: io::reader) -> grid_t {

View File

@ -52,11 +52,11 @@ mod map_reduce {
type reducer = fn@(str, getter);
enum ctrl_proto {
find_reducer(str, chan<chan<reduce_proto>>);
mapper_done;
find_reducer(str, chan<chan<reduce_proto>>),
mapper_done,
}
enum reduce_proto { emit_val(int); done; ref; release; }
enum reduce_proto { emit_val(int), done, ref, release, }
fn start_mappers(ctrl: chan<ctrl_proto>, -inputs: [str]) ->
[joinable_task] {

View File

@ -1,7 +1,7 @@
// error-pattern: mismatched types
enum a { A; }
enum b { B; }
enum a { A, }
enum b { B, }
fn main() { let x: a = A; alt x { B { } } }

View File

@ -1,7 +1,7 @@
// error-pattern: mismatched types
enum a { A(int); }
enum b { B(int); }
enum a { A(int), }
enum b { B(int), }
fn main() { let x: a = A(0); alt x { B(y) { } } }

View File

@ -2,7 +2,7 @@
// error-pattern: unresolved
enum color { rgb(int, int, int); rgba(int, int, int, int); }
enum color { rgb(int, int, int), rgba(int, int, int, int), }
fn main() {
let red: color = rgb(255, 0, 0);

View File

@ -6,7 +6,7 @@
mod foo {
export t;
enum t { t1; }
enum t { t1, }
}
fn main() { let x = foo::t1; }

View File

@ -5,7 +5,7 @@ mod foo {
fn x() { }
enum y { y1; }
enum y { y1, }
}
fn main() { let z = foo::y1; }

View File

@ -3,6 +3,6 @@
// error-pattern: enum of infinite size
enum mlist { cons(int, mlist); nil; }
enum mlist { cons(int, mlist), nil, }
fn main() { let a = cons(10, cons(11, nil)); }

View File

@ -1,6 +1,6 @@
// error-pattern:refutable pattern
enum xx { xx(int); yy; }
enum xx { xx(int), yy, }
fn main() {
let @{x: xx(x), y: y} = @{x: xx(10), y: 20};

View File

@ -1,5 +1,5 @@
// error-pattern:Declaration of thpppt shadows
enum ack { thpppt; ffff; }
enum ack { thpppt, ffff, }
fn main() {
let thpppt: int = 42;

View File

@ -1,4 +1,4 @@
// error-pattern:mismatched types
// From Issue #778
enum clam<T> { a(T); }
enum clam<T> { a(T), }
fn main() { let c; c = a(c); alt c { a::<int>(_) { } } }

View File

@ -1,5 +1,5 @@
// error-pattern: mismatched types
enum blah { a(int, int, uint); b(int, int); }
enum blah { a(int, int, uint), b(int, int), }
fn main() { alt a(1, 1, 2u) { a(_, x, y) | b(x, y) { } } }

View File

@ -6,7 +6,7 @@ import option::some;
// error-pattern: mismatched types
enum bar { t1((), option::t<[int]>); t2; }
enum bar { t1((), option::t<[int]>), t2, }
fn foo(t: bar) -> int { alt t { t1(_, some(x)) { ret x * 3; } _ { fail; } } }

View File

@ -5,7 +5,7 @@ import option::some;
// error-pattern: mismatched types
enum bar { t1((), option::t<[int]>); t2; }
enum bar { t1((), option::t<[int]>), t2, }
fn foo(t: bar) {
alt t {

View File

@ -1,8 +1,8 @@
//error-pattern: non-scalar cast
enum non_nullary {
nullary;
other(int);
nullary,
other(int),
}
fn main() {

View File

@ -3,9 +3,9 @@
// black and white have the same discriminator value ...
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
black = 0x000000;
white = 0x000000;
red = 0xff0000,
green = 0x00ff00,
blue = 0x0000ff,
black = 0x000000,
white = 0x000000,
}

View File

@ -1,10 +1,10 @@
//error-pattern: discriminator values can only be used with a c-like enum
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
black = 0x000000;
white = 0xffffff;
other (str);
red = 0xff0000,
green = 0x00ff00,
blue = 0x0000ff,
black = 0x000000,
white = 0xffffff,
other (str),
}

View File

@ -1,8 +1,8 @@
//error-pattern: mismatched types
enum color {
red = 1u;
blue = 2;
red = 1u,
blue = 2,
}
fn main() {}

View File

@ -1,5 +1,5 @@
// error-pattern:unreachable pattern
enum foo { a(@foo, int); b(uint); }
enum foo { a(@foo, int), b(uint), }
fn main() { alt b(1u) { b(_) | a(@_, 1) { } a(_, 1) { } } }

View File

@ -1,8 +1,8 @@
// pp-exact
enum foo {
foo; // a foo.
bar;
foo, // a foo.
bar,
}
fn main() { }

View File

@ -4,6 +4,6 @@
// -*- rust -*-
// error-pattern:non-exhaustive match failure
enum t { a; b; }
enum t { a, b, }
fn main() { let x = a; alt x { b { } } }

View File

@ -5,7 +5,7 @@ use std;
import option;
import option::none;
enum sty { ty_nil; }
enum sty { ty_nil, }
type raw_t = {struct: sty, cname: option::t<str>, hash: uint};

View File

@ -1,4 +1,4 @@
enum option<T> { some(T); none; }
enum option<T> { some(T), none, }
type r<T> = {mutable v: [option<T>]};

View File

@ -1,7 +1,7 @@
mod m1 {
enum foo { foo1; foo2; }
enum foo { foo1, foo2, }
}
fn bar(x: m1::foo) { alt x { m1::foo1 { } } }

View File

@ -5,7 +5,7 @@ use std;
import std::dbg;
enum t { make_t(@int); clam; }
enum t { make_t(@int), clam, }
fn foo(s: @int) {
let count = dbg::refcount(s);

View File

@ -1,4 +1,4 @@
enum maybe<T> { nothing; just(T); }
enum maybe<T> { nothing, just(T), }
fn foo(x: maybe<int>) {
alt x { nothing { #error("A"); } just(a) { #error("B"); } }

View File

@ -1,6 +1,6 @@
enum thing { a; b; c; }
enum thing { a, b, c, }
fn foo(it: block(int)) { it(10); }

View File

@ -3,7 +3,7 @@
fn main() {
alt "test" { "not-test" { fail; } "test" { } _ { fail; } }
enum t { tag1(str); tag2; }
enum t { tag1(str), tag2, }
alt tag1("test") {

View File

@ -3,9 +3,9 @@
// -*- rust -*-
enum color {
rgb(int, int, int);
rgba(int, int, int, int);
hsl(int, int, int);
rgb(int, int, int),
rgba(int, int, int, int),
hsl(int, int, int),
}
fn process(c: color) -> int {

View File

@ -1,5 +1,5 @@
type foo = {a: int, b: uint};
enum bar { u(@foo); w(int); }
enum bar { u(@foo), w(int), }
fn main() {
assert (alt u(@{a: 10, b: 40u}) {

View File

@ -8,7 +8,7 @@ import comm;
import comm::port;
import comm::recv;
enum request { quit; close(chan<bool>); }
enum request { quit, close(chan<bool>), }
type ctx = chan<request>;

View File

@ -20,9 +20,9 @@ type t = int;
type t = bool;
#[cfg(bogus)]
enum tg { foo; }
enum tg { foo, }
enum tg { bar; }
enum tg { bar, }
#[cfg(bogus)]
resource r(i: int) { }

View File

@ -1,6 +1,6 @@
// -*- rust -*-
enum list { cons(int, @list); nil; }
enum list { cons(int, @list), nil, }
type bubu = {x: int, y: int};

View File

@ -1,6 +1,6 @@
enum taggy {
cons(@mutable taggy);
nil;
cons(@mutable taggy),
nil,
}
fn f() {

View File

@ -1,5 +1,5 @@
enum t { foo(@int); }
enum t { foo(@int), }
fn main() { let tt = foo(@10); alt tt { foo(z) { } } }

View File

@ -1,4 +1,4 @@
enum chan { chan_t; }
enum chan { chan_t, }
fn wrapper3(i: chan) {
assert i == chan_t;

View File

@ -1,6 +1,6 @@
// pp-exact
enum color { red = 1; green; blue; imaginary = -1; }
enum color { red = 1, green, blue, imaginary = -1, }
fn main() {
test_color(red, 1, "red");

View File

@ -5,7 +5,7 @@ mod foo {
export t;
export f;
enum t { t1; }
enum t { t1, }
fn f() -> t { ret t1; }
}

View File

@ -2,6 +2,6 @@
export foo;
export main;
enum list_cell<T> { cons(@list_cell<T>); }
enum list_cell<T> { cons(@list_cell<T>), }
fn main() { }

View File

@ -2,7 +2,7 @@
mod foo {
export t1;
enum t { t1; }
enum t { t1, }
}
fn main() { let v = foo::t1; }

View File

@ -6,7 +6,7 @@ mod foo {
export g;
// not exported
enum t { t1; t2; }
enum t { t1, t2, }
fn f() -> t { ret t1; }

View File

@ -10,7 +10,7 @@ fn test_rec() {
}
fn test_tag() {
enum mood { happy; sad; }
enum mood { happy, sad, }
let rs = alt true { true { happy } false { sad } };
assert (rs == happy);
}

View File

@ -10,7 +10,7 @@ fn test_rec() {
}
fn test_tag() {
enum mood { happy; sad; }
enum mood { happy, sad, }
let rs = if true { happy } else { sad };
assert (rs == happy);
}

View File

@ -1,4 +1,4 @@
enum wrapper<T> { wrapped(T); }
enum wrapper<T> { wrapped(T), }
fn main() { let w = wrapped([1, 2, 3, 4, 5]); }

View File

@ -1,6 +1,6 @@
enum list<T> { cons(@T, @list<T>); nil; }
enum list<T> { cons(@T, @list<T>), nil, }
fn main() {
let a: list<int> =

View File

@ -1,6 +1,6 @@
enum foo<T> { arm(T); }
enum foo<T> { arm(T), }
fn altfoo<T>(f: foo<T>) {
let hit = false;

View File

@ -2,6 +2,6 @@
// This causes memory corruption in stage0.
enum thing<K> { some(K); }
enum thing<K> { some(K), }
fn main() { let x = some("hi"); }

View File

@ -1,5 +1,5 @@
enum clam<T> { a(T); }
enum clam<T> { a(T), }
fn main() { let c = a(3); }

View File

@ -2,7 +2,7 @@
// -*- rust -*-
enum noption<T> { some(T); }
enum noption<T> { some(T), }
fn main() {
let nop: noption<int> = some::<int>(5);

View File

@ -1,5 +1,5 @@
enum option<T> { some(@T); none; }
enum option<T> { some(@T), none, }
fn main() { let a: option<int> = some::<int>(@10); a = none::<int>; }

View File

@ -30,7 +30,7 @@ mod map_reduce {
type mapper = native fn(str, putter);
enum ctrl_proto { find_reducer([u8], chan<int>); mapper_done; }
enum ctrl_proto { find_reducer([u8], chan<int>), mapper_done, }
fn start_mappers(ctrl: chan<ctrl_proto>, inputs: [str]) {
for i: str in inputs {

View File

@ -23,7 +23,7 @@ fn test_rec() {
fn test_tag() {
enum t {
t0(r);
t0(r),
}
let i = @mutable 0;

View File

@ -7,7 +7,7 @@ import comm::port;
import comm::recv;
import comm::send;
enum msg { closed; received([u8]); }
enum msg { closed, received([u8]), }
fn producer(c: chan<[u8]>) {
send(c, [1u8, 2u8, 3u8, 4u8]);

View File

@ -1,6 +1,6 @@
enum maybe_pointy {
no_pointy;
yes_pointy(@pointy);
no_pointy,
yes_pointy(@pointy),
}
type pointy = {

View File

@ -1,5 +1,5 @@
enum t { a; b(@int); }
enum t { a, b(@int), }
fn main() { let x = b(@10); x = a; }

View File

@ -2,6 +2,6 @@
// -*- rust -*-
enum list { cons(int, @list); nil; }
enum list { cons(int, @list), nil, }
fn main() { cons(10, @cons(11, @cons(12, @nil))); }

View File

@ -2,8 +2,8 @@ use std;
import std::list;
enum foo {
a(uint);
b(str);
a(uint),
b(str),
}
fn check_log<T>(exp: str, v: T) {

View File

@ -1,7 +1,7 @@
enum foo {
a(uint);
b(str);
c;
a(uint),
b(str),
c,
}
fn main() {

View File

@ -1,8 +1,8 @@
// Tests that shapes respect linearize_ty_params().
enum option<T> {
none;
some(T);
none,
some(T),
}
type smallintmap<T> = @{mutable v: [mutable option<T>]};

View File

@ -4,7 +4,7 @@ use std;
type cell = {mutable c: @list};
enum list { link(@cell); nil; }
enum list { link(@cell), nil, }
fn main() {
let first: @cell = @{mutable c: @nil()};

View File

@ -1,4 +1,4 @@
// -*- rust -*-
enum mlist { cons(int, @mlist); nil; }
enum mlist { cons(int, @mlist), nil, }
fn main() { cons(10, @cons(11, @cons(12, @nil))); }

View File

@ -2,12 +2,12 @@
// -*- rust -*-
enum colour { red; green; blue; }
enum colour { red, green, blue, }
enum tree { children(@list); leaf(colour); }
enum tree { children(@list), leaf(colour), }
enum list { cons(@tree, @list); nil; }
enum list { cons(@tree, @list), nil, }
enum small_list { kons(int, @small_list); neel; }
enum small_list { kons(int, @small_list), neel, }
fn main() { }

View File

@ -6,7 +6,7 @@ import option;
import option::some;
import option::none;
enum t { foo(int, uint); bar(int, option::t<int>); }
enum t { foo(int, uint), bar(int, option::t<int>), }
fn nested(o: t) {
alt o {

View File

@ -1,4 +1,4 @@
enum blah { a; b; }
enum blah { a, b, }
fn or_alt(q: blah) -> int {
alt q { a | b { 42 } }

View File

@ -1,4 +1,4 @@
enum blah { a(int, int, uint); b(int, int); c; }
enum blah { a(int, int, uint), b(int, int), c, }
fn or_alt(q: blah) -> int {
alt q { a(x, y, _) | b(x, y) { ret x + y; } c { ret 0; } }

View File

@ -1,6 +1,6 @@
enum t1 { a(int); b(uint); }
enum t1 { a(int), b(uint), }
type t2 = {x: t1, y: int};
enum t3 { c(t2, uint); }
enum t3 { c(t2, uint), }
fn m(in: t3) -> int {
alt in {

View File

@ -5,7 +5,7 @@ type closable = @mutable bool;
resource close_res(i: closable) { *i = false; }
enum option<T> { none; some(T); }
enum option<T> { none, some(T), }
fn sink(res: option<close_res>) { }

View File

@ -1,6 +1,6 @@
enum option<T> { none; some(T); }
enum option<T> { none, some(T), }
fn f<T: copy>() -> option<T> { ret none; }

View File

@ -16,6 +16,6 @@ fn foo(c: [int]) {
}
}
enum t<T> { none; some(T); }
enum t<T> { none, some(T), }
fn main() { let x = 10; let x = x + 20; assert (x == 30); foo([]); }

View File

@ -10,8 +10,8 @@ import option;
enum opt_span {
//hack (as opposed to option::t), to make `span` compile
os_none;
os_some(@span);
os_none,
os_some(@span),
}
type span = {lo: uint, hi: uint, expanded_from: opt_span};
type spanned<T> = { data: T, span: span };

View File

@ -1,6 +1,6 @@
enum opt<T> { none; }
enum opt<T> { none, }
fn main() {
let x = none::<int>;

View File

@ -1,5 +1,5 @@
enum clam<T> { a(T); }
enum clam<T> { a(T), }
fn main() { let c = a(2); alt c { a::<int>(_) { } } }

View File

@ -1,5 +1,5 @@
enum clam<T> { a(T); }
enum clam<T> { a(T), }
fn main() { }

View File

@ -2,7 +2,7 @@
// -*- rust -*-
enum clam<T> { a(T, int); b; }
enum clam<T> { a(T, int), b, }
fn uhoh<T>(v: [clam<T>]) {
alt v[1] {

View File

@ -1,5 +1,5 @@
enum taggy { foo(@taggy); bar; }
enum taggy { foo(@taggy), bar, }
fn main() { assert (bar <= bar); }

View File

@ -1,6 +1,6 @@
enum foo { large; small; }
enum foo { large, small, }
fn main() {
let a = {x: 1, y: 2, z: 3};

View File

@ -1,6 +1,6 @@
// xfail-test
enum color { red; green; blue; black; white; }
enum color { red, green, blue, black, white, }
fn main() {
assert (uint::to_str(red as uint, 10) == #fmt["%?", red]);

View File

@ -1,11 +1,11 @@
// xfail-pretty Issue #1510
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
black = 0x000000;
white = 0xFFFFFF;
red = 0xff0000,
green = 0x00ff00,
blue = 0x0000ff,
black = 0x000000,
white = 0xFFFFFF,
}
fn main() {

View File

@ -2,7 +2,7 @@
fn foo() {
fn zed(z: bar) { }
enum bar { nil; }
enum bar { nil, }
fn baz() { zed(nil); }
}

View File

@ -1,10 +1,10 @@
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
black = 0x000000;
white = 0xFFFFFF;
imaginary = -1;
red = 0xff0000,
green = 0x00ff00,
blue = 0x0000ff,
black = 0x000000,
white = 0xFFFFFF,
imaginary = -1,
}
fn main() {

View File

@ -2,7 +2,7 @@
// -*- rust -*-
enum colour { red(int, int); green; }
enum colour { red(int, int), green, }
fn f() { let x = red(1, 2); let y = green; assert (x != y); }

View File

@ -50,7 +50,7 @@ fn test_str() {
}
fn test_tag() {
enum t { tag1; tag2(int); tag3(int, u8, char); }
enum t { tag1, tag2(int), tag3(int, u8, char), }
let po = port();
let ch = chan(po);
send(ch, tag1);

View File

@ -1,6 +1,6 @@
enum maybe_pointy {
none;
p(@pointy);
none,
p(@pointy),
}
type pointy = {

View File

@ -1,6 +1,6 @@
enum maybe_pointy {
none;
p(@pointy);
none,
p(@pointy),
}
type pointy = {

View File

@ -1,5 +1,5 @@
fn main() {
enum t { t1(int); t2(int); }
enum t { t1(int), t2(int), }
let x = ~t1(10);

View File

@ -1,5 +1,5 @@
fn test1() {
enum bar { u(~int); w(int); }
enum bar { u(~int), w(int), }
let x = u(~10);
assert alt x {

View File

@ -1,6 +1,6 @@
type foo = {a: int, b: uint};
enum bar { u(~foo); w(int); }
enum bar { u(~foo), w(int), }
fn main() {
assert (alt u(~{a: 10, b: 40u}) {

View File

@ -1,5 +1,5 @@
enum bar { u(~int); w(int); }
enum bar { u(~int), w(int), }
fn main() {
assert alt u(~10) {

View File

@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x;
}
enum myoption<T> { none; some(T); }
enum myoption<T> { none, some(T), }
fn main() { log(debug, 5); }

View File

@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x;
}
enum myoption<T> { none; some(T); }
enum myoption<T> { none, some(T), }
fn main() { log(debug, 5); }

View File

@ -1,5 +1,5 @@
enum t { a; b(str); }
enum t { a, b(str), }
fn make(i: int) -> t {
if i > 10 { ret a; }