Skip to content

Commit dfa1af2

Browse files
committed
clippy
1 parent d164ab6 commit dfa1af2

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

clippy_lints/src/future_not_send.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +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::{Opaque, PredicateKind::Trait, ToPolyTraitRef};
6+
use rustc_middle::ty::{Opaque, PredicateKind::Trait};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use rustc_span::{sym, Span};
99
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
@@ -91,12 +91,11 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9191
cx.tcx.infer_ctxt().enter(|infcx| {
9292
for FulfillmentError { obligation, .. } in send_errors {
9393
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
94-
if let Trait(trait_pred, _) = obligation.predicate.kind() {
95-
let trait_ref = trait_pred.to_poly_trait_ref();
96-
db.note(&*format!(
94+
if let Trait(trait_pred, _) = obligation.predicate.ignore_qualifiers().skip_binder().kind() {
95+
db.note(&format!(
9796
"`{}` doesn't implement `{}`",
98-
trait_ref.skip_binder().self_ty(),
99-
trait_ref.print_only_trait_path(),
97+
trait_pred.self_ty(),
98+
trait_pred.trait_ref.print_only_trait_path(),
10099
));
101100
}
102101
}

clippy_lints/src/methods/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,13 +1558,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
15581558
// if return type is impl trait, check the associated types
15591559
if let ty::Opaque(def_id, _) = ret_ty.kind {
15601560
// one of the associated types must be Self
1561-
for predicate in cx.tcx.predicates_of(def_id).predicates {
1562-
if let ty::PredicateKind::Projection(poly_projection_predicate) = predicate.0.kind() {
1563-
let binder = poly_projection_predicate.ty();
1564-
let associated_type = binder.skip_binder();
1565-
1561+
for &(predicate, _span) in cx.tcx.predicates_of(def_id).predicates {
1562+
if let ty::PredicateKind::Projection(projection_predicate) = predicate.ignore_qualifiers().skip_binder().kind() {
15661563
// walk the associated type and check for Self
1567-
if contains_self_ty(associated_type) {
1564+
if contains_self_ty(projection_predicate.ty) {
15681565
return;
15691566
}
15701567
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
114114
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds().iter())
115115
.filter(|p| !p.is_global())
116116
.filter_map(|obligation| {
117-
if let ty::PredicateKind::Trait(poly_trait_ref, _) = obligation.predicate.kind() {
118-
if poly_trait_ref.def_id() == sized_trait || poly_trait_ref.skip_binder().has_escaping_bound_vars()
119-
{
117+
// Note that we do not want to deal with qualified predicates here.
118+
if let ty::PredicateKind::Trait(pred, _) = obligation.predicate.kind() {
119+
if pred.def_id() == sized_trait {
120120
return None;
121121
}
122-
Some(poly_trait_ref)
122+
Some(pred)
123123
} else {
124124
None
125125
}
@@ -159,23 +159,27 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
159159
}
160160
}
161161

162-
//
163162
// * Exclude a type that is specifically bounded by `Borrow`.
164163
// * Exclude a type whose reference also fulfills its bound. (e.g., `std::convert::AsRef`,
165164
// `serde::Serialize`)
166165
let (implements_borrow_trait, all_borrowable_trait) = {
167166
let preds = preds
168167
.iter()
169-
.filter(|t| t.skip_binder().self_ty() == ty)
168+
.filter(|t| t.self_ty() == ty)
170169
.collect::<Vec<_>>();
171170

172171
(
173172
preds.iter().any(|t| t.def_id() == borrow_trait),
174173
!preds.is_empty() && {
175174
let ty_empty_region = cx.tcx.mk_imm_ref(cx.tcx.lifetimes.re_root_empty, ty);
176175
preds.iter().all(|t| {
177-
let ty_params = &t.skip_binder().trait_ref.substs.iter().skip(1).collect::<Vec<_>>();
178-
implements_trait(cx, ty_empty_region, t.def_id(), ty_params)
176+
let ty_params = t
177+
.trait_ref
178+
.substs
179+
.iter()
180+
.skip(1)
181+
.collect::<Vec<_>>();
182+
implements_trait(cx, ty_empty_region, t.def_id(), &ty_params)
179183
})
180184
},
181185
)

clippy_lints/src/utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,8 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
12631263
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
12641264
ty::Opaque(ref def_id, _) => {
12651265
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates {
1266-
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) = predicate.kind() {
1267-
if must_use_attr(&cx.tcx.get_attrs(poly_trait_predicate.skip_binder().trait_ref.def_id)).is_some() {
1266+
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.ignore_qualifiers().skip_binder().kind() {
1267+
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
12681268
return true;
12691269
}
12701270
}

0 commit comments

Comments
 (0)