Skip to content

Refactor branch Clause:: #107603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2003,9 +2003,9 @@ dependencies = [

[[package]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop the Cargo.lock change from these changes?

name = "http-auth"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b40b39d66c28829a0cf4d09f7e139ff8201f7500a5083732848ed3b4b4d850"
checksum = "3d4ad8df7ddb631856ed3e5a385b781ae8d731727ae5dd7c5aa4784bfa878405"
dependencies = [
"memchr",
]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {

// Find out if the predicates show that the type is a Fn or FnMut
let find_fn_kind_from_did = |(pred, _): (ty::Predicate<'tcx>, _)| {
if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = pred.kind().skip_binder()
if let ty::PredicateKind::Clause(ty::clause::Trait(pred)) = pred.kind().skip_binder()
&& pred.self_ty() == ty
{
if Some(pred.def_id()) == tcx.lang_items().fn_trait() {
Expand Down Expand Up @@ -782,7 +782,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let predicates: Result<Vec<_>, _> = errors
.into_iter()
.map(|err| match err.obligation.predicate.kind().skip_binder() {
PredicateKind::Clause(ty::Clause::Trait(predicate)) => {
PredicateKind::Clause(ty::clause::Trait(predicate)) => {
match predicate.self_ty().kind() {
ty::Param(param_ty) => Ok((
generics.type_param(param_ty, tcx),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
{
predicates.iter().any(|pred| {
match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(data)) if data.self_ty() == ty => {}
ty::PredicateKind::Clause(ty::Clause::Projection(data)) if data.projection_ty.self_ty() == ty => {}
ty::PredicateKind::Clause(ty::clause::Trait(data)) if data.self_ty() == ty => {}
ty::PredicateKind::Clause(ty::clause::Projection(data)) if data.projection_ty.self_ty() == ty => {}
_ => return false,
}
tcx.any_free_region_meets(pred, |r| {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory<'tcx>,
) {
self.prove_predicate(
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
ty::Binder::dummy(ty::PredicateKind::Clause(ty::clause::Trait(ty::TraitPredicate {
trait_ref,
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Positive,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

let outlives_predicate =
tcx.mk_predicate(Binder::dummy(ty::PredicateKind::Clause(
ty::Clause::TypeOutlives(ty::OutlivesPredicate(self_ty, *region)),
ty::clause::TypeOutlives(ty::OutlivesPredicate(self_ty, *region)),
)));
self.prove_predicate(
outlives_predicate,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ impl<'a> TraitDef<'a> {
defaultness: ast::Defaultness::Final,
generics: Generics::default(),
where_clauses: (
ast::TyAliasWhereClause::default(),
ast::TyAliasWhereClause::default(),
ast::TyAliasWhereclause::default(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A global "Clause" -> "clause" rename is going to give a ton of mistakes like this. Can you fix those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did not notice that, will be fixing it :)

ast::TyAliasWhereclause::default(),
),
where_predicates_split: 0,
bounds: Vec::new(),
Expand All @@ -595,7 +595,7 @@ impl<'a> TraitDef<'a> {
})
});

let mut where_clause = ast::WhereClause::default();
let mut where_clause = ast::Whereclause::default();
where_clause.span = generics.where_clause.span;
let ctxt = self.span.ctxt();
let span = generics.span.with_ctxt(ctxt);
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,21 +1309,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let bound_pred = pred.kind();
match bound_pred.skip_binder() {
ty::PredicateKind::Clause(clause) => match clause {
ty::Clause::Trait(trait_pred) => {
ty::clause::Trait(trait_pred) => {
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
trait_bounds.push((
bound_pred.rebind(trait_pred.trait_ref),
span,
trait_pred.constness,
));
}
ty::Clause::Projection(proj) => {
ty::clause::Projection(proj) => {
projection_bounds.push((bound_pred.rebind(proj), span));
}
ty::Clause::TypeOutlives(_) => {
ty::clause::TypeOutlives(_) => {
// Do nothing, we deal with regions separately
}
ty::Clause::RegionOutlives(_) => bug!(),
ty::clause::RegionOutlives(_) => bug!(),
},
ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::ObjectSafe(_)
Expand Down Expand Up @@ -1424,7 +1424,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {

let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
ty::PredicateKind::Clause(ty::clause::Trait(pred)) => {
let pred = bound_predicate.rebind(pred);
associated_types.entry(span).or_default().extend(
tcx.associated_items(pred.def_id())
Expand All @@ -1433,7 +1433,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map(|item| item.def_id),
);
}
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
ty::PredicateKind::Clause(ty::clause::Projection(pred)) => {
let pred = bound_predicate.rebind(pred);
// A `Self` within the original bound will be substituted with a
// `trait_object_dummy_self`, so check for that.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,23 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let p = p.kind();
match (predicate.skip_binder(), p.skip_binder()) {
(
ty::PredicateKind::Clause(ty::Clause::Trait(a)),
ty::PredicateKind::Clause(ty::Clause::Trait(b)),
ty::PredicateKind::Clause(ty::clause::Trait(a)),
ty::PredicateKind::Clause(ty::clause::Trait(b)),
) => relator.relate(predicate.rebind(a), p.rebind(b)).is_ok(),
(
ty::PredicateKind::Clause(ty::Clause::Projection(a)),
ty::PredicateKind::Clause(ty::Clause::Projection(b)),
ty::PredicateKind::Clause(ty::clause::Projection(a)),
ty::PredicateKind::Clause(ty::clause::Projection(b)),
) => relator.relate(predicate.rebind(a), p.rebind(b)).is_ok(),
(
ty::PredicateKind::ConstEvaluatable(a),
ty::PredicateKind::ConstEvaluatable(b),
) => relator.relate(predicate.rebind(a), predicate.rebind(b)).is_ok(),
(
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
ty::PredicateKind::Clause(ty::clause::TypeOutlives(ty::OutlivesPredicate(
ty_a,
lt_a,
))),
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
ty::PredicateKind::Clause(ty::clause::TypeOutlives(ty::OutlivesPredicate(
ty_b,
lt_b,
))),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn bounds_from_generic_predicates<'tcx>(
debug!("predicate {:?}", predicate);
let bound_predicate = predicate.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(trait_predicate)) => {
ty::PredicateKind::Clause(ty::clause::Trait(trait_predicate)) => {
let entry = types.entry(trait_predicate.self_ty()).or_default();
let def_id = trait_predicate.def_id();
if Some(def_id) != tcx.lang_items().sized_trait() {
Expand All @@ -319,7 +319,7 @@ fn bounds_from_generic_predicates<'tcx>(
entry.push(trait_predicate.def_id());
}
}
ty::PredicateKind::Clause(ty::Clause::Projection(projection_pred)) => {
ty::PredicateKind::Clause(ty::clause::Projection(projection_pred)) => {
projections.push(bound_predicate.rebind(projection_pred));
}
_ => {}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
let mut unsatisfied_bounds: Vec<_> = required_bounds
.into_iter()
.filter(|clause| match clause.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(
ty::PredicateKind::Clause(ty::clause::RegionOutlives(ty::OutlivesPredicate(
a,
b,
))) => !region_known_to_outlive(
Expand All @@ -474,7 +474,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
a,
b,
),
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(
ty::PredicateKind::Clause(ty::clause::TypeOutlives(ty::OutlivesPredicate(
a,
b,
))) => !ty_known_to_outlive(
Expand Down Expand Up @@ -616,7 +616,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
}));
// The predicate we expect to see. (In our example,
// `Self: 'me`.)
let clause = ty::PredicateKind::Clause(ty::Clause::TypeOutlives(
let clause = ty::PredicateKind::Clause(ty::clause::TypeOutlives(
ty::OutlivesPredicate(ty_param, region_param),
));
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
Expand Down Expand Up @@ -654,7 +654,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
name: region_b_param.name,
}));
// The predicate we expect to see.
let clause = ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
let clause = ty::PredicateKind::Clause(ty::clause::RegionOutlives(
ty::OutlivesPredicate(region_a_param, region_b_param),
));
let clause = tcx.mk_predicate(ty::Binder::dummy(clause));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
.or_default()
.push(error.obligation.cause.span);
}
if let ty::PredicateKind::Clause(ty::Clause::Trait(
if let ty::PredicateKind::Clause(ty::clause::Trait(
ty::TraitPredicate {
trait_ref,
polarity: ty::ImplPolarity::Positive,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ fn associated_type_bounds<'tcx>(

let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => tr.self_ty() == item_ty,
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
ty::PredicateKind::Clause(ty::clause::Trait(tr)) => tr.self_ty() == item_ty,
ty::PredicateKind::Clause(ty::clause::Projection(proj)) => {
proj.projection_ty.self_ty() == item_ty
}
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => outlives.0 == item_ty,
ty::PredicateKind::Clause(ty::clause::TypeOutlives(outlives)) => outlives.0 == item_ty,
_ => false,
}
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
let bound_predicate = pred.kind();
match bound_predicate.skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
ty::PredicateKind::Clause(ty::clause::Trait(data)) => {
// The order here needs to match what we would get from `subst_supertrait`
let pred_bound_vars = bound_predicate.bound_vars();
let mut all_bound_vars = bound_vars.clone();
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
_ => bug!(),
};
let pred = ty::Binder::dummy(ty::PredicateKind::Clause(
ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
ty::clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)),
))
.to_predicate(icx.tcx);

Expand Down Expand Up @@ -290,14 +290,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
name: duplicate.name.ident().name,
}));
predicates.push((
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
ty::Binder::dummy(ty::PredicateKind::Clause(ty::clause::RegionOutlives(
ty::OutlivesPredicate(orig_region, dup_region),
)))
.to_predicate(icx.tcx),
duplicate.span,
));
predicates.push((
ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
ty::Binder::dummy(ty::PredicateKind::Clause(ty::clause::RegionOutlives(
ty::OutlivesPredicate(dup_region, orig_region),
)))
.to_predicate(icx.tcx),
Expand Down Expand Up @@ -416,11 +416,11 @@ pub(super) fn explicit_predicates_of<'tcx>(
.iter()
.copied()
.filter(|(pred, _)| match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(tr)) => !is_assoc_item_ty(tr.self_ty()),
ty::PredicateKind::Clause(ty::Clause::Projection(proj)) => {
ty::PredicateKind::Clause(ty::clause::Trait(tr)) => !is_assoc_item_ty(tr.self_ty()),
ty::PredicateKind::Clause(ty::clause::Projection(proj)) => {
!is_assoc_item_ty(proj.projection_ty.self_ty())
}
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(outlives)) => {
ty::PredicateKind::Clause(ty::clause::TypeOutlives(outlives)) => {
!is_assoc_item_ty(outlives.0)
}
_ => true,
Expand Down Expand Up @@ -553,7 +553,7 @@ pub(super) fn super_predicates_that_define_assoc_type(
// which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred);
if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) =
if let ty::PredicateKind::Clause(ty::clause::Trait(bound)) =
pred.kind().skip_binder()
{
tcx.at(span).super_predicates_of(bound.def_id());
Expand Down Expand Up @@ -655,7 +655,7 @@ pub(super) fn type_param_predicates(
)
.into_iter()
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => data.self_ty().is_param(index),
ty::PredicateKind::Clause(ty::clause::Trait(data)) => data.self_ty().is_param(index),
_ => false,
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn setup_constraining_predicates<'tcx>(
for j in i..predicates.len() {
// Note that we don't have to care about binders here,
// as the impl trait ref never contains any late-bound regions.
if let ty::PredicateKind::Clause(ty::Clause::Projection(projection)) =
if let ty::PredicateKind::Clause(ty::clause::Projection(projection)) =
predicates[j].0.kind().skip_binder()
{
// Special case: watch out for some kind of sneaky attempt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
// the functions in `cgp` add the constrained parameters to a list of
// unconstrained parameters.
for (predicate, _) in impl_generic_predicates.predicates.iter() {
if let ty::PredicateKind::Clause(ty::Clause::Projection(proj)) =
if let ty::PredicateKind::Clause(ty::clause::Projection(proj)) =
predicate.kind().skip_binder()
{
let projection_ty = proj.projection_ty;
Expand Down Expand Up @@ -425,8 +425,8 @@ fn trait_predicates_eq<'tcx>(
let pred2_kind = predicate2.kind().skip_binder();
let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) {
(
ty::PredicateKind::Clause(ty::Clause::Trait(pred1)),
ty::PredicateKind::Clause(ty::Clause::Trait(pred2)),
ty::PredicateKind::Clause(ty::clause::Trait(pred1)),
ty::PredicateKind::Clause(ty::clause::Trait(pred2)),
) => (pred1, pred2),
// Just use plain syntactic equivalence if either of the predicates aren't
// trait predicates or have bound vars.
Expand Down Expand Up @@ -465,7 +465,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
_ if predicate.is_global() => (),
// We allow specializing on explicitly marked traits with no associated
// items.
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
ty::PredicateKind::Clause(ty::clause::Trait(ty::TraitPredicate {
trait_ref,
constness: _,
polarity: _,
Expand All @@ -485,7 +485,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
.emit();
}
}
ty::PredicateKind::Clause(ty::Clause::Projection(ty::ProjectionPredicate {
ty::PredicateKind::Clause(ty::clause::Projection(ty::ProjectionPredicate {
projection_ty,
term,
})) => {
Expand All @@ -509,14 +509,14 @@ fn trait_predicate_kind<'tcx>(
predicate: ty::Predicate<'tcx>,
) -> Option<TraitSpecializationKind> {
match predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(ty::TraitPredicate {
ty::PredicateKind::Clause(ty::clause::Trait(ty::TraitPredicate {
trait_ref,
constness: _,
polarity: _,
})) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind),
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
ty::PredicateKind::Clause(ty::clause::RegionOutlives(_))
| ty::PredicateKind::Clause(ty::clause::TypeOutlives(_))
| ty::PredicateKind::Clause(ty::clause::Projection(_))
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::Subtype(_)
| ty::PredicateKind::Coerce(_)
Expand Down
Loading