Skip to content

Commit 99c49d9

Browse files
committed
Auto merge of rust-lang#109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs) - rust-lang#109137 (resolve: Querify most cstore access methods (subset 2)) - rust-lang#109380 (add `known-bug` test for unsoundness issue) - rust-lang#109462 (Make alias-eq have a relation direction (and rename it to alias-relate)) - rust-lang#109475 (Simpler checked shifts in MIR building) - rust-lang#109504 (Stabilize `arc_into_inner` and `rc_into_inner`.) - rust-lang#109506 (make param bound vars visibly bound vars with -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9a6b0c3 + 477ce58 commit 99c49d9

File tree

54 files changed

+730
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+730
-246
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13361336
ty::Clause::RegionOutlives(_) | ty::Clause::ConstArgHasType(..) => bug!(),
13371337
},
13381338
ty::PredicateKind::WellFormed(_)
1339-
| ty::PredicateKind::AliasEq(..)
1339+
| ty::PredicateKind::AliasRelate(..)
13401340
| ty::PredicateKind::ObjectSafe(_)
13411341
| ty::PredicateKind::ClosureKind(_, _, _)
13421342
| ty::PredicateKind::Subtype(_)

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ fn trait_predicate_kind<'tcx>(
528528
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
529529
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
530530
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
531-
| ty::PredicateKind::AliasEq(..)
531+
| ty::PredicateKind::AliasRelate(..)
532532
| ty::PredicateKind::WellFormed(_)
533533
| ty::PredicateKind::Subtype(_)
534534
| ty::PredicateKind::Coerce(_)

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5656
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
5757
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
5858
| ty::PredicateKind::WellFormed(..)
59-
| ty::PredicateKind::AliasEq(..)
59+
| ty::PredicateKind::AliasRelate(..)
6060
| ty::PredicateKind::ObjectSafe(..)
6161
| ty::PredicateKind::ClosureKind(..)
6262
| ty::PredicateKind::Subtype(..)

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
666666
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
667667
| ty::PredicateKind::WellFormed(..)
668668
| ty::PredicateKind::ObjectSafe(..)
669-
| ty::PredicateKind::AliasEq(..)
669+
| ty::PredicateKind::AliasRelate(..)
670670
| ty::PredicateKind::ConstEvaluatable(..)
671671
| ty::PredicateKind::ConstEquate(..)
672672
// N.B., this predicate is created by breaking down a

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
838838
| ty::PredicateKind::ConstEvaluatable(..)
839839
| ty::PredicateKind::ConstEquate(..)
840840
| ty::PredicateKind::Ambiguous
841-
| ty::PredicateKind::AliasEq(..)
841+
| ty::PredicateKind::AliasRelate(..)
842842
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
843843
}
844844
});

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> InferCtxt<'tcx> {
128128
(_, ty::Alias(AliasKind::Projection, _)) | (ty::Alias(AliasKind::Projection, _), _)
129129
if self.tcx.trait_solver_next() =>
130130
{
131-
relation.register_type_equate_obligation(a, b);
131+
relation.register_type_relate_obligation(a, b);
132132
Ok(a)
133133
}
134134

@@ -842,23 +842,25 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
842842
let (a, b) = if self.a_is_expected() { (a, b) } else { (b, a) };
843843

844844
self.register_predicates([ty::Binder::dummy(if self.tcx().trait_solver_next() {
845-
ty::PredicateKind::AliasEq(a.into(), b.into())
845+
ty::PredicateKind::AliasRelate(a.into(), b.into(), ty::AliasRelationDirection::Equate)
846846
} else {
847847
ty::PredicateKind::ConstEquate(a, b)
848848
})]);
849849
}
850850

851-
/// Register an obligation that both types must be equal to each other.
852-
///
853-
/// If they aren't equal then the relation doesn't hold.
854-
fn register_type_equate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
855-
let (a, b) = if self.a_is_expected() { (a, b) } else { (b, a) };
856-
857-
self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasEq(
851+
/// Register an obligation that both types must be related to each other according to
852+
/// the [`ty::AliasRelationDirection`] given by [`ObligationEmittingRelation::alias_relate_direction`]
853+
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
854+
self.register_predicates([ty::Binder::dummy(ty::PredicateKind::AliasRelate(
858855
a.into(),
859856
b.into(),
857+
self.alias_relate_direction(),
860858
))]);
861859
}
860+
861+
/// Relation direction emitted for `AliasRelate` predicates, corresponding to the direction
862+
/// of the relation.
863+
fn alias_relate_direction(&self) -> ty::AliasRelationDirection;
862864
}
863865

864866
fn int_unification_error<'tcx>(

compiler/rustc_infer/src/infer/equate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,8 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> {
210210
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
211211
self.fields.register_obligations(obligations);
212212
}
213+
214+
fn alias_relate_direction(&self) -> ty::AliasRelationDirection {
215+
ty::AliasRelationDirection::Equate
216+
}
213217
}

compiler/rustc_infer/src/infer/glb.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,9 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
155155
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
156156
self.fields.register_obligations(obligations);
157157
}
158+
159+
fn alias_relate_direction(&self) -> ty::AliasRelationDirection {
160+
// FIXME(deferred_projection_equality): This isn't right, I think?
161+
ty::AliasRelationDirection::Equate
162+
}
158163
}

compiler/rustc_infer/src/infer/lub.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,9 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
155155
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
156156
self.fields.register_obligations(obligations)
157157
}
158+
159+
fn alias_relate_direction(&self) -> ty::AliasRelationDirection {
160+
// FIXME(deferred_projection_equality): This isn't right, I think?
161+
ty::AliasRelationDirection::Equate
162+
}
158163
}

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,34 @@ where
711711
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
712712
self.delegate.register_obligations(obligations);
713713
}
714+
715+
fn alias_relate_direction(&self) -> ty::AliasRelationDirection {
716+
unreachable!("manually overridden to handle ty::Variance::Contravariant ambient variance")
717+
}
718+
719+
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
720+
self.register_predicates([ty::Binder::dummy(match self.ambient_variance {
721+
ty::Variance::Covariant => ty::PredicateKind::AliasRelate(
722+
a.into(),
723+
b.into(),
724+
ty::AliasRelationDirection::Subtype,
725+
),
726+
// a :> b is b <: a
727+
ty::Variance::Contravariant => ty::PredicateKind::AliasRelate(
728+
b.into(),
729+
a.into(),
730+
ty::AliasRelationDirection::Subtype,
731+
),
732+
ty::Variance::Invariant => ty::PredicateKind::AliasRelate(
733+
a.into(),
734+
b.into(),
735+
ty::AliasRelationDirection::Equate,
736+
),
737+
// FIXME(deferred_projection_equality): Implement this when we trigger it.
738+
// Probably just need to do nothing here.
739+
ty::Variance::Bivariant => unreachable!(),
740+
})]);
741+
}
714742
}
715743

716744
/// When we encounter a binder like `for<..> fn(..)`, we actually have

0 commit comments

Comments
 (0)