Skip to content

Commit

Permalink
use type alias impl trait in outlives_bounds::InferCtxtExt
Browse files Browse the repository at this point in the history
  • Loading branch information
SparrowLii committed Aug 22, 2022
1 parent d037f18 commit d39fefd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_mir_dataflow/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
/// .iterate_to_fixpoint()
/// .into_results_cursor(body);
/// ```
#[inline]
fn into_engine<'mir>(
self,
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -413,7 +414,7 @@ where
}

/* Extension methods */

#[inline]
fn into_engine<'mir>(
self,
tcx: TyCtxt<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
let outlives_environment = OutlivesEnvironment::with_bounds(
param_env,
Some(&infcx),
infcx.implied_bounds_tys(param_env, id, wf_tys.iter().map(|ty| *ty)),
infcx.implied_bounds_tys(param_env, id, wf_tys.clone()),
);
let region_bound_pairs = outlives_environment.region_bound_pairs();

Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ fn get_impl_substs<'tcx>(













let errors = ocx.select_all_or_error();
if !errors.is_empty() {
ocx.infcx.report_fulfillment_errors(&errors, None, false);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ This API is completely unstable and subject to change.
#![feature(slice_partition_dedup)]
#![feature(try_blocks)]
#![feature(is_some_with)]
#![feature(type_alias_impl_trait)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_typeck/src/outlives/outlives_bounds.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::HirId;
use rustc_middle::ty::{self, ParamEnv, Ty};
Expand All @@ -8,6 +9,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt

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

type Bounds<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a;
pub trait InferCtxtExt<'a, 'tcx> {
fn implied_outlives_bounds(
&self,
Expand All @@ -20,8 +22,8 @@ pub trait InferCtxtExt<'a, 'tcx> {
&'a self,
param_env: ty::ParamEnv<'tcx>,
body_id: hir::HirId,
tys: impl IntoIterator<Item = Ty<'tcx>> + 'a,
) -> Box<dyn Iterator<Item = OutlivesBound<'tcx>> + 'a>;
tys: FxHashSet<Ty<'tcx>>,
) -> Bounds<'a, 'tcx>;
}

impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
Expand Down Expand Up @@ -100,15 +102,13 @@ impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> {
&'a self,
param_env: ParamEnv<'tcx>,
body_id: HirId,
tys: impl IntoIterator<Item = Ty<'tcx>> + 'a,
) -> Box<dyn Iterator<Item = OutlivesBound<'tcx>> + 'a> {
Box::new(
tys.into_iter()
.map(move |ty| {
let ty = self.resolve_vars_if_possible(ty);
self.implied_outlives_bounds(param_env, body_id, ty)
})
.flatten(),
)
tys: FxHashSet<Ty<'tcx>>,
) -> Bounds<'a, 'tcx> {
tys.into_iter()
.map(move |ty| {
let ty = self.resolve_vars_if_possible(ty);
self.implied_outlives_bounds(param_env, body_id, ty)
})
.flatten()
}
}

0 comments on commit d39fefd

Please sign in to comment.