Skip to content

Commit 61eab6e

Browse files
committed
Auto merge of rust-lang#5853 - flip1995:rustup, r=flip1995
Rustup r? @ghost changelog: none
2 parents d3e9db7 + 04f4471 commit 61eab6e

File tree

5 files changed

+22
-29
lines changed

5 files changed

+22
-29
lines changed

clippy_lints/src/future_not_send.rs

+5-6
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, PredicateAtom::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.skip_binders() {
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

+3-6
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::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() {
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

+7-10
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
113113
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds().iter())
114114
.filter(|p| !p.is_global())
115115
.filter_map(|obligation| {
116-
if let ty::PredicateKind::Trait(poly_trait_ref, _) = obligation.predicate.kind() {
117-
if poly_trait_ref.def_id() == sized_trait || poly_trait_ref.skip_binder().has_escaping_bound_vars()
118-
{
116+
// Note that we do not want to deal with qualified predicates here.
117+
if let ty::PredicateKind::Atom(ty::PredicateAtom::Trait(pred, _)) = obligation.predicate.kind() {
118+
if pred.def_id() == sized_trait {
119119
return None;
120120
}
121-
Some(poly_trait_ref)
121+
Some(pred)
122122
} else {
123123
None
124124
}
@@ -163,18 +163,15 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
163163
// * Exclude a type whose reference also fulfills its bound. (e.g., `std::convert::AsRef`,
164164
// `serde::Serialize`)
165165
let (implements_borrow_trait, all_borrowable_trait) = {
166-
let preds = preds
167-
.iter()
168-
.filter(|t| t.skip_binder().self_ty() == ty)
169-
.collect::<Vec<_>>();
166+
let preds = preds.iter().filter(|t| t.self_ty() == ty).collect::<Vec<_>>();
170167

171168
(
172169
preds.iter().any(|t| t.def_id() == borrow_trait),
173170
!preds.is_empty() && {
174171
let ty_empty_region = cx.tcx.mk_imm_ref(cx.tcx.lifetimes.re_root_empty, ty);
175172
preds.iter().all(|t| {
176-
let ty_params = &t.skip_binder().trait_ref.substs.iter().skip(1).collect::<Vec<_>>();
177-
implements_trait(cx, ty_empty_region, t.def_id(), ty_params)
173+
let ty_params = t.trait_ref.substs.iter().skip(1).collect::<Vec<_>>();
174+
implements_trait(cx, ty_empty_region, t.def_id(), &ty_params)
178175
})
179176
},
180177
)

clippy_lints/src/unit_return_expecting_ord.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId;
44
use rustc_hir::{Expr, ExprKind, StmtKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::ty;
7-
use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
7+
use rustc_middle::ty::{GenericPredicates, PredicateAtom, ProjectionPredicate, TraitPredicate};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::{BytePos, Span};
1010

@@ -42,8 +42,8 @@ fn get_trait_predicates_for_trait_id<'tcx>(
4242
let mut preds = Vec::new();
4343
for (pred, _) in generics.predicates {
4444
if_chain! {
45-
if let PredicateKind::Trait(poly_trait_pred, _) = pred.kind();
46-
let trait_pred = cx.tcx.erase_late_bound_regions(&poly_trait_pred);
45+
if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
46+
let trait_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(poly_trait_pred));
4747
if let Some(trait_def_id) = trait_id;
4848
if trait_def_id == trait_pred.trait_ref.def_id;
4949
then {
@@ -60,8 +60,8 @@ fn get_projection_pred<'tcx>(
6060
pred: TraitPredicate<'tcx>,
6161
) -> Option<ProjectionPredicate<'tcx>> {
6262
generics.predicates.iter().find_map(|(proj_pred, _)| {
63-
if let PredicateKind::Projection(proj_pred) = proj_pred.kind() {
64-
let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred);
63+
if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
64+
let projection_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(proj_pred));
6565
if projection_pred.projection_ty.substs == pred.trait_ref.substs {
6666
return Some(projection_pred);
6767
}

clippy_lints/src/utils/mod.rs

+2-2
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::PredicateAtom::Trait(trait_predicate, _) = predicate.skip_binders() {
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)