impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::fold::TypeFoldable;
- use rustc_middle::ty::PredicateKind::*;
+ use rustc_middle::ty::PredicateAtom::*;
if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
for &(predicate, span) in predicates.predicates {
// We don't actually look inside of the predicate,
// so it is safe to skip this binder here.
- let predicate_kind_name = match predicate.ignore_qualifiers(cx.tcx).skip_binder().kind() {
+ let predicate_kind_name = match predicate.skip_binders() {
Trait(..) => "Trait",
TypeOutlives(..) |
RegionOutlives(..) => "Lifetime",
Subtype(..) |
ConstEvaluatable(..) |
ConstEquate(..) => continue,
- ForAll(_) => bug!("unexpected predicate: {:?}", predicate)
};
if predicate.is_global() {
cx.struct_span_lint(TRIVIAL_BOUNDS, span, |lint| {
impl ExplicitOutlivesRequirements {
fn lifetimes_outliving_lifetime<'tcx>(
- tcx: TyCtxt<'tcx>,
inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
index: u32,
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
- .filter_map(|(pred, _)| match pred.ignore_qualifiers(tcx).skip_binder().kind() {
- &ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
+ .filter_map(|(pred, _)| match pred.skip_binders() {
+ ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
_ => None,
},
}
fn lifetimes_outliving_type<'tcx>(
- tcx: TyCtxt<'tcx>,
inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
index: u32,
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
- .filter_map(|(pred, _)| match pred.ignore_qualifiers(tcx).skip_binder().kind() {
- &ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
+ .filter_map(|(pred, _)| match pred.skip_binders() {
+ ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
a.is_param(index).then_some(b)
}
_ => None,
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {
- Self::lifetimes_outliving_lifetime(tcx, inferred_outlives, index)
+ Self::lifetimes_outliving_lifetime(inferred_outlives, index)
}
hir::GenericParamKind::Type { .. } => {
- Self::lifetimes_outliving_type(tcx, inferred_outlives, index)
+ Self::lifetimes_outliving_type(inferred_outlives, index)
}
hir::GenericParamKind::Const { .. } => Vec::new(),
}
cx.tcx.named_region(predicate.lifetime.hir_id)
{
(
- Self::lifetimes_outliving_lifetime(
- cx.tcx,
- inferred_outlives,
- index,
- ),
+ Self::lifetimes_outliving_lifetime(inferred_outlives, index),
&predicate.bounds,
predicate.span,
)
if let Res::Def(DefKind::TyParam, def_id) = path.res {
let index = ty_generics.param_def_id_to_index[&def_id];
(
- Self::lifetimes_outliving_type(
- cx.tcx,
- inferred_outlives,
- index,
- ),
+ Self::lifetimes_outliving_type(inferred_outlives, index),
&predicate.bounds,
predicate.span,
)