Skip to content

Commit

Permalink
Generalize dropck to ignore item-less traits.
Browse files Browse the repository at this point in the history
Fix #24805

(see follow-on commit for test.)
  • Loading branch information
pnkfelix committed Apr 30, 2015
1 parent 42bfeec commit c76d66e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/librustc_typeck/check/dropck.rs
Expand Up @@ -453,29 +453,25 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>(
let dtor_predicates = ty::lookup_predicates(rcx.tcx(), impl_did);

let has_pred_of_interest = dtor_predicates.predicates.iter().any(|pred| {
// In `impl<T> Drop where ...`, we automatically
// assume some predicate will be meaningful and thus
// represents a type through which we could reach
// borrowed data. However, there can be implicit
// predicates (namely for Sized), and so we still need
// to walk through and filter out those cases.
// In `impl<T> Drop where ...`, assume most predicates
// represent capability on `T` via which a destructor
// could access borrowed data. But some bounds (Sized,
// Copy, etc), have no items, i.e. no added capabilty
// for such type-specific access.

let result = match *pred {
ty::Predicate::Trait(ty::Binder(ref t_pred)) => {
let def_id = t_pred.trait_ref.def_id;
match rcx.tcx().lang_items.to_builtin_kind(def_id) {
// Issue 24895: deliberately do not include `BoundCopy` here.
Some(ty::BoundSend) |
Some(ty::BoundSized) |
Some(ty::BoundSync) => false,
_ => true,
}
// A OIBIT (or even a normal builtin) trait
// defines no associated items, and is
// uninteresting from point of view of dropck.
ty::trait_items(rcx.tcx(), def_id).len() != 0
}
ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) |
ty::Predicate::TypeOutlives(..) |
ty::Predicate::Projection(..) => {
// we assume all of these where-clauses may
// for now, assume all other where-clauses may
// give the drop implementation the capabilty
// to access borrowed data.
true
Expand Down

0 comments on commit c76d66e

Please sign in to comment.