Do not lint for ~const Drop bounds
This commit is contained in:
parent
104e40fb74
commit
9125fbfd60
1 changed files with 5 additions and 0 deletions
|
@ -87,6 +87,7 @@ declare_lint_pass!(
|
|||
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
use rustc_middle::ty::PredicateKind::*;
|
||||
use rustc_middle::ty;
|
||||
|
||||
let predicates = cx.tcx.explicit_predicates_of(item.def_id);
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
|
@ -94,6 +95,10 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
|||
Trait(trait_predicate) => trait_predicate,
|
||||
_ => continue,
|
||||
};
|
||||
if trait_predicate.constness == ty::BoundConstness::ConstIfConst {
|
||||
// `~const Drop` definitely have meanings so avoid linting here.
|
||||
continue
|
||||
}
|
||||
let def_id = trait_predicate.trait_ref.def_id;
|
||||
if cx.tcx.lang_items().drop_trait() == Some(def_id) {
|
||||
// Explicitly allow `impl Drop`, a drop-guards-as-Voldemort-type pattern.
|
||||
|
|
Loading…
Add table
Reference in a new issue