Review changes
This commit is contained in:
parent
82569601f2
commit
e73b8dcbca
@ -4,7 +4,7 @@
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::{Opaque, PredicateAtom::Trait};
|
||||
use rustc_middle::ty::{Opaque, PredicateKind::Trait};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
|
||||
@ -97,7 +97,7 @@ fn check_fn(
|
||||
&obligation,
|
||||
);
|
||||
if let Trait(trait_pred, _) =
|
||||
obligation.predicate.skip_binders()
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
db.note(&format!(
|
||||
"`{}` doesn't implement `{}`",
|
||||
|
@ -1697,7 +1697,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::Impl
|
||||
if let ty::Opaque(def_id, _) = *ret_ty.kind() {
|
||||
// one of the associated types must be Self
|
||||
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
|
||||
if let ty::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
|
||||
// walk the associated type and check for Self
|
||||
if contains_ty(projection_predicate.ty, self_ty) {
|
||||
return;
|
||||
|
@ -115,13 +115,10 @@ fn check_fn(
|
||||
.filter(|p| !p.is_global())
|
||||
.filter_map(|obligation| {
|
||||
// Note that we do not want to deal with qualified predicates here.
|
||||
match obligation.predicate.bound_atom().skip_binder() {
|
||||
ty::PredicateAtom::Trait(pred, _) if !pred.has_escaping_bound_vars() => {
|
||||
if pred.def_id() == sized_trait {
|
||||
return None;
|
||||
}
|
||||
match obligation.predicate.kind().no_bound_vars() {
|
||||
Some(ty::PredicateKind::Trait(pred, _)) if pred.def_id() != sized_trait => {
|
||||
Some(pred)
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
|
@ -4,7 +4,7 @@
|
||||
use rustc_hir::{Expr, ExprKind, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::{GenericPredicates, PredicateAtom, ProjectionPredicate, TraitPredicate};
|
||||
use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
@ -42,7 +42,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
|
||||
let mut preds = Vec::new();
|
||||
for (pred, _) in generics.predicates {
|
||||
if_chain! {
|
||||
if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
|
||||
if let PredicateKind::Trait(poly_trait_pred, _) = pred.kind().skip_binder();
|
||||
let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred));
|
||||
if let Some(trait_def_id) = trait_id;
|
||||
if trait_def_id == trait_pred.trait_ref.def_id;
|
||||
@ -60,7 +60,7 @@ fn get_projection_pred<'tcx>(
|
||||
pred: TraitPredicate<'tcx>,
|
||||
) -> Option<ProjectionPredicate<'tcx>> {
|
||||
generics.predicates.iter().find_map(|(proj_pred, _)| {
|
||||
if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(proj_pred) = proj_pred.kind().skip_binder() {
|
||||
let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred));
|
||||
if projection_pred.projection_ty.substs == pred.trait_ref.substs {
|
||||
return Some(projection_pred);
|
||||
|
@ -1470,7 +1470,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
|
||||
ty::Opaque(ref def_id, _) => {
|
||||
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
||||
if let ty::PredicateAtom::Trait(trait_predicate, _) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.kind().skip_binder() {
|
||||
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
|
||||
return true;
|
||||
}
|
||||
|
@ -19,18 +19,18 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>) -> McfResult {
|
||||
loop {
|
||||
let predicates = tcx.predicates_of(current);
|
||||
for (predicate, _) in predicates.predicates {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(_)
|
||||
| ty::PredicateAtom::TypeOutlives(_)
|
||||
| ty::PredicateAtom::WellFormed(_)
|
||||
| ty::PredicateAtom::Projection(_)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateAtom::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::Trait(pred, _) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::Projection(_)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::Trait(pred, _) => {
|
||||
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user