Skip to content

Commit d39fefd

Browse files
committed
use type alias impl trait in outlives_bounds::InferCtxtExt
1 parent d037f18 commit d39fefd

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

compiler/rustc_mir_dataflow/src/framework/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
256256
/// .iterate_to_fixpoint()
257257
/// .into_results_cursor(body);
258258
/// ```
259+
#[inline]
259260
fn into_engine<'mir>(
260261
self,
261262
tcx: TyCtxt<'tcx>,
@@ -413,7 +414,7 @@ where
413414
}
414415

415416
/* Extension methods */
416-
417+
#[inline]
417418
fn into_engine<'mir>(
418419
self,
419420
tcx: TyCtxt<'tcx>,

compiler/rustc_typeck/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
699699
let outlives_environment = OutlivesEnvironment::with_bounds(
700700
param_env,
701701
Some(&infcx),
702-
infcx.implied_bounds_tys(param_env, id, wf_tys.iter().map(|ty| *ty)),
702+
infcx.implied_bounds_tys(param_env, id, wf_tys.clone()),
703703
);
704704
let region_bound_pairs = outlives_environment.region_bound_pairs();
705705

compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs

+10
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ fn get_impl_substs<'tcx>(
158158

159159

160160

161+
162+
163+
164+
165+
166+
167+
168+
169+
170+
161171
let errors = ocx.select_all_or_error();
162172
if !errors.is_empty() {
163173
ocx.infcx.report_fulfillment_errors(&errors, None, false);

compiler/rustc_typeck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ This API is completely unstable and subject to change.
7272
#![feature(slice_partition_dedup)]
7373
#![feature(try_blocks)]
7474
#![feature(is_some_with)]
75+
#![feature(type_alias_impl_trait)]
7576
#![recursion_limit = "256"]
7677

7778
#[macro_use]

compiler/rustc_typeck/src/outlives/outlives_bounds.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_data_structures::fx::FxHashSet;
12
use rustc_hir as hir;
23
use rustc_hir::HirId;
34
use rustc_middle::ty::{self, ParamEnv, Ty};
@@ -8,6 +9,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt
89

910
pub use rustc_middle::traits::query::OutlivesBound;
1011

12+
type Bounds<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a;
1113
pub trait InferCtxtExt<'a, 'tcx> {
1214
fn implied_outlives_bounds(
1315
&self,
@@ -20,8 +22,8 @@ pub trait InferCtxtExt<'a, 'tcx> {
2022
&'a self,
2123
param_env: ty::ParamEnv<'tcx>,
2224
body_id: hir::HirId,
23-
tys: impl IntoIterator<Item = Ty<'tcx>> + 'a,
24-
) -> Box<dyn Iterator<Item = OutlivesBound<'tcx>> + 'a>;
25+
tys: FxHashSet<Ty<'tcx>>,
26+
) -> Bounds<'a, 'tcx>;
2527
}
2628

2729
impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
@@ -100,15 +102,13 @@ impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
100102
&'a self,
101103
param_env: ParamEnv<'tcx>,
102104
body_id: HirId,
103-
tys: impl IntoIterator<Item = Ty<'tcx>> + 'a,
104-
) -> Box<dyn Iterator<Item = OutlivesBound<'tcx>> + 'a> {
105-
Box::new(
106-
tys.into_iter()
107-
.map(move |ty| {
108-
let ty = self.resolve_vars_if_possible(ty);
109-
self.implied_outlives_bounds(param_env, body_id, ty)
110-
})
111-
.flatten(),
112-
)
105+
tys: FxHashSet<Ty<'tcx>>,
106+
) -> Bounds<'a, 'tcx> {
107+
tys.into_iter()
108+
.map(move |ty| {
109+
let ty = self.resolve_vars_if_possible(ty);
110+
self.implied_outlives_bounds(param_env, body_id, ty)
111+
})
112+
.flatten()
113113
}
114114
}

0 commit comments

Comments
 (0)