diff options
| author | Jihyun Yu <jihyun@nclab.kaist.ac.kr> | 2013-03-02 12:57:05 +0900 |
|---|---|---|
| committer | Jihyun Yu <jihyun@nclab.kaist.ac.kr> | 2013-03-02 12:57:05 +0900 |
| commit | 95bc9ea26df56b29f74583317ab080fdc7b99757 (patch) | |
| tree | 5bc88308814e2b0013f886efa2deaa7b56c5c8e5 /src | |
| parent | 0fd1b58f236b4fe653d164836e94feebb2972931 (diff) | |
| download | rust-95bc9ea26df56b29f74583317ab080fdc7b99757.tar.gz rust-95bc9ea26df56b29f74583317ab080fdc7b99757.zip | |
Remove REC, change related tests/docs
Diffstat (limited to 'src')
23 files changed, 54 insertions, 235 deletions
diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 1fef4ad42f1..7197de36404 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -62,17 +62,17 @@ pub struct DVec<A> { /// Creates a new, empty dvec pub pure fn DVec<A>() -> DVec<A> { - DVec {mut data: ~[]} + DVec {data: ~[]} } /// Creates a new dvec with a single element pub pure fn from_elem<A>(e: A) -> DVec<A> { - DVec {mut data: ~[e]} + DVec {data: ~[e]} } /// Creates a new dvec with the contents of a vector pub pure fn from_vec<A>(v: ~[A]) -> DVec<A> { - DVec {mut data: v} + DVec {data: v} } /// Consumes the vector and returns its contents diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 8b6d27496d9..09588f3280d 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -322,8 +322,8 @@ pub struct Pipe { mut in: c_int, mut out: c_int } #[cfg(unix)] pub fn pipe() -> Pipe { unsafe { - let mut fds = Pipe {mut in: 0 as c_int, - mut out: 0 as c_int }; + let mut fds = Pipe {in: 0 as c_int, + out: 0 as c_int }; assert (libc::pipe(&mut fds.in) == (0 as c_int)); return Pipe {in: fds.in, out: fds.out}; } @@ -339,8 +339,8 @@ pub fn pipe() -> Pipe { // fully understand. Here we explicitly make the pipe non-inheritable, // which means to pass it to a subprocess they need to be duplicated // first, as in rust_run_program. - let mut fds = Pipe { mut in: 0 as c_int, - mut out: 0 as c_int }; + let mut fds = Pipe {in: 0 as c_int, + out: 0 as c_int }; let res = libc::pipe(&mut fds.in, 1024 as c_uint, (libc::O_BINARY | libc::O_NOINHERIT) as c_int); assert (res == 0 as c_int); @@ -566,13 +566,17 @@ pub fn path_exists(p: &Path) -> bool { * * If the given path is relative, return it prepended with the current working * directory. If the given path is already an absolute path, return it - * as is. This is a shortcut for calling os::getcwd().unsafe_join(p) + * as is. */ // NB: this is here rather than in path because it is a form of environment // querying; what it does depends on the process working directory, not just // the input paths. pub fn make_absolute(p: &Path) -> Path { - getcwd().unsafe_join(p) + if p.is_absolute { + copy *p + } else { + getcwd().push_many(p.components) + } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 2266c2511f8..ca5f6671130 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -300,7 +300,7 @@ impl<T:Ord> Ord for &const T { pub fn test() { unsafe { struct Pair {mut fst: int, mut snd: int}; - let mut p = Pair {mut fst: 10, mut snd: 20}; + let mut p = Pair {fst: 10, snd: 20}; let pptr: *mut Pair = &mut p; let iptr: *mut int = cast::reinterpret_cast(&pptr); assert (*iptr == 10);; @@ -308,7 +308,7 @@ pub fn test() { assert (*iptr == 30); assert (p.fst == 30);; - *pptr = Pair {mut fst: 50, mut snd: 60}; + *pptr = Pair {fst: 50, snd: 60}; assert (*iptr == 50); assert (p.fst == 50); assert (p.snd == 60); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 7d04f676079..cbe0580a609 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -219,7 +219,7 @@ pub mod reader { } pub fn Decoder(d: Doc) -> Decoder { - Decoder { mut parent: d, mut pos: d.start } + Decoder { parent: d, pos: d.start } } priv impl Decoder { diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 39d3fd569a6..51ff69da98d 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -87,7 +87,7 @@ enum Sem<Q> = Exclusive<SemInner<Q>>; #[doc(hidden)] fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> { Sem(exclusive(SemInner { - mut count: count, waiters: new_waitqueue(), blocked: q })) + count: count, waiters: new_waitqueue(), blocked: q })) } #[doc(hidden)] fn new_sem_and_signal(count: int, num_condvars: uint) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6294243d486..444f1201fc3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -1093,15 +1093,10 @@ pub impl Parser { self.mk_expr(lo, hi, expr_tup(es)) } } else if *self.token == token::LBRACE { - if self.looking_at_record_literal() { - ex = self.parse_record_literal(); - hi = self.span.hi; - } else { - self.bump(); - let blk = self.parse_block_tail(lo, default_blk); - return self.mk_expr(blk.span.lo, blk.span.hi, - expr_block(blk)); - } + self.bump(); + let blk = self.parse_block_tail(lo, default_blk); + return self.mk_expr(blk.span.lo, blk.span.hi, + expr_block(blk)); } else if token::is_bar(*self.token) { return self.parse_lambda_expr(); } else if self.eat_keyword(~"if") { @@ -1223,6 +1218,7 @@ pub impl Parser { self.bump(); let mut fields = ~[]; let mut base = None; + fields.push(self.parse_field(token::COLON)); while *self.token != token::RBRACE { if self.try_parse_obsolete_with() { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0f161a444bd..ac21e27bb8b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1213,7 +1213,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { print_expr(s, expr); end(s); } - _ => word(s.s, ~",") + _ => (word(s.s, ~",")) } word(s.s, ~"}"); } diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index fec5c994de7..cbbf484ad55 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -9,18 +9,23 @@ // except according to those terms. // error-pattern: mismatched types -type clam = {x: @int, y: @int}; +struct clam { + x: @int, + y: @int, +} -type fish = {a: @int}; +struct fish { + a: @int, +} fn main() { - let a: clam = {x: @1, y: @2}; - let b: clam = {x: @10, y: @20}; + let a: clam = clam{x: @1, y: @2}; + let b: clam = clam{x: @10, y: @20}; let z: int = a.x + b.y; log(debug, z); assert (z == 21); - let forty: fish = {a: @40}; - let two: fish = {a: @2}; + let forty: fish = fish{a: @40}; + let two: fish = fish{a: @2}; let answer: int = forty.a + two.a; log(debug, answer); assert (answer == 42); diff --git a/src/test/compile-fail/bad-record-pat-2.rs b/src/test/compile-fail/bad-record-pat-2.rs deleted file mode 100644 index 3707dc923c8..00000000000 --- a/src/test/compile-fail/bad-record-pat-2.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:did not expect a record with a field `q` - -fn main() { match {x: 1, y: 2} { {x: x, q: q} => { } } } diff --git a/src/test/compile-fail/bad-record-pat.rs b/src/test/compile-fail/bad-record-pat.rs deleted file mode 100644 index a7ce8e2ef5c..00000000000 --- a/src/test/compile-fail/bad-record-pat.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:expected a record with 2 fields, found one with 1 - -fn main() { match {x: 1, y: 2} { {x: x} => { } } } diff --git a/src/test/compile-fail/binop-add-tup-assign.rs b/src/test/compile-fail/binop-add-tup-assign.rs deleted file mode 100644 index 3e560c8eaf6..00000000000 --- a/src/test/compile-fail/binop-add-tup-assign.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:+ cannot be applied to type `{x: bool}` - -fn main() { let x = {x: true}; x += {x: false}; } diff --git a/src/test/compile-fail/binop-add-tup.rs b/src/test/compile-fail/binop-add-tup.rs deleted file mode 100644 index 660e951c847..00000000000 --- a/src/test/compile-fail/binop-add-tup.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:+ cannot be applied to type `{x: bool}` - -fn main() { let x = {x: true} + {x: false}; } diff --git a/src/test/compile-fail/break-outside-loop.rs b/src/test/compile-fail/break-outside-loop.rs index c36d60fdac1..b3154c9742a 100644 --- a/src/test/compile-fail/break-outside-loop.rs +++ b/src/test/compile-fail/break-outside-loop.rs @@ -9,9 +9,14 @@ // except according to those terms. // error-pattern:`break` outside of loop + +struct Foo { + t: ~str +} + fn main() { let pth = break; - let rs: {t: ~str} = {t: pth}; + let rs: Foo = Foo{t: pth}; } diff --git a/src/test/compile-fail/fru-extra-field.rs b/src/test/compile-fail/fru-extra-field.rs deleted file mode 100644 index 64d76d6fb74..00000000000 --- a/src/test/compile-fail/fru-extra-field.rs +++ /dev/null @@ -1,21 +0,0 @@ -// -*- rust -*- -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern: record - -type point = {x: int, y: int}; - -fn main() { - let origin: point = {x: 0, y: 0}; - - let origin3d: point = {z: 0,.. origin}; -} diff --git a/src/test/compile-fail/let-destruct-refutable.rs b/src/test/compile-fail/let-destruct-refutable.rs deleted file mode 100644 index 9bd9db20779..00000000000 --- a/src/test/compile-fail/let-destruct-refutable.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:refutable pattern -// error-pattern:refutable pattern - -enum xx { xx(int), yy, } - -fn main() { - let @{x: xx(x), y: y} = @{x: xx(10), y: 20}; - assert (x + y == 30); - - let [a, b] = ~[1, 2]; -} diff --git a/src/test/compile-fail/nonscalar-cast.rs b/src/test/compile-fail/nonscalar-cast.rs index 54c0f6ca07f..d84775d02ac 100644 --- a/src/test/compile-fail/nonscalar-cast.rs +++ b/src/test/compile-fail/nonscalar-cast.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -10,6 +10,10 @@ // error-pattern:non-scalar cast +struct foo { + x:int +} + fn main() { - log(debug, { x: 1 } as int); + log(debug, foo{ x: 1 } as int); } diff --git a/src/test/compile-fail/rec-expected.rs b/src/test/compile-fail/rec-expected.rs deleted file mode 100644 index 962201aa9b9..00000000000 --- a/src/test/compile-fail/rec-expected.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type foo = {a: int}; -type bar = {b: int}; - -fn want_foo(f: foo) {} -fn have_bar(b: bar) { - want_foo(b); //~ ERROR expected a record with field `a` -} - -fn main() {} diff --git a/src/test/compile-fail/rec-extend.rs b/src/test/compile-fail/rec-extend.rs deleted file mode 100644 index aa4f9d0501a..00000000000 --- a/src/test/compile-fail/rec-extend.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:expected `int` but found `bool` - -fn main() { - - let a = {foo: 0i}; - - let b = {foo: true,.. a}; -} diff --git a/src/test/compile-fail/rec-missing-fields.rs b/src/test/compile-fail/rec-missing-fields.rs deleted file mode 100644 index 2ad2f00ee26..00000000000 --- a/src/test/compile-fail/rec-missing-fields.rs +++ /dev/null @@ -1,19 +0,0 @@ -// -*- rust -*- -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern: mismatched types - -// Issue #51. - -type point = {x: int, y: int}; - -fn main() { let p: point = {x: 10}; log(debug, p.y); } diff --git a/src/test/compile-fail/writing-through-read-alias.rs b/src/test/compile-fail/writing-through-read-alias.rs deleted file mode 100644 index 3b2591c3bfa..00000000000 --- a/src/test/compile-fail/writing-through-read-alias.rs +++ /dev/null @@ -1,19 +0,0 @@ -// -*- rust -*- -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:assigning to immutable field - -type point = {x: int, y: int, z: int}; - -fn f(p: point) { p.x = 13; } - -fn main() { let x: point = {x: 10, y: 11, z: 12}; f(x); } diff --git a/src/test/compile-fail/writing-to-immutable-rec.rs b/src/test/compile-fail/writing-to-immutable-rec.rs deleted file mode 100644 index 4cc9dae7deb..00000000000 --- a/src/test/compile-fail/writing-to-immutable-rec.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: assigning to immutable field -fn main() { let r: {x: int} = {x: 1}; r.x = 6; } diff --git a/src/test/run-pass/lint-structural-records.rs b/src/test/run-pass/lint-structural-records.rs deleted file mode 100644 index e5107ba187c..00000000000 --- a/src/test/run-pass/lint-structural-records.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[warn(structural_records)]; -pub fn main() { - let _foo = {x:5}; -} diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index 1b602ab7d30..def49ef0f8c 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -24,7 +24,7 @@ fn make_uniq_closure<A:Owned + Copy>(a: A) -> fn~() -> uint { fn empty_pointy() -> @mut Pointy { return @mut Pointy { - mut a : none, + a : none, d : make_uniq_closure(~"hi") } } |
