From d39fefdd694b02c7e7b4a64ccbb38d9f8be16df0 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Mon, 1 Aug 2022 10:23:09 +0800 Subject: [PATCH] use type alias impl trait in `outlives_bounds::InferCtxtExt` --- .../rustc_mir_dataflow/src/framework/mod.rs | 3 ++- compiler/rustc_typeck/src/check/wfcheck.rs | 2 +- .../src/impl_wf_check/min_specialization.rs | 10 ++++++++ compiler/rustc_typeck/src/lib.rs | 1 + .../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 @@ fn apply_switch_int_edge_effects( /// .iterate_to_fixpoint() /// .into_results_cursor(body); /// ``` + #[inline] fn into_engine<'mir>( self, tcx: TyCtxt<'tcx>, @@ -413,7 +414,7 @@ fn apply_switch_int_edge_effects( } /* 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 @@ #![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 @@ pub use rustc_middle::traits::query::OutlivesBound; +type Bounds<'a, 'tcx: 'a> = impl Iterator> + 'a; pub trait InferCtxtExt<'a, 'tcx> { fn implied_outlives_bounds( &self, @@ -20,8 +22,8 @@ fn implied_bounds_tys( &'a self, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, - tys: impl IntoIterator> + 'a, - ) -> Box> + 'a>; + tys: FxHashSet>, + ) -> Bounds<'a, 'tcx>; } impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx> { @@ -100,15 +102,13 @@ fn implied_bounds_tys( &'a self, param_env: ParamEnv<'tcx>, body_id: HirId, - tys: impl IntoIterator> + 'a, - ) -> Box> + '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>, + ) -> 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() } }