Skip to content

Remove the last bits of structural records from tests/rustc/rusti/rustpkg. #5075

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 2 commits into from
Feb 22, 2013
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
4 changes: 2 additions & 2 deletions src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum mode {
mode_debug_info,
}

pub type config = {
pub struct config {
// The library paths required for running the compiler
compile_lib_path: ~str,

Expand Down Expand Up @@ -68,4 +68,4 @@ pub type config = {
// Explain what's going on
verbose: bool

};
}
35 changes: 18 additions & 17 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#[crate_type = "bin"];

#[no_core];
#[legacy_records];

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

return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: opt_path(matches, ~"rustc-path"),
src_base: opt_path(matches, ~"src-base"),
build_base: opt_path(matches, ~"build-base"),
aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
config {
compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: opt_path(matches, ~"rustc-path"),
src_base: opt_path(matches, ~"src-base"),
build_base: opt_path(matches, ~"build-base"),
aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
} else { option::None },
logfile: option::map(&getopts::opt_maybe_str(matches,
logfile: option::map(&getopts::opt_maybe_str(matches,
~"logfile"),
|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
verbose: getopts::opt_present(matches, ~"verbose")};
|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
verbose: getopts::opt_present(matches, ~"verbose")
}
}

pub fn log_config(config: config) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,13 +1278,13 @@ fn test_simplification() {
let item_in = ast::ii_item(quote_item!(
fn new_int_alist<B:Copy>() -> alist<int, B> {
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
return {eq_fn: eq_int, data: ~[]};
return alist {eq_fn: eq_int, data: ~[]};
}
).get());
let item_out = simplify_ast(item_in);
let item_exp = ast::ii_item(quote_item!(
fn new_int_alist<B:Copy>() -> alist<int, B> {
return {eq_fn: eq_int, data: ~[]};
return alist {eq_fn: eq_int, data: ~[]};
}
).get());
match (item_out, item_exp) {
Expand Down
32 changes: 15 additions & 17 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,23 +706,21 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
}

fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
if !cx.legacy_records {
let visit = item_stopping_visitor(
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_expr: |e: @ast::expr| {
match e.node {
ast::expr_rec(*) =>
cx.sess.span_lint(
structural_records, e.id, it.id,
e.span,
~"structural records are deprecated"),
_ => ()
}
},
.. *visit::default_simple_visitor()
}));
visit::visit_item(it, (), visit);
}
let visit = item_stopping_visitor(
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_expr: |e: @ast::expr| {
match e.node {
ast::expr_rec(*) =>
cx.sess.span_lint(
structural_records, e.id, it.id,
e.span,
~"structural records are deprecated"),
_ => ()
}
},
.. *visit::default_simple_visitor()
}));
visit::visit_item(it, (), visit);
}

fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ struct ctxt_ {
mut next_id: uint,
vecs_implicitly_copyable: bool,
legacy_modes: bool,
legacy_records: bool,
cstore: @mut metadata::cstore::CStore,
sess: session::Session,
def_map: resolve::DefMap,
Expand Down Expand Up @@ -789,16 +788,10 @@ pub fn mk_ctxt(s: session::Session,
crate: @ast::crate)
-> ctxt {
let mut legacy_modes = false;
let mut legacy_records = false;
for crate.node.attrs.each |attribute| {
match attribute.node.value.node {
ast::meta_word(w) if *w == ~"legacy_modes" => {
legacy_modes = true;
if legacy_records { break; }
}
ast::meta_word(w) if *w == ~"legacy_records" => {
legacy_records = true;
if legacy_modes { break; }
}
_ => {}
}
Expand All @@ -814,7 +807,6 @@ pub fn mk_ctxt(s: session::Session,
mut next_id: 0u,
vecs_implicitly_copyable: vecs_implicitly_copyable,
legacy_modes: legacy_modes,
legacy_records: legacy_records,
cstore: s.cstore,
sess: s,
def_map: dm,
Expand Down
1 change: 0 additions & 1 deletion src/librusti/rusti.rc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#[crate_type = "lib"];

#[legacy_records];
#[no_core];

#[allow(vecs_implicitly_copyable,
Expand Down
1 change: 0 additions & 1 deletion src/librusti/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#[allow(non_implicitly_copyable_typarams)];
#[allow(owned_heap_memory)];
#[allow(path_statement)];
#[allow(structural_records)];
#[allow(unrecognized_lint)];
#[allow(unused_imports)];
#[allow(vecs_implicitly_copyable)];
Expand Down
2 changes: 0 additions & 2 deletions src/librustpkg/rustpkg.rc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#[allow(vecs_implicitly_copyable,
non_implicitly_copyable_typarams)];

#[legacy_records];

extern mod core(vers = "0.6");
extern mod std(vers = "0.6");
extern mod rustc(vers = "0.6");
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ pub impl Parser {
fields.push(self.parse_field(token::COLON));
}
self.expect(token::RBRACE);
//self.warn(~"REC");
self.warn(~"REC");
return expr_rec(fields, base);
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/bench/pingpong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// Compare bounded and unbounded protocol performance.

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

extern mod std;
Expand Down
16 changes: 8 additions & 8 deletions src/test/compile-fail/borrowck-assign-comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

type point = { x: int, y: int };
struct point {x: int, mut y: int }

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

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

fn b() {
let mut p = {x: 3, mut y: 4};
let _q = &p;

let mut p = point {x: 3, mut y: 4};
// This assignment is legal because `y` is inherently mutable (and
// hence &_q.y is &mut int).
let _q = &p;

p.y = 5;
}

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

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

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

let mut p = {x: 3, mut y: 4};
let mut p = point {x: 3, mut y: 4};
let _q = &p.y; //~ NOTE loan of mutable field granted here
p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
copy p;
Expand Down
22 changes: 17 additions & 5 deletions src/test/compile-fail/borrowck-assign-to-subfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@
// except according to those terms.

fn main() {
let mut p = {a: 1,
w: {a: 1},
x: @{a: 1},
y: @const {a: 1},
z: @mut{a: 1}};
struct A {
a: int,
w: B,
x: @B,
y: @const B,
z: @mut B
}
struct B {
a: int
}
let mut p = A {
a: 1,
w: B {a: 1},
x: @B {a: 1},
y: @const B {a: 1},
z: @mut B {a: 1}
};

// even though `x` is not declared as a mutable field,
// `p` as a whole is mutable, so it can be modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
uint::range(0, x.len(), |i| op(&x[i]));
}

struct A {
mut a: int
}

fn main() {
let x = [{mut a: 0}];
let x = [A {mut a: 0}];
for each(x) |y| {
let z = &y.a; //~ ERROR illegal borrow unless pure
x[0].a = 10; //~ NOTE impure due to assigning to mutable field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
}

fn main() {
let x = ~[{mut a: 0}];
struct A {
mut a: int
}
let x = ~[A {mut a: 0}];
for each(x) |y| {
let z = &y.a; //~ ERROR illegal borrow unless pure
x[0].a = 10; //~ NOTE impure due to assigning to mutable field
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/borrowck-loan-rcvr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

type point = { x: int, y: int };
struct point { x: int, y: int }

trait methods {
fn impurem();
Expand All @@ -27,7 +27,7 @@ impl methods for point {
}

fn a() {
let mut p = {x: 3, y: 4};
let mut p = point {x: 3, y: 4};

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

fn b() {
let mut p = {x: 3, y: 4};
let mut p = point {x: 3, y: 4};

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

Expand All @@ -56,7 +56,7 @@ fn b() {

fn c() {
// Loaning @mut as & is considered legal due to dynamic checks:
let q = @mut {x: 3, y: 4};
let q = @mut point {x: 3, y: 4};
q.purem();
q.impurem();
}
Expand Down
8 changes: 6 additions & 2 deletions src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct node_ {
mut a: ~cycle
}

enum cycle {
node({mut a: ~cycle}),
node(node_),
empty
}
fn main() {
let x = ~node({mut a: ~empty});
let x = ~node(node_ {mut a: ~empty});
// Create a cycle!
match *x { //~ NOTE loan of immutable local variable granted here
node(ref y) => {
Expand Down
8 changes: 6 additions & 2 deletions src/test/compile-fail/borrowck-uniq-via-lend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ fn local() {
}

fn local_rec() {
let mut v = {f: ~3};
struct F { f: ~int }
let mut v = F {f: ~3};
borrow(v.f);
}

fn local_recs() {
let mut v = {f: {g: {h: ~3}}};
struct F { f: G }
struct G { g: H }
struct H { h: ~int }
let mut v = F {f: G {g: H {h: ~3}}};
borrow(v.f.g.h);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-1896-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

fn createClosure (closedUint: uint) -> boxedFn {
{ theFn: fn@ () -> uint { closedUint } } //~ ERROR mismatched types
boxedFn {theFn: fn@ () -> uint { closedUint }} //~ ERROR mismatched types
}

fn main () {
Expand Down
Loading