Skip to content
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

Remove drop block support #6148

Closed
wants to merge 8 commits into from
Closed
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
3 changes: 1 addition & 2 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ pub fn load_props(testfile: &Path) -> TestProps {
}

pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false;
for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; }
if parse_name_directive(ln, xfail_target()) { return true; }
if config.mode == common::mode_pretty &&
parse_name_directive(ln, ~"xfail-pretty") { return true; }
};
return found;
return true;

fn xfail_target() -> ~str {
~"xfail-" + str::from_slice(os::SYSNAME)
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn run_rpass_test(config: config, props: TestProps, testfile: &Path) {
fatal_ProcRes(~"test run failed!", ProcRes);
}
} else {
let mut ProcRes = jit_test(config, props, testfile);
let ProcRes = jit_test(config, props, testfile);

if ProcRes.status != 0 { fatal_ProcRes(~"jit failed!", ProcRes); }
}
Expand Down
1 change: 0 additions & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ they contained the following prologue:
#[warn(vecs_implicitly_copyable)];
#[deny(non_camel_case_types)];
#[allow(deprecated_mutable_fields)];
#[allow(deprecated_drop)];

// Make core testable by not duplicating lang items. See #2912
#[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");
Expand Down
32 changes: 15 additions & 17 deletions src/libcore/pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ use cast::{forget, transmute, transmute_copy};
use either::{Either, Left, Right};
use kinds::Owned;
use libc;
use ops::Drop;
use option::{None, Option, Some};
use unstable::finally::Finally;
use unstable::intrinsics;
use ptr;
use task;
Expand Down Expand Up @@ -395,26 +397,22 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
let p_ = p.unwrap();
let p = unsafe { &*p_ };

#[unsafe_destructor]
struct DropState<'self> {
p: &'self PacketHeader,

drop {
unsafe {
if task::failing() {
self.p.state = Terminated;
let old_task = swap_task(&mut self.p.blocked_task,
ptr::null());
if !old_task.is_null() {
rustrt::rust_task_deref(old_task);
}
do (|| {
try_recv_(p)
}).finally {
unsafe {
if task::failing() {
p.header.state = Terminated;
let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
if !old_task.is_null() {
rustrt::rust_task_deref(old_task);
}
}
}
};

let _drop_state = DropState { p: &p.header };
}
}

fn try_recv_<T:Owned>(p: &Packet<T>) -> Option<T> {
// optimistic path
match p.header.state {
Full => {
Expand Down Expand Up @@ -451,7 +449,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
Blocked);
match old_state {
Empty => {
debug!("no data available on %?, going to sleep.", p_);
debug!("no data available on %?, going to sleep.", p);
if count == 0 {
wait_event(this);
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ pub static tag_mod_impl_trait: uint = 0x47u;
different tags.
*/
pub static tag_item_impl_method: uint = 0x48u;
pub static tag_item_dtor: uint = 0x49u;
pub static tag_item_trait_method_self_ty: uint = 0x4b;
pub static tag_item_trait_method_self_ty_region: uint = 0x4c;

Expand Down
7 changes: 0 additions & 7 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,6 @@ pub fn get_impl_method(cstore: @mut cstore::CStore,
decoder::get_impl_method(cstore.intr, cdata, def.node, mname)
}

/* If def names a class with a dtor, return it. Otherwise, return none. */
pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id)
-> Option<ast::def_id> {
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::struct_dtor(cdata, def.node)
}

pub fn get_item_visibility(cstore: @mut cstore::CStore,
def_id: ast::def_id)
-> ast::visibility {
Expand Down
16 changes: 0 additions & 16 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,22 +445,6 @@ pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
found.get()
}

pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option<ast::def_id> {
let items = reader::get_doc(reader::Doc(cdata.data), tag_items);
let mut found = None;
let cls_items = match maybe_find_item(id, items) {
Some(it) => it,
None => fail!(fmt!("struct_dtor: class id not found \
when looking up dtor for %d", id))
};
for reader::tagged_docs(cls_items, tag_item_dtor) |doc| {
let doc1 = reader::get_doc(doc, tag_def_id);
let did = reader::with_doc_data(doc1, |d| parse_def_id(d));
found = Some(translate_def_id(cdata, did));
};
found
}

pub fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str {
return item_symbol(lookup_item(id, data));
}
Expand Down
27 changes: 0 additions & 27 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,26 +765,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
class itself */
let idx = encode_info_for_struct(ecx, ebml_w, path,
struct_def.fields, index);
/* Encode the dtor */
for struct_def.dtor.each |dtor| {
index.push(entry {val: dtor.node.id, pos: ebml_w.writer.tell()});
encode_info_for_ctor(ecx,
ebml_w,
dtor.node.id,
ecx.tcx.sess.ident_of(
*ecx.tcx.sess.str_of(item.ident) +
~"_dtor"),
path,
if generics.ty_params.len() > 0u {
Some(ii_dtor(copy *dtor,
item.ident,
copy *generics,
local_def(item.id))) }
else {
None
},
generics);
}

/* Index the class*/
add_to_index();
Expand Down Expand Up @@ -816,13 +796,6 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: &writer::Encoder,
encode_name(ecx, ebml_w, item.ident);
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
encode_region_param(ecx, ebml_w, item);
/* Encode the dtor */
/* Encode id for dtor */
for struct_def.dtor.each |dtor| {
do ebml_w.wr_tag(tag_item_dtor) {
encode_def_id(ebml_w, local_def(dtor.node.id));
}
};

/* Encode def_ids for each field and method
for methods, write all the stuff get_trait_method
Expand Down
26 changes: 0 additions & 26 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
ast::ii_foreign(i) => {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
let dtor_body = fld.fold_block(&dtor.node.body);
ast::ii_dtor(
codemap::spanned {
node: ast::struct_dtor_ { body: dtor_body,
.. /*bad*/copy (*dtor).node },
.. (/*bad*/copy *dtor) },
nm, /*bad*/copy *tps, parent_id)
}
}
}

Expand Down Expand Up @@ -363,23 +354,6 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
ast::ii_foreign(i) => {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => {
let dtor_body = fld.fold_block(&dtor.node.body);
let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
let new_generics = fold::fold_generics(generics, fld);
let dtor_id = fld.new_id((*dtor).node.id);
let new_parent = xcx.tr_def_id(parent_id);
let new_self = fld.new_id((*dtor).node.self_id);
ast::ii_dtor(
codemap::spanned {
node: ast::struct_dtor_ { id: dtor_id,
attrs: dtor_attrs,
self_id: new_self,
body: dtor_body },
.. (/*bad*/copy *dtor)
},
nm, new_generics, new_parent)
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,7 @@ fn check_loans_in_fn(fk: &visit::fn_kind,

let declared_purity, src;
match *fk {
visit::fk_item_fn(*) | visit::fk_method(*) |
visit::fk_dtor(*) => {
visit::fk_item_fn(*) | visit::fk_method(*) => {
declared_purity = ty::ty_fn_purity(fty);
src = id;
}
Expand Down Expand Up @@ -658,8 +657,7 @@ fn check_loans_in_fn(fk: &visit::fn_kind,
// inherits the fn_args from enclosing ctxt
}
visit::fk_anon(*) | visit::fk_fn_block(*) |
visit::fk_method(*) | visit::fk_item_fn(*) |
visit::fk_dtor(*) => {
visit::fk_method(*) | visit::fk_item_fn(*) => {
let mut fn_args = ~[];
for decl.inputs.each |input| {
// For the purposes of purity, only consider function-
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/borrowck/gather_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ fn req_loans_in_fn(fk: &visit::fn_kind,

match *fk {
visit::fk_anon(*) | visit::fk_fn_block(*) => {}
visit::fk_item_fn(*) | visit::fk_method(*) |
visit::fk_dtor(*) => {
visit::fk_item_fn(*) | visit::fk_method(*) => {
self.item_ub = body.node.id;
}
}
Expand Down
11 changes: 0 additions & 11 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
}
}
}
item_struct(struct_def, _) => {
match struct_def.dtor {
None => {}
Some(ref dtor) => {
let struct_did = def_id { crate: 0, node: item.id };
check_struct_safe_for_destructor(cx,
dtor.span,
struct_did);
}
}
}
_ => {}
}
}
Expand Down
29 changes: 0 additions & 29 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub enum lint {
type_limits,
default_methods,
deprecated_mutable_fields,
deprecated_drop,
unused_unsafe,

managed_heap_memory,
Expand Down Expand Up @@ -210,13 +209,6 @@ pub fn get_lint_dict() -> LintDict {
default: deny
}),

(~"deprecated_drop",
LintSpec {
lint: deprecated_drop,
desc: "deprecated \"drop\" notation for the destructor",
default: deny
}),

(~"unused_unsafe",
LintSpec {
lint: unused_unsafe,
Expand Down Expand Up @@ -463,7 +455,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
check_item_type_limits(cx, i);
check_item_default_methods(cx, i);
check_item_deprecated_mutable_fields(cx, i);
check_item_deprecated_drop(cx, i);
check_item_unused_unsafe(cx, i);
check_item_unused_mut(cx, i);
}
Expand Down Expand Up @@ -668,26 +659,6 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
}
}

fn check_item_deprecated_drop(cx: ty::ctxt, item: @ast::item) {
match item.node {
ast::item_struct(struct_def, _) => {
match struct_def.dtor {
None => {}
Some(ref dtor) => {
cx.sess.span_lint(deprecated_drop,
item.id,
item.id,
dtor.span,
~"`drop` notation for destructors is \
deprecated; implement the `Drop` \
trait instead");
}
}
}
_ => {}
}
}

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

fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ use syntax::ast::*;
use syntax::codemap::span;
use syntax::parse::token::special_idents;
use syntax::print::pprust::{expr_to_str, block_to_str};
use syntax::visit::{fk_anon, fk_dtor, fk_fn_block, fk_item_fn, fk_method};
use syntax::visit::{fk_anon, fk_fn_block, fk_item_fn, fk_method};
use syntax::visit::{vt};
use syntax::{visit, ast_util};

Expand Down Expand Up @@ -440,9 +440,6 @@ fn visit_fn(fk: &visit::fn_kind,
sty_static => {}
}
}
fk_dtor(_, _, self_id, _) => {
fn_maps.add_variable(Arg(self_id, special_idents::self_));
}
fk_item_fn(*) | fk_anon(*) | fk_fn_block(*) => {}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ pub fn resolve_fn(fk: &visit::fn_kind,
cx: ctxt,
visitor: visit::vt<ctxt>) {
let fn_cx = match *fk {
visit::fk_item_fn(*) | visit::fk_method(*) |
visit::fk_dtor(*) => {
visit::fk_item_fn(*) | visit::fk_method(*) => {
// Top-level functions are a root scope.
ctxt {parent: Some(id),.. cx}
}
Expand Down
21 changes: 1 addition & 20 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
use syntax::ast::{prim_ty, private, provided};
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
use syntax::ast::{struct_dtor, struct_field, struct_variant_kind};
use syntax::ast::{struct_field, struct_variant_kind};
use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, TyParam, ty_path};
Expand Down Expand Up @@ -3512,7 +3512,6 @@ pub impl Resolver {
self.resolve_struct(item.id,
generics,
struct_def.fields,
&struct_def.dtor,
visitor);
}

Expand Down Expand Up @@ -3770,7 +3769,6 @@ pub impl Resolver {
id: node_id,
generics: &Generics,
fields: &[@struct_field],
optional_destructor: &Option<struct_dtor>,
visitor: ResolveVisitor) {
// If applicable, create a rib for the type parameters.
do self.with_type_parameter_rib(HasTypeParameters
Expand All @@ -3784,23 +3782,6 @@ pub impl Resolver {
for fields.each |field| {
self.resolve_type(field.node.ty, visitor);
}

// Resolve the destructor, if applicable.
match *optional_destructor {
None => {
// Nothing to do.
}
Some(ref destructor) => {
self.resolve_function(NormalRibKind,
None,
NoTypeParameters,
&destructor.node.body,
HasSelfBinding
((*destructor).node.self_id,
true),
visitor);
}
}
}
}

Expand Down
Loading