Skip to content
Merged
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
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ struct CollectRegionConstraintsResult<'tcx> {
location_map: Rc<DenseLocationMap>,
universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
region_bound_pairs: Frozen<RegionBoundPairs<'tcx>>,
known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesPredicate<'tcx>>>,
known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesClause<'tcx>>>,
constraints: MirTypeckRegionConstraints<'tcx>,
deferred_closure_requirements: DeferredClosureRequirements<'tcx>,
deferred_opaque_type_errors: Vec<DeferredOpaqueTypeError<'tcx>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ pub(crate) fn apply_definition_site_hidden_types<'tcx>(
body: &Body<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
region_bound_pairs: &RegionBoundPairs<'tcx>,
known_type_outlives_obligations: &[ty::PolyTypeOutlivesPredicate<'tcx>],
known_type_outlives_obligations: &[ty::PolyTypeOutlivesClause<'tcx>],
constraints: &mut MirTypeckRegionConstraints<'tcx>,
hidden_types: &mut FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'tcx>>,
opaque_types: &[(OpaqueTypeKey<'tcx>, ProvisionalHiddenType<'tcx>)],
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 @@ -24,7 +24,7 @@ pub(crate) fn fully_perform_op_raw<'tcx, R: fmt::Debug, Op>(
body: &Body<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
region_bound_pairs: &RegionBoundPairs<'tcx>,
known_type_outlives_obligations: &[ty::PolyTypeOutlivesPredicate<'tcx>],
known_type_outlives_obligations: &[ty::PolyTypeOutlivesClause<'tcx>],
constraints: &mut MirTypeckRegionConstraints<'tcx>,
locations: Locations,
category: ConstraintCategory<'tcx>,
Expand Down
15 changes: 7 additions & 8 deletions compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) struct ConstraintConversion<'a, 'tcx> {
/// logic expecting to see (e.g.) `ReStatic`, and if we supplied
/// our special inference variable there, we would mess that up.
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesClause<'tcx>],
locations: Locations,
span: Span,
category: ConstraintCategory<'tcx>,
Expand All @@ -47,7 +47,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
infcx: &'a BorrowckInferCtxt<'tcx>,
universal_regions: &'a UniversalRegions<'tcx>,
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesClause<'tcx>],
locations: Locations,
span: Span,
category: ConstraintCategory<'tcx>,
Expand Down Expand Up @@ -115,7 +115,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
self.category = outlives_requirement.category;
self.span = outlives_requirement.blame_span;
self.convert(
ty::OutlivesPredicate(subject, outlived_region),
ty::OutlivesClause(subject, outlived_region),
self.category,
&Default::default(),
);
Expand All @@ -125,9 +125,9 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {

fn convert(
&mut self,
predicate: ty::ArgOutlivesPredicate<'tcx>,
clause: ty::ArgOutlivesClause<'tcx>,
constraint_category: ConstraintCategory<'tcx>,
higher_ranked_assumptions: &FxHashSet<ty::ArgOutlivesPredicate<'tcx>>,
higher_ranked_assumptions: &FxHashSet<ty::ArgOutlivesClause<'tcx>>,
) {
let tcx = self.infcx.tcx;
debug!("generate: constraints at: {:#?}", self.locations);
Expand All @@ -141,15 +141,14 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
..
} = *self;

let pred = predicate;
// Constraint is implied by a coroutine's well-formedness.
if self.infcx.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
&& higher_ranked_assumptions.contains(&pred)
&& higher_ranked_assumptions.contains(&clause)
{
return;
}

let ty::OutlivesPredicate(k1, r2) = pred;
let ty::OutlivesClause(k1, r2) = clause;
match k1.kind() {
GenericArgKind::Lifetime(r1) => {
let r1_vid = self.to_region_vid(r1);
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/type_check/free_region_relations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type NormalizedInputsAndOutput<'tcx> = Vec<Ty<'tcx>>;
pub(crate) struct CreateResult<'tcx> {
pub(crate) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
pub(crate) region_bound_pairs: Frozen<RegionBoundPairs<'tcx>>,
pub(crate) known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesPredicate<'tcx>>>,
pub(crate) known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesClause<'tcx>>>,
pub(crate) normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
}

Expand Down Expand Up @@ -342,9 +342,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {

fn normalize_and_push_type_outlives_obligation(
&self,
mut outlives: ty::PolyTypeOutlivesPredicate<'tcx>,
mut outlives: ty::PolyTypeOutlivesClause<'tcx>,
span: Span,
known_type_outlives_obligations: &mut Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
known_type_outlives_obligations: &mut Vec<ty::PolyTypeOutlivesClause<'tcx>>,
constraints: &mut Vec<&QueryRegionConstraints<'tcx>>,
) {
// In the new solver, normalize the type-outlives obligation assumptions.
Expand Down Expand Up @@ -413,12 +413,12 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {

OutlivesBound::RegionSubParam(r_a, param_b) => {
self.region_bound_pairs
.insert(ty::OutlivesPredicate(GenericKind::Param(param_b), r_a));
.insert(ty::OutlivesClause(GenericKind::Param(param_b), r_a));
}

OutlivesBound::RegionSubAlias(r_a, alias_b) => {
self.region_bound_pairs
.insert(ty::OutlivesPredicate(GenericKind::Alias(alias_b), r_a));
.insert(ty::OutlivesClause(GenericKind::Alias(alias_b), r_a));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ struct TypeChecker<'a, 'tcx> {
/// all of the promoted items.
user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>,
region_bound_pairs: &'a RegionBoundPairs<'tcx>,
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesPredicate<'tcx>],
known_type_outlives_obligations: &'a [ty::PolyTypeOutlivesClause<'tcx>],
reported_errors: FxIndexSet<(Ty<'tcx>, Span)>,
universal_regions: &'a UniversalRegions<'tcx>,
location_table: &'a PoloniusLocationTable,
Expand All @@ -257,7 +257,7 @@ pub(crate) struct MirTypeckResults<'tcx> {
pub(crate) constraints: MirTypeckRegionConstraints<'tcx>,
pub(crate) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
pub(crate) region_bound_pairs: Frozen<RegionBoundPairs<'tcx>>,
pub(crate) known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesPredicate<'tcx>>>,
pub(crate) known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesClause<'tcx>>>,
pub(crate) deferred_closure_requirements: DeferredClosureRequirements<'tcx>,
pub(crate) polonius_context: Option<PoloniusContext>,
}
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 @@ -89,7 +89,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::print::with_types_for_signature;
use rustc_middle::ty::{
self, GenericArgs, GenericArgsRef, OutlivesPredicate, Region, RegionExt, Ty, TyCtxt, TypingMode,
self, GenericArgs, GenericArgsRef, OutlivesClause, Region, RegionExt, Ty, TyCtxt, TypingMode,
};
use rustc_middle::{bug, span_bug};
use rustc_session::diagnostics::feature_err;
Expand Down Expand Up @@ -413,7 +413,7 @@ fn bounds_from_generic_clauses<'tcx>(
ty::ClauseKind::Projection(projection_pred) => {
projections.push(bound_clause.rebind(projection_pred));
}
ty::ClauseKind::RegionOutlives(OutlivesPredicate(a, b)) => {
ty::ClauseKind::RegionOutlives(OutlivesClause(a, b)) => {
regions.entry(a).or_default().push(b);
}
_ => {}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ pub(crate) fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId)
let unsatisfied_bounds: Vec<_> = required_bounds
.into_iter()
.filter(|clause| match clause.kind().skip_binder() {
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
ty::ClauseKind::RegionOutlives(ty::OutlivesClause(a, b)) => {
!region_known_to_outlive(
tcx,
gat_def_id,
Expand All @@ -520,7 +520,7 @@ pub(crate) fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId)
b,
)
}
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
ty::ClauseKind::TypeOutlives(ty::OutlivesClause(a, b)) => {
!ty_known_to_outlive(tcx, gat_def_id, param_env, &FxIndexSet::default(), a, b)
}
_ => bug!("Unexpected ClauseKind"),
Expand Down Expand Up @@ -642,10 +642,10 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
tcx,
ty::EarlyParamRegion { index: region_param.index, name: region_param.name },
);
// The predicate we expect to see. (In our example,
// The clause we expect to see. (In our example,
// `Self: 'me`.)
bounds.insert(
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty_param, region_param))
ty::ClauseKind::TypeOutlives(ty::OutlivesClause(ty_param, region_param))
.upcast(tcx),
);
}
Expand Down Expand Up @@ -677,9 +677,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
tcx,
ty::EarlyParamRegion { index: region_b_param.index, name: region_b_param.name },
);
// The predicate we expect to see.
// The clause we expect to see.
bounds.insert(
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
ty::ClauseKind::RegionOutlives(ty::OutlivesClause(
region_a_param,
region_b_param,
))
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/collect/clauses_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ fn gather_explicit_clauses_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generi
}
};
let clause =
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2)).upcast(tcx);
ty::ClauseKind::RegionOutlives(ty::OutlivesClause(r1, r2)).upcast(tcx);
(clause, span)
}))
}
Expand Down Expand Up @@ -389,12 +389,12 @@ fn compute_bidirectional_outlives_clauses<'tcx>(
);
let span = tcx.def_span(param.def_id);
clauses.push((
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(orig_lifetime, dup_lifetime))
ty::ClauseKind::RegionOutlives(ty::OutlivesClause(orig_lifetime, dup_lifetime))
.upcast(tcx),
span,
));
clauses.push((
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(dup_lifetime, orig_lifetime))
ty::ClauseKind::RegionOutlives(ty::OutlivesClause(dup_lifetime, orig_lifetime))
.upcast(tcx),
span,
));
Expand Down Expand Up @@ -1076,7 +1076,7 @@ pub(super) fn const_conditions<'tcx>(
},
// While associated types are not really const, we do allow them to have `[const]`
// bounds and where clauses. `const_conditions` is responsible for gathering
// these up so we can check them in `compare_type_predicate_entailment`, and
// these up so we can check them in `compare_type_clause_entailment`, and
// in `HostEffect` goal computation.
Node::TraitItem(item) => match item.kind {
hir::TraitItemKind::Fn(_, _) | hir::TraitItemKind::Type(_, _) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {

let region = self.lower_lifetime(lifetime, RegionInferReason::OutlivesBound);
let bound = ty::Binder::bind_with_vars(
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(param_ty, region)),
ty::ClauseKind::TypeOutlives(ty::OutlivesClause(param_ty, region)),
bound_vars,
);
bounds.push((bound.upcast(self.tcx()), lifetime.ident.span));
Expand Down
40 changes: 14 additions & 26 deletions compiler/rustc_hir_analysis/src/outlives/explicit.rs
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, OutlivesPredicate, TyCtxt};
use rustc_middle::ty::{self, OutlivesClause, TyCtxt};

use super::utils::*;

#[derive(Debug)]
pub(crate) struct ExplicitPredicatesMap<'tcx> {
map: FxIndexMap<DefId, ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>>>,
pub(crate) struct ExplicitClausesMap<'tcx> {
map: FxIndexMap<DefId, ty::EarlyBinder<'tcx, RequiredClauses<'tcx>>>,
}

impl<'tcx> ExplicitPredicatesMap<'tcx> {
pub(crate) fn new() -> ExplicitPredicatesMap<'tcx> {
ExplicitPredicatesMap { map: FxIndexMap::default() }
impl<'tcx> ExplicitClausesMap<'tcx> {
pub(crate) fn new() -> ExplicitClausesMap<'tcx> {
ExplicitClausesMap { map: FxIndexMap::default() }
}

pub(crate) fn explicit_clauses_of(
&mut self,
tcx: TyCtxt<'tcx>,
def_id: DefId,
) -> &ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>> {
) -> &ty::EarlyBinder<'tcx, RequiredClauses<'tcx>> {
self.map.entry(def_id).or_insert_with(|| {
let gen_clauses = if def_id.is_local() {
tcx.explicit_clauses_of(def_id)
} else {
tcx.clauses_of(def_id)
};
let mut required_predicates = RequiredPredicates::default();
let mut required_clauses = RequiredClauses::default();

// Process clauses and convert to `RequiredPredicates` entry, see below.
// Process clauses and convert to `RequiredClauses` entry, see below.
for &(clause, span) in gen_clauses.clauses {
match clause.kind().skip_binder() {
ty::ClauseKind::TypeOutlives(OutlivesPredicate(ty, reg)) => {
insert_outlives_predicate(
tcx,
ty.into(),
reg,
span,
&mut required_predicates,
)
ty::ClauseKind::TypeOutlives(OutlivesClause(ty, reg)) => {
insert_outlives_clause(tcx, ty.into(), reg, span, &mut required_clauses)
}

ty::ClauseKind::RegionOutlives(OutlivesPredicate(reg1, reg2)) => {
insert_outlives_predicate(
tcx,
reg1.into(),
reg2,
span,
&mut required_predicates,
)
ty::ClauseKind::RegionOutlives(OutlivesClause(reg1, reg2)) => {
insert_outlives_clause(tcx, reg1.into(), reg2, span, &mut required_clauses)
}
ty::ClauseKind::Trait(_)
| ty::ClauseKind::Projection(_)
Expand All @@ -59,7 +47,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
}
}

ty::EarlyBinder::bind_iter(required_predicates)
ty::EarlyBinder::bind_iter(required_clauses)
})
}
}
Loading
Loading