Skip to content

Commit f5cc0b9

Browse files
committed
auto merge of #5075 : luqmana/rust/derec, r=catamorphism
Now only `lib core/pipes.rs` has `#[allow(structural_records)]`. That can be removed after a snapshot.
2 parents ab784b7 + 48c1c3c commit f5cc0b9

37 files changed

+131
-196
lines changed

src/compiletest/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum mode {
2121
mode_debug_info,
2222
}
2323

24-
pub type config = {
24+
pub struct config {
2525
// The library paths required for running the compiler
2626
compile_lib_path: ~str,
2727

@@ -68,4 +68,4 @@ pub type config = {
6868
// Explain what's going on
6969
verbose: bool
7070

71-
};
71+
}

src/compiletest/compiletest.rc

+18-17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#[crate_type = "bin"];
1212

1313
#[no_core];
14-
#[legacy_records];
1514

1615
#[allow(vecs_implicitly_copyable)];
1716
#[allow(non_camel_case_types)];
@@ -77,26 +76,28 @@ pub fn parse_config(args: ~[~str]) -> config {
7776
Path(getopts::opt_str(m, nm))
7877
}
7978

80-
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
81-
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
82-
rustc_path: opt_path(matches, ~"rustc-path"),
83-
src_base: opt_path(matches, ~"src-base"),
84-
build_base: opt_path(matches, ~"build-base"),
85-
aux_base: opt_path(matches, ~"aux-base"),
86-
stage_id: getopts::opt_str(matches, ~"stage-id"),
87-
mode: str_mode(getopts::opt_str(matches, ~"mode")),
88-
run_ignored: getopts::opt_present(matches, ~"ignored"),
89-
filter:
79+
config {
80+
compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
81+
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
82+
rustc_path: opt_path(matches, ~"rustc-path"),
83+
src_base: opt_path(matches, ~"src-base"),
84+
build_base: opt_path(matches, ~"build-base"),
85+
aux_base: opt_path(matches, ~"aux-base"),
86+
stage_id: getopts::opt_str(matches, ~"stage-id"),
87+
mode: str_mode(getopts::opt_str(matches, ~"mode")),
88+
run_ignored: getopts::opt_present(matches, ~"ignored"),
89+
filter:
9090
if vec::len(matches.free) > 0u {
9191
option::Some(matches.free[0])
9292
} else { option::None },
93-
logfile: option::map(&getopts::opt_maybe_str(matches,
93+
logfile: option::map(&getopts::opt_maybe_str(matches,
9494
~"logfile"),
95-
|s| Path(*s)),
96-
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
97-
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
98-
jit: getopts::opt_present(matches, ~"jit"),
99-
verbose: getopts::opt_present(matches, ~"verbose")};
95+
|s| Path(*s)),
96+
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
97+
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
98+
jit: getopts::opt_present(matches, ~"jit"),
99+
verbose: getopts::opt_present(matches, ~"verbose")
100+
}
100101
}
101102

102103
pub fn log_config(config: config) {

src/librustc/middle/astencode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1278,13 +1278,13 @@ fn test_simplification() {
12781278
let item_in = ast::ii_item(quote_item!(
12791279
fn new_int_alist<B:Copy>() -> alist<int, B> {
12801280
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
1281-
return {eq_fn: eq_int, data: ~[]};
1281+
return alist {eq_fn: eq_int, data: ~[]};
12821282
}
12831283
).get());
12841284
let item_out = simplify_ast(item_in);
12851285
let item_exp = ast::ii_item(quote_item!(
12861286
fn new_int_alist<B:Copy>() -> alist<int, B> {
1287-
return {eq_fn: eq_int, data: ~[]};
1287+
return alist {eq_fn: eq_int, data: ~[]};
12881288
}
12891289
).get());
12901290
match (item_out, item_exp) {

src/librustc/middle/lint.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -706,23 +706,21 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
706706
}
707707
708708
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
709-
if !cx.legacy_records {
710-
let visit = item_stopping_visitor(
711-
visit::mk_simple_visitor(@visit::SimpleVisitor {
712-
visit_expr: |e: @ast::expr| {
713-
match e.node {
714-
ast::expr_rec(*) =>
715-
cx.sess.span_lint(
716-
structural_records, e.id, it.id,
717-
e.span,
718-
~"structural records are deprecated"),
719-
_ => ()
720-
}
721-
},
722-
.. *visit::default_simple_visitor()
723-
}));
724-
visit::visit_item(it, (), visit);
725-
}
709+
let visit = item_stopping_visitor(
710+
visit::mk_simple_visitor(@visit::SimpleVisitor {
711+
visit_expr: |e: @ast::expr| {
712+
match e.node {
713+
ast::expr_rec(*) =>
714+
cx.sess.span_lint(
715+
structural_records, e.id, it.id,
716+
e.span,
717+
~"structural records are deprecated"),
718+
_ => ()
719+
}
720+
},
721+
.. *visit::default_simple_visitor()
722+
}));
723+
visit::visit_item(it, (), visit);
726724
}
727725

728726
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {

src/librustc/middle/ty.rs

-8
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ struct ctxt_ {
233233
mut next_id: uint,
234234
vecs_implicitly_copyable: bool,
235235
legacy_modes: bool,
236-
legacy_records: bool,
237236
cstore: @mut metadata::cstore::CStore,
238237
sess: session::Session,
239238
def_map: resolve::DefMap,
@@ -789,16 +788,10 @@ pub fn mk_ctxt(s: session::Session,
789788
crate: @ast::crate)
790789
-> ctxt {
791790
let mut legacy_modes = false;
792-
let mut legacy_records = false;
793791
for crate.node.attrs.each |attribute| {
794792
match attribute.node.value.node {
795793
ast::meta_word(w) if *w == ~"legacy_modes" => {
796794
legacy_modes = true;
797-
if legacy_records { break; }
798-
}
799-
ast::meta_word(w) if *w == ~"legacy_records" => {
800-
legacy_records = true;
801-
if legacy_modes { break; }
802795
}
803796
_ => {}
804797
}
@@ -814,7 +807,6 @@ pub fn mk_ctxt(s: session::Session,
814807
mut next_id: 0u,
815808
vecs_implicitly_copyable: vecs_implicitly_copyable,
816809
legacy_modes: legacy_modes,
817-
legacy_records: legacy_records,
818810
cstore: s.cstore,
819811
sess: s,
820812
def_map: dm,

src/librusti/rusti.rc

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#[crate_type = "lib"];
1919

20-
#[legacy_records];
2120
#[no_core];
2221

2322
#[allow(vecs_implicitly_copyable,

src/librusti/wrapper.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#[allow(non_implicitly_copyable_typarams)];
1717
#[allow(owned_heap_memory)];
1818
#[allow(path_statement)];
19-
#[allow(structural_records)];
2019
#[allow(unrecognized_lint)];
2120
#[allow(unused_imports)];
2221
#[allow(vecs_implicitly_copyable)];

src/librustpkg/rustpkg.rc

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#[allow(vecs_implicitly_copyable,
2121
non_implicitly_copyable_typarams)];
2222

23-
#[legacy_records];
24-
2523
extern mod core(vers = "0.6");
2624
extern mod std(vers = "0.6");
2725
extern mod rustc(vers = "0.6");

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ pub impl Parser {
19261926
fields.push(self.parse_field(token::COLON));
19271927
}
19281928
self.expect(token::RBRACE);
1929-
//self.warn(~"REC");
1929+
self.warn(~"REC");
19301930
return expr_rec(fields, base);
19311931
}
19321932

src/test/bench/pingpong.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Compare bounded and unbounded protocol performance.
1212

13-
#[allow(structural_records)]; // Pipes
14-
// Until a snapshot
1513
// xfail-pretty
1614

1715
extern mod std;

src/test/compile-fail/borrowck-assign-comp.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
type point = { x: int, y: int };
11+
struct point {x: int, mut y: int }
1212

1313
fn a() {
14-
let mut p = {x: 3, y: 4};
14+
let mut p = point {x: 3, y: 4};
1515
let _q = &p; //~ NOTE loan of mutable local variable granted here
1616

1717
// This assignment is illegal because the field x is not
@@ -21,29 +21,29 @@ fn a() {
2121
}
2222

2323
fn b() {
24-
let mut p = {x: 3, mut y: 4};
25-
let _q = &p;
26-
24+
let mut p = point {x: 3, mut y: 4};
2725
// This assignment is legal because `y` is inherently mutable (and
2826
// hence &_q.y is &mut int).
27+
let _q = &p;
28+
2929
p.y = 5;
3030
}
3131

3232
fn c() {
3333
// this is sort of the opposite. We take a loan to the interior of `p`
3434
// and then try to overwrite `p` as a whole.
3535

36-
let mut p = {x: 3, mut y: 4};
36+
let mut p = point {x: 3, mut y: 4};
3737
let _q = &p.y; //~ NOTE loan of mutable local variable granted here
38-
p = {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
38+
p = point {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
3939
copy p;
4040
}
4141

4242
fn d() {
4343
// just for completeness's sake, the easy case, where we take the
4444
// address of a subcomponent and then modify that subcomponent:
4545

46-
let mut p = {x: 3, mut y: 4};
46+
let mut p = point {x: 3, mut y: 4};
4747
let _q = &p.y; //~ NOTE loan of mutable field granted here
4848
p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
4949
copy p;

src/test/compile-fail/borrowck-assign-to-subfield.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let mut p = {a: 1,
13-
w: {a: 1},
14-
x: @{a: 1},
15-
y: @const {a: 1},
16-
z: @mut{a: 1}};
12+
struct A {
13+
a: int,
14+
w: B,
15+
x: @B,
16+
y: @const B,
17+
z: @mut B
18+
}
19+
struct B {
20+
a: int
21+
}
22+
let mut p = A {
23+
a: 1,
24+
w: B {a: 1},
25+
x: @B {a: 1},
26+
y: @const B {a: 1},
27+
z: @mut B {a: 1}
28+
};
1729

1830
// even though `x` is not declared as a mutable field,
1931
// `p` as a whole is mutable, so it can be modified.

src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
1212
uint::range(0, x.len(), |i| op(&x[i]));
1313
}
1414

15+
struct A {
16+
mut a: int
17+
}
18+
1519
fn main() {
16-
let x = [{mut a: 0}];
20+
let x = [A {mut a: 0}];
1721
for each(x) |y| {
1822
let z = &y.a; //~ ERROR illegal borrow unless pure
1923
x[0].a = 10; //~ NOTE impure due to assigning to mutable field

src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
1313
}
1414

1515
fn main() {
16-
let x = ~[{mut a: 0}];
16+
struct A {
17+
mut a: int
18+
}
19+
let x = ~[A {mut a: 0}];
1720
for each(x) |y| {
1821
let z = &y.a; //~ ERROR illegal borrow unless pure
1922
x[0].a = 10; //~ NOTE impure due to assigning to mutable field

src/test/compile-fail/borrowck-loan-rcvr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
type point = { x: int, y: int };
11+
struct point { x: int, y: int }
1212

1313
trait methods {
1414
fn impurem();
@@ -27,7 +27,7 @@ impl methods for point {
2727
}
2828

2929
fn a() {
30-
let mut p = {x: 3, y: 4};
30+
let mut p = point {x: 3, y: 4};
3131

3232
// Here: it's ok to call even though receiver is mutable, because we
3333
// can loan it out.
@@ -41,7 +41,7 @@ fn a() {
4141
}
4242

4343
fn b() {
44-
let mut p = {x: 3, y: 4};
44+
let mut p = point {x: 3, y: 4};
4545

4646
// Here I create an outstanding loan and check that we get conflicts:
4747

@@ -56,7 +56,7 @@ fn b() {
5656

5757
fn c() {
5858
// Loaning @mut as & is considered legal due to dynamic checks:
59-
let q = @mut {x: 3, y: 4};
59+
let q = @mut point {x: 3, y: 4};
6060
q.purem();
6161
q.impurem();
6262
}

src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
struct node_ {
12+
mut a: ~cycle
13+
}
14+
1115
enum cycle {
12-
node({mut a: ~cycle}),
16+
node(node_),
1317
empty
1418
}
1519
fn main() {
16-
let x = ~node({mut a: ~empty});
20+
let x = ~node(node_ {mut a: ~empty});
1721
// Create a cycle!
1822
match *x { //~ NOTE loan of immutable local variable granted here
1923
node(ref y) => {

src/test/compile-fail/borrowck-uniq-via-lend.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ fn local() {
1616
}
1717

1818
fn local_rec() {
19-
let mut v = {f: ~3};
19+
struct F { f: ~int }
20+
let mut v = F {f: ~3};
2021
borrow(v.f);
2122
}
2223

2324
fn local_recs() {
24-
let mut v = {f: {g: {h: ~3}}};
25+
struct F { f: G }
26+
struct G { g: H }
27+
struct H { h: ~int }
28+
let mut v = F {f: G {g: H {h: ~3}}};
2529
borrow(v.f.g.h);
2630
}
2731

src/test/compile-fail/issue-1896-1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
type boxedFn = { theFn: fn () -> uint };
11+
struct boxedFn { theFn: fn~() -> uint }
1212

1313
fn createClosure (closedUint: uint) -> boxedFn {
14-
{ theFn: fn@ () -> uint { closedUint } } //~ ERROR mismatched types
14+
boxedFn {theFn: fn@ () -> uint { closedUint }} //~ ERROR mismatched types
1515
}
1616

1717
fn main () {

0 commit comments

Comments
 (0)