Skip to content

Commit 40b8428

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 2316d6c commit 40b8428

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

src/librustc_typeck/check/wf.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,6 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
206206
&fcx.inh.param_env.free_substs,
207207
&trait_ref);
208208

209-
// There are special rules that apply to drop.
210-
if
211-
fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
212-
!attr::contains_name(item.attrs.as_slice(), "unsafe_destructor")
213-
{
214-
match self_ty.sty {
215-
ty::ty_struct(def_id, _) |
216-
ty::ty_enum(def_id, _) => {
217-
check_struct_safe_for_destructor(fcx, item.span, def_id);
218-
}
219-
_ => {
220-
// Coherence already reports an error in this case.
221-
}
222-
}
223-
}
224-
225209
if fcx.tcx().lang_items.copy_trait() == Some(trait_ref.def_id) {
226210
// This is checked in coherence.
227211
return
@@ -595,22 +579,3 @@ fn filter_to_trait_obligations<'tcx>(bounds: ty::GenericBounds<'tcx>)
595579
}
596580
result
597581
}
598-
599-
///////////////////////////////////////////////////////////////////////////
600-
// Special drop trait checking
601-
602-
fn check_struct_safe_for_destructor<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
603-
span: Span,
604-
struct_did: ast::DefId) {
605-
let struct_tpt = ty::lookup_item_type(fcx.tcx(), struct_did);
606-
if struct_tpt.generics.has_type_params(subst::TypeSpace)
607-
|| struct_tpt.generics.has_region_params(subst::TypeSpace)
608-
{
609-
span_err!(fcx.tcx().sess, span, E0141,
610-
"cannot implement a destructor on a structure \
611-
with type parameters");
612-
span_note!(fcx.tcx().sess, span,
613-
"use \"#[unsafe_destructor]\" on the implementation \
614-
to force the compiler to allow this");
615-
}
616-
}

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,8 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
300300
"unsafe_destructor") {
301301
self.gate_feature("unsafe_destructor",
302302
i.span,
303-
"`#[unsafe_destructor]` allows too \
304-
many unsafe patterns and may be \
305-
removed in the future");
303+
"`#[unsafe_destructor]` does nothing \
304+
anymore")
306305
}
307306

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

0 commit comments

Comments
 (0)