Skip to content

Commit 23c6f23

Browse files
Uplift push_outlives_components
1 parent 3bec617 commit 23c6f23

File tree

12 files changed

+370
-284
lines changed

12 files changed

+370
-284
lines changed

compiler/rustc_infer/src/infer/outlives/components.rs

-266
This file was deleted.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use crate::infer::free_regions::RegionRelations;
77
use crate::infer::lexical_region_resolve;
88
use rustc_middle::traits::query::{NoSolution, OutlivesBound};
99
use rustc_middle::ty;
10+
// TODO: Remove me
11+
pub use rustc_type_ir::outlives as components;
1012

11-
pub mod components;
1213
pub mod env;
1314
pub mod for_liveness;
1415
pub mod obligations;

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ where
291291
fn components_must_outlive(
292292
&mut self,
293293
origin: infer::SubregionOrigin<'tcx>,
294-
components: &[Component<'tcx>],
294+
components: &[Component<TyCtxt<'tcx>>],
295295
region: ty::Region<'tcx>,
296296
category: ConstraintCategory<'tcx>,
297297
) {

compiler/rustc_infer/src/infer/outlives/verify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
139139

140140
fn bound_from_components(
141141
&self,
142-
components: &[Component<'tcx>],
142+
components: &[Component<TyCtxt<'tcx>>],
143143
visited: &mut SsoHashSet<GenericArg<'tcx>>,
144144
) -> VerifyBound<'tcx> {
145145
let mut bounds = components
@@ -158,7 +158,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
158158

159159
fn bound_from_single_component(
160160
&self,
161-
component: &Component<'tcx>,
161+
component: &Component<TyCtxt<'tcx>>,
162162
visited: &mut SsoHashSet<GenericArg<'tcx>>,
163163
) -> VerifyBound<'tcx> {
164164
match *component {

compiler/rustc_middle/src/ty/consts/kind.rs

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ pub struct Expr<'tcx> {
5454
pub kind: ExprKind,
5555
args: ty::GenericArgsRef<'tcx>,
5656
}
57+
58+
impl<'tcx> rustc_type_ir::inherent::ExprConst<TyCtxt<'tcx>> for Expr<'tcx> {
59+
fn args(self) -> ty::GenericArgsRef<'tcx> {
60+
self.args
61+
}
62+
}
63+
5764
impl<'tcx> Expr<'tcx> {
5865
pub fn new_binop(
5966
tcx: TyCtxt<'tcx>,

compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(
284284
/// those relationships.
285285
fn implied_bounds_from_components<'tcx>(
286286
sub_region: ty::Region<'tcx>,
287-
sup_components: SmallVec<[Component<'tcx>; 4]>,
287+
sup_components: SmallVec<[Component<TyCtxt<'tcx>>; 4]>,
288288
) -> Vec<OutlivesBound<'tcx>> {
289289
sup_components
290290
.into_iter()

compiler/rustc_type_ir/src/inherent.rs

+8
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ pub trait Region<I: Interner<Region = Self>>:
232232
fn new_anon_bound(interner: I, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self;
233233

234234
fn new_static(interner: I) -> Self;
235+
236+
fn is_bound(self) -> bool {
237+
matches!(self.kind(), ty::ReBound(..))
238+
}
235239
}
236240

237241
pub trait Const<I: Interner<Const = Self>>:
@@ -272,6 +276,10 @@ pub trait Const<I: Interner<Const = Self>>:
272276
}
273277
}
274278

279+
pub trait ExprConst<I: Interner<ExprConst = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
280+
fn args(self) -> I::GenericArgs;
281+
}
282+
275283
pub trait GenericsOf<I: Interner<GenericsOf = Self>> {
276284
fn count(&self) -> usize;
277285
}

compiler/rustc_type_ir/src/interner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub trait Interner:
109109
type ParamConst: Copy + Debug + Hash + Eq + ParamLike;
110110
type BoundConst: Copy + Debug + Hash + Eq + BoundVarLike<Self>;
111111
type ValueConst: Copy + Debug + Hash + Eq;
112-
type ExprConst: Copy + Debug + Hash + Eq + Relate<Self>;
112+
type ExprConst: ExprConst<Self>;
113113

114114
// Kinds of regions
115115
type Region: Region<Self>;

compiler/rustc_type_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub mod inherent;
2727
pub mod ir_print;
2828
pub mod lang_items;
2929
pub mod lift;
30+
pub mod outlives;
3031
pub mod relate;
3132
pub mod solve;
3233

0 commit comments

Comments
 (0)