Skip to content

Commit eb6a56d

Browse files
committed
---
yaml --- r: 63663 b: refs/heads/snap-stage3 c: 5e26808 h: refs/heads/master i: 63661: 166b9cf 63659: c52460e 63655: 10cce62 63647: 7814297 v: v3
1 parent a0ccdf7 commit eb6a56d

File tree

22 files changed

+129
-108
lines changed

22 files changed

+129
-108
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 92424f0670723e417a96a96310a6ad871994c6b7
4+
refs/heads/snap-stage3: 5e26808141592354a4c9ab28a7e2190e9acf8942
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/Makefile.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,29 @@ $(foreach target,$(CFG_TARGET_TRIPLES),\
239239
# Standard library variables
240240
######################################################################
241241

242-
STDLIB_CRATE := $(S)src/libstd/std.rs
242+
STDLIB_CRATE := $(S)src/libstd/core.rc
243243
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
244-
*.rs */*.rs */*/*rs */*/*/*rs))
244+
core.rc *.rs */*.rs */*/*rs */*/*/*rs))
245245

246246
######################################################################
247247
# Extra library variables
248248
######################################################################
249249

250-
EXTRALIB_CRATE := $(S)src/libextra/extra.rs
250+
EXTRALIB_CRATE := $(S)src/libextra/std.rc
251251
EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
252-
*.rs */*.rs))
252+
std.rc *.rs */*.rs))
253253

254254
######################################################################
255255
# rustc crate variables
256256
######################################################################
257257

258-
COMPILER_CRATE := $(S)src/librustc/rustc.rs
258+
COMPILER_CRATE := $(S)src/librustc/rustc.rc
259259
COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
260-
*.rs */*.rs */*/*.rs */*/*/*.rs))
260+
rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs))
261261

262-
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
262+
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc
263263
LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
264-
*.rs */*.rs */*/*.rs))
264+
syntax.rc *.rs */*.rs */*/*.rs))
265265

266266
DRIVER_CRATE := $(S)src/driver/driver.rs
267267

branches/snap-stage3/mk/tools.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
# and host architectures
1313

1414
# The test runner that runs the cfail/rfail/rpass and bxench tests
15-
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rs
16-
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*.rs)
15+
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rc
16+
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)
1717

1818
# Rustpkg, the package manager and build system
19-
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rs
20-
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*.rs)
19+
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rc
20+
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*rs)
2121

2222
# Rustdoc, the documentation tool
23-
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rs
23+
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
2424
RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)
2525

2626
# Rusti, the JIT REPL
27-
RUSTI_LIB := $(S)src/librusti/rusti.rs
27+
RUSTI_LIB := $(S)src/librusti/rusti.rc
2828
RUSTI_INPUTS := $(wildcard $(S)src/librusti/*.rs)
2929

3030
# Rust, the convenience tool
31-
RUST_LIB := $(S)src/librust/rust.rs
31+
RUST_LIB := $(S)src/librust/rust.rc
3232
RUST_INPUTS := $(wildcard $(S)src/librust/*.rs)
3333

3434
# FIXME: These are only built for the host arch. Eventually we'll

branches/snap-stage3/src/libextra/rc.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ impl<T> Rc<T> {
7070
impl<T> Drop for Rc<T> {
7171
fn finalize(&self) {
7272
unsafe {
73-
(*self.ptr).count -= 1;
74-
if (*self.ptr).count == 0 {
75-
ptr::replace_ptr(self.ptr, intrinsics::uninit());
76-
free(self.ptr as *c_void)
73+
if self.ptr.is_not_null() {
74+
(*self.ptr).count -= 1;
75+
if (*self.ptr).count == 0 {
76+
ptr::replace_ptr(self.ptr, intrinsics::uninit());
77+
free(self.ptr as *c_void)
78+
}
7779
}
7880
}
7981
}
@@ -220,10 +222,12 @@ impl<T> RcMut<T> {
220222
impl<T> Drop for RcMut<T> {
221223
fn finalize(&self) {
222224
unsafe {
223-
(*self.ptr).count -= 1;
224-
if (*self.ptr).count == 0 {
225-
ptr::replace_ptr(self.ptr, uninit());
226-
free(self.ptr as *c_void)
225+
if self.ptr.is_not_null() {
226+
(*self.ptr).count -= 1;
227+
if (*self.ptr).count == 0 {
228+
ptr::replace_ptr(self.ptr, uninit());
229+
free(self.ptr as *c_void)
230+
}
227231
}
228232
}
229233
}

branches/snap-stage3/src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ use syntax::ast;
2424
use syntax::ast_map;
2525
use syntax::diagnostic::expect;
2626

27-
pub struct ProvidedTraitMethodInfo {
28-
ty: ty::Method,
29-
def_id: ast::def_id
30-
}
31-
3227
pub struct StaticMethodInfo {
3328
ident: ast::ident,
3429
def_id: ast::def_id,
@@ -134,7 +129,7 @@ pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,
134129

135130
pub fn get_provided_trait_methods(tcx: ty::ctxt,
136131
def: ast::def_id)
137-
-> ~[ProvidedTraitMethodInfo] {
132+
-> ~[@ty::Method] {
138133
let cstore = tcx.cstore;
139134
let cdata = cstore::get_crate_data(cstore, def.crate);
140135
decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx)

branches/snap-stage3/src/librustc/metadata/decoder.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::prelude::*;
1414

1515
use metadata::cstore::crate_metadata;
1616
use metadata::common::*;
17-
use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
17+
use metadata::csearch::StaticMethodInfo;
1818
use metadata::csearch;
1919
use metadata::cstore;
2020
use metadata::decoder;
@@ -752,7 +752,7 @@ pub fn get_trait_method_def_ids(cdata: cmd,
752752

753753
pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
754754
id: ast::node_id, tcx: ty::ctxt) ->
755-
~[ProvidedTraitMethodInfo] {
755+
~[@ty::Method] {
756756
let data = cdata.data;
757757
let item = lookup_item(id, data);
758758
let mut result = ~[];
@@ -763,13 +763,8 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
763763

764764
if item_method_sort(mth) != 'p' { loop; }
765765

766-
let ty_method = get_method(intr, cdata, did.node, tcx);
767-
let provided_trait_method_info = ProvidedTraitMethodInfo {
768-
ty: ty_method,
769-
def_id: did
770-
};
771-
772-
vec::push(&mut result, provided_trait_method_info);
766+
vec::push(&mut result,
767+
@get_method(intr, cdata, did.node, tcx));
773768
}
774769

775770
return result;

branches/snap-stage3/src/librustc/middle/lint.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ pub enum lint {
9696

9797
missing_doc,
9898
unreachable_code,
99-
100-
warnings,
10199
}
102100

103101
pub fn level_to_str(lv: level) -> &'static str {
@@ -282,13 +280,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
282280
desc: "detects unreachable code",
283281
default: warn
284282
}),
285-
286-
("warnings",
287-
LintSpec {
288-
lint: warnings,
289-
desc: "mass-change the level for lints which produce warnings",
290-
default: warn
291-
}),
292283
];
293284

294285
/*
@@ -371,11 +362,10 @@ impl Context {
371362

372363
fn span_lint(&self, lint: lint, span: span, msg: &str) {
373364
let (level, src) = match self.curr.find(&(lint as uint)) {
374-
None => { return }
375-
Some(&(warn, src)) => (self.get_level(warnings), src),
376365
Some(&pair) => pair,
366+
None => { return; }
377367
};
378-
if level == allow { return }
368+
if level == allow { return; }
379369

380370
let mut note = None;
381371
let msg = match src {

branches/snap-stage3/src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
135135
ty::lookup_field_type(cx.tcx, def_id, field.id, substs)
136136
};
137137
let packed = ty::lookup_packed(cx.tcx, def_id);
138-
let dtor = ty::ty_dtor(cx.tcx, def_id).is_present();
138+
let dtor = ty::ty_dtor(cx.tcx, def_id).has_drop_flag();
139139
let ftys =
140140
if dtor { ftys + [ty::mk_bool()] } else { ftys };
141141
return Univariant(mk_struct(cx, ftys, packed), dtor)

branches/snap-stage3/src/librustc/middle/trans/glue.rs

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,8 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
404404
build_return(bcx);
405405
}
406406

407-
pub fn trans_struct_drop(bcx: block,
408-
t: ty::t,
409-
v0: ValueRef,
410-
dtor_did: ast::def_id,
411-
class_did: ast::def_id,
412-
substs: &ty::substs)
413-
-> block {
407+
pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
408+
class_did: ast::def_id, substs: &ty::substs) -> block {
414409
let repr = adt::represent_type(bcx.ccx(), t);
415410
let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
416411
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
@@ -452,6 +447,43 @@ pub fn trans_struct_drop(bcx: block,
452447
}
453448
}
454449

450+
pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
451+
class_did: ast::def_id, substs: &ty::substs) -> block {
452+
let repr = adt::represent_type(bcx.ccx(), t);
453+
454+
// Find and call the actual destructor
455+
let dtor_addr = get_res_dtor(bcx.ccx(), dtor_did,
456+
class_did, /*bad*/copy substs.tps);
457+
458+
// The second argument is the "self" argument for drop
459+
let params = unsafe {
460+
let ty = Type::from_ref(llvm::LLVMTypeOf(dtor_addr));
461+
ty.element_type().func_params()
462+
};
463+
464+
// Class dtors have no explicit args, so the params should
465+
// just consist of the environment (self)
466+
assert_eq!(params.len(), 1);
467+
468+
// Take a reference to the class (because it's using the Drop trait),
469+
// do so now.
470+
let llval = alloca(bcx, val_ty(v0));
471+
Store(bcx, v0, llval);
472+
473+
let self_arg = PointerCast(bcx, llval, params[0]);
474+
let args = ~[self_arg];
475+
476+
Call(bcx, dtor_addr, args);
477+
478+
// Drop the fields
479+
let field_tys = ty::struct_fields(bcx.tcx(), class_did, substs);
480+
for field_tys.iter().enumerate().advance |(i, fld)| {
481+
let llfld_a = adt::trans_field_ptr(bcx, repr, v0, 0, i);
482+
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
483+
}
484+
485+
bcx
486+
}
455487

456488
pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
457489
// NB: v0 is an *alias* of type t here, not a direct value.
@@ -472,7 +504,10 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
472504
ty::ty_struct(did, ref substs) => {
473505
let tcx = bcx.tcx();
474506
match ty::ty_dtor(tcx, did) {
475-
ty::TraitDtor(dtor) => {
507+
ty::TraitDtor(dtor, true) => {
508+
trans_struct_drop_flag(bcx, t, v0, dtor, did, substs)
509+
}
510+
ty::TraitDtor(dtor, false) => {
476511
trans_struct_drop(bcx, t, v0, dtor, did, substs)
477512
}
478513
ty::NoDtor => {
@@ -592,6 +627,23 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
592627
ty::ty_opaque_closure_ptr(ck) => {
593628
closure::make_opaque_cbox_take_glue(bcx, ck, v)
594629
}
630+
ty::ty_struct(did, ref substs) => {
631+
let tcx = bcx.tcx();
632+
let bcx = iter_structural_ty(bcx, v, t, take_ty);
633+
634+
match ty::ty_dtor(tcx, did) {
635+
ty::TraitDtor(dtor, false) => {
636+
// Zero out the struct
637+
unsafe {
638+
let ty = Type::from_ref(llvm::LLVMTypeOf(v));
639+
memzero(bcx, v, ty);
640+
}
641+
642+
}
643+
_ => { }
644+
}
645+
bcx
646+
}
595647
_ if ty::type_is_structural(t) => {
596648
iter_structural_ty(bcx, v, t, take_ty)
597649
}

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,21 +3649,21 @@ pub fn def_has_ty_params(def: ast::def) -> bool {
36493649
}
36503650
}
36513651

3652-
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[ast::ident] {
3652+
pub fn provided_trait_methods(cx: ctxt, id: ast::def_id) -> ~[@Method] {
36533653
if is_local(id) {
36543654
match cx.items.find(&id.node) {
36553655
Some(&ast_map::node_item(@ast::item {
36563656
node: item_trait(_, _, ref ms),
36573657
_
36583658
}, _)) =>
36593659
match ast_util::split_trait_methods(*ms) {
3660-
(_, p) => p.map(|method| method.ident)
3660+
(_, p) => p.map(|m| method(cx, ast_util::local_def(m.id)))
36613661
},
36623662
_ => cx.sess.bug(fmt!("provided_trait_methods: %? is not a trait",
36633663
id))
36643664
}
36653665
} else {
3666-
csearch::get_provided_trait_methods(cx, id).map(|ifo| ifo.ty.ident)
3666+
csearch::get_provided_trait_methods(cx, id)
36673667
}
36683668
}
36693669

@@ -3852,7 +3852,7 @@ pub fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
38523852

38533853
pub enum DtorKind {
38543854
NoDtor,
3855-
TraitDtor(def_id)
3855+
TraitDtor(def_id, bool)
38563856
}
38573857

38583858
impl DtorKind {
@@ -3866,13 +3866,24 @@ impl DtorKind {
38663866
pub fn is_present(&const self) -> bool {
38673867
!self.is_not_present()
38683868
}
3869+
3870+
pub fn has_drop_flag(&self) -> bool {
3871+
match self {
3872+
&NoDtor => false,
3873+
&TraitDtor(_, flag) => flag
3874+
}
3875+
}
38693876
}
38703877

38713878
/* If struct_id names a struct with a dtor, return Some(the dtor's id).
38723879
Otherwise return none. */
38733880
pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
38743881
match cx.destructor_for_type.find(&struct_id) {
3875-
Some(&method_def_id) => TraitDtor(method_def_id),
3882+
Some(&method_def_id) => {
3883+
let flag = !has_attr(cx, struct_id, "no_drop_flag");
3884+
3885+
TraitDtor(method_def_id, flag)
3886+
}
38763887
None => NoDtor,
38773888
}
38783889
}

0 commit comments

Comments
 (0)