Skip to content

Commit adb7fc6

Browse files
committed
Fix tools
1 parent 22c5e0c commit adb7fc6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

clippy_lints/src/future_not_send.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rustc_hir::intravisit::FnKind;
33
use rustc_hir::{Body, FnDecl, HirId};
44
use rustc_infer::infer::TyCtxtInferExt;
55
use rustc_lint::{LateContext, LateLintPass};
6+
use rustc_middle::ty::subst::Subst;
67
use rustc_middle::ty::{Opaque, PredicateAtom::Trait};
78
use rustc_session::{declare_lint_pass, declare_tool_lint};
89
use rustc_span::{sym, Span};
@@ -62,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6263
}
6364
let ret_ty = utils::return_ty(cx, hir_id);
6465
if let Opaque(id, subst) = *ret_ty.kind() {
65-
let preds = cx.tcx.predicates_of(id).instantiate(cx.tcx, subst);
66+
let preds = cx.tcx.explicit_item_bounds(id);
6667
let mut is_future = false;
67-
for p in preds.predicates {
68+
for &(p, _span) in preds {
69+
let p = p.subst(cx.tcx, subst);
6870
if let Some(trait_ref) = p.to_opt_poly_trait_ref() {
6971
if Some(trait_ref.def_id()) == cx.tcx.lang_items().future_trait() {
7072
is_future = true;
@@ -90,8 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9092
|db| {
9193
cx.tcx.infer_ctxt().enter(|infcx| {
9294
for FulfillmentError { obligation, .. } in send_errors {
93-
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
94-
if let Trait(trait_pred, _) = obligation.predicate.skip_binders() {
95+
infcx.maybe_note_obligation_cause_for_async_await(
96+
db,
97+
&obligation,
98+
);
99+
if let Trait(trait_pred, _) =
100+
obligation.predicate.skip_binders()
101+
{
95102
db.note(&format!(
96103
"`{}` doesn't implement `{}`",
97104
trait_pred.self_ty(),

clippy_lints/src/methods/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1667,8 +1667,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
16671667
// if return type is impl trait, check the associated types
16681668
if let ty::Opaque(def_id, _) = *ret_ty.kind() {
16691669
// one of the associated types must be Self
1670-
for &(predicate, _span) in cx.tcx.predicates_of(def_id).predicates {
1671-
if let ty::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() {
1670+
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
1671+
if let ty::PredicateAtom::Projection(projection_predicate) =
1672+
predicate.skip_binders()
1673+
{
16721674
// walk the associated type and check for Self
16731675
if contains_ty(projection_predicate.ty, self_ty) {
16741676
return;

clippy_lints/src/utils/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,10 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
12851285
},
12861286
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
12871287
ty::Opaque(ref def_id, _) => {
1288-
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates {
1288+
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
12891289
if let ty::PredicateAtom::Trait(trait_predicate, _) = predicate.skip_binders() {
1290-
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
1290+
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some()
1291+
{
12911292
return true;
12921293
}
12931294
}

0 commit comments

Comments
 (0)