Skip to content

Commit e88b227

Browse files
committed
---
yaml --- r: 16269 b: refs/heads/try c: 49c6dac h: refs/heads/master i: 16267: 23b67f1 v: v3
1 parent b1dd801 commit e88b227

18 files changed

+78
-95
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 8972588583398b207f0f7033b2af20bca509eba7
5+
refs/heads/try: 49c6dac47aa93d11b2d4c8deeded4626e23081e7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/driver/rustc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import std::map::hashmap;
1515
import getopts::{opt_present};
1616
import rustc::driver::driver::*;
1717
import syntax::codemap;
18-
import rustc::driver::{diagnostic, session};
18+
import syntax::diagnostic;
19+
import rustc::driver::session;
1920
import rustc::middle::lint;
2021
import io::reader_util;
2122

branches/try/src/rustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import syntax::{ast, ast_util};
77
import syntax::attr;
88
import middle::ty;
99
import syntax::ast_map;
10-
import common::*;
1110
import tydecode::{parse_ty_data, parse_def_id, parse_bounds_data,
1211
parse_ident};
1312
import syntax::print::pprust;
1413
import cmd=cstore::crate_metadata;
1514
import util::ppaux::ty_to_str;
1615
import ebml::deserializer;
1716
import syntax::diagnostic::span_handler;
17+
import common::*;
1818

1919
export class_dtor;
2020
export get_class_fields;

branches/try/src/rustc/middle/trans/base.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
22522252
dtor"); }
22532253
};
22542254
trans_class_dtor(ccx, *pt, dtor.node.body,
2255-
dtor.node.id, psubsts, some(hash_id), parent_id)
2255+
dtor.node.id, psubsts, some(hash_id), parent_id, s)
22562256
}
22572257
// Ugh -- but this ensures any new variants won't be forgotten
22582258
ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") }
@@ -2448,7 +2448,19 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result {
24482448
}
24492449
ast::def_self(sid) {
24502450
let slf = alt copy cx.fcx.llself {
2451-
some(s) { cast_self(cx, s) }
2451+
some(s) {
2452+
alt option::map(ty::ty_to_def_id(s.t)) {|did|
2453+
ty::ty_dtor(cx.tcx(), did)} {
2454+
some(some(_)) {
2455+
/* self is a class with a dtor, which means we
2456+
have to select out the object itself
2457+
(If any other code does the same thing, that's
2458+
a bug */
2459+
GEPi(cx, cast_self(cx, s), [0u, 1u])
2460+
}
2461+
_ { cast_self(cx, s) }
2462+
}
2463+
}
24522464
none { cx.sess().bug("trans_local_var: reference to self \
24532465
out of context"); }
24542466
};
@@ -2523,29 +2535,17 @@ fn trans_rec_field(bcx: block, base: @ast::expr,
25232535

25242536
fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t,
25252537
field: ast::ident, sp: span) -> lval_result {
2526-
let mut deref = false;
25272538
let fields = alt ty::get(ty).struct {
25282539
ty::ty_rec(fs) { fs }
25292540
ty::ty_class(did, substs) {
2530-
if option::is_some(ty::ty_dtor(bcx.tcx(), did)) {
2531-
deref = true;
2532-
}
25332541
ty::class_items_as_fields(bcx.tcx(), did, substs)
25342542
}
25352543
// Constraint?
25362544
_ { bcx.tcx().sess.span_bug(sp, "trans_rec_field:\
25372545
base expr has non-record type"); }
25382546
};
25392547
let ix = field_idx_strict(bcx.tcx(), sp, field, fields);
2540-
2541-
/* self is a class with a dtor, which means we
2542-
have to select out the object itself
2543-
(If any other code does the same thing, that's
2544-
a bug */
2545-
let val = if deref {
2546-
GEPi(bcx, GEPi(bcx, val, [0u, 1u]), [0u, ix])
2547-
}
2548-
else { GEPi(bcx, val, [0u, ix]) };
2548+
let val = GEPi(bcx, val, [0u, ix]);
25492549

25502550
ret {bcx: bcx, val: val, kind: owned};
25512551
}
@@ -4887,8 +4887,9 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
48874887
fn trans_class_dtor(ccx: @crate_ctxt, path: path,
48884888
body: ast::blk,
48894889
dtor_id: ast::node_id, substs: option<param_substs>,
4890-
hash_id: option<mono_id>, parent_id: ast::def_id)
4891-
-> ValueRef {
4890+
hash_id: option<mono_id>, parent_id: ast::def_id,
4891+
// mangled exported name for dtor
4892+
s: str) -> ValueRef {
48924893
let tcx = ccx.tcx;
48934894
/* Look up the parent class's def_id */
48944895
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
@@ -4902,7 +4903,6 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49024903
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
49034904
T_ptr(type_of(ccx, class_ty))],
49044905
llvm::LLVMVoidType());
4905-
let s = get_dtor_symbol(ccx, path, dtor_id);
49064906
/* Register the dtor as a function. It has external linkage */
49074907
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
49084908
lib::llvm::SetLinkage(lldecl, lib::llvm::ExternalLinkage);
@@ -4912,7 +4912,9 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49124912
option::iter(hash_id) {|h_id|
49134913
ccx.monomorphized.insert(h_id, lldecl);
49144914
}
4915-
/* Translate the dtor body */
4915+
/* Register the symbol for the dtor, and generate the code for its
4916+
body */
4917+
ccx.item_symbols.insert(dtor_id, s);
49164918
trans_fn(ccx, path, ast_util::dtor_dec(),
49174919
body, lldecl, impl_self(class_ty), substs, dtor_id);
49184920
lldecl
@@ -4995,8 +4997,11 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
49954997
get_item_val(ccx, ctor.node.id), psubsts,
49964998
ctor.node.id, local_def(item.id), ctor.span);
49974999
option::iter(m_dtor) {|dtor|
5000+
let s = mangle_exported_name(ccx, *path +
5001+
[path_name(ccx.names("dtor"))],
5002+
ty::node_id_to_type(ccx.tcx, dtor.node.id));
49985003
trans_class_dtor(ccx, *path, dtor.node.body,
4999-
dtor.node.id, none, none, local_def(item.id));
5004+
dtor.node.id, none, none, local_def(item.id), s);
50005005
};
50015006
}
50025007
// If there are ty params, the ctor will get monomorphized
@@ -5157,21 +5162,8 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
51575162
} + [path_name(i.ident)]
51585163
}
51595164

5160-
/* If there's already a symbol for the dtor with <id>, return it;
5161-
otherwise, create one and register it, returning it as well */
5162-
fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id) -> str {
5163-
alt ccx.item_symbols.find(id) {
5164-
some(s) { s }
5165-
none {
5166-
let s = mangle_exported_name(ccx, path +
5167-
[path_name(ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
5168-
ccx.item_symbols.insert(id, s);
5169-
s
5170-
}
5171-
}
5172-
}
5173-
51745165
fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
5166+
#debug("get_item_val: %d", id);
51755167
let tcx = ccx.tcx;
51765168
alt ccx.item_vals.find(id) {
51775169
some(v) { v }
@@ -5250,8 +5242,11 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
52505242
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
52515243
T_ptr(type_of(ccx, class_ty))],
52525244
llvm::LLVMVoidType());
5253-
let s = get_dtor_symbol(ccx, *pt, dt.node.id);
5254-
5245+
/* The symbol for the dtor should have already been registered */
5246+
let s: str = alt ccx.item_symbols.find(id) {
5247+
some(s) { s }
5248+
none { ccx.sess.bug("in get_item_val, dtor is unbound"); }
5249+
};
52555250
/* Make the declaration for the dtor */
52565251
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
52575252
lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);

branches/try/src/rustc/middle/tstate/auxiliary.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import tstate::ann::{pre_and_post, pre_and_post_state, empty_ann, prestate,
1313
set_postcondition, ts_ann,
1414
clear_in_postcond,
1515
clear_in_poststate_};
16-
import tritv::*;
17-
import bitvectors::promises_;
1816
import driver::session::session;
17+
import tritv::{dont_care, tfalse, tritv_get, ttrue};
1918

2019
import syntax::print::pprust::{constr_args_to_str, lit_to_str};
2120

@@ -811,7 +810,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
811810
// dest def_id
812811
let insts = find_instances(fcx, subst, val);
813812
for insts.each {|p|
814-
if promises_(p.from, src_post) {
813+
if bitvectors::promises_(p.from, src_post) {
815814
set_in_poststate_(p.to, target_post);
816815
}
817816
}

branches/try/src/rustc/middle/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import std::map::hashmap;
44
import driver::session;
55
import session::session;
66
import syntax::{ast, ast_map};
7-
import syntax::ast::*;
87
import syntax::ast_util;
98
import syntax::ast_util::{is_local, local_def, split_class_items,
109
new_def_hash};
1110
import syntax::codemap::span;
1211
import metadata::csearch;
13-
import util::common::*;
1412
import util::ppaux::region_to_str;
1513
import util::ppaux::vstore_to_str;
1614
import util::ppaux::{ty_to_str, tys_to_str, ty_constr_to_str};
17-
import syntax::print::pprust::*;
1815
import middle::lint::{get_warning_level, vecs_not_implicitly_copyable,
1916
ignore};
17+
import syntax::ast::*;
18+
import syntax::print::pprust::*;
19+
2020
export ty_vid, region_vid, vid;
2121
export br_hashmap;
2222
export is_instantiable;

branches/try/src/rustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ an rptr (`&r.T`) use the region `r` that appears in the rptr.
4545
"];
4646

4747
import check::fn_ctxt;
48-
import rscope::*;
48+
import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
49+
import rscope::{in_binding_rscope, region_scope, type_rscope};
4950

5051
iface ast_conv {
5152
fn tcx() -> ty::ctxt;

branches/try/src/rustc/middle/typeck/check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ import collect::{methods}; // ccx.to_ty()
7171
import method::{methods}; // methods for method::lookup
7272
import middle::ty::tys_in_fn_ty;
7373
import regionmanip::{replace_bound_regions_in_fn_ty, region_of};
74-
import rscope::*;
74+
import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
75+
import rscope::{in_binding_rscope, region_scope, type_rscope};
7576

7677
type fn_ctxt =
7778
// var_bindings, locals and next_var_id are shared

branches/try/src/rustc/util/ppaux.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import std::map::hashmap;
22
import middle::ty;
3-
import middle::ty::*;
3+
import middle::ty::{arg, bound_region, br_anon, br_named, canon_mode};
4+
import middle::ty::{ck_block, ck_box, ck_uniq, constr, ctxt, field, method};
5+
import middle::ty::{mt, re_bound, re_free, re_scope, re_var, region, t};
6+
import middle::ty::{ty_bool, ty_bot, ty_box, ty_class, ty_constr, ty_enum};
7+
import middle::ty::{ty_estr, ty_evec, ty_float, ty_fn, ty_iface, ty_int};
8+
import middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param};
9+
import middle::ty::{ty_ptr, ty_rec, ty_res, ty_rptr, ty_self, ty_str, ty_tup};
10+
import middle::ty::{ty_type, ty_uniq, ty_uint, ty_var, ty_var_integral};
11+
import middle::ty::{ty_vec, vid};
412
import metadata::encoder;
513
import syntax::codemap;
614
import syntax::print::pprust;

branches/try/src/test/run-fail/morestack2.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,18 @@ fn getbig_call_c_and_fail(i: int) {
2020
}
2121
}
2222

23-
class and_then_get_big_again {
24-
new() {}
25-
drop {
23+
resource and_then_get_big_again(_i: ()) {
2624
fn getbig(i: int) {
2725
if i != 0 {
2826
getbig(i - 1);
2927
}
3028
}
3129
getbig(10000);
32-
}
3330
}
3431

3532
fn main() {
3633
task::spawn {||
37-
let r = and_then_get_big_again();
34+
let r = and_then_get_big_again(());
3835
getbig_call_c_and_fail(10000);
3936
};
4037
}

branches/try/src/test/run-fail/morestack3.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@
55
use std;
66

77
fn getbig_and_fail(&&i: int) {
8-
let _r = and_then_get_big_again();
8+
let r = and_then_get_big_again(@0);
99
if i != 0 {
1010
getbig_and_fail(i - 1);
1111
} else {
1212
fail;
1313
}
1414
}
1515

16-
class and_then_get_big_again {
17-
new() {}
18-
drop {
16+
resource and_then_get_big_again(_i: @int) {
1917
fn getbig(i: int) {
2018
if i != 0 {
2119
getbig(i - 1);
2220
}
2321
}
2422
getbig(100);
25-
}
2623
}
2724

2825
fn main() {

branches/try/src/test/run-fail/morestack4.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
use std;
66

77
fn getbig_and_fail(&&i: int) {
8-
let r = and_then_get_big_again();
8+
let r = and_then_get_big_again(@0);
99
if i != 0 {
1010
getbig_and_fail(i - 1);
1111
} else {
1212
fail;
1313
}
1414
}
1515

16-
class and_then_get_big_again {
17-
new() {}
18-
drop {}
16+
resource and_then_get_big_again(_i: @int) {
1917
}
2018

2119
fn main() {
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
// error-pattern:whatever
22

3-
class r {
4-
// Setting the exit status after the runtime has already
5-
// failed has no effect and the process exits with the
6-
// runtime's exit code
7-
drop {
8-
os::set_exit_status(50);
9-
}
10-
new() {}
11-
}
12-
133
fn main() {
144
log(error, "whatever");
155
task::spawn {||
16-
let i = r();
6+
resource r(_i: ()) {
7+
// Setting the exit status after the runtime has already
8+
// failed has no effect and the process exits with the
9+
// runtime's exit code
10+
os::set_exit_status(50);
11+
}
12+
let i = r(());
1713
};
1814
fail;
1915
}

branches/try/src/test/run-fail/too-much-recursion-unwinding.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@ fn recurse() {
99
recurse();
1010
}
1111

12-
class r {
13-
let recursed: *mut bool;
14-
new(recursed: *mut bool) unsafe { self.recursed = recursed; }
15-
drop unsafe {
12+
resource r(recursed: *mut bool) unsafe {
1613
if !*recursed {
1714
*recursed = true;
1815
recurse();
1916
}
20-
}
2117
}
2218

2319
fn main() {

branches/try/src/test/run-fail/unwind-box-res.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ fn failfn() {
44
fail;
55
}
66

7-
class r {
8-
let v: *int;
9-
new(v: *int) { self.v = v; }
10-
drop unsafe {
11-
let _v2: ~int = unsafe::reinterpret_cast(self.v);
12-
}
7+
resource r(v: *int) unsafe {
8+
let v2: ~int = unsafe::reinterpret_cast(v);
139
}
1410

1511
fn main() unsafe {

branches/try/src/test/run-fail/unwind-resource-fail.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// error-pattern:fail
22
// xfail-test
33

4-
class r {
5-
new(i:int) {}
6-
drop { fail; }
4+
resource r(i: int) {
5+
// What happens when destructors throw?
6+
fail;
77
}
88

99
fn main() {

0 commit comments

Comments
 (0)