Skip to content

Commit 34c614b

Browse files
committed
port of pcwalton removal of #[unsafe_destructor] check.
Since the earlier commits impose rules on lifetimes that make destructors safe, we no longer need the `#[unsafe_destructor]` attribute nor its associated check. ---- Since this is removing a (somewhat common albeit unsafe) attribute, this is a (wait for it) [breaking-change]
1 parent 4502f0e commit 34c614b

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

src/librustc_typeck/check/wf.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use util::ppaux::Repr;
2222
use std::collections::HashSet;
2323
use syntax::ast;
2424
use syntax::ast_util::{local_def};
25-
use syntax::attr;
2625
use syntax::codemap::Span;
2726
use syntax::parse::token;
2827
use syntax::visit;
@@ -226,22 +225,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
226225
&fcx.inh.param_env.free_substs,
227226
&trait_ref);
228227

229-
// There are special rules that apply to drop.
230-
if
231-
fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
232-
!attr::contains_name(&item.attrs, "unsafe_destructor")
233-
{
234-
match self_ty.sty {
235-
ty::ty_struct(def_id, _) |
236-
ty::ty_enum(def_id, _) => {
237-
check_struct_safe_for_destructor(fcx, item.span, def_id);
238-
}
239-
_ => {
240-
// Coherence already reports an error in this case.
241-
}
242-
}
243-
}
244-
245228
if fcx.tcx().lang_items.copy_trait() == Some(trait_ref.def_id) {
246229
// This is checked in coherence.
247230
return
@@ -621,22 +604,3 @@ fn filter_to_trait_obligations<'tcx>(bounds: ty::GenericBounds<'tcx>)
621604
}
622605
result
623606
}
624-
625-
///////////////////////////////////////////////////////////////////////////
626-
// Special drop trait checking
627-
628-
fn check_struct_safe_for_destructor<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
629-
span: Span,
630-
struct_did: ast::DefId) {
631-
let struct_tpt = ty::lookup_item_type(fcx.tcx(), struct_did);
632-
if struct_tpt.generics.has_type_params(subst::TypeSpace)
633-
|| struct_tpt.generics.has_region_params(subst::TypeSpace)
634-
{
635-
span_err!(fcx.tcx().sess, span, E0141,
636-
"cannot implement a destructor on a structure \
637-
with type parameters");
638-
span_note!(fcx.tcx().sess, span,
639-
"use \"#[unsafe_destructor]\" on the implementation \
640-
to force the compiler to allow this");
641-
}
642-
}

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,8 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
346346
"unsafe_destructor") {
347347
self.gate_feature("unsafe_destructor",
348348
i.span,
349-
"`#[unsafe_destructor]` allows too \
350-
many unsafe patterns and may be \
351-
removed in the future");
349+
"`#[unsafe_destructor]` does nothing \
350+
anymore")
352351
}
353352

354353
if attr::contains_name(&i.attrs[],

0 commit comments

Comments
 (0)