diff options
| author | SparrowLii <liyuan179@huawei.com> | 2022-08-01 10:23:09 +0800 |
|---|---|---|
| committer | SparrowLii <liyuan179@huawei.com> | 2022-08-22 18:10:28 +0800 |
| commit | d39fefdd694b02c7e7b4a64ccbb38d9f8be16df0 (patch) | |
| tree | 25c432bb502d991d5d9d0150c1223ddb8dce8dfe | |
| parent | d037f1843e9472d547dc22edbfb18788174c0754 (diff) | |
| download | rust-d39fefdd694b02c7e7b4a64ccbb38d9f8be16df0.tar.gz rust-d39fefdd694b02c7e7b4a64ccbb38d9f8be16df0.zip | |
use type alias impl trait in `outlives_bounds::InferCtxtExt`
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/framework/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/wfcheck.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/outlives/outlives_bounds.rs | 24 |
5 files changed, 26 insertions, 14 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs index f9fd6c9c56b..d9aff94fef2 100644 --- a/compiler/rustc_mir_dataflow/src/framework/mod.rs +++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs @@ -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>, @@ -413,7 +414,7 @@ where } /* Extension methods */ - + #[inline] fn into_engine<'mir>( self, tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 8396cb1ae0a..057e5f93563 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -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(); diff --git a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs index 72af5d79e09..64cd69750f3 100644 --- a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs @@ -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); diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index 8c6fb6a7718..1ff9c627131 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -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] diff --git a/compiler/rustc_typeck/src/outlives/outlives_bounds.rs b/compiler/rustc_typeck/src/outlives/outlives_bounds.rs index 769a3e7e11a..024e20d9223 100644 --- a/compiler/rustc_typeck/src/outlives/outlives_bounds.rs +++ b/compiler/rustc_typeck/src/outlives/outlives_bounds.rs @@ -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}; @@ -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, @@ -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> { @@ -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() } } |
