1
Fork 0

s/Clause/ClauseKind

This commit is contained in:
Michael Goulet 2023-06-16 05:59:42 +00:00
parent 18a6d911ca
commit fca56a8d2c
101 changed files with 592 additions and 544 deletions

View file

@ -1592,27 +1592,27 @@ declare_lint_pass!(
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::Clause;
use rustc_middle::ty::ClauseKind;
use rustc_middle::ty::PredicateKind::*;
if cx.tcx.features().trivial_bounds {
let predicates = cx.tcx.predicates_of(item.owner_id);
for &(predicate, span) in predicates.predicates {
let predicate_kind_name = match predicate.kind().skip_binder() {
Clause(Clause::Trait(..)) => "trait",
Clause(Clause::TypeOutlives(..)) |
Clause(Clause::RegionOutlives(..)) => "lifetime",
Clause(ClauseKind::Trait(..)) => "trait",
Clause(ClauseKind::TypeOutlives(..)) |
Clause(ClauseKind::RegionOutlives(..)) => "lifetime",
// `ConstArgHasType` is never global as `ct` is always a param
Clause(Clause::ConstArgHasType(..)) |
Clause(ClauseKind::ConstArgHasType(..)) |
// Ignore projections, as they can only be global
// if the trait bound is global
Clause(Clause::Projection(..)) |
AliasRelate(..) |
Clause(ClauseKind::Projection(..)) |
// Ignore bounds that a user can't type
Clause(Clause::WellFormed(..)) |
Clause(ClauseKind::WellFormed(..)) |
// FIXME(generic_const_exprs): `ConstEvaluatable` can be written
Clause(Clause::ConstEvaluatable(..)) |
Clause(ClauseKind::ConstEvaluatable(..)) |
AliasRelate(..) |
ObjectSafe(..) |
ClosureKind(..) |
Subtype(..) |
@ -1984,13 +1984,13 @@ declare_lint_pass!(ExplicitOutlivesRequirements => [EXPLICIT_OUTLIVES_REQUIREMEN
impl ExplicitOutlivesRequirements {
fn lifetimes_outliving_lifetime<'tcx>(
inferred_outlives: &'tcx [(ty::Clause<'tcx>, Span)],
inferred_outlives: &'tcx [(ty::ClauseKind<'tcx>, Span)],
def_id: DefId,
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
.filter_map(|(clause, _)| match *clause {
ty::Clause::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
_ => None,
},
@ -2000,13 +2000,13 @@ impl ExplicitOutlivesRequirements {
}
fn lifetimes_outliving_type<'tcx>(
inferred_outlives: &'tcx [(ty::Clause<'tcx>, Span)],
inferred_outlives: &'tcx [(ty::ClauseKind<'tcx>, Span)],
index: u32,
) -> Vec<ty::Region<'tcx>> {
inferred_outlives
.iter()
.filter_map(|(clause, _)| match *clause {
ty::Clause::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
a.is_param(index).then_some(b)
}
_ => None,

View file

@ -78,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
// Liberate bound regions in the predicate since we
// don't actually care about lifetimes in this check.
let predicate = cx.tcx.liberate_late_bound_regions(def_id, pred.kind());
let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) = predicate else {
let ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) = predicate else {
continue;
};
// Only check types, since those are the only things that may
@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
let add_bound = match (proj_term.kind(), assoc_pred.kind().skip_binder()) {
(
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }),
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)),
ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)),
) => Some(AddBound {
suggest_span: cx.tcx.def_span(*def_id).shrink_to_hi(),
trait_ref: trait_pred.print_modifiers_and_trait_path(),

View file

@ -87,12 +87,12 @@ declare_lint_pass!(
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::Clause;
use rustc_middle::ty::ClauseKind;
use rustc_middle::ty::PredicateKind::*;
let predicates = cx.tcx.explicit_predicates_of(item.owner_id);
for &(predicate, span) in predicates.predicates {
let Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
let Clause(ClauseKind::Trait(trait_predicate)) = predicate.kind().skip_binder() else {
continue
};
let def_id = trait_predicate.trait_ref.def_id;

View file

@ -289,7 +289,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
.filter_only_self()
.find_map(|(pred, _span)| {
// We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateKind::Clause(ty::Clause::Trait(
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(
ref poly_trait_predicate,
)) = pred.kind().skip_binder()
{